--- python3.2-3.2.3.orig/debian/PVER-doc.doc-base.PVER-new.in +++ python3.2-3.2.3/debian/PVER-doc.doc-base.PVER-new.in @@ -0,0 +1,10 @@ +Document: @PVER@-new +Title: What's new in Python @VER@ +Author: A.M. Kuchling +Abstract: This documents lists new features and changes worth mentioning + in Python @VER@. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/whatsnew/@VER@.html +Files: /usr/share/doc/@PVER@/html/whatsnew/@VER@.html --- python3.2-3.2.3.orig/debian/copyright +++ python3.2-3.2.3/debian/copyright @@ -0,0 +1,741 @@ +This package was put together by Klee Dienes from +sources from ftp.python.org:/pub/python, based on the Debianization by +the previous maintainers Bernd S. Brentrup and +Bruce Perens. Current maintainer is Matthias Klose . + +It was downloaded from http://python.org/ + +Copyright: + +Upstream Author: Guido van Rossum and others. + +License: + +The following text includes the Python license and licenses and +acknowledgements for incorporated software. The licenses can be read +in the HTML and texinfo versions of the documentation as well, after +installing the pythonx.y-doc package. Licenses for files not licensed +under the Python Licenses are found at the end of this file. + + +Python License +============== + +A. HISTORY OF THE SOFTWARE +========================== + +Python was created in the early 1990s by Guido van Rossum at Stichting +Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands +as a successor of a language called ABC. Guido remains Python's +principal author, although it includes many contributions from others. + +In 1995, Guido continued his work on Python at the Corporation for +National Research Initiatives (CNRI, see http://www.cnri.reston.va.us) +in Reston, Virginia where he released several versions of the +software. + +In May 2000, Guido and the Python core development team moved to +BeOpen.com to form the BeOpen PythonLabs team. In October of the same +year, the PythonLabs team moved to Digital Creations (now Zope +Corporation, see http://www.zope.com). In 2001, the Python Software +Foundation (PSF, see http://www.python.org/psf/) was formed, a +non-profit organization created specifically to own Python-related +Intellectual Property. Zope Corporation is a sponsoring member of +the PSF. + +All Python releases are Open Source (see http://www.opensource.org for +the Open Source Definition). Historically, most, but not all, Python +releases have also been GPL-compatible; the table below summarizes +the various releases. + + Release Derived Year Owner GPL- + from compatible? (1) + + 0.9.0 thru 1.2 1991-1995 CWI yes + 1.3 thru 1.5.2 1.2 1995-1999 CNRI yes + 1.6 1.5.2 2000 CNRI no + 2.0 1.6 2000 BeOpen.com no + 1.6.1 1.6 2001 CNRI yes (2) + 2.1 2.0+1.6.1 2001 PSF no + 2.0.1 2.0+1.6.1 2001 PSF yes + 2.1.1 2.1+2.0.1 2001 PSF yes + 2.2 2.1.1 2001 PSF yes + 2.1.2 2.1.1 2002 PSF yes + 2.1.3 2.1.2 2002 PSF yes + 2.2.1 2.2 2002 PSF yes + 2.2.2 2.2.1 2002 PSF yes + 2.2.3 2.2.2 2003 PSF yes + 2.3 2.2.2 2002-2003 PSF yes + 2.3.1 2.3 2002-2003 PSF yes + 2.3.2 2.3.1 2002-2003 PSF yes + 2.3.3 2.3.2 2002-2003 PSF yes + 2.3.4 2.3.3 2004 PSF yes + 2.3.5 2.3.4 2005 PSF yes + 2.4 2.3 2004 PSF yes + 2.4.1 2.4 2005 PSF yes + 2.4.2 2.4.1 2005 PSF yes + 2.4.3 2.4.2 2006 PSF yes + 2.5 2.4 2006 PSF yes + 2.5.1 2.5 2007 PSF yes + 2.5.2 2.5.1 2008 PSF yes + 2.5.3 2.5.2 2008 PSF yes + 2.6 2.5 2008 PSF yes + 2.6.1 2.6 2008 PSF yes + 2.6.2 2.6.1 2009 PSF yes + 2.6.3 2.6.2 2009 PSF yes + 2.6.4 2.6.3 2009 PSF yes + 2.6.5 2.6.4 2010 PSF yes + 3.0 2.6 2008 PSF yes + 3.0.1 3.0 2009 PSF yes + 3.1 3.0.1 2009 PSF yes + 3.1.1 3.1 2009 PSF yes + 3.1.2 3.1.1 2010 PSF yes + 3.1.3 3.1.2 2010 PSF yes + 3.1.4 3.1.3 2011 PSF yes + 3.2 3.1 2011 PSF yes + 3.2.1 3.2 2011 PSF yes + 3.2.2 3.2.1 2011 PSF yes + +Footnotes: + +(1) GPL-compatible doesn't mean that we're distributing Python under + the GPL. All Python licenses, unlike the GPL, let you distribute + a modified version without making your changes open source. The + GPL-compatible licenses make it possible to combine Python with + other software that is released under the GPL; the others don't. + +(2) According to Richard Stallman, 1.6.1 is not GPL-compatible, + because its license has a choice of law clause. According to + CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1 + is "not incompatible" with the GPL. + +Thanks to the many outside volunteers who have worked under Guido's +direction to make these releases possible. + + +B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON +=============================================================== + +PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 +-------------------------------------------- + +1. This LICENSE AGREEMENT is between the Python Software Foundation +("PSF"), and the Individual or Organization ("Licensee") accessing and +otherwise using this software ("Python") in source or binary form and +its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, PSF +hereby grants Licensee a nonexclusive, royalty-free, world-wide +license to reproduce, analyze, test, perform and/or display publicly, +prepare derivative works, 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 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 +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to Python. + +4. PSF is making Python available to Licensee on an "AS IS" +basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, +OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. Nothing in this License Agreement shall be deemed to create any +relationship of agency, partnership, or joint venture between PSF and +Licensee. This License Agreement does not grant permission to use PSF +trademarks or trade name in a trademark sense to endorse or promote +products or services of Licensee, or any third party. + +8. By copying, installing or otherwise using Python, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + + +BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0 +------------------------------------------- + +BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1 + +1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an +office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the +Individual or Organization ("Licensee") accessing and otherwise using +this software in source or binary form and its associated +documentation ("the Software"). + +2. Subject to the terms and conditions of this BeOpen Python License +Agreement, BeOpen hereby grants Licensee a non-exclusive, +royalty-free, world-wide license to reproduce, analyze, test, perform +and/or display publicly, prepare derivative works, distribute, and +otherwise use the Software alone or in any derivative version, +provided, however, that the BeOpen Python License is retained in the +Software, alone or in any derivative version prepared by Licensee. + +3. BeOpen is making the Software available to Licensee on an "AS IS" +basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE +SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS +AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY +DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +5. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +6. This License Agreement shall be governed by and interpreted in all +respects by the law of the State of California, excluding conflict of +law provisions. Nothing in this License Agreement shall be deemed to +create any relationship of agency, partnership, or joint venture +between BeOpen and Licensee. This License Agreement does not grant +permission to use BeOpen trademarks or trade names in a trademark +sense to endorse or promote products or services of Licensee, or any +third party. As an exception, the "BeOpen Python" logos available at +http://www.pythonlabs.com/logos.html may be used according to the +permissions granted on that web page. + +7. By copying, installing or otherwise using the software, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + + +CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1 +--------------------------------------- + +1. This LICENSE AGREEMENT is between the Corporation for National +Research Initiatives, having an office at 1895 Preston White Drive, +Reston, VA 20191 ("CNRI"), and the Individual or Organization +("Licensee") accessing and otherwise using Python 1.6.1 software in +source or binary form and its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, CNRI +hereby grants Licensee a nonexclusive, royalty-free, world-wide +license to reproduce, analyze, test, perform and/or display publicly, +prepare derivative works, distribute, and otherwise use Python 1.6.1 +alone or in any derivative version, provided, however, that CNRI's +License Agreement and CNRI's notice of copyright, i.e., "Copyright (c) +1995-2001 Corporation for National Research Initiatives; All Rights +Reserved" are retained in Python 1.6.1 alone or in any derivative +version prepared by Licensee. Alternately, in lieu of CNRI's License +Agreement, Licensee may substitute the following text (omitting the +quotes): "Python 1.6.1 is made available subject to the terms and +conditions in CNRI's License Agreement. This Agreement together with +Python 1.6.1 may be located on the Internet using the following +unique, persistent identifier (known as a handle): 1895.22/1013. This +Agreement may also be obtained from a proxy server on the Internet +using the following URL: http://hdl.handle.net/1895.22/1013". + +3. In the event Licensee prepares a derivative work that is based on +or incorporates Python 1.6.1 or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to Python 1.6.1. + +4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS" +basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1, +OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. This License Agreement shall be governed by the federal +intellectual property law of the United States, including without +limitation the federal copyright law, and, to the extent such +U.S. federal law does not apply, by the law of the Commonwealth of +Virginia, excluding Virginia's conflict of law provisions. +Notwithstanding the foregoing, with regard to derivative works based +on Python 1.6.1 that incorporate non-separable material that was +previously distributed under the GNU General Public License (GPL), the +law of the Commonwealth of Virginia shall govern this License +Agreement only as to issues arising under or with respect to +Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this +License Agreement shall be deemed to create any relationship of +agency, partnership, or joint venture between CNRI and Licensee. This +License Agreement does not grant permission to use CNRI trademarks or +trade name in a trademark sense to endorse or promote products or +services of Licensee, or any third party. + +8. By clicking on the "ACCEPT" button where indicated, or by copying, +installing or otherwise using Python 1.6.1, Licensee agrees to be +bound by the terms and conditions of this License Agreement. + + ACCEPT + + +CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2 +-------------------------------------------------- + +Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam, +The Netherlands. All rights reserved. + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Stichting Mathematisch +Centrum or CWI not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO +THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE +FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + +Licenses and Acknowledgements for Incorporated Software +======================================================= + +Mersenne Twister +---------------- + +The `_random' module includes code based on a download from +`http://www.math.keio.ac.jp/~matumoto/MT2002/emt19937ar.html'. The +following are the verbatim comments from the original code: + + A C-program for MT19937, with initialization improved 2002/1/26. + Coded by Takuji Nishimura and Makoto Matsumoto. + + Before using, initialize the state by using init_genrand(seed) + or init_by_array(init_key, key_length). + + Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, + 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. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT + OWNER 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. + + Any feedback is very welcome. + http://www.math.keio.ac.jp/matumoto/emt.html + email: matumoto@math.keio.ac.jp + + +Sockets +------- + +The `socket' module uses the functions, `getaddrinfo', and +`getnameinfo', which are coded in separate source files from the WIDE +Project, `http://www.wide.ad.jp/about/index.html'. + + Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + 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 the project nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + GAI_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 PROJECT OR CONTRIBUTORS BE LIABLE + FOR GAI_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 GAI_ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN GAI_ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + + +Floating point exception control +-------------------------------- + +The source for the `fpectl' module includes the following notice: + + --------------------------------------------------------------------- + / Copyright (c) 1996. \ + | The Regents of the University of California. | + | All rights reserved. | + | | + | Permission to use, copy, modify, and distribute this software for | + | any purpose without fee is hereby granted, provided that this en- | + | tire notice is included in all copies of any software which is or | + | includes a copy or modification of this software and in all | + | copies of the supporting documentation for such software. | + | | + | This work was produced at the University of California, Lawrence | + | Livermore National Laboratory under contract no. W-7405-ENG-48 | + | between the U.S. Department of Energy and The Regents of the | + | University of California for the operation of UC LLNL. | + | | + | DISCLAIMER | + | | + | This software was prepared as an account of work sponsored by an | + | agency of the United States Government. Neither the United States | + | Government nor the University of California nor any of their em- | + | ployees, makes any warranty, express or implied, or assumes any | + | liability or responsibility for the accuracy, completeness, or | + | usefulness of any information, apparatus, product, or process | + | disclosed, or represents that its use would not infringe | + | privately-owned rights. Reference herein to any specific commer- | + | cial products, process, or service by trade name, trademark, | + | manufacturer, or otherwise, does not necessarily constitute or | + | imply its endorsement, recommendation, or favoring by the United | + | States Government or the University of California. The views and | + | opinions of authors expressed herein do not necessarily state or | + | reflect those of the United States Government or the University | + | of California, and shall not be used for advertising or product | + \ endorsement purposes. / + --------------------------------------------------------------------- + + +Cookie management +----------------- + +The `Cookie' module contains the following notice: + + Copyright 2000 by Timothy O'Malley + + All Rights Reserved + + Permission to use, copy, modify, and distribute this software + and its documentation for any purpose and without fee is hereby + granted, provided that the above copyright notice appear in all + copies and that both that copyright notice and this permission + notice appear in supporting documentation, and that the name of + Timothy O'Malley not be used in advertising or publicity + pertaining to distribution of the software without specific, written + prior permission. + + Timothy O'Malley DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS, IN NO EVENT SHALL Timothy O'Malley BE LIABLE FOR + ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + + +Execution tracing +----------------- + +The `trace' module contains the following notice: + + portions copyright 2001, Autonomous Zones Industries, Inc., all rights... + err... reserved and offered to the public under the terms of the + Python 2.2 license. + Author: Zooko O'Whielacronx + http://zooko.com/ + mailto:zooko@zooko.com + + Copyright 2000, Mojam Media, Inc., all rights reserved. + Author: Skip Montanaro + + Copyright 1999, Bioreason, Inc., all rights reserved. + Author: Andrew Dalke + + Copyright 1995-1997, Automatrix, Inc., all rights reserved. + Author: Skip Montanaro + + Copyright 1991-1995, Stichting Mathematisch Centrum, all rights reserved. + + Permission to use, copy, modify, and distribute this Python software and + its associated documentation for any purpose without fee is hereby + granted, provided that the above copyright notice appears in all copies, + and that both that copyright notice and this permission notice appear in + supporting documentation, and that the name of neither Automatrix, + Bioreason or Mojam Media be used in advertising or publicity pertaining + to distribution of the software without specific, written prior + permission. + + +UUencode and UUdecode functions +------------------------------- + +The `uu' module contains the following notice: + + Copyright 1994 by Lance Ellinghouse + Cathedral City, California Republic, United States of America. + All Rights Reserved + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose and without fee is hereby granted, + provided that the above copyright notice appear in all copies and that + both that copyright notice and this permission notice appear in + supporting documentation, and that the name of Lance Ellinghouse + not be used in advertising or publicity pertaining to distribution + of the software without specific, written prior permission. + LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO + THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS, IN NO EVENT SHALL LANCE ELLINGHOUSE CENTRUM BE LIABLE + FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + Modified by Jack Jansen, CWI, July 1995: + - Use binascii module to do the actual line-by-line conversion + between ascii and binary. This results in a 1000-fold speedup. The C + version is still 5 times faster, though. + - Arguments more compliant with python standard + + +XML Remote Procedure Calls +-------------------------- + +The `xmlrpclib' module contains the following notice: + + The XML-RPC client interface is + + Copyright (c) 1999-2002 by Secret Labs AB + Copyright (c) 1999-2002 by Fredrik Lundh + + By obtaining, using, and/or copying this software and/or its + associated documentation, you agree that you have read, understood, + and will comply with the following terms and conditions: + + Permission to use, copy, modify, and distribute this software and + its associated documentation for any purpose and without fee is + hereby granted, provided that the above copyright notice appears in + all copies, and that both that copyright notice and this permission + notice appear in supporting documentation, and that the name of + Secret Labs AB or the author not be used in advertising or publicity + pertaining to distribution of the software without specific, written + prior permission. + + SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- + ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR + BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + OF THIS SOFTWARE. + +Licenses for Software linked to +=============================== + +Note that the choice of GPL compatibility outlined above doesn't extend +to modules linked to particular libraries, since they change the +effective License of the module binary. + + +GNU Readline +------------ + +The 'readline' module makes use of GNU Readline. + + The GNU Readline Library 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, or (at + your option) any later version. + + On Debian systems, you can find the complete statement in + /usr/share/doc/readline-common/copyright'. A copy of the GNU General + Public License is available in /usr/share/common-licenses/GPL-2'. + + +OpenSSL +------- + +The '_ssl' module makes use of OpenSSL. + + The OpenSSL toolkit stays under a dual license, i.e. both the + conditions of the OpenSSL License and the original SSLeay license + apply to the toolkit. Actually both licenses are BSD-style Open + Source licenses. Note that both licenses are incompatible with + the GPL. + + On Debian systems, you can find the complete license text in + /usr/share/doc/openssl/copyright'. + + +Files with other licenses than the Python License +------------------------------------------------- + +Files: Lib/profile.py Lib/pstats.py +Copyright: Disney Enterprises, Inc. All Rights Reserved. +License: # Licensed to PSF under a Contributor Agreement + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + either express or implied. See the License for the specific language + overning permissions and limitations under the License. + + On Debian systems, the Apache 2.0 license can be found in + /usr/share/common-licenses/Apache-2.0. + +Files: Modules/zlib/* +Copyright: (C) 1995-2010 Jean-loup Gailly and Mark Adler +License: This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + If you use the zlib library in a product, we would appreciate *not* receiving + lengthy legal documents to sign. The sources are provided for free but without + warranty of any kind. The library has been entirely written by Jean-loup + Gailly and Mark Adler; it does not include third-party code. + +Files: Modules/_ctypes/libffi/* +Copyright: Copyright (C) 1996-2009 Red Hat, Inc and others. +License: Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + ``Software''), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + Documentation: + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. A copy of the license is included in the + section entitled ``GNU General Public License''. + +Files: Modules/expat/* +Copyright: Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd + and Clark Cooper + Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers +License: Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Files: Misc/python-mode.el +Copyright: Copyright (C) 1992,1993,1994 Tim Peters +License: This software is provided as-is, without express or implied + warranty. Permission to use, copy, modify, distribute or sell this + software, without fee, for any purpose and by any individual or + organization, is hereby granted, provided that the above copyright + notice and this paragraph appear in all copies. + +Files: PC/_subprocess.c +Copyright: Copyright (c) 2004 by Fredrik Lundh + Copyright (c) 2004 by Secret Labs AB, http://www.pythonware.com + Copyright (c) 2004 by Peter Astrand +License: + * Permission to use, copy, modify, and distribute this software and + * its associated documentation for any purpose and without fee is + * hereby granted, provided that the above copyright notice appears in + * all copies, and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of the + * authors not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. + * + * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Files: PC/winsound.c +Copyright: Copyright (c) 1999 Toby Dickenson +License: * Permission to use this software in any way is granted without + * fee, provided that the copyright notice above appears in all + * copies. This software is provided "as is" without any warranty. + */ + +/* Modified by Guido van Rossum */ +/* Beep added by Mark Hammond */ +/* Win9X Beep and platform identification added by Uncle Timmy */ --- python3.2-3.2.3.orig/debian/PVER-dbg.postinst.in +++ python3.2-3.2.3/debian/PVER-dbg.postinst.in @@ -0,0 +1,24 @@ +#! /bin/sh -e + +if [ "$1" = configure ]; then + if [ -d /usr/include/@PVER@_d ] && [ ! -h /usr/include/@PVER@_d ]; then + if rmdir /usr/include/@PVER@_d 2> /dev/null; then + ln -sf @PVER@dmu /usr/include/@PVER@_d + else + echo >&2 "WARNING: non-empty directory on upgrade: /usr/include/@PVER@_d" + ls -l /usr/include/@PVER@_d + fi + fi + if [ -d /usr/lib/@PVER@/config_d ] && [ ! -h /usr/lib/@PVER@/config_d ]; then + if rmdir /usr/lib/@PVER@/config_d 2> /dev/null; then + ln -sf config-dmu /usr/lib/@PVER@/config_d + else + echo >&2 "WARNING: non-empty directory on upgrade: /usr/lib/@PVER@/config_d" + ls -l /usr/lib/@PVER@/config_d + fi + fi +fi + +#DEBHELPER# + +exit 0 --- python3.2-3.2.3.orig/debian/changelog +++ python3.2-3.2.3/debian/changelog @@ -0,0 +1,2382 @@ +python3.2 (3.2.3-3) unstable; urgency=low + + * Update to 20120709 from the 3.2 branch. Fixes: + - Issue #15020: The program name used to search for Python's path is now + "python3" under Unix, not "python". + - Issue #15033: Fix the exit status bug when modules invoked using -m + switch, return the proper failure return value (1). + - Issue #12268: File readline, readlines and read() or readall() methods + no longer lose data when an underlying read system call is interrupted. + IOError is no longer raised due to a read system call returning EINTR + from within these methods. + - Issue #15142: Fix reference leak when deallocating instances of types + created using PyType_FromSpec(). + - Issue #10053: Don't close FDs when FileIO.__init__ fails. + - Issue #14990: Correctly fail with SyntaxError on invalid encoding + declaration. + - Issue #15247: FileIO now raises an error when given a file descriptor + pointing to a directory. + - Issue #5346: Preserve permissions of mbox, MMDF and Babyl mailbox + files on flush(). + - Issue #10571: Fix the "--sign" option of distutils' upload command. + - Issue #9559: If messages were only added, a new file is no longer + created and renamed over the old file when flush() is called on an + mbox, MMDF or Babyl mailbox. + - Issue #14653: email.utils.mktime_tz() no longer relies on system + mktime() when timezone offest is supplied. + - Fix GzipFile's handling of filenames given as bytes objects. + - Issue #15101: Make pool finalizer avoid joining current thread. + - Issue #15036: Mailbox no longer throws an error if a flush is done + between operations when removing or changing multiple items in mbox, + MMDF, or Babyl mailboxes. + - test_nntplib now tolerates being run from behind NNTP gateways that add + "X-Antivirus" headers to articles. + - Issue #15043: test_gdb is now skipped entirely if gdb security settings + block loading of the gdb hooks. + - Issue #13557: Clarify effect of giving two different namespaces to exec + or execfile(). + - Issue #15300: Ensure the temporary test working directories are in the same + parent folder when running tests in multiprocess mode from a Python build. + * Lookup extension modules with a multiarch suffix too. + * Include /usr/include/ncursesw in CPPFLAGS for the curses configure + checks. Closes: #681007. LP: #1021783. + * Fix running the testsuite. + * Backport issue #13150: sysconfig no longer parses the Makefile and config.h + files when imported, instead doing it at build time. This makes importing + sysconfig faster and reduces Python startup time by 20%. + * Don't build the _hashlib and _ssl extensions as a builtin, but as + extensions. Addresses: #680930. + * python3.2: Add a break for python-virtualenv (<< 1.7.1.2-2~). + * For lto builds, use -g instead of -g1; filter out lto flags in the + installed Makefile. Addresses: #681348. + * Don't run the test_gdb test on mips/mipsel, not even in debug mode. + + -- Matthias Klose Fri, 13 Jul 2012 21:40:01 +0200 + +python3.2 (3.2.3-2) unstable; urgency=medium + + * Fix symlink for the -gdb.py file. + * Update to 20120625 from the 3.2 branch. + + -- Matthias Klose Tue, 26 Jun 2012 00:01:40 +0200 + +python3.2 (3.2.3-1) unstable; urgency=low + + * Python 3.2.3 release. + * Update to 20120615 from the 3.2 branch. + * Use xdg-open/gvfs-open in Lib/webbrowser.py (Michael Vogt). + LP: #971311. + * Build _ctypes as an extension, not a builtin. LP: #909292. + Closes: #665359. + * Mark symbols defined in the _ctypes extension as optional. + * The wininst-* files cannot be built within Debian from the included + sources, needing a zlib mingw build, which the zlib maintainer isn't + going to provide. Closes: #639408. + * Proposed patch for CVE-2012-2135: Vulnerability in the utf-16 decoder + after error handling. Closes: #670389. + * Remove PVER-doc.doc-base.PVER-doc.in. Closes: #663333. + * Use the underscore.js file provided by the libjs-underscore package. + * Let pydoc handle dist-packages the same as site-packages. + Closes: #671412. + * Avoid runtime path for the sqlite extension. + * Do not italicize punctuation in python(1) manual page (Matt Kraai). + + -- Matthias Klose Fri, 15 Jun 2012 14:26:53 +0200 + +python3.2 (3.2.3~rc2-1) unstable; urgency=low + + * Python 3.2.3 release candidate 2. + * Build-depend on expat (>= 2.1~). + + -- Matthias Klose Wed, 21 Mar 2012 06:34:44 +0100 + +python3.2 (3.2.3~rc1-1) unstable; urgency=low + + * Python 3.2.3 release candidate 1. + * Update to 20120309 from the 3.2 branch. + * Fix libpython.a symlink. Closes: #660146. + * Build-depend on xauth. + * Run the gdb tests for the debug build only. + + -- Matthias Klose Fri, 09 Mar 2012 18:40:39 +0100 + +python3.2 (3.2.2-4) unstable; urgency=low + + * The static library belongs into the -dev package. + * Remove obsolete attributes in the control file. + + -- Matthias Klose Sat, 07 Jan 2012 20:46:39 +0100 + +python3.2 (3.2.2-3) unstable; urgency=low + + * Update to 20120106 from the 3.2 branch. + * Install manual pages for 2to3 and python-config. + * Fix file permission of token.py module. + * Add the ability to build an python3.x udeb, as copy of the + python3.x-minimal package (Colin Watson). + * Overwrite some lintian warnings: + - The -dbg interpreters are not unusual. + - The -gdb.py files don't need a python dependency. + - lintian can't handle a whatis entry starting with one word on the line. + * Fix test failures related to distutils debian installation layout. + * Update symbols files. + * Add build-arch/build-indep targets. + * Regenerate Setup and Makefiles after correcting Setup.local. + * profiled-build.diff: Pass PY_CFLAGS instead of CFLAGS for the profiled + build. + * Pass dpkg-buildflags to the build process, and build third party + extensions with these flags. + * Add support to build using -flto (and -g1) on some architectures. + * Disable pgo builds for some architectures (for now, keep just + amd64 armel armhf i386 powerpc ppc64). + * Build-depend on libgdbm-dev to build and run the gdbm tests. + * Build-depend on xvfb to run the tkinter tests. + + -- Matthias Klose Fri, 06 Jan 2012 20:10:13 +0100 + +python3.2 (3.2.2-2) unstable; urgency=low + + * Update platform patches (alpha, hppa, mips, sparc). + + -- Matthias Klose Fri, 02 Dec 2011 10:24:05 +0100 + +python3.2 (3.2.2-1) unstable; urgency=low + + * Python 3.2.2 release. + * Update to 20111201 from the 3.2 branch. + * Search headers in /usr/include/ncursesw for the curses/panel extensions. + * New patch, ctypes-arm, allow for ",hard-float" after libc6 in ldconfig -p + output (Loic Minier). LP: #898172. + + -- Matthias Klose Thu, 01 Dec 2011 13:19:16 +0100 + +python3.2 (3.2.2~rc1-1) unstable; urgency=low + + * Python 3.2.2 release candidate 1. + + -- Matthias Klose Sun, 14 Aug 2011 20:25:35 +0200 + +python3.2 (3.2.1-2) unstable; urgency=low + + * Update to 20110803 from the 3.2 branch. + * Revert previous change to treat Linux 3.x as Linux 2. Use the + plat-linux3 directory instead. + * Use linux-any for some build dependencies. Closes: #634310. + + -- Matthias Klose Wed, 03 Aug 2011 15:16:05 +0200 + +python3.2 (3.2.1-1) unstable; urgency=medium + + * Python 3.2.1 release. + * Update lib-argparse patch (Pino Toscano). Closes: #631635. + * Treat Linux 3.x as Linux 2. Closes: #633015. + + -- Matthias Klose Sun, 10 Jul 2011 21:46:36 +0200 + +python3.2 (3.2.1~rc2-1) unstable; urgency=low + + * Python 3.2.1 release candidate 2. + * Add profile/pstats to the python3.2 package, update debian copyright. + * Don't run the benchmark on hurd-i386. + * Disable threading tests on hurd-i386. Closes: #631634. + * Don't add the bsddb multilib path, if already in the standard lib path. + + -- Matthias Klose Mon, 04 Jul 2011 20:27:52 +0200 + +python3.2 (3.2.1~rc1-1) unstable; urgency=low + + * Python 3.2.1 release candidate 1. + * Only enable sphinx-0.x patches when building with sphinx-0.x. + + -- Matthias Klose Wed, 18 May 2011 12:15:47 +0200 + +python3.2 (3.2-4) unstable; urgency=low + + * Update to 20110504 from the 3.2 branch. + * Disable the profiled build on ia64 and m68k. + * Update symbols file for m68k (Thorsten Glaser). + + -- Matthias Klose Wed, 04 May 2011 21:32:08 +0200 + +python3.2 (3.2-3) unstable; urgency=low + + * Update to 20110427 from the 3.2 branch. + - Fix argparse import. Closes: #624277. + * Keep the ssl.PROTOCOL_SSLv2 module constant , just raise an exception + when trying to create a PySSL object. #624127. + * Don't depend on the locale and specific awk implementations in prerm. + Closes: #623466, #620836. + * Remove the old local site directory. Closes: #623057. + + -- Matthias Klose Wed, 27 Apr 2011 20:40:29 +0200 + +python3.2 (3.2-2) unstable; urgency=low + + * Update to 20110419 from the 3.2 branch. + * Re-enable profile-guided builds. + * Build without OpenSSL v2 support. Closes: #622004. + * Force linking the curses module against libncursesw. Closes: #622064. + * Re-enable running the testsuite during the build. + + -- Matthias Klose Tue, 19 Apr 2011 17:54:36 +0200 + +python3.2 (3.2-1) unstable; urgency=low + + * Python 3.2 final release. + + -- Matthias Klose Sun, 20 Feb 2011 19:22:24 +0100 + +python3.2 (3.2~rc3-1) experimental; urgency=low + + * Python 3.2 release candidate 3. + + -- Matthias Klose Mon, 14 Feb 2011 16:12:14 +0100 + +python3.2 (3.2~rc1-2) experimental; urgency=low + + * Fix upgrade of the python3.2-dev package. Closes: #610370. + + -- Matthias Klose Wed, 19 Jan 2011 02:21:19 +0100 + +python3.2 (3.2~rc1-1) experimental; urgency=low + + * Python 3.2 release candidate 1. + + -- Matthias Klose Sun, 16 Jan 2011 22:17:09 +0100 + +python3.2 (3.2~b2-1) experimental; urgency=low + + * Python 3.2 beta2 release. + * Fix FTBFS on hurd-i386 (Pino Toscano). Closes: #606152). + + -- Matthias Klose Tue, 21 Dec 2010 21:23:21 +0100 + +python3.2 (3.2~b1-1) experimental; urgency=low + + * Python 3.2 beta1 release. + * Configure with --enable-loadable-sqlite-extensions. + + -- Matthias Klose Mon, 06 Dec 2010 12:19:09 +0100 + +python3.2 (3.2~a4-2) experimental; urgency=low + + * Fix build failure on the hurd. + + -- Matthias Klose Fri, 26 Nov 2010 06:38:41 +0100 + +python3.2 (3.2~a4-1) experimental; urgency=low + + * Python 3.2 alpha4 release. + * Update to the py3k branch (20101124). + * Move the Makefile into the -min package, required by sysconfig. + Addresses: #603237. + + -- Matthias Klose Wed, 24 Nov 2010 22:20:32 +0100 + +python3.2 (3.2~a3-2) experimental; urgency=low + + * Update to the py3k branch (20101018). + - Issue #10094: Use versioned .so files on GNU/kfreeBSD and the GNU Hurd. + Closes: #600183. + + -- Matthias Klose Mon, 18 Oct 2010 19:34:39 +0200 + +python3.2 (3.2~a3-1) experimental; urgency=low + + * Python 3.2 alpha3 release. + * Make Lib/plat-gnukfreebsd[78] ready for python3. Closes: #597874. + + -- Matthias Klose Tue, 12 Oct 2010 16:13:15 +0200 + +python3.2 (3.2~a2-7) experimental; urgency=low + + * Update to the py3k branch (20100926). + + -- Matthias Klose Sun, 26 Sep 2010 14:41:18 +0200 + +python3.2 (3.2~a2-6) experimental; urgency=low + + * Update to the py3k branch (20100919). + * Update GNU/Hurd patches (Pino Toscano). Closes: #597320. + + -- Matthias Klose Sun, 19 Sep 2010 12:45:14 +0200 + +python3.2 (3.2~a2-5) experimental; urgency=low + + * Update to the py3k branch (20100916). + * Provide Lib/plat-gnukfreebsd[78] (Jakub Wilk). Addresses: #593818. + * Assume working semaphores, don't rely on running kernel for the check. + LP: #630511. + + -- Matthias Klose Thu, 16 Sep 2010 14:41:58 +0200 + +python3.2 (3.2~a2-4) experimental; urgency=low + + * Update to the py3k branch (20100911). + * Add the sysconfig module to python3.2-minimal. + * Remove dist-packages/README. + * Make xargs --show-limits in the maintainer scripts independent from + the locale. + + -- Matthias Klose Sat, 11 Sep 2010 20:59:47 +0200 + +python3.2 (3.2~a2-3) experimental; urgency=low + + * Update to the py3k branch (20100910). + * Disable profile feedback based optimization on armel. + * Add copyright information for expat, libffi and zlib. Sources + for the wininst-* files are in PC/bdist_wininst. Closes: #596276. + * Run the testsuite in parallel, when parallel= is set in DEB_BUILD_OPTIONS. + + -- Matthias Klose Fri, 10 Sep 2010 20:28:16 +0200 + +python3.2 (3.2~a2-2) experimental; urgency=low + + * Fix distutils.sysconfig.get_makefile_name for debug builds. + + -- Matthias Klose Thu, 09 Sep 2010 02:40:11 +0200 + +python3.2 (3.2~a2-1) experimental; urgency=low + + * Python 3.2 alpha2 release. + * Update to the py3k branch (20100908). + * Provide /usr/lib/python3/dist-packages as location for public python + packages. + + -- Matthias Klose Wed, 08 Sep 2010 17:36:06 +0200 + +python3.2 (3.2~a1-1) experimental; urgency=low + + * Python 3.2 alpha1 release. + - Files removed: Lib/profile.py, Lib/pstats.py, PC/icons/source.xar. + * Update to the py3k branch (20100827). + * Fix detection of ffi.h header file. Closes: #591408. + * python3.1-dev: Depend on libssl-dev. LP: #611845. + + -- Matthias Klose Fri, 27 Aug 2010 21:40:31 +0200 + +python3.2 (3.2~~20100707-0ubuntu1) maverick; urgency=low + + * Move the pkgconfig file into the -dev package. + * Update preremoval scripts for __pycache__ layout. + * Run hooks from /usr/share/python3/runtime.d/ + * Update distutils-install-layout and debug-build patches. + + -- Matthias Klose Wed, 07 Jul 2010 12:38:52 +0200 + +python3.2 (3.2~~20100706-0ubuntu1) maverick; urgency=low + + * Test build, taken from the py3k branch (20100706). + * Merge with the python3.1 packaging. + + -- Matthias Klose Tue, 06 Jul 2010 17:10:51 +0200 + +python3.2 (3.2~~20100704-0ubuntu1) maverick; urgency=low + + * Test build, taken from the py3k branch (20100704). + + -- Matthias Klose Sun, 04 Jul 2010 16:04:45 +0200 + +python3.2 (3.2~~20100421-0ubuntu1) lucid; urgency=low + + * Test build, taken from the py3k branch (20100421). + + -- Matthias Klose Wed, 21 Apr 2010 22:04:14 +0200 + +python3.1 (3.1.2+20100703-1) unstable; urgency=low + + * Update to the 3.1 release branch, 20100703. + * Convert internal dpatch system to quilt. + * Update module list for python3-minimal. + + -- Matthias Klose Sat, 03 Jul 2010 14:18:18 +0200 + +python3.1 (3.1.2-3) unstable; urgency=low + + * Update to the 3.1 release branch, 20100508. + * Fix backport of issue #8140. Closes: #578896. + + -- Matthias Klose Sat, 08 May 2010 15:37:35 +0200 + +python3.1 (3.1.2-2) unstable; urgency=low + + * Update to the 3.1 release branch, 20100421. + * Update patch for issue #8032, gdb7 hooks for debugging. + * Fix issue #8233: When run as a script, py_compile.py optionally + takes a single argument `-`. + * Don't build-depend on locales on avr32. + + -- Matthias Klose Wed, 21 Apr 2010 21:12:37 +0200 + +python3.1 (3.1.2-1) unstable; urgency=low + + * Python 3.1.2 release. + * Fix issue #4961: Inconsistent/wrong result of askyesno function in + tkMessageBox with Tcl8.5. LP: #462950. + * Don't complain when /usr/local is not writable on installation. + * Apply proposed patch for issue #8032, gdb7 hooks for debugging. + + -- Matthias Klose Sun, 21 Mar 2010 17:59:49 +0100 + +python3.1 (3.1.2~rc1-2) unstable; urgency=low + + * Update to the 3.1 release branch, 20100316. + * Backport issue #8140: Extend compileall to compile single files. + Add -i option. + + -- Matthias Klose Tue, 16 Mar 2010 02:38:45 +0100 + +python3.1 (3.1.2~rc1-1) unstable; urgency=low + + * Python 3.1.2 release candidate 1. + - Replace the Monty Python audio test file. Closes: #568676. + * Build using libdb4.8-dev. Only used for the dbm extension; the bsddb3 + extension isn't built from the core packages anymore. + + -- Matthias Klose Thu, 11 Mar 2010 17:26:17 +0100 + +python3.1 (3.1.1-3) unstable; urgency=low + + * Update to the 3.1 release branch, 20100119. + * Hurd fixes (Pino Toscano): + - hurd-broken-poll.dpatch: ported from 2.5. + - hurd-disable-nonworking-constants.dpatch: disable a few constants from + the public API whose C counterparts are not implemented, so using them + either always blocks or always fails (caused issues in the test suite). + - hurd-path_max.dpatch (hurd only): change few PATH_MAX occurrences to + MAXPATHLEN (which is defined by the python lib if not defined by the OS). + - cthreads.dpatch: Refresh. + - Exclude the profiled build for hurd. + - Disable six blocking tests from the test suite. + * Don't run the testsuite on armel and hppa until someone figures out + the blocking tests. + + -- Matthias Klose Tue, 19 Jan 2010 22:02:14 +0100 + +python3.1 (3.1.1-2) unstable; urgency=low + + * Update to the 3.1 release branch, 20100116. + * Fix bashism in makesetup shell script. Closes: #530170, #530171. + * Fix build issues on avr (Bradley Smith). Closes: #528439. + - Configure --without-ffi. + - Don't run lengthly tests. + + -- Matthias Klose Sat, 16 Jan 2010 23:28:05 +0100 + +python3.1 (3.1.1-1) experimental; urgency=low + + * Python 3.1.1 final release. + * Update to the 3.1 release branch, 20091011. + * Remove /usr/local/lib/python3.1 on package removal, if empty. + * Build _hashlib as a builtin. LP: #445530. + * python3.1-doc: Don't compress the sphinx inventory. + * python3.1-doc: Fix jquery.js symlink. LP: #447370. + * Run the benchmark with -C 2 -n 5 -w 4 on all architectures. + * python3.1-dbg: Don't create debug subdirectory in /usr/local. No + separate debug directory needed anymore. + * Fix title of devhelp document. LP: #423551. + + -- Matthias Klose Sun, 11 Oct 2009 22:01:57 +0200 + +python3.1 (3.1-1) experimental; urgency=low + + * Python 3.1 final release. + * Update to the 3.1 release branch, 20090723. + * Add explicit build dependency on tk8.5-dev. + + -- Matthias Klose Thu, 23 Jul 2009 15:20:35 +0200 + +python3.1 (3.1-0ubuntu2) karmic; urgency=low + + * Disable profile feedback based optimization on amd64 (GCC + PR gcov-profile/38292). + + -- Matthias Klose Fri, 24 Jul 2009 16:27:22 +0200 + +python3.1 (3.1-0ubuntu1) karmic; urgency=low + + * Python 3.1 final release. + * Update to the 3.1 release branch, 20090723. + * Add explicit build dependency on tk8.5-dev. + + -- Matthias Klose Thu, 23 Jul 2009 18:52:17 +0200 + +python3.1 (3.1~rc2+20090622-1) experimental; urgency=low + + [Matthias Klose] + * Python 3.1 rc2 release. Closes: #529320. + * Update to the trunk, 20090622, remove patches integrated upstream. + * Configure with --with-fpectl --with-dbmliborder=bdb --with-wide-unicode. + NOTE: The --with-wide-unicode configuration will break most extensions + built with 3.1~a1, but is consistent with python2.x configurations. + * Add symbols files for libpython3.1 and python3.1-dbg, don't include symbols + from builtins, which can either be built as builtins or extensions. + * Keep an empty lib-dynload in python3.1-minimal to avoid a warning on + startup. + * python3.1-doc: Depend on libjs-jquery, use jquery.js from this package. + Closes: #523485. + * Do not add /usr/lib/pythonXY.zip on sys.path. + * Add symbols files for libpython3.1 and python3.1-dbg, don't include symbols + from builtins, which can either be built as builtins or extensions. + * Keep an empty lib-dynload in python3.1-minimal to avoid a warning on + startup. + * Fix some lintian warnings. + * Use the information in /etc/lsb-release for platform.dist(). LP: #196526. + * Move the bdist_wininst files into the -dev package (only needed to build + windows installers). + * Document changes to the site directory name in the installation manual. + * Don't build a profiled binary. Closes: #521811. + + * Address issues when working with PYTHONUSERBASE and non standard prefix + (pointed out by Larry Hastings): + - distutils.sysconfig.get_python_lib(): Only return ".../dist-packages" if + prefix is the default prefix and if PYTHONUSERBASE is not set in the + environment. + - site.addusersitepackages(): Add USER_BASE/.../dist-packages to sys.path. + * Always use the `unix_prefix' scheme for setup.py install in a virtualenv + setup. LP: #339904. + * Don't make the setup.py install options --install-layout=deb and --prefix + conflict with each other. + * distutils: Always install into `/usr/local/lib/python3.1/dist-packages' + if an option `--prefix=/usr/local' is present (except for virtualenv + and PYTHONUSERBASE installations). LP: #362570. + * Always use `site-packages' as site directory name in virtualenv. + + [Marc Deslauriers] + * debian/pyhtml2devhelp.py: update for sphinx generated documentation. + * debian/rules: re-enable documentation files for devhelp. + + -- Matthias Klose Mon, 22 Jun 2009 16:18:39 +0200 + +python3.1 (3.1~a1+20090322-1) experimental; urgency=low + + * Python 3.1 alpha1 release. + * Update to the trunk, 20090322. + * Update installation schemes: LP: #338395. + - When the --prefix option is used for setup.py install, Use the + `unix_prefix' scheme. + - Use the `deb_system' scheme if --install-layout=deb is specified. + - Use the the `unix_local' scheme if neither --install-layout=deb + nor --prefix is specified. + * Use the information in /etc/lsb-release for platform.dist(). LP: #196526. + * pydoc: Fix detection of local documentation files. + * Build a shared library configured --with-pydebug. LP: #322580. + * Fix some lintian warnings. + + -- Matthias Klose Mon, 23 Mar 2009 00:01:27 +0100 + +python3.1 (3.1~~20090226-1) experimental; urgency=low + + * Python-3.1 snapshot (20090226), upload to experimental. + + -- Matthias Klose Thu, 26 Feb 2009 16:18:41 +0100 + +python3.1 (3.1~~20090222-0ubuntu1) jaunty; urgency=low + + * Python-3.1 snapshot (20090222). + * Build the _dbm extension using the Berkeley DB backend. + + -- Matthias Klose Sun, 22 Feb 2009 12:58:58 +0100 + +python3.0 (3.0.1-0ubuntu4) jaunty; urgency=low + + * Don't build-depend on locales on sparc. Currently not installable. + + -- Matthias Klose Sun, 22 Feb 2009 12:48:38 +0100 + +python3.0 (3.0.1-0ubuntu3) jaunty; urgency=low + + * Update to 20090222 from the release30-maint branch. + + -- Matthias Klose Sun, 22 Feb 2009 11:09:58 +0100 + +python3.0 (3.0.1-0ubuntu2) jaunty; urgency=low + + * Allow docs to be built with Sphinx 0.5.x. + + -- Matthias Klose Tue, 17 Feb 2009 12:58:02 +0100 + +python3.0 (3.0.1-0ubuntu1) jaunty; urgency=low + + * New upstream version. + + -- Matthias Klose Mon, 16 Feb 2009 17:18:23 +0100 + +python3.0 (3.0-0ubuntu2) jaunty; urgency=low + + * Update to 20090213 from the release30-maint branch. + + -- Matthias Klose Fri, 13 Feb 2009 15:49:12 +0100 + +python3.0 (3.0-0ubuntu1) jaunty; urgency=low + + * Final Python-3.0 release. + + -- Matthias Klose Thu, 04 Dec 2008 09:00:09 +0100 + +python3.0 (3.0~rc3-0ubuntu4) jaunty; urgency=low + + * Update to 20081127 from the py3k branch. + * Ensure that all extensions from the -minimal package are statically + linked into the interpreter. LP: #301597. + * Include expat, _elementtree, datetime in -minimal to link + these extensions statically. + + -- Matthias Klose Thu, 27 Nov 2008 08:49:02 +0100 + +python3.0 (3.0~rc3-0ubuntu3) jaunty; urgency=low + + * Ignore errors when running the profile task. + + -- Matthias Klose Sun, 23 Nov 2008 15:50:17 +0100 + +python3.0 (3.0~rc3-0ubuntu2) jaunty; urgency=low + + * Don't run test_ioctl on the buildd, before the buildd chroot is fixed: + Unable to open /dev/tty. + + -- Matthias Klose Sun, 23 Nov 2008 15:28:02 +0100 + +python3.0 (3.0~rc3-0ubuntu1) jaunty; urgency=low + + * Update to the python-3.0 release candidate 3. + + -- Matthias Klose Sun, 23 Nov 2008 13:14:20 +0100 + +python3.0 (3.0~rc1+20081027-0ubuntu1) intrepid; urgency=low + + * Update to 20081027 from the py3k branch. LP: #279227. + * Fix typos and section names in doc-base files. LP: #273344. + * Build a new package libpython3.0. + * For locally installed packages, create a directory + /usr/local/lib/python3.0/dist-packages. This is the default for + installations done with distutils and setuptools. Third party stuff + packaged within the distribution goes to /usr/lib/python3.0/dist-packages. + There is no /usr/lib/python3.0/site-packages in the file system and + on sys.path. No package within the distribution must not install + anything in this location. + * distutils: Add an option --install-layout=deb, which + - installs into $prefix/dist-packages instead of $prefix/site-packages. + - doesn't encode the python version into the egg name. + + -- Matthias Klose Mon, 27 Oct 2008 23:38:42 +0100 + +python3.0 (3.0~b3+20080915-0ubuntu1) intrepid; urgency=low + + * Update to 20080915 from the py3k branch. + * Build gdbm + + -- Matthias Klose Mon, 15 Sep 2008 23:56:44 +0200 + +python3.0 (3.0~b3-0ubuntu1~ppa1) intrepid; urgency=low + + * Python 3.0 beta3 release. + + -- Matthias Klose Sun, 24 Aug 2008 03:49:26 +0200 + +python3.0 (3.0~b2-0ubuntu1~ppa1) intrepid; urgency=low + + * Python 3.0 beta2 release. + + -- Matthias Klose Thu, 07 Aug 2008 14:57:02 +0000 + +python3.0 (3.0~b1-0ubuntu1~ppa1) intrepid; urgency=low + + * Python 3.0 beta1 release. + + -- Matthias Klose Tue, 15 Jul 2008 16:10:52 +0200 + +python3.0 (3.0~a5+0530-0ubuntu1) intrepid; urgency=low + + * Update to snapshot taken from the py3k branch. + + -- Matthias Klose Thu, 29 May 2008 15:50:55 +0200 + +python3.0 (3.0~a1-0ubuntu2) gutsy; urgency=low + + * Disable running the benchmark. + + -- Matthias Klose Fri, 31 Aug 2007 23:22:34 +0000 + +python3.0 (3.0~a1-0ubuntu1) gutsy; urgency=low + + * First Python-3.0 alpha release. + + -- Matthias Klose Fri, 31 Aug 2007 21:26:21 +0200 + +python2.6 (2.6~alpha~pre1-~0ubuntu1~ppa1) gutsy; urgency=low + + * Snapshot build, an "how to use tilde in version numbers" upload. + * SVN 20070831. + + -- Matthias Klose Fri, 31 Aug 2007 15:56:09 +0200 + +python2.5 (2.5.2-4) unstable; urgency=low + + * Update to 20080427, taken from the 2.5 release branch. + - Fix issues #2670, #2682. + * Disable running pybench on the hppa buildd (ftbfs). + * Allow setting BASECFLAGS, OPT and EXTRA_LDFLAGS (like, CC, CXX, CPP, + CFLAGS, CPPFLAGS, CCSHARED, LDSHARED) from the environment. + * Support parallel= in DEB_BUILD_OPTIONS (see #209008). + + -- Matthias Klose Sun, 27 Apr 2008 10:40:51 +0200 + +python2.5 (2.5.2-3) unstable; urgency=medium + + * Update to 20080416, taken from the 2.5 release branch. + - Fix CVE-2008-1721, integer signedness error in the zlib extension module. + - Fix urllib2 file descriptor happens byte-at-a-time, reverting + a fix for excessively large memory allocations when calling .read() + on a socket object wrapped with makefile(). + * Disable some regression tests on some architectures: + - arm: test_compiler, test_ctypes. + - armel: test_compiler. + - hppa: test_fork1, test_wait3. + - m68k: test_bsddb3, test_compiler. + * Build-depend on libffi-dev instead of libffi4-dev. + * Fix CVE-2008-1679, integer overflows in the imageop module. + + -- Matthias Klose Wed, 16 Apr 2008 23:37:46 +0200 + +python2.5 (2.5.2-2) unstable; urgency=low + + * Use site.addsitedir() to add directories in /usr/local to sys.path. + Addresses: #469157, #469818. + + -- Matthias Klose Sat, 08 Mar 2008 16:11:23 +0100 + +python2.5 (2.5.2-1) unstable; urgency=low + + * Python 2.5.2 release. + * Merge from Ubuntu: + - Move site customization into sitecustomize.py, don't make site.py + a config file. Addresses: #309719, #413172, #457361. + - Move site.py to python2.4-minimal, remove `addbuilddir' from site.py, + which is unnecessary for installed builds. + - python2.5-dev: Recommend libc-dev instead of suggesting it. LP: #164909. + - Fix issue 961805, Tk Text.edit_modified() fails. LP: #84720. + + -- Matthias Klose Thu, 28 Feb 2008 23:18:52 +0100 + +python2.5 (2.5.1-7) unstable; urgency=low + + * Update to 20080209, taken from the 2.5 release branch. + * Build the _bsddb extension with db-4.5 again; 4.6 is seriously + broken when used with the _bsddb extension. + * Do not run pybench on arm and armel. + * python2.5: Provide python2.5-wsgiref. + * Fix a pseudo RC report with duplicated attributes in the control + file. Closes: #464307. + + -- Matthias Klose Sun, 10 Feb 2008 00:22:57 +0100 + +python2.5 (2.5.1-6) unstable; urgency=low + + * Update to 20080102, taken from the 2.5 release branch. + - Only define _BSD_SOURCE on OpenBSD systems. Closes: #455400. + * Fix handling of packages in linecache.py (Kevin Goodsell). LP: #70902. + * Bump debhelper to v5. + * Register binfmt for .py[co] files. + * Use absolute paths when byte-compiling files. Addresses: #453346. + Closes: #413566, LP: #177722. + * CVE-2007-4965, http://bugs.python.org/issue1179: + Multiple integer overflows in the imageop module in Python 2.5.1 and + earlier allow context-dependent attackers to cause a denial of service + (application crash) and possibly obtain sensitive information (memory + contents) via crafted arguments to (1) the tovideo method, and unspecified + other vectors related to (2) imageop.c, (3) rbgimgmodule.c, and other + files, which trigger heap-based buffer overflows. + Patch prepared by Stephan Herrmann. Closes: #443333, LP: #163845. + * Register info docs when doing source only uploads. LP: #174786. + * Remove deprecated value from categories in desktop file. LP: #172874. + * python2.5-dbg: Don't include the gdbm and _tkinter extensions, now provided + in separate packages. + * Provide a symlink changelog -> NEWS. Closes: #439271. + * Fix build failure on hurd, working around poll() on systems on which it + returns an error on invalid FDs. Closes: #438914. + * Configure --with-system-ffi on all architectures. Closes: #448520. + * Fix version numbers in copyright and README files (Dan O'Huiginn). + Closes: #446682. + * Move some documents from python2.5 to python2.5-dev. + + -- Matthias Klose Wed, 02 Jan 2008 22:22:19 +0100 + +python2.5 (2.5.1-5) unstable; urgency=low + + * Build the _bsddb extension with db-4.6. + + -- Matthias Klose Fri, 17 Aug 2007 00:39:35 +0200 + +python2.5 (2.5.1-4) unstable; urgency=low + + * Update to 20070813, taken from the 2.5 release branch. + * Include plat-mac/plistlib.py (plat-mac is not in sys.path by default. + Closes: #435826. + * Use emacs22 to build the documentation in info format. Closes: #434969. + * Build-depend on db-dev (>= 4.6). Closes: #434965. + + -- Matthias Klose Mon, 13 Aug 2007 22:22:44 +0200 + +python2.5 (2.5.1-3) unstable; urgency=high + + * Support mixed-endian IEEE floating point, as found in the ARM old-ABI + (Aurelien Jarno). Closes: #434905. + + -- Matthias Klose Fri, 27 Jul 2007 20:01:35 +0200 + +python2.5 (2.5.1-2) unstable; urgency=low + + * Update to 20070717, taken from the 2.5 release branch. + * Fix reference count for sys.pydebug variable. Addresses: #431393. + * Build depend on libbluetooth-dev instead of libbluetooth2-dev. + + -- Matthias Klose Tue, 17 Jul 2007 14:09:47 +0200 + +python2.5 (2.5.1-1) unstable; urgency=low + + * Python-2.5.1 release. + * Build-depend on gcc-4.1 (>= 4.1.2-4) on alpha, powerpc, s390, sparc. + * Merge from Ubuntu: + - Add debian/patches/subprocess-eintr-safety.dpatch (LP: #87292): + - Create and use wrappers around read(), write(), and os.waitpid() in the + subprocess module which retry the operation on an EINTR (which happens + if e. g. an alarm was raised while the system call was in progress). + It is incredibly hard and inconvenient to sensibly handle this in + applications, so let's fix this at the right level. + - Patch based on original proposal of Peter <85>strand + in http://python.org/sf/1068268. + - Add two test cases. + - Change the interpreter to build and install python extensions + built with the python-dbg interpreter with a different name into + the same path (by appending `_d' to the extension name). The debug build + of the interpreter tries to first load a foo_d.so or foomodule_d.so + extension, then tries again with the normal name. + - When trying to import the profile and pstats modules, don't + exit, add a hint to the exception pointing to the python-profiler + package, don't exit. + - Keep the module version in the .egg-info name, only remove the + python version. + - python2.5-dbg: Install Misc/SpecialBuilds.txt, document the + debug changes in README.debug. + * Update to 20070425, taken from the 2.5 release branch. + + -- Matthias Klose Wed, 25 Apr 2007 22:12:50 +0200 + +python2.5 (2.5-6) unstable; urgency=medium + + * webbrowser.py: Recognize other browsers: www-browser, x-www-browser, + iceweasel, iceape. + * Move pyconfig.h from the python2.5-dev into the python2.5 package; + required by builds for pure python modules without having python2.5-dev + installed (matching the functionality in python2.4). + * Move the unicodedata module into python2.5-minimal; allows byte compilation + of UTF8 encoded files. + * Do not install anymore outdated debhelper sample scripts. + * Install Misc/SpecialBuilds.txt as python2.5-dbg document. + + -- Matthias Klose Wed, 21 Feb 2007 01:17:12 +0100 + +python2.5 (2.5-5) unstable; urgency=high + + * Do not run the python benchmark on m68k. Timer problems. + Fixes FTBFS on m68k. + * Update to 20061209, taken from the 2.5 release branch. + - Fixes building the library reference in info format. + + -- Matthias Klose Sat, 9 Dec 2006 13:40:48 +0100 + +python2.5 (2.5-4) unstable; urgency=medium + + * Update to 20061203, taken from the 2.5 release branch. + - Fixes build failures on knetfreebsd and the hurd. Closes: #397000. + * Clarify README about distutils. Closes: #396394. + * Move python2.5-config to python2.5-dev. Closes: #401451. + * Cleanup build-conflicts. Addresses: #394512. + + -- Matthias Klose Sun, 3 Dec 2006 18:22:49 +0100 + +python2.5 (2.5-3.1) unstable; urgency=low + + * Non-maintainer upload. + * python2.5-minimal depends on python-minimal (>= 2.4.4-1) because it's the + first version which lists python2.5 as an unsupported runtime (ie a + runtime that is available but for which modules are not auto-compiled). + And being listed there is required for python-central to accept the + installation of python2.5-minimal. Closes: #397006 + + -- Raphael Hertzog Wed, 22 Nov 2006 15:41:06 +0100 + +python2.5 (2.5-3) unstable; urgency=medium + + * Update to 20061029 (2.4.4 was released on 20061019), taken from + the 2.5 release branch. We do not want to have regressions in + 2.5 compared to the 2.4.4 release. + * Don't run pybench on m68k, fails in the calibration loop. Closes: #391030. + * Run the installation/removal hooks. Closes: #383292, #391036. + + -- Matthias Klose Sun, 29 Oct 2006 11:35:19 +0100 + +python2.5 (2.5-2) unstable; urgency=medium + + * Update to 20061003, taken from the 2.5 release branch. + * On arm and m68k, don't run the pybench in debug mode. + * Fix building the source within exec_prefix (Alexander Wirt). + Closes: #385336. + + -- Matthias Klose Tue, 3 Oct 2006 10:08:36 +0200 + +python2.5 (2.5-1) unstable; urgency=low + + * Python 2.5 release. + * Update to 20060926, taken from the 2.5 release branch. + * Run the Python benchmark during the build, compare the results + of the static and shared builds. + * Fix invalid html in python2.5.devhelp.gz. + * Add a python2.5 console entry to the menu (hidden by default). + * python2.5: Suggest python-profiler. + + -- Matthias Klose Tue, 26 Sep 2006 02:36:11 +0200 + +python2.5 (2.5~c1-1) unstable; urgency=low + + * Python 2.5 release candidate 1. + * Update to trunk 20060818. + + -- Matthias Klose Sat, 19 Aug 2006 19:21:05 +0200 + +python2.5 (2.5~b3-1) unstable; urgency=low + + * Build the _ctypes module for m68k-linux. + + -- Matthias Klose Fri, 11 Aug 2006 18:19:19 +0000 + +python2.5 (2.5~b3-0ubuntu1) edgy; urgency=low + + * Python 2.5 beta3 release. + * Update to trunk 20060811. + * Rebuild the documentation. + * Fix value of sys.exec_prefix in the debug build. + * Do not build the library reference in info format; fails to build. + * Link the interpreter against the shared runtime library. With + gcc-4.1 the difference in the pystones benchmark dropped from about + 12% to about 6%. + * Install the statically linked version of the interpreter as + python2.5-static for now. + * Link the shared libpython with -O1. + + -- Matthias Klose Thu, 10 Aug 2006 14:04:48 +0000 + +python2.5 (2.4.3+2.5b2-3) unstable; urgency=low + + * Disable the testsuite on s390; don't care about "minimally configured" + buildd's. + + -- Matthias Klose Sun, 23 Jul 2006 11:45:03 +0200 + +python2.5 (2.4.3+2.5b2-2) unstable; urgency=low + + * Update to trunk 20060722. + * Merge idle-lib from idle-python2.5 into python2.5. + * Merge lib-tk from python-tk into python2.5. + * Tkinter.py: Suggest installation of python-tk package on failed + import of the _tkinter extension. + * Don't run the testsuite for the debug build on alpha. + * Don't run the test_compiler test on m68k. Just takes too long. + * Disable building ctypes on m68k (requires support for closures). + + -- Matthias Klose Sat, 22 Jul 2006 22:26:42 +0200 + +python2.5 (2.4.3+2.5b2-1) unstable; urgency=low + + * Python 2.5 beta2 release. + * Update to trunk 20060716. + * When built on a buildd, do not run the following test which try to + access the network: test_codecmaps_cn, test_codecmaps_hk, test_codecmaps_jp, + test_codecmaps_kr, test_codecmaps_tw, test_normalization. + * When built on a buildd, do not run tests requiring missing write permissions: + test_ossaudiodev. + + -- Matthias Klose Sun, 16 Jul 2006 02:53:50 +0000 + +python2.5 (2.4.3+2.5b2-0ubuntu1) edgy; urgency=low + + * Python 2.5 beta2 release. + + -- Matthias Klose Thu, 13 Jul 2006 17:16:52 +0000 + +python2.5 (2.4.3+2.5b1-1ubuntu2) edgy; urgency=low + + * Fix python-dev dependencies. + * Update to trunk 20060709. + + -- Matthias Klose Sun, 9 Jul 2006 18:50:32 +0200 + +python2.5 (2.4.3+2.5b1-1ubuntu1) edgy; urgency=low + + * Python 2.5 beta1 release. + * Update to trunk 20060623. + * Merge changes from the python2.4 packages. + * python2.5-minimal: Add _struct. + + -- Matthias Klose Fri, 23 Jun 2006 16:04:46 +0200 + +python2.5 (2.4.3+2.5a1-1) experimental; urgency=low + + * Update to trunk 20060409. + * Run testsuite for debug build as well. + * Build-depend on gcc-4.1. + + -- Matthias Klose Sun, 9 Apr 2006 22:27:05 +0200 + +python2.5 (2.4.3+2.5a1-0ubuntu1) dapper; urgency=low + + * Python 2.5 alpha1 release. + * Drop integrated patches. + * Add build dependencies on libsqlite3-dev and libffi4-dev. + * Add (build-)dependency on mime-support, libgpmg1 (test suite). + * Build using the system FFI. + * python2.5 provides python2.5-ctypes and python2.5-pysqlite2, + python2.5-elementtree. + * Move hashlib.py to python-minimal. + * Lib/hotshot/pstats.py: Error out on missing profile/pstats modules. + + -- Matthias Klose Wed, 5 Apr 2006 14:56:15 +0200 + +python2.4 (2.4.3-8ubuntu1) edgy; urgency=low + + * Resynchronize with Debian unstable. Remaining changes: + - Apply langpack-gettext patch. + - diff.gz contains pregenerated html and info docs. + - Build the -doc package from this source. + + -- Matthias Klose Thu, 22 Jun 2006 18:39:57 +0200 + +python2.4 (2.4.3-8) unstable; urgency=low + + * Remove python2.4's dependency on python-central. On installation of + the runtime, call hooks /usr/share/python/runtime.d/*.rtinstall. + On removal, call hooks /usr/share/python/runtime.d/*.rtremove. + Addresses: #372658. + * Call the rtinstall hooks only, if it's a new installation, or the first + installation using the hooks. Adresses: #373677. + + -- Matthias Klose Sun, 18 Jun 2006 00:56:13 +0200 + +python2.4 (2.4.3-7) unstable; urgency=medium + + * Reupload, depend on python-central (>= 0.4.15). + * Add build-conflict on python-xml. + + -- Matthias Klose Wed, 14 Jun 2006 18:56:57 +0200 + +python2.4 (2.4.3-6) medium; urgency=low + + * idle-python2.4: Remove the old postinst and prerm scripts. + * Name the runtime correctly in python2.4-minimal's installation + scripts. + + -- Matthias Klose Mon, 12 Jun 2006 17:39:56 +0000 + +python2.4 (2.4.3-5) unstable; urgency=low + + * python2.4-prerm: Handle the case, when python-central is not installed. + * idle-python2.4: Depend on python-tk instead of python2.4-tk. + + -- Matthias Klose Fri, 9 Jun 2006 05:17:17 +0200 + +python2.4 (2.4.3-4) unstable; urgency=low + + * SVN update up to 2006-06-07 + * Use python-central. + * Don't build the -tk and -gdbm packages from this source; now built + from the python-stdlib-extensions source. + * Remove leftover build dependency on libgmp3-dev. + * Do not build-depend on libbluetooth1-dev and libgpmg1-dev on + hurd-i386, kfreebsd-i386, kfreebsd-amd64. Closes: #365830. + * Do not run the test_tcl test; hangs for unknown reasons on at least + the following buildds: vivaldi(m68k), goedel (alpha), mayer (mipsel). + And no virtual package to file bug reports for the buildds ... + Closes: #364419. + * Move the Makefile from python2.4-dev to python2.4. Closes: #366473. + * Fix typo in pdb(1). Closes: #365772. + * New autoconf likes the mandir in /usr/share instead of /usr; work + with both locations. Closes: #367618. + + -- Matthias Klose Wed, 7 Jun 2006 21:37:20 +0200 + +python2.4 (2.4.3-3) unstable; urgency=low + + * SVN update up to 2006-04-21 + * Update locale aliases from /usr/share/X11/locale/locale.alias. + * Start idle with option -n from the desktop menu, so that the program + can be started in parallel. + * Testsuite related changes only: + - Add build dependencies mime-support, libgpmg1 (needed by test cases). + - Run the testsuite with bsddb, audio and curses resources enabled. + - Re-run the failed tests in verbose mode. + - Run the test suite for the debug build as well. + - Build depend on netbase, needed by test_socketmodule. + - Build depend on libgpmg1, needed by test_curses. + - On the buildds do not run the tests needing the network resource. + * Update python logo. + * Check for the availability of the profile and pstats modules when + importing hotshot.pstats. Closes: #334067. + * Don't build the -doc package from the python2.4 source. + * Set OPT in the installed Makefile to -O2. + + -- Matthias Klose Fri, 21 Apr 2006 19:58:43 +0200 + +python2.4 (2.4.3-2) unstable; urgency=low + + * Add (build-)dependency on mime-support. + + -- Matthias Klose Tue, 4 Apr 2006 22:21:41 +0200 + +python2.4 (2.4.3-1) unstable; urgency=low + + * Python 2.4.3 release. + + -- Matthias Klose Thu, 30 Mar 2006 23:42:37 +0200 + +python2.4 (2.4.3-0ubuntu1) dapper; urgency=low + + * Python 2.4.3 release. + - Fixed a bug that the gb18030 codec raises RuntimeError on encoding + surrogate pair area on UCS4 build. Ubuntu: #29289. + + -- Matthias Klose Thu, 30 Mar 2006 10:57:32 +0200 + +python2.4 (2.4.2+2.4.3c1-0ubuntu1) dapper; urgency=low + + * SVN update up to 2006-03-25 (2.4.3 candidate 1). + - Regenerate the documentation. + + -- Matthias Klose Mon, 27 Mar 2006 12:03:05 +0000 + +python2.4 (2.4.2-1ubuntu3) dapper; urgency=low + + * SVN update up to 2006-03-04 + - Regenerate the documentation. + - map.mmap(-1, size, ...) can return anonymous memory again on Unix. + Ubuntu #26201. + * Build-depend on libncursesw5-dev, ncursesw5 is preferred for linking. + Provides UTF-8 compliant curses bindings. + * Fix difflib where certain patterns of differences were making difflib + touch the recursion limit. + + -- Matthias Klose Sat, 4 Mar 2006 21:38:24 +0000 + +python2.4 (2.4.2-1ubuntu2) dapper; urgency=low + + * SVN update up to 2006-01-17 + - pwd is now a builtin module, remove it from python-minimal. + - Regenerate the documentation. + * python2.4-tk: Suggest tix instead of tix8.1. + * Move config/Makefile from the -dev package into the runtime package + to be able to use the bdist_wininst distutils command. Closes: #348335. + + -- Matthias Klose Tue, 17 Jan 2006 11:02:24 +0000 + +python2.4 (2.4.2-1ubuntu1) dapper; urgency=low + + * Temporarily remove build dependency on lsb-release. + + -- Matthias Klose Sun, 20 Nov 2005 17:40:18 +0100 + +python2.4 (2.4.2-1build1) dapper; urgency=low + + * Rebuild (openssl-0.9.8). + + -- Matthias Klose Sun, 20 Nov 2005 15:27:24 +0000 + +python2.4 (2.4.2-1) unstable; urgency=low + + * Python 2.4.2 release. + + -- Matthias Klose Thu, 29 Sep 2005 01:49:28 +0200 + +python2.4 (2.4.1+2.4.2rc1-1) unstable; urgency=low + + * Python 2.4.2 release candidate 1. + * Fix "Fatal Python error" from cStringIO's writelines. + Patch by Andrew Bennetts. + + -- Matthias Klose Thu, 22 Sep 2005 10:33:22 +0200 + +python2.4 (2.4.1-5) unstable; urgency=low + + * CVS update up to 2005-09-14 + - Regenerate the html and info docs. + * Add some more locale aliases. + * Fix substitution pf python version in README.python2.4-minimal. + Closes: #327487. + * On m68k, build using -O2 (closes: #326903). + * On Debian, don't configure --with-fpectl, which stopped working with + glibc-2.3.5. + + -- Matthias Klose Wed, 14 Sep 2005 17:32:56 +0200 + +python2.4 (2.4.1-4) unstable; urgency=low + + * CVS update up to 2005-09-04 + - teTeX 3.0 related fixes (closes: #322407). + - Regenerate the html and info docs. + * Add entry for IDLE in the Gnome menus. + * Don't build-depend on libbluetooth-dev on the Hurd (closes: #307037). + * Reenable the cthreads patch for the Hurd (closes: #307052). + + -- Matthias Klose Sun, 4 Sep 2005 18:31:42 +0200 + +python2.4 (2.4.1-3) unstable; urgency=low + + * Synchronise with Ubuntu: + - Build a python2.4-minimal package. + + -- Matthias Klose Tue, 12 Jul 2005 00:23:10 +0000 + +python2.4 (2.4.1-2ubuntu3) breezy; urgency=low + + * CVS update up to 2005-07-07 + * Regenerate the documentation. + + -- Matthias Klose Thu, 7 Jul 2005 09:21:28 +0200 + +python2.4 (2.4.1-2ubuntu2) breezy; urgency=low + + * CVS update up to 2005-06-15 + * Regenerate the documentation. + * Synchronize with Debian. Ubuntu 10485. + * idle-python2.4 enhances python2.4. Ubuntu 11562. + * README.Debian: Fix reference to the doc directory (closes: #311677). + + -- Matthias Klose Wed, 15 Jun 2005 08:56:57 +0200 + +python2.4 (2.4.1-2ubuntu1) breezy; urgency=low + + * Update build dependencies: + db4.2-dev -> db4.3-dev, + libreadline4-dev -> libreadline5-dev. + * python2.4-dev: Add missing templates to generate HTML docs. Ubuntu 11531. + + -- Matthias Klose Sun, 29 May 2005 00:01:05 +0200 + +python2.4 (2.4.1-2) unstable; urgency=low + + * Add the debug symbols for the python2.4, python2.4-gdbm + and python2.4-tk packages to the python2.4-dbg package. + * Add gdbinit example to doc directory. + + -- Matthias Klose Thu, 5 May 2005 11:12:32 +0200 + +python2.4 (2.4.1-1ubuntu2) breezy; urgency=low + + * Add the debug symbols for the python2.4, python2.4-minimal, python2.4-gdbm + and python2.4-tk packages to the python2.4-dbg package. Ubuntu 10261, + * Add gdbinit example to doc directory. + * For os.utime, use utimes(2), correctly working with glibc-2.3.5. + Ubuntu 10294. + + -- Matthias Klose Thu, 5 May 2005 09:06:07 +0200 + +python2.4 (2.4.1-1ubuntu1) breezy; urgency=low + + * Reupload as 2.4.1-1ubuntu1. + + -- Matthias Klose Thu, 14 Apr 2005 10:46:32 +0200 + +python2.4 (2.4.1-1) unstable; urgency=low + + * Python 2.4.1 release. + * Fix noise in python-doc installation/removal. + * New Python section for the info docs. + + -- Matthias Klose Wed, 30 Mar 2005 19:42:03 +0200 + +python2.4 (2.4.1-0) hoary; urgency=low + + * Python 2.4.1 release. + * Fix noise in python-doc installation/removal. + * New Python section for the info docs. + + -- Matthias Klose Wed, 30 Mar 2005 16:35:34 +0200 + +python2.4 (2.4+2.4.1rc2-2) unstable; urgency=low + + * Add the valgrind support file to /etc/python2.4 + * Build the -dbg package with -DPy_USING_MEMORY_DEBUGGER. + * Lib/locale.py: + - correctly parse LANGUAGE as a colon separated list of languages. + - prefer LC_ALL, LC_CTYPE and LANG over LANGUAGE to get the correct + encoding. + - Don't map 'utf8', 'utf-8' to 'utf', which is not a known encoding + for glibc. + * Fix two typos in python(1). Addresses: #300124. + + -- Matthias Klose Sat, 19 Mar 2005 21:50:14 +0100 + +python2.4 (2.4+2.4.1rc2-1) unstable; urgency=low + + * Python 2.4.1 release candidate 2. + * Build-depend on libbluetooth1-dev. + + -- Matthias Klose Sat, 19 Mar 2005 00:57:14 +0100 + +python2.4 (2.4dfsg-2) unstable; urgency=low + + * CVS update up to 2005-03-03 + + -- Matthias Klose Thu, 3 Mar 2005 22:22:16 +0100 + +python2.4 (2.4dfsg-1ubuntu4) hoary; urgency=medium + + * Move exception finalisation later in the shutdown process - this + fixes the crash seen in bug #1165761, taken from CVS. + * codecs.StreamReader: Reset codec when seeking. Ubuntu #6972. + * Apply fix for SF1124295, fixing an obscure bit of Zope's security machinery. + * distutils: Don't add standard library dirs to library_dirs + and runtime_library_dirs. On amd64, runtime paths pointing to /usr/lib64 + aren't recognized by dpkg-shlibdeps, and the packages containing these + libraries aren't added to ${shlibs:Depends}. + * Lib/locale.py: + - correctly parse LANGUAGE as a colon separated list of languages. + - prefer LC_ALL, LC_CTYPE and LANG over LANGUAGE to get the correct + encoding. + - Don't map 'utf8', 'utf-8' to 'utf', which is not a known encoding + for glibc. + * os.py: Avoid using items() in environ.update(). Fixes #1124513. + * Python/pythonrun.c: + * Build depend on locales, generate the locales needed for the + testsuite. + * Add build dependency on libbluetooth1-dev, adding some bluetooth + functionality to the socket module. + * Lib/test/test_sundry.py: Don't fail on import of profile & pstats, + which are separated out to the python-profiler package. + * Fix typos in manpage. + + -- Matthias Klose Tue, 29 Mar 2005 13:35:53 +0200 + + +python2.4 (2.4dfsg-1ubuntu3) hoary; urgency=low + + * debian/patches/langpack-gettext.dpatch: + - langpack support for python-gettext added + + -- Michael Vogt Tue, 1 Mar 2005 13:13:36 +0100 + +python2.4 (2.4dfsg-1ubuntu2) hoary; urgency=low + + * Revert 'essential' status on python2.4-minimal. This status on + on python-minimal is sufficient (Ubuntu #6392). + + -- Matthias Klose Wed, 9 Feb 2005 23:09:42 +0100 + +python2.4 (2.4dfsg-1ubuntu1) hoary; urgency=low + + * Resyncronise with Debian. + * Mark the python2.4-minimal package as 'essential'. + + -- Matthias Klose Wed, 9 Feb 2005 13:31:09 +0100 + +python2.4 (2.4dfsg-1) unstable; urgency=medium + + * Add licenses and acknowledgements for incorporated software in the + debian/copyright file (addresses: #293932). + * Replace md5 implementation with one having a DFSG conforming license. + * Remove the profile.py and pstats.py modules from the source package, + not having a DFSG conforming license. The modules can be found in + the python2.x-profile package in the non-free section. + Addresses: #293932. + * Add missing norwegian locales (Tollef Fog Heen). + * CVS updates of the release24-maint branch upto 2005-02-08 (date of + the Python 2.3.5 release). + + -- Matthias Klose Tue, 8 Feb 2005 19:13:10 +0100 + +python2.4 (2.4-7ubuntu1) hoary; urgency=low + + * Fix the name of the python-dbg man page. + * Resyncronise with Debian. + * Move more modules to -minimal (new code in copy.py requires these): + dis, inspect, opcode, token, tokenize. + + -- Matthias Klose Tue, 8 Feb 2005 19:13:10 +0100 + +python2.4 (2.4-7) unstable; urgency=medium + + * Add licenses and acknowledgements for incorporated software in the + debian/copyright file (addresses: #293932). + * Replace md5 implementation with one having a DFSG conforming license. + * Add missing norwegian locales (Tollef Fog Heen). + * CVS updates of the release24-maint branch upto 2005-02-08 (date of + the Python 2.3.5 release). + + -- Matthias Klose Tue, 8 Feb 2005 19:13:10 +0100 + +python2.4 (2.4-6) unstable; urgency=low + + * Build a python2.4-dbg package using --with-pydebug. Add a debug + directory /lib-dynload/debug to sys.path instead of + /lib-dynload und install the extension modules of the + debug build in this directory. + Change the module load path to load extension modules from other + site-packages/debug directories (for further details see the + README in the python2.4-dbg package). Closes: #5415. + * Apply the pydebug-path patch. The package was already built in -5. + + -- Matthias Klose Fri, 4 Feb 2005 22:15:13 +0100 + +python2.4 (2.4-5) unstable; urgency=high + + * Fix a flaw in SimpleXMLRPCServerthat can affect any XML-RPC servers. + This affects any programs have been written that allow remote + untrusted users to do unrestricted traversal and can allow them to + access or change function internals using the im_* and func_* attributes. + References: CAN-2005-0089. + * CVS updates of the release24-maint branch upto 2005-02-04. + + -- Matthias Klose Fri, 4 Feb 2005 08:12:10 +0100 + +python2.4 (2.4-4) unstable; urgency=medium + + * Update debian/copyright to the 2.4 license text (closes: #290898). + * Remove /usr/bin/smtpd.py (closes: #291049). + + -- Matthias Klose Mon, 17 Jan 2005 23:54:37 +0100 + +python2.4 (2.4-3ubuntu6) hoary; urgency=low + + * Use old-style dpatches instead of dpatch-run. + + -- Tollef Fog Heen Mon, 7 Feb 2005 15:58:05 +0100 + +python2.4 (2.4-3ubuntu5) hoary; urgency=low + + * Actually apply the patch as well (add to list of patches in + debian/rules) + + -- Tollef Fog Heen Sun, 6 Feb 2005 15:12:58 +0100 + +python2.4 (2.4-3ubuntu4) hoary; urgency=low + + * Add nb_NO and nn_NO locales to Lib/locale.py + + -- Tollef Fog Heen Sun, 6 Feb 2005 14:33:05 +0100 + +python2.4 (2.4-3ubuntu3) hoary; urgency=low + + * Fix a flaw in SimpleXMLRPCServerthat can affect any XML-RPC servers. + This affects any programs have been written that allow remote + untrusted users to do unrestricted traversal and can allow them to + access or change function internals using the im_* and func_* attributes. + References: CAN-2005-0089. + + -- Matthias Klose Wed, 2 Feb 2005 09:08:20 +0000 + +python2.4 (2.4-3ubuntu2) hoary; urgency=low + + * Build a python2.4-dbg package using --with-pydebug. Add a debug + directory /lib-dynload/debug to sys.path instead of + /lib-dynload und install the extension modules of the + debug build in this directory. + Change the module load path to load extension modules from other + site-packages/debug directories (for further details see the + README in the python2.4-dbg package). Closes: #5415. + * Update debian/copyright to the 2.4 license text (closes: #290898). + * Add operator and copy to the -minimal package. + + -- Matthias Klose Mon, 17 Jan 2005 23:19:47 +0100 + +python2.4 (2.4-3ubuntu1) hoary; urgency=low + + * Resynchronise with Debian. + * python2.4: Depend on the very same version of python2.4-minimal. + * Docment, that time.strptime currently cannot be used, if the + python-minimal package is installed without the python package. + + -- Matthias Klose Sun, 9 Jan 2005 19:35:48 +0100 + +python2.4 (2.4-3) unstable; urgency=medium + + * Build the fpectl module. + * Updated to CVS release24-maint 20050107. + + -- Matthias Klose Sat, 8 Jan 2005 19:05:21 +0100 + +python2.4 (2.4-2ubuntu5) hoary; urgency=low + + * Updated to CVS release24-maint 20050102. + * python-minimal: + - os.py: Use dict instead of UserDict, remove UserDict from -minimal. + - add pickle, threading, needed for subprocess module. + - optparse.py: conditionally import gettext, if not available, + define _ as the identity function. Patch taken from the trunk. + Avoids import of _locale, locale, gettext, copy, repr, itertools, + collections, token, tokenize. + - Add a build check to make sure that the minimal module list is + closed under dependency. + * Fix lintian warnings. + + -- Matthias Klose Sun, 2 Jan 2005 22:00:14 +0100 + +python2.4 (2.4-2ubuntu4) hoary; urgency=low + + * Add UserDict.py to the -minimal package, since os.py needs it. + + -- Colin Watson Thu, 30 Dec 2004 20:41:28 +0000 + +python2.4 (2.4-2ubuntu3) hoary; urgency=low + + * Add os.py and traceback.py to the -minimal package, get the list + of modules from the README. + + -- Matthias Klose Mon, 27 Dec 2004 08:20:45 +0100 + +python2.4 (2.4-2ubuntu2) hoary; urgency=low + + * Add compileall.py and py_compile.py to the -minimal package, not + just to the README ... + + -- Matthias Klose Sat, 25 Dec 2004 22:24:56 +0100 + +python2.4 (2.4-2ubuntu1) hoary; urgency=low + + * Separate the interpreter and a minimal subset of modules into + a python2.4-minimal package. See the README.Debian.gz in this + package. + * Move site.py to python2.4-minimal as well. + * Add documentation files for devhelp. + + -- Matthias Klose Sun, 19 Dec 2004 22:47:32 +0100 + +python2.4 (2.4-2) unstable; urgency=medium + + * Updated patch for #283108. Thanks to Jim Meyering. + + -- Matthias Klose Fri, 3 Dec 2004 17:00:16 +0100 + +python2.4 (2.4-1) unstable; urgency=low + + * Final 2.4 release. + * Flush stdout/stderr if closed (SF #1074011). + + -- Matthias Klose Wed, 1 Dec 2004 07:54:34 +0100 + +python2.4 (2.3.97-2) unstable; urgency=low + + * Don't run test_tcl, hanging on the buildds. + + -- Matthias Klose Fri, 19 Nov 2004 23:48:42 +0100 + +python2.4 (2.3.97-1) unstable; urgency=low + + * Python 2.4 Release Candidate 1. + + -- Matthias Klose Fri, 19 Nov 2004 21:27:02 +0100 + +python2.4 (2.3.96-1) experimental; urgency=low + + * Updated to CVS release24-maint 20041113. + * Build the docs in info format again. + + -- Matthias Klose Sat, 13 Nov 2004 21:21:10 +0100 + +python2.4 (2.3.95-2) experimental; urgency=low + + * Move distutils package from the python2.4-dev into the python2.4 + package. + + -- Matthias Klose Thu, 11 Nov 2004 22:56:14 +0100 + +python2.4 (2.3.95-1) experimental; urgency=low + + * Python 2.4 beta2 release. + + -- Matthias Klose Thu, 4 Nov 2004 23:43:47 +0100 + +python2.4 (2.3.94-1) experimental; urgency=low + + * Python 2.4 beta1 release. + + -- Matthias Klose Sat, 16 Oct 2004 08:33:57 +0200 + +python2.4 (2.3.93-1) experimental; urgency=low + + * Python 2.4 alpha3 release. + + -- Matthias Klose Fri, 3 Sep 2004 21:53:47 +0200 + +python2.4 (2.3.92-1) experimental; urgency=low + + * Python 2.4 alpha2 release. + + -- Matthias Klose Thu, 5 Aug 2004 23:53:18 +0200 + +python2.4 (2.3.91-1) experimental; urgency=low + + * Python 2.4 alpha1 release. + Highlights: http://www.python.org/2.4/highlights.html + + -- Matthias Klose Fri, 9 Jul 2004 17:38:54 +0200 + +python2.4 (2.3.90-1) experimental; urgency=low + + * Package HEAD branch (pre alpha ..). + + -- Matthias Klose Mon, 14 Jun 2004 23:19:57 +0200 + +python2.3 (2.3.4-1) unstable; urgency=medium + + * Final Python 2.3.4 Release. + * In the API docs, fix signature of PyModule_AddIntConstant (closes: #250826). + * locale.getdefaultlocale: don't fail with empty environment variables. + Closes: #249816. + * Include distutils/command/wininst.exe in -dev package (closes: #249006). + * Disable cthreads on the Hurd (Michael Banck). Closes: #247211. + * Add a note to pygettext(1), that this program is deprecated in favour + of xgettext, which now includes support for Python as well. + Closes: #246332. + + -- Matthias Klose Fri, 28 May 2004 22:59:42 +0200 + +python2.3 (2.3.3.91-1) unstable; urgency=low + + * Python 2.3.4 Release Candidate 1. + * Do not use the default namespace for attributes. Patch taken from the + 2.3 maintenance branch. + The xmllib module is obsolete. Use xml.sax instead. + * http://python.org/sf/945642 - fix nonblocking i/o with ssl socket. + + -- Matthias Klose Thu, 13 May 2004 21:24:52 +0200 + +python2.3 (2.3.3-7) unstable; urgency=low + + * Add a workaround for GNU libc nl_langinfo()'s returning NULL. + Closes: #239237. + Patch taken from 2.3 maintenance branch. + * threading.py: Remove calls to currentThread() in _Condition methods that + were side-effect. Side-effects were deemed unnecessary and were causing + problems at shutdown time when threads were catching exceptions at start + time and then triggering exceptions trying to call currentThread() after + gc'ed. Masked the initial exception which was deemed bad. + Closes: #195812. + * Properly support normalization of empty unicode strings. Closes: #239986. + Patch taken from 2.3 maintenance branch. + * README.maintainers: Add section where to find the documentation tools. + * Fix crash in pyexpat module (closes: #229281). + * For the Hurd, set the interpreters recursion limit to 930. + * Do not try to byte-compile the test files on installation; this + currently breaks the Hurd install. + + -- Matthias Klose Sat, 1 May 2004 07:50:46 +0200 + +python2.3 (2.3.3-6) unstable; urgency=low + + * Don't build the unversioned python{,-*} packages anymore. Now + built from the python-defaults package. + * Update to the proposed python-policy: byte-compile using -E. + * Remove python-elisp's dependency on emacs20 (closes: #232785). + * Don't build python-elisp from the python2.3 source anymore, + get it from python-mode.sf.net as a separate source package. + * python2.3-dev suggests libc-dev (closes: #231091). + * get LDSHARED and CCSHARED (like, CC, CXX, CPP, CFLAGS) from + the environment + * Set CXX in installed config/Makefile (closes: #230273). + + -- Matthias Klose Tue, 24 Feb 2004 07:07:51 +0100 + +python2.3 (2.3.3-5) unstable; urgency=low + + * Build-depend on libdb4.2-dev, instead of libdb4.1-dev. According + to the docs the file format is compatible. + + -- Matthias Klose Mon, 12 Jan 2004 10:37:45 +0100 + +python2.3 (2.3.3-4) unstable; urgency=low + + * Fix broken _bsddb module. setup.py picked up the wrong library. + + -- Matthias Klose Sun, 4 Jan 2004 11:30:00 +0100 + +python2.3 (2.3.3-3) unstable; urgency=low + + * Fix typo in patch (closes: #224797, #226064). + + -- Matthias Klose Sun, 4 Jan 2004 09:23:21 +0100 + +python2.3 (2.3.3-2) unstable; urgency=medium + + * Lib/email/Charset: use locale unaware function to lower case of locale + name (closes: #224797). + * Update python-mode to version from python-mode.sf.net. Fixes highlighting + problems (closes: #223520). + * Backport from mainline: Add IPV6_ socket options from RFCs 3493 and 3542. + + -- Matthias Klose Fri, 2 Jan 2004 14:03:26 +0100 + +python2.3 (2.3.3-1) unstable; urgency=low + + * New upstream release. + * Copy the templates, tools and scripts from the Doc dir in the source + to /usr/share/lib/python2.3/doc in the python2.3-dev package. Needed + for packages building documentation like python does (closes: #207337). + + -- Matthias Klose Fri, 19 Dec 2003 10:57:39 +0100 + +python2.3 (2.3.2.91-1) unstable; urgency=low + + * New upstream version (2.3.3 release candidate). + * Update python-mode.el (closes: #158811, #159630). + Closing unreproducible report (closes: #159628). + + -- Matthias Klose Sat, 6 Dec 2003 14:41:14 +0100 + +python2.3 (2.3.2-7) unstable; urgency=low + + * Put the conflict in the correct direction. python2.3 (2.3.2-6) doesn't + conflict with python (<= 2.3.2-5) but python (2.3.2-6) conflicts with + python2.3 (<= 2.3.2-5) (thanks to Brian May). Really closes #221791. + + -- Matthias Klose Fri, 21 Nov 2003 00:20:02 +0100 + +python2.3 (2.3.2-6) unstable; urgency=low + + * Add conflicts with older python{,2.3} packages to fix overwrite + errors (closes: #221791). + + -- Matthias Klose Thu, 20 Nov 2003 07:24:36 +0100 + +python2.3 (2.3.2-5) unstable; urgency=low + + * Updated to CVS release23-maint 20031119. + * Re-upgrade the dependency of python2.3 on python (>= 2.3) to + a dependency (closes: #221523). + + -- Matthias Klose Wed, 19 Nov 2003 00:30:27 +0100 + +python2.3 (2.3.2-4) unstable; urgency=low + + * Don't build-depend on latex2html (moved to non-free), but keep + the prebuilt docs in debian/patches (closes: #221347). + * Fix typos in the library reference (closes: #220510, #220954). + * Fix typo in python-elisp's autoloading code (closes: #220308). + * Update proposed python policy: private modules can be installed + into /usr/lib/ (arch dependent) and into /usr/share/ + (arch independent). + + -- Matthias Klose Tue, 18 Nov 2003 00:41:39 +0100 + +python2.3 (2.3.2-3) unstable; urgency=low + + * Downgrade the dependency of python2.3 on python (>= 2.3) to + a recommendation. + * Fix path to interpreter in binfmt file. + * Fix segfault in unicodedata module (closes: #218697). + * Adjust python-elisp autoload code (closes: #219821). + + -- Matthias Klose Sun, 9 Nov 2003 19:43:37 +0100 + +python2.3 (2.3.2-2) unstable; urgency=medium + + * Fix broken doc link (closes: #214217). + * Disable wrongly detected large file support for GNU/Hurd. + * Really fix the FTBFS for the binary-indep target (closes: #214303). + + -- Matthias Klose Mon, 6 Oct 2003 07:54:58 +0200 + +python2.3 (2.3.2-1) unstable; urgency=low + + * New upstream version. + * Fix a FTBFS for the binary-indep target. + + -- Matthias Klose Sat, 4 Oct 2003 10:20:15 +0200 + +python2.3 (2.3.1-3) unstable; urgency=low + + * Fix names of codec packages in recommends. + * On alpha compile using -mieee (see #212912). + + -- Matthias Klose Sun, 28 Sep 2003 10:48:12 +0200 + +python2.3 (2.3.1-2) unstable; urgency=low + + * Update python policy draft (closes: #128911, #163785). + * Re-add os.fsync function (closes: #212672). + * Let python2.3-doc conflict with older python2.3 versions (closes: #211882). + * Add recommends for pythonX.Y-japanese-codecs, pythonX.Y-iconvcodec, + pythonX.Y-cjkcodecs, pythonX.Y-korean-codecs (closes: #207161). + * Generate binfmt file (closes: #208005). + * Add IPPROTO_IPV6 option to the socketmodule (closes: #206569). + * Bugs reported against python2.2 and fixed in python2.3: + - Crashes in idle (closes: #186887, #200084). + + -- Matthias Klose Sat, 27 Sep 2003 11:21:47 +0200 + +python2.3 (2.3.1-1) unstable; urgency=low + + * New upstream version (bug fix release). + + -- Matthias Klose Wed, 24 Sep 2003 11:27:43 +0200 + +python2.3 (2.3-4) unstable; urgency=high + + * Disable check for utimes function, which is broken in glibc-2.3.2. + Packages using distutils had '1970/01/01-01:00:01' timestamps in files. + * Bugs fixed by making python2.3 the default python version: + - Canvas.scan_dragto() takes a 3rd optional parmeter "gain". + Closes: #158168. + - New command line parsing module (closes: #38628). + - compileall.py allows compiling single files (closes: #139971). + * Bugs reported for 2.2 and fixed in 2.3: + - Idle does save files with ASCII characters (closes: #179313). + - imaplib support for prefix-quoted strings (closes: #150485). + - posixpath includes getctime (closes: #173827). + - pydoc has support for keywords (closes: #186775). + * Bugs reported for 2.1 and fixed in 2.3: + - Fix handling of "#anchor" URLs in urlparse (closes: #147844). + - Fix readline if C stdin is not a tty, even if sys.stdin is. + Closes: #131810. + * Updated to CVS release23-maint 20030810 (fixing memory leaks in + array and socket modules). + * pydoc's usage output uses the basename of the script. + * Don't explicitely remove /etc/python2.3 on purge (closes: #202864). + * python conflicts with python-xmlbase (closes: #204773). + * Add dependency python (>= 2.3) to python2.3, so make sure the + unversioned names can be used. + + -- Matthias Klose Sun, 10 Aug 2003 09:27:52 +0200 + +python2.3 (2.3-3) unstable; urgency=medium + + * Fix shlibs file. + + -- Matthias Klose Fri, 8 Aug 2003 08:45:12 +0200 + +python2.3 (2.3-2) unstable; urgency=medium + + * Make python2.3 the default python version. + + -- Matthias Klose Tue, 5 Aug 2003 22:13:22 +0200 + +python2.3 (2.3-1) unstable; urgency=low + + * Python 2.3 final release. + + -- Matthias Klose Wed, 30 Jul 2003 08:12:28 +0200 + +python2.3 (2.2.107-1rc2) unstable; urgency=medium + + * Python 2.3 release candidate 2. + * Don't compress .txt files referenced by the html docs (closes: #200298). + * Include the email/_compat* files (closes: #200349). + + -- Matthias Klose Fri, 25 Jul 2003 07:08:09 +0200 + +python2.3 (2.2.106-2beta2) unstable; urgency=medium + + * Python 2.3 beta2 release, updated to CVS 20030704. + - Fixes AssertionError in httplib (closed: #192452). + - Fixes uncaught division by zero in difflib.py (closed: #199287). + * Detect presence of setgroups(2) at configure time (closes: #199839). + * Use default gcc on arm as well. + + -- Matthias Klose Sat, 5 Jul 2003 10:21:33 +0200 + +python2.3 (2.2.105-1beta2) unstable; urgency=low + + * Python 2.3 beta2 release. + - Includes merged idle fork. + - Fixed socket.setdefaulttimeout(). Closes: #189380. + - socket.ssl works with _socketobj. Closes: #196082. + * Do not link libtix to the _tkinter module. It's loaded via + 'package require tix' at runtime. python2.3-tkinter now + suggests tix8.1 instead. + * On arm, use gcc-3.2 to build. + * Add -fno-strict-aliasing rules to OPT to avoid warnings + "dereferencing type-punned pointer will break strict-aliasing rules", + when building with gcc-3.3. + + -- Matthias Klose Mon, 30 Jun 2003 00:19:32 +0200 + +python2.3 (2.2.104-1beta1.1) unstable; urgency=low + + * Non-maintainer upload with maintainer consent. + * debian/control (Build-Depends): s/libgdbmg1-dev/libgdbm-dev/. + + -- James Troup Wed, 4 Jun 2003 02:24:27 +0100 + +python2.3 (2.2.104-1beta1) unstable; urgency=low + + * Python 2.3 beta1 release, updated to CVS 20030514. + - build the current documentation. + * Reenable Tix support. + + -- Matthias Klose Wed, 14 May 2003 07:38:57 +0200 + +python2.3 (2.2.103-1beta1) unstable; urgency=low + + * Python 2.3 beta1 release, updated to CVS 20030506. + - updated due to build problems on mips/mipsel. + - keep the 2.3b1 documentation (doc build problems with cvs). + + -- Matthias Klose Wed, 7 May 2003 06:26:39 +0200 + +python2.3 (2.2.102-1beta1) unstable; urgency=low + + * Python 2.3 beta1 release. + + -- Matthias Klose Sat, 3 May 2003 22:45:16 +0200 + +python2.3 (2.2.101-1exp1) unstable; urgency=medium + + * Python 2.3 alpha2 release, updated to CVS 20030321. + * Tkinter: Catch exceptions thrown for undefined substitutions in + events (needed for tk 8.4.2). + + -- Matthias Klose Fri, 21 Mar 2003 21:32:14 +0100 + +python2.3 (2.2.100-1exp1) unstable; urgency=low + + * Python 2.3 alpha2 release, updated to CVS 20030221. + + -- Matthias Klose Fri, 21 Feb 2003 19:37:17 +0100 + +python2.3 (2.2.99-1exp1) unstable; urgency=low + + * Python 2.3 alpha1 release updated to CVS 20030123. + - should fix the testsuite (and package build) failure on alpha. + * Remove build dependency on libexpat1-dev. Merge the python2.3-xmlbase + package into python2.3 (closes: #177739). + + -- Matthias Klose Thu, 23 Jan 2003 22:48:12 +0100 + +python2.3 (2.2.98-1exp1) unstable; urgency=low + + * Python 2.3 alpha1 release updated to CVS 20030117. + * Build using libdb4.1. + + -- Matthias Klose Sat, 18 Jan 2003 00:14:01 +0100 + +python2.3 (2.2.97-1exp1) unstable; urgency=low + + * Python 2.3 alpha1 release updated to CVS 20030109. + * Build-Depend on g++ (>= 3:3.2). + * Python package maintainers: please wait uploading python dependent + packages until python2.2 and python2.1 are compiled using gcc-3.2. + + -- Matthias Klose Thu, 9 Jan 2003 23:56:42 +0100 + +python2.3 (2.2.96-1exp1) unstable; urgency=low + + * Python 2.3 alpha1 release (not exactly the tarball, but taken from + CVS 20030101). + - Includes support for linking with threaded tk8.4 (closes: #172714). + * Install and register whatsnew document (closes: #173859). + * Properly unregister info documentation. + + -- Matthias Klose Wed, 1 Jan 2003 17:38:54 +0100 + +python2.3 (2.2.95-1exp1) unstable; urgency=low + + * Experimental packages from CVS 021212. + - data in unicodedate module is up to date (closes: #171061). + * Fix idle packaging (closes: #170394). + * Configure using unicode UCS-4 (closes: #171062). + This change breaks compatibility with binary modules, but what do you + expect from experimental packages ... Please recompile dependent packages. + * Don't strip binaries for now. + + -- Matthias Klose Thu, 12 Dec 2002 21:42:27 +0100 + +python2.3 (2.2.94-1exp1) unstable; urgency=low + + * Experimental packages from CVS 021120. + * Remove outdated README.dbm. + * Depend on tk8.4. + * python-elisp: Install emacsen install file with mode 644 (closes: #167718). + + -- Matthias Klose Thu, 21 Nov 2002 01:04:51 +0100 + +python2.3 (2.2.93-1exp1) unstable; urgency=medium + + * Experimental packages from CVS 021015. + * Build a static library libpython2.3-pic.a. + * Enable large file support for the Hurd (closes: #164602). + + -- Matthias Klose Tue, 15 Oct 2002 21:06:27 +0200 + +python2.3 (2.2.92-1exp1) unstable; urgency=low + + * Experimental packages from CVS 020922. + * Fix build error on ia64 (closes: #161234). + * Build depend on gcc-3.2-3.2.1-0pre2 to fix build error on arm. + + -- Matthias Klose Sun, 22 Sep 2002 18:30:28 +0200 + +python2.3 (2.2.91-1exp1) unstable; urgency=low + + * Experimental packages from CVS 020906. + * idle-python2.3: Fix conflict (closes: #159267). + * Fix location of python-mode.el (closes: #159564, #159619). + * Use tix8.1. + * Apply fix for distutils/ccompiler problem (closes: #159288). + + -- Matthias Klose Sat, 7 Sep 2002 09:55:07 +0200 + +python2.3 (2.2.90-1exp1) unstable; urgency=low + + * Experimental packages from CVS 020820. + * Don't build python2.3-elisp, but put the latest version into + python-elisp. + + -- Matthias Klose Thu, 22 Aug 2002 21:52:04 +0200 + +python2.2 (2.2.1-6) unstable; urgency=low + + * CVS updates of the release22-maint branch upto 2002-07-23. + * Enable IPv6 support (closes: #152543). + * Add python2.2-tk suggestion for python2.2 (pydoc -g). + * Fix from SF patch #527518: proxy config with user+pass authentication. + * Point pydoc to the correct location of the docs (closes: #147579). + * Remove '*.py[co]' files, when removing the python package, + not when purging (closes: #147130). + * Update to new py2texi.el version (Milan Zamazal). + + -- Matthias Klose Mon, 29 Jul 2002 23:11:32 +0200 + +python2.2 (2.2.1-5) unstable; urgency=low + + * CVS updates of the release22-maint branch upto 2002-05-03. + * Build the info docs (closes: #145653). + + -- Matthias Klose Fri, 3 May 2002 22:35:46 +0200 + +python2.2 (2.2.1-4) unstable; urgency=high + + * Fix indentation errors introduced in last upload (closes: #143809). + + -- Matthias Klose Sun, 21 Apr 2002 01:00:14 +0200 + +python2.2 (2.2.1-3) unstable; urgency=high + + * Add Build-Conflicts: tcl8.0-dev, tk8.0-dev, tcl8.2-dev, tk8.2-dev. + Closes: #143534 (build a working _tkinter module, on machines, where + 8.0's tk.h gets included). + * CVS updates of the release22-maint branch upto 2002-04-20. + + -- Matthias Klose Sat, 20 Apr 2002 09:22:37 +0200 + +python2.2 (2.2.1-2) unstable; urgency=low + + * Forgot to copy the dlmodule patch from the 2.1.3 package. Really + closes: #141681. + + -- Matthias Klose Sat, 13 Apr 2002 01:28:05 +0200 + +python2.2 (2.2.1-1) unstable; urgency=high + + * Final 2.2.1 release. + * According to report #131813, the python interpreter is much faster on some + architectures, when beeing linked statically with the python library (25%). + Gregor and me tested on i386, m68k and alpha, but we could not reproduce + such a speedup (generally between 5% and 10%). But we are linking the + python executable now statically ... + * Build info docs from the tex source, merge the python-doc-info + package into the python-doc package. + * Always build the dl module. Failure in case of + sizeof(int)!=sizeof(long)!=sizeof(void*) + is delayed until dl.open is called. Closes: #141681. + + -- Matthias Klose Thu, 11 Apr 2002 00:19:19 +0200 + +python2.2 (2.2.0.92-0) unstable; urgency=low + + * Package CVS sources, omit cvs-updates.dpatch (closes: #140977). + + -- Matthias Klose Wed, 3 Apr 2002 08:20:52 +0200 + +python2.2 (2.2-6) unstable; urgency=medium + + * Update to python-2.2.1 release candidate 2 (final release scheduled + for April 10). + * Enable dl module (closes: #138992). + * Build doc files with python binary from package (closes: #139657). + * Build _tkinter module with BLT and Tix support. + * python2.2-elisp: Conflict with python2-elisp (closes: #138970). + * string.split docs updated in python-2.2.1 (closes: #129272). + + -- Matthias Klose Mon, 1 Apr 2002 13:52:36 +0200 + +python2.2 (2.2-5) unstable; urgency=low + + * CVS updates of the release22-maint branch upto 20020310 (aproaching + the first 2.2.1 release candidate). + * Stolen from HEAD: check argument of locale.nl_langinfo (closes: #137371). + + -- Matthias Klose Fri, 15 Mar 2002 01:05:59 +0100 + +python2.2 (2.2-4) unstable; urgency=medium + + * Include test/{__init__.py,README,pystone.py} in package (closes: #129013). + * Fix python-elisp conflict (closes: #129046). + * Don't compress stylesheets (closes: #133179). + * CVS updates of the release22-maint branch upto 20020310. + + -- Matthias Klose Sun, 10 Mar 2002 23:32:28 +0100 + +python2.2 (2.2-3) unstable; urgency=medium + + * Updates from the CVS python22-maint branch up to 20020107. + webbrowser.py: properly escape url's. + * The Hurd does not have large file support: disabled. + + -- Matthias Klose Mon, 7 Jan 2002 21:55:57 +0100 + +python2.2 (2.2-2) unstable; urgency=medium + + * CVS updates of the release22-maint branch upto 20011229. Fixes: + - Include TCP_CORK flag in plat-linux2 headers (fixes: #84340). + - Update CDROM.py module (fixes: #125785). + * Add missing chunk of the GNU/Hurd patch (therefore urgency medium). + * Send anonymous password when using anonftp (closes: #126814). + + -- Matthias Klose Sat, 29 Dec 2001 20:18:26 +0100 + +python2.2 (2.2-1) unstable; urgency=low + + * New upstream version: 2.2. + * Bugs fixed upstream: + - Docs for os.kill reference the signal module for constants. + - Documentation strings in the tutorial end with a period (closes: #94770). + - Tk: grid_location method moved from Grid to Misc (closes: #98338). + - mhlib.SubMessage.getbodytext takes decode parameter (closes: #31876). + - Strings in modules are locale aware (closes: #51444). + - Printable 8-bit characters in strings are correctly printed + (closes: #64354). + - Dictionary can be updated with abstract mapping object (closes: #46566). + * Make site.py a config files. + + -- Matthias Klose Sat, 22 Dec 2001 00:51:46 +0100 + +python2.2 (2.1.99c1-1) unstable; urgency=low + + * New upstream version: 2.2c1 (release candidate). + * Do not provide python2.2-base anymore. + * Install correct README.Debian for python2.2 package. Include hint + where to find Makefile.pre.in. + * Suggest installation of python-ssl. + * Remove idle config files on purge. + * Remove empty /usr/lib/python2.2 directory on purge. + + -- Matthias Klose Sat, 15 Dec 2001 17:56:27 +0100 + +python2.2 (2.1.99beta2-1) unstable; urgency=high + + * debian/rules: Reflect removal of regrtest package (closes: #122278). + Resulted in build failures on all architectures. + * Build -doc package from source. + + -- Matthias Klose Sat, 8 Dec 2001 00:38:41 +0100 + +python2.2 (2.1.99beta2-0.1) unstable; urgency=low + + * Non maintainer upload. + * New upstream version (this is 2.2beta2). + * Do not build the python-regrtest package anymore; keep the test framework + components test/regrtest.py and test/test_support.py in the python + package (closes: #119408). + + -- Gregor Hoffleit Tue, 27 Nov 2001 09:53:26 +0100 + +python2.2 (2.1.99beta1-4) unstable; urgency=low + + * Configure with --with-fpectl (closes: #118125). + * setup.py: Remove broken check for _curses_panel module (#116081). + * idle: Move config-* files to /etc and mark as conffiles (#106390). + * Move idle packages to section `devel'. + + -- Matthias Klose Wed, 31 Oct 2001 10:56:45 +0100 + +python2.2 (2.1.99beta1-3) unstable; urgency=low + + * Fix shlibs file (was still referring to 2.1). Closes: #116810. + * README.Debian: point to draft of python-policy in the python package. + + -- Matthias Klose Wed, 31 Oct 2001 10:56:45 +0100 + +python2.2 (2.1.99beta1-2) unstable; urgency=medium + + * Fix shlibs file (was still referring to 2.1). Closes: #116810. + * Rename package python2.2-base to python2.2. + + -- Matthias Klose Wed, 24 Oct 2001 23:00:50 +0200 + +python2.2 (2.1.99beta1-1) unstable; urgency=low + + * New upstream version (beta). Call the package version 2.1.99beta1-1. + * New maintainer until the final 2.2 release. + * Updated the debian patches. + + -- Matthias Klose Sat, 20 Oct 2001 18:56:26 +0200 + +python2.1 (2.1.1-1.2) unstable; urgency=low + + * Really remove the python alternative. + + -- Matthias Klose Sat, 20 Oct 2001 15:16:56 +0200 + +python2.1 (2.1.1-1.1) unstable; urgency=low + + * README FOR PACKAGE MAINTAINERS: It is planned to remove the python2-XXX + packages from unstable and move on to python2.1. + If you repackage/adapt your modules for python2.1, don't build + python2-XXX and python2.1-XXX packages from the same source package, + so that the python2-XXX package can be removed without influencing the + python2.1-XXX package. + + See the debian-python mailing list at http://lists.debian.org/devel.html + for details and the current discussion and a draft for a debian-python + policy (August to October 2001). + + * Remove alternative for /usr/bin/python. The python-base package now + provides the default python version. + + * Regenerate control file to fix build dependencies (closes: #116190). + * Remove alternative for /usr/bin/{python,pydoc}. + * Provide a libpython2.1.so symlink in /usr/lib/python2.1/config, + so that the shared library is found when -L/usr/lib/python2.1/config + is specified. + * Conflict with old package versions, where /usr/bin/python is a real + program (closes: #115943). + * python2.1-elisp conflicts with python-elisp (closes: #115895). + * We now have 2.1 (closes: #96851, #107849, #110243). + + -- Matthias Klose Fri, 19 Oct 2001 17:34:41 +0200 + +python2.1 (2.1.1-1) unstable; urgency=low + + * Incorporated Matthias' modifications. + + -- Gregor Hoffleit Thu, 11 Oct 2001 00:16:42 +0200 + +python2.1 (2.1.1-0.2) unstable; urgency=low + + * New upstream 2.1.1. + * GPL compatible licence (fixes #84080, #102949, #110643). + * Fixed upstream (closes: #99692, #111340). + * Build in separate build directory. + * Split Debian patches into debian/patches directory. + * Build dependencies: Add libgmp3-dev, libexpat1-dev, tighten + debhelper dependency. + * debian/rules: Updated a "bit". + * python-elisp: Remove custom dependency (closes: #87783), + fix emacs path (closes: #89712), remove emacs19 dependency (#82694). + * Mention distutils in python-dev package description (closes: #108170). + * Update README.Debian (closes: #85430). + * Run versioned python in postinsts (closes: #113349). + * debian/sample.{postinst,prerm}: Change to version independent scripts. + * Use '/usr/bin/env python2.1' as interpreter for all python scripts. + * Add libssl-dev to Build-Conflicts. + * python-elisp: Add support for emacs21 (closes: #98635). + * Do not compress .py files in doc directories. + * Don't link explicitely with libc. + + -- Matthias Klose Wed, 3 Oct 2001 09:53:08 +0200 + +python2.1 (2.1.1-0.1) unstable; urgency=low + + * New upstream version (CVS branch release21-maint, will become 2.1.1): + This CVS branch will be released as 2.1.1 under a GPL compatible + license. + + -- Gregor Hoffleit Wed, 27 Jun 2001 22:47:58 +0200 + +python2 (2.1-0.1) unstable; urgency=low + + * Fixed Makefile.pre.in. + * Fixed the postinst files in order to use 2.1 (instead of 2.0). + * Mention the immanent release of 2.0.1 and 2.1.1, with a GPL + compatible license. + + -- Gregor Hoffleit Sun, 17 Jun 2001 21:05:25 +0200 + +python2 (2.1-0) unstable; urgency=low + + * New upstream version. + * Experimental packages. + + -- Gregor Hoffleit Thu, 10 May 2001 00:20:04 +0200 + +python2 (2.0-7) unstable; urgency=low + + * Rebuilt with recent tcl8.3-dev/tk8.3-dev in order to fix a + dependency problem with python2-tk (closes: #87793, #92962). + * Change postinst to create and update /usr/local/lib/python2.0 and + site-python with permissions and owner as mandated by policy: + 2775 and root:staff (closes: #89047). + * Fix to compileall.py: A superfluous argument made compileall without + options fail (cf. #92990 for python). + * Move the distutils module into python2-dev. It needs Makefile.pre.in + in order to work (closes: #89900). + * Remove build-dependency on libgdbm2-dev (which isn't built anyway). + * Add a build-dependency on libdb2-dev (cf. #90220 for python). + + -- Gregor Hoffleit Sat, 14 Apr 2001 21:07:51 +0200 + +python2 (2.0-6) unstable; urgency=low + + * Remove python-zlib package; merge it into python-base. + * Mark that README.python2 is not yet updated. + + -- Gregor Hoffleit Wed, 21 Feb 2001 12:34:18 +0100 + +python2 (2.0-5) unstable; urgency=low + + * Recompile with tcl/tk8.3 (closes: #82088). + * Modifications to README.why-python2 (closes: #82116). + * Add menu hint to idle2 menu entry. + * idle2 is renamed idle-python2 and now build correctly (closes: #82218). + * Add build-dependency on autoconf (closes: #85339). + * Build bsddbmodule as shared module (Modules/Setup.config.in), + and link libpython2.so with -lm in Makefile (closes: #86027). + * various cleanups in debian/rules, e.g. removing dh_suidregister. + * Make pdb available as /usr/bin/pdb-python2 in python2-dev + (cf. #79870 in python-base). + * Remove libgmp3 from build-dependencies, since we currently can't + build the mpzmodule for Python2 due to license problems. + + -- Gregor Hoffleit Sun, 18 Feb 2001 00:12:17 +0100 + +python2 (2.0-4) unstable; urgency=low + + * control: make python2-elisp conflict with python-elisp (it doesn't + make sense to have both of them installed, does it ?) + * include build-depend on libxmltok1-dev. + * again, build with tcl/tk8.0. + + -- Gregor Hoffleit Wed, 10 Jan 2001 23:37:01 +0100 + +python2 (2.0-3) unstable; urgency=low + + * Modules/Setup.in: Added a missing \ that made _tkinter be built + incorrectly. + * rules: on the fly, change all '#!' python scripts to use python2. + + -- Gregor Hoffleit Wed, 13 Dec 2000 20:07:24 +0100 + +python2 (2.0-2) unstable; urgency=low + + * Aaargh. Remove conflicts/provides/replaces on python-base to make + parallel installation of python-base and python2-base possible. + * Install examples into /usr/share/doc/python2 (not python) and fix + symlink to python2.0 (thanks to Rick Younie for + pointing out this). + * Rename man page to python2.1. + + -- Gregor Hoffleit Wed, 13 Dec 2000 09:31:05 +0100 + +python2 (2.0-1) unstable; urgency=low + + * New upstream version. Initial release for python2. + + -- Gregor Hoffleit Mon, 11 Dec 2000 22:39:46 +0100 --- python3.2-3.2.3.orig/debian/idle-PVER.1.in +++ python3.2-3.2.3/debian/idle-PVER.1.in @@ -0,0 +1,104 @@ +.TH IDLE 1 "21 September 2004" +.SH NAME +\fBIDLE\fP \- An Integrated DeveLopment Environment for Python +.SH SYNTAX +.B idle [ \fI-dins\fP ] [ \fI-t title\fP ] [ \fIfile\fP ...] +.PP +.B idle [ \fI-dins\fP ] [ \fI-t title\fP ] ( \fI-c cmd\fP | \fI-r file\fP ) [ \fIarg\fP ...] +.PP +.B idle [ \fI-dins\fP ] [ \fI-t title\fP ] - [ \fIarg\fP ...] +.SH DESCRIPTION +This manual page documents briefly the +.BR idle +command. +This manual page was written for Debian +because the original program does not have a manual page. +For more information, refer to IDLE's help menu. +.PP +.B IDLE +is an Integrated DeveLopment Environment for Python. IDLE is based on +Tkinter, Python's bindings to the Tk widget set. Features are 100% pure +Python, multi-windows with multiple undo and Python colorizing, a Python +shell window subclass, a debugger. IDLE is cross-platform, i.e. it works +on all platforms where Tk is installed. +.LP +.SH OPTIONS +.TP +.B \-h +.PD +Print this help message and exit. +.TP +.B \-n +.PD +Run IDLE without a subprocess (see Help/IDLE Help for details). +.PP +The following options will override the IDLE 'settings' configuration: +.TP +.B \-e +.PD +Open an edit window. +.TP +.B \-i +.PD +Open a shell window. +.PP +The following options imply -i and will open a shell: +.TP +.B \-c cmd +.PD +Run the command in a shell, or +.TP +.B \-r file +.PD +Run script from file. +.PP +.TP +.B \-d +.PD +Enable the debugger. +.TP +.B \-s +.PD +Run $IDLESTARTUP or $PYTHONSTARTUP before anything else. +.TP +.B \-t title +.PD +Set title of shell window. +.PP +A default edit window will be bypassed when -c, -r, or - are used. +.PP +[arg]* and [file]* are passed to the command (-c) or script (-r) in sys.argv[1:]. +.SH EXAMPLES +.TP +idle +.PD +Open an edit window or shell depending on IDLE's configuration. +.TP +idle foo.py foobar.py +.PD +Edit the files, also open a shell if configured to start with shell. +.TP +idle -est "Baz" foo.py +.PD +Run $IDLESTARTUP or $PYTHONSTARTUP, edit foo.py, and open a shell +window with the title "Baz". +.TP +idle -c "import sys; print sys.argv" "foo" +.PD +Open a shell window and run the command, passing "-c" in sys.argv[0] +and "foo" in sys.argv[1]. +.TP +idle -d -s -r foo.py "Hello World" +.PD +Open a shell window, run a startup script, enable the debugger, and +run foo.py, passing "foo.py" in sys.argv[0] and "Hello World" in +sys.argv[1]. +.TP +echo "import sys; print sys.argv" | idle - "foobar" +.PD +Open a shell window, run the script piped in, passing '' in sys.argv[0] +and "foobar" in sys.argv[1]. +.SH SEE ALSO +python(1). +.SH AUTHORS +Various. --- python3.2-3.2.3.orig/debian/control.stdlib +++ python3.2-3.2.3/debian/control.stdlib @@ -0,0 +1,16 @@ +Package: @PVER@-tk +Architecture: any +Depends: @PVER@ (= ${Source-Version}), ${shlibs:Depends} +Suggests: tix +XB-Python-Version: @VER@ +Description: Tkinter - Writing Tk applications with Python (v@VER@) + A module for writing portable GUI applications with Python (v@VER@) using Tk. + Also known as Tkinter. + +Package: @PVER@-gdbm +Architecture: any +Depends: @PVER@ (= ${Source-Version}), ${shlibs:Depends} +Description: GNU dbm database support for Python (v@VER@) + GNU dbm database module for Python. Install this if you want to + create or read GNU dbm database files with Python. + --- python3.2-3.2.3.orig/debian/mincheck.py +++ python3.2-3.2.3/debian/mincheck.py @@ -0,0 +1,41 @@ + +import sys + +def get_listed(fn): + modules = set() + for line in open(fn).readlines(): + modules.add(line.split()[1]) + return modules + +def get_dependencies(fn): + t = eval(open(fn).read()) + modules = set() + depgraph = t['depgraph'] + for mod, deps in depgraph.items(): + if mod != '__main__': + modules.add(mod) + modules.update(deps.keys()) + return depgraph, modules + +def main(): + mods = get_listed(sys.argv[1]) + depgraph, deps = get_dependencies(sys.argv[2]) + print("Listed modules:", sorted(mods)) + print("") + print("Dependent modules:", sorted(deps)) + print("") + + missing = deps.difference(mods) + if missing: + print("Missing modules in python-minimal:") + print(missing) + for m in missing: + users = [] + for caller, callees in depgraph.items(): + if m in callees: + users.append(caller) + print(m, "used in: ", users) + sys.exit(len(missing)) + +main() + --- python3.2-3.2.3.orig/debian/pyhtml2devhelp.py +++ python3.2-3.2.3/debian/pyhtml2devhelp.py @@ -0,0 +1,222 @@ +#! /usr/bin/python + +import formatter, htmllib +import os, sys, re + +class PyHTMLParser(htmllib.HTMLParser): + pages_to_include = set(('whatsnew/index.html', 'tutorial/index.html', 'using/index.html', + 'reference/index.html', 'library/index.html', 'howto/index.html', + 'extending/index.html', 'c-api/index.html', 'install/index.html', + 'distutils/index.html')) + + def __init__(self, formatter, basedir, fn, indent, parents=set()): + htmllib.HTMLParser.__init__(self, formatter) + self.basedir = basedir + self.dir, self.fn = os.path.split(fn) + self.data = '' + self.parents = parents + self.link = {} + self.indent = indent + self.last_indent = indent - 1 + self.sub_indent = 0 + self.sub_count = 0 + self.next_link = False + + def process_link(self): + new_href = os.path.join(self.dir, self.link['href']) + text = self.link['text'] + indent = self.indent + self.sub_indent + if self.last_indent == indent: + print '%s' % (' ' * self.last_indent) + self.sub_count -= 1 + print '%s' % (' ' * indent, new_href, text) + self.sub_count += 1 + self.last_indent = self.indent + self.sub_indent + + def start_li(self, attrs): + self.sub_indent += 1 + self.next_link = True + + def end_li(self): + indent = self.indent + self.sub_indent + if self.sub_count > 0: + print '%s' % (' ' * self.last_indent) + self.sub_count -= 1 + self.last_indent -= 1 + self.sub_indent -= 1 + + def start_a(self, attrs): + self.link = {} + for attr in attrs: + self.link[attr[0]] = attr[1] + self.data = '' + + def end_a(self): + process = False + text = self.data.replace('\t', '').replace('\n', ' ').replace('&', '&').replace('<', '<').replace('>', '>') + self.link['text'] = text + # handle a tag without href attribute + try: + href = self.link['href'] + except KeyError: + return + + abs_href = os.path.join(self.basedir, href) + if abs_href in self.parents: + return + if href.startswith('..') or href.startswith('http:') \ + or href.startswith('mailto:') or href.startswith('news:'): + return + if href in ('', 'about.html', 'modindex.html', 'genindex.html', 'glossary.html', + 'search.html', 'contents.html', 'download.html', 'bugs.html', + 'license.html', 'copyright.html'): + return + + if self.link.has_key('class'): + if self.link['class'] in ('biglink'): + process = True + if self.link['class'] in ('reference external'): + if self.next_link: + process = True + next_link = False + + if process == True: + self.process_link() + if href in self.pages_to_include: + self.parse_file(os.path.join(self.dir, href)) + + def finish(self): + if self.sub_count > 0: + print '%s' % (' ' * self.last_indent) + + def handle_data(self, data): + self.data += data + + def parse_file(self, href): + # TODO basedir bestimmen + parent = os.path.join(self.basedir, self.fn) + self.parents.add(parent) + parser = PyHTMLParser(formatter.NullFormatter(), + self.basedir, href, self.indent + 1, + self.parents) + text = file(self.basedir + '/' + href).read() + parser.feed(text) + parser.finish() + parser.close() + if parent in self.parents: + self.parents.remove(parent) + +class PyIdxHTMLParser(htmllib.HTMLParser): + def __init__(self, formatter, basedir, fn, indent): + htmllib.HTMLParser.__init__(self, formatter) + self.basedir = basedir + self.dir, self.fn = os.path.split(fn) + self.data = '' + self.link = {} + self.indent = indent + self.active = False + self.indented = False + self.nolink = False + self.header = '' + self.last_letter = 'Z' + self.last_text = '' + + def process_link(self): + new_href = os.path.join(self.dir, self.link['href']) + text = self.link['text'] + if not self.active: + return + if text.startswith('['): + return + if self.link.get('rel', None) in ('prev', 'parent', 'next', 'contents', 'index'): + return + if self.indented: + text = self.last_text + ' ' + text + else: + # Save it in case we need it again + self.last_text = re.sub(' \([\w\-\.\s]+\)', '', text) + indent = self.indent + print '%s' % (' ' * indent, new_href, text) + + def start_dl(self, attrs): + if self.last_text: + # Looks like we found the second part to a command + self.indented = True + + def end_dl(self): + self.indented = False + + def start_dt(self, attrs): + self.data = '' + self.nolink = True + + def end_dt(self): + if not self.active: + return + if self.nolink == True: + # Looks like we found the first part to a command + self.last_text = re.sub(' \([\w\-\.\s]+\)', '', self.data) + self.nolink = False + + def start_h2(self, attrs): + for k, v in attrs: + if k == 'id': + self.header = v + if v == '_': + self.active = True + + def start_td(self, attrs): + self.indented = False + self.last_text = '' + + def start_table(self, attrs): + pass + + def end_table(self): + if self.header == self.last_letter: + self.active = False + + def start_a(self, attrs): + self.nolink = False + self.link = {} + for attr in attrs: + self.link[attr[0]] = attr[1] + self.data = '' + + def end_a(self): + text = self.data.replace('\t', '').replace('\n', ' ').replace('&', '&').replace('<', '<').replace('>', '>') + self.link['text'] = text + # handle a tag without href attribute + try: + href = self.link['href'] + except KeyError: + return + self.process_link() + + def handle_data(self, data): + self.data += data + +def main(): + base = sys.argv[1] + fn = sys.argv[2] + version = sys.argv[3] + + parser = PyHTMLParser(formatter.NullFormatter(), base, fn, indent=0) + print '' + print '' % (version, version) + print '' + parser.parse_file(fn) + print '' + + print '' + + fn = 'genindex-all.html' + parser = PyIdxHTMLParser(formatter.NullFormatter(), base, fn, indent=1) + text = file(base + '/' + fn).read() + parser.feed(text) + parser.close() + + print '' + print '' + +main() --- python3.2-3.2.3.orig/debian/compat +++ python3.2-3.2.3/debian/compat @@ -0,0 +1 @@ +5 --- python3.2-3.2.3.orig/debian/PVER-doc.doc-base.PVER-ext.in +++ python3.2-3.2.3/debian/PVER-doc.doc-base.PVER-ext.in @@ -0,0 +1,16 @@ +Document: @PVER@-ext +Title: Extending and Embedding the Python Interpreter (v@VER@) +Author: Guido van Rossum +Abstract: This document describes how to write modules in C or C++ to extend + the Python interpreter with new modules. Those modules can define + new functions but also new object types and their methods. The + document also describes how to embed the Python interpreter in + another application, for use as an extension language. Finally, + it shows how to compile and link extension modules so that they + can be loaded dynamically (at run time) into the interpreter, if + the underlying operating system supports this feature. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/extending/index.html +Files: /usr/share/doc/@PVER@/html/extending/*.html --- python3.2-3.2.3.orig/debian/PVER-doc.doc-base.PVER-dist.in +++ python3.2-3.2.3/debian/PVER-doc.doc-base.PVER-dist.in @@ -0,0 +1,13 @@ +Document: @PVER@-dist +Title: Distributing Python Modules (v@VER@) +Author: Greg Ward +Abstract: This document describes the Python Distribution Utilities + (``Distutils'') from the module developer's point-of-view, describing + how to use the Distutils to make Python modules and extensions easily + available to a wider audience with very little overhead for + build/release/install mechanics. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/distutils/index.html +Files: /usr/share/doc/@PVER@/html/distutils/*.html --- python3.2-3.2.3.orig/debian/control.udeb +++ python3.2-3.2.3/debian/control.udeb @@ -0,0 +1,11 @@ + +Package: @PVER@-udeb +XC-Package-Type: udeb +Section: debian-installer +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +XB-Python-Runtime: @PVER@ +XB-Python-Version: @VER@ +Description: A minimal subset of the Python language (version @VER@) + This package contains the interpreter and some essential modules, packaged + for use in the installer. --- python3.2-3.2.3.orig/debian/README.PVER.in +++ python3.2-3.2.3/debian/README.PVER.in @@ -0,0 +1,95 @@ + + Python @VER@ for Debian + --------------------- + +This is Python @VER@ packaged for Debian. + +This document contains information specific to the Debian packages of +Python @VER@. + + + + [TODO: This document is not yet up-to-date with the packages.] + +Currently, it features those two main topics: + + 1. Release notes for the Debian packages: + 2. Notes for developers using the Debian Python packages: + +Release notes and documentation from the upstream package are installed +in /usr/share/doc/@PVER@/. + +There's a mailing list for discussion of issues related to Python on Debian +systems: debian-python@lists.debian.org. The list is not intended for +general Python problems, but as a forum for maintainers of Python-related +packages and interested third parties. + + + +1. Release notes for the Debian packages: + + +Results of the regression test: +------------------------------ + +The package does successfully run the regression tests for all included +modules. Seven packages are skipped since they are platform-dependent and +can't be used with Linux. + + +2. Notes for developers using the Debian python packages: + +See the draft of the Debian Python policy in /usr/share/doc/python. + +distutils can be found in the @PVER@-dev package. Development files +like the python library or Makefiles can be found in the @PVER@-dev +package in /usr/lib/@PVER@/config. Therefore, if you need to install +a pure python extension, you only need @PVER@. On the other hand, to +install a C extension, you need @PVER@-dev. + +a) Locally installed Python add-ons + + /usr/local/lib/@PVER@/site-packages/ + /usr/local/lib/site-python/ (version-independent modules) + +b) Python add-ons packaged for Debian + + /usr/lib/@PVER@/site-packages/ + /usr/lib/site-python/ (version-independent modules) + +Note that no package must install files directly into /usr/lib/@PVER@/ +or /usr/local/lib/@PVER@/. Only the site-packages directory is allowed +for third-party extensions. + +Use of the new `package' scheme is strongly encouraged. The `ni' interface +is obsolete in python 1.5. + +Header files for extensions go into /usr/include/@PVER@/. + + +Installing extensions for local use only: +---------------------------------------- + +Consider using distutils ... + +Most extensions use Python's Makefile.pre.in. Note that Makefile.pre.in +by default will install files into /usr/lib/, not into /usr/local/lib/, +which is not allowed for local extensions. You'll have to change the +Makefile accordingly. Most times, "make prefix=/usr/local install" will +work. + + +Packaging python extensions for Debian: +-------------------------------------- + +Maintainers of Python extension packages should read + + /usr/share/doc/python/python-policy.txt.gz + + + + + 03/09/98 + Gregor Hoffleit + +Last change: 2001-12-14 --- python3.2-3.2.3.orig/debian/dh_doclink +++ python3.2-3.2.3/debian/dh_doclink @@ -0,0 +1,28 @@ +#! /bin/sh + +pkg=`echo $1 | sed 's/^-p//'` +target=$2 + +ln -sf $target debian/$pkg/usr/share/doc/$pkg + +f=debian/$pkg.postinst.debhelper +if [ ! -e $f ] || [ "`grep -c '^# dh_doclink' $f`" -eq 0 ]; then +cat >> $f <> $f < +Build-Depends: debhelper (>= 5.0.51~), quilt, autoconf, libreadline-dev, libncursesw5-dev (>= 5.3), zlib1g-dev, libdb5.1-dev, libgdbm-dev, tk8.5-dev, blt-dev (>= 2.4z), libssl-dev, sharutils, libbz2-dev, libexpat1-dev, libbluetooth-dev [linux-any], locales [!armel !avr32 !hppa !ia64 !mipsel], libsqlite3-dev, libffi-dev (>= 3.0.5), mime-support, libgpm2 [linux-any], netbase, lsb-release, bzip2, gdb, python, xvfb, xauth +Build-Depends-Indep: python-sphinx +Build-Conflicts: autoconf2.13 +Standards-Version: 3.9.3 +Vcs-Browser: https://code.launchpad.net/~doko/python/pkg3.2-debian +Vcs-Bzr: http://bazaar.launchpad.net/~doko/python/pkg3.2-debian + +Package: python3.2 +Architecture: any +Priority: optional +Depends: python3.2-minimal (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends} +Suggests: python3.2-doc, binutils +Provides: python3.2-cjkcodecs, python3.2-ctypes, python3.2-elementtree, python3.2-celementtree, python3.2-wsgiref, python3.2-gdbm, python3.2-profiler +Conflicts: python3-profiler (<= 3.2-2) +Breaks: python-virtualenv (<< 1.7.1.2-2~) +Replaces: python3-profiler (<= 3.2-2) +Description: Interactive high-level object-oriented language (version 3.2) + Version 3.2 of the high-level, interactive object oriented language, + includes an extensive class library with lots of goodies for + network programming, system administration, sounds and graphics. + +Package: python3.2-minimal +Architecture: any +Priority: optional +Depends: ${shlibs:Depends}, ${misc:Depends} +Recommends: python3.2 +Suggests: binfmt-support +Replaces: python3.2 (<< 3.2~b2-1~) +Conflicts: binfmt-support (<< 1.1.2) +Description: Minimal subset of the Python language (version 3.2) + This package contains the interpreter and some essential modules. It can + be used in the boot process for some basic tasks. + See /usr/share/doc/python3.2-minimal/README.Debian for a list of the modules + contained in this package. + +Package: libpython3.2 +Architecture: any +Section: libs +Priority: optional +Depends: python3.2 (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Replaces: python3.2 (<< 3.0~rc1) +Description: Shared Python runtime library (version 3.2) + Version 3.2 of the high-level, interactive object oriented language, + includes an extensive class library with lots of goodies for + network programming, system administration, sounds and graphics. + . + This package contains the shared runtime library, normally not needed + for programs using the statically linked interpreter. + +Package: python3.2-examples +Architecture: all +Depends: python3.2 (>= ${source:Version}), ${misc:Depends} +Description: Examples for the Python language (v3.2) + Examples, Demos and Tools for Python (v3.2). These are files included in + the upstream Python distribution (v3.2). + +Package: python3.2-dev +Architecture: any +Depends: python3.2 (= ${binary:Version}), libpython3.2 (= ${binary:Version}), libssl-dev, libexpat1-dev, ${shlibs:Depends}, ${misc:Depends} +Replaces: python3.2 (<< 3.2.2-4) +Recommends: libc6-dev | libc-dev +Description: Header files and a static library for Python (v3.2) + Header files, a static library and development tools for building + Python (v3.2) modules, extending the Python interpreter or embedding + Python (v3.2) in applications. + . + Maintainers of Python packages should read README.maintainers. + +Package: idle-python3.2 +Architecture: all +Depends: python3.2, python3-tk, python3.2-tk, ${misc:Depends} +Enhances: python3.2 +Description: IDE for Python (v3.2) using Tkinter + IDLE is an Integrated Development Environment for Python (v3.2). + IDLE is written using Tkinter and therefore quite platform-independent. + +Package: python3.2-doc +Section: doc +Architecture: all +Depends: libjs-jquery, libjs-underscore, ${misc:Depends} +Suggests: python3.2 +Description: Documentation for the high-level object-oriented language Python (v3.2) + These is the official set of documentation for the interactive high-level + object-oriented language Python (v3.2). All documents are provided + in HTML format. The package consists of ten documents: + . + * What's New in Python3.2 + * Tutorial + * Python Library Reference + * Macintosh Module Reference + * Python Language Reference + * Extending and Embedding Python + * Python/C API Reference + * Installing Python Modules + * Documenting Python + * Distributing Python Modules + +Package: python3.2-dbg +Section: debug +Architecture: any +Priority: extra +Depends: python3.2 (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}, python +Suggests: python3-gdbm-dbg, python3-tk-dbg +Description: Debug Build of the Python Interpreter (version 3.2) + Python interpreter configured with --pydebug. Dynamically loaded modules are + searched in /usr/lib/python3.2/lib-dynload/debug first. --- python3.2-3.2.3.orig/debian/mkbinfmt.py +++ python3.2-3.2.3/debian/mkbinfmt.py @@ -0,0 +1,18 @@ +# mkbinfmt.py +import imp, sys, os.path + +magic = "".join(["\\x%.2x" % c for c in imp.get_magic()]) + +name = sys.argv[1] + +binfmt = '''\ +package %s +interpreter /usr/bin/%s +magic %s\ +''' % (name, name, magic) + +#filename = '/usr/share/binfmts/' + name +#open(filename,'w+').write(binfmt) + +sys.stdout.write(binfmt) +sys.stdout.write('\n') --- python3.2-3.2.3.orig/debian/pygettext.1 +++ python3.2-3.2.3/debian/pygettext.1 @@ -0,0 +1,108 @@ +.TH PYGETTEXT 1 "" "pygettext 1.4" +.SH NAME +pygettext \- Python equivalent of xgettext(1) +.SH SYNOPSIS +.B pygettext +[\fIOPTIONS\fR] \fIINPUTFILE \fR... +.SH DESCRIPTION +pygettext is deprecated. The current version of xgettext supports +many languages, including Python. + +pygettext uses Python's standard tokenize module to scan Python +source code, generating .pot files identical to what GNU xgettext generates +for C and C++ code. From there, the standard GNU tools can be used. +.PP +pygettext searches only for _() by default, even though GNU xgettext +recognizes the following keywords: gettext, dgettext, dcgettext, +and gettext_noop. See the \fB\-k\fR/\fB\--keyword\fR flag below for how to +augment this. +.PP +.SH OPTIONS +.TP +\fB\-a\fR, \fB\-\-extract\-all\fR +Extract all strings. +.TP +\fB\-d\fR, \fB\-\-default\-domain\fR=\fINAME\fR +Rename the default output file from messages.pot to name.pot. +.TP +\fB\-E\fR, \fB\-\-escape\fR +Replace non-ASCII characters with octal escape sequences. +.TP +\fB\-D\fR, \fB\-\-docstrings\fR +Extract module, class, method, and function docstrings. +These do not need to be wrapped in _() markers, and in fact cannot +be for Python to consider them docstrings. (See also the \fB\-X\fR option). +.TP +\fB\-h\fR, \fB\-\-help\fR +Print this help message and exit. +.TP +\fB\-k\fR, \fB\-\-keyword\fR=\fIWORD\fR +Keywords to look for in addition to the default set, which are: _ +.IP +You can have multiple \fB\-k\fR flags on the command line. +.TP +\fB\-K\fR, \fB\-\-no\-default\-keywords\fR +Disable the default set of keywords (see above). +Any keywords explicitly added with the \fB\-k\fR/\fB\--keyword\fR option +are still recognized. +.TP +\fB\-\-no\-location\fR +Do not write filename/lineno location comments. +.TP +\fB\-n\fR, \fB\-\-add\-location\fR +Write filename/lineno location comments indicating where each +extracted string is found in the source. These lines appear before +each msgid. The style of comments is controlled by the +\fB\-S\fR/\fB\--style\fR option. This is the default. +.TP +\fB\-o\fR, \fB\-\-output\fR=\fIFILENAME\fR +Rename the default output file from messages.pot to FILENAME. +If FILENAME is `-' then the output is sent to standard out. +.TP +\fB\-p\fR, \fB\-\-output\-dir\fR=\fIDIR\fR +Output files will be placed in directory DIR. +.TP +\fB\-S\fR, \fB\-\-style\fR=\fISTYLENAME\fR +Specify which style to use for location comments. +Two styles are supported: +.RS +.IP \(bu 4 +Solaris # File: filename, line: line-number +.IP \(bu 4 +GNU #: filename:line +.RE +.IP +The style name is case insensitive. +GNU style is the default. +.TP +\fB\-v\fR, \fB\-\-verbose\fR +Print the names of the files being processed. +.TP +\fB\-V\fR, \fB\-\-version\fR +Print the version of pygettext and exit. +.TP +\fB\-w\fR, \fB\-\-width\fR=\fICOLUMNS\fR +Set width of output to columns. +.TP +\fB\-x\fR, \fB\-\-exclude\-file\fR=\fIFILENAME\fR +Specify a file that contains a list of strings that are not be +extracted from the input files. Each string to be excluded must +appear on a line by itself in the file. +.TP +\fB\-X\fR, \fB\-\-no\-docstrings\fR=\fIFILENAME\fR +Specify a file that contains a list of files (one per line) that +should not have their docstrings extracted. This is only useful in +conjunction with the \fB\-D\fR option above. +.PP +If `INPUTFILE' is -, standard input is read. +.SH BUGS +pygettext attempts to be option and feature compatible with GNU xgettext +where ever possible. However some options are still missing or are not fully +implemented. Also, xgettext's use of command line switches with option +arguments is broken, and in these cases, pygettext just defines additional +switches. +.SH AUTHOR +pygettext is written by Barry Warsaw . +.PP +Joonas Paalasmaa put this manual page together +based on "pygettext --help". --- python3.2-3.2.3.orig/debian/idle.desktop.in +++ python3.2-3.2.3/debian/idle.desktop.in @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=IDLE (using Python-@VER@) +Comment=Integrated Development Environment for Python (using Python-@VER@) +Exec=/usr/bin/idle-@PVER@ -n +Icon=/usr/share/pixmaps/@PVER@.xpm +Terminal=false +Type=Application +Categories=Application;Development; +StartupNotify=true --- python3.2-3.2.3.orig/debian/idle-PVER.prerm.in +++ python3.2-3.2.3/debian/idle-PVER.prerm.in @@ -0,0 +1,31 @@ +#! /bin/sh -e + +remove_bytecode() +{ + pkg=$1 + max=$(LANG=C LC_ALL=C xargs --show-limits < /dev/null 2>&1 | awk '/Maximum/ {print int($NF / 4)}') + dpkg -L $pkg \ + | awk -F/ 'BEGIN {OFS="/"} /\.py$/ {$NF=sprintf("__pycache__/%s.*.py[co]", substr($NF,1,length($NF)-3)); print}' \ + | xargs --max-chars=$max echo \ + | while read files; do rm -f $files; done + find /usr/lib/@PVER@ -name dist-packages -prune -o -name __pycache__ -empty -print \ + | xargs -r rm -rf +} + +case "$1" in + remove|upgrade) + remove_bytecode idle-@PVER@ + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 --- python3.2-3.2.3.orig/debian/idle-PVER.postinst.in +++ python3.2-3.2.3/debian/idle-PVER.postinst.in @@ -0,0 +1,30 @@ +#! /bin/sh -e +# +# postinst script for the Debian idle-@PVER@ package. +# Written 1998 by Gregor Hoffleit . +# + +DIRLIST="/usr/lib/python@VER@/idlelib" + +case "$1" in + configure|abort-upgrade|abort-remove|abort-deconfigure) + + for i in $DIRLIST ; do + @PVER@ /usr/lib/@PVER@/compileall.py -q $i + if grep -sq '^byte-compile[^#]*optimize' /etc/python/debian_config + then + @PVER@ -O /usr/lib/@PVER@/compileall.py -q $i + fi + done + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; + +esac + +#DEBHELPER# + +exit 0 --- python3.2-3.2.3.orig/debian/PVER.pycentral.in +++ python3.2-3.2.3/debian/PVER.pycentral.in @@ -0,0 +1,4 @@ +[@PVER@] +runtime: @PVER@ +interpreter: /usr/bin/@PVER@ +prefix: /usr/lib/@PVER@ --- python3.2-3.2.3.orig/debian/PVER-dbg.symbols.in +++ python3.2-3.2.3/debian/PVER-dbg.symbols.in @@ -0,0 +1,33 @@ +libpython@VER@dmu.so.1.0 python@VER@-dbg #MINVER# +#include "libpython.symbols" + _PyDict_Dummy@Base @SVER@ + _PyMem_DebugFree@Base @SVER@ + _PyMem_DebugMalloc@Base @SVER@ + _PyMem_DebugRealloc@Base @SVER@ + _PyObject_DebugCheckAddress@Base @SVER@ + _PyObject_DebugCheckAddressApi@Base @SVER@ + _PyObject_DebugDumpAddress@Base @SVER@ + _PyObject_DebugFree@Base @SVER@ + _PyObject_DebugFreeApi@Base @SVER@ + _PyObject_DebugMalloc@Base @SVER@ + _PyObject_DebugMallocApi@Base @SVER@ + _PyObject_DebugMallocStats@Base @SVER@ + _PyObject_DebugRealloc@Base @SVER@ + _PyObject_DebugReallocApi@Base @SVER@ + _PySet_Dummy@Base @SVER@ + _Py_AddToAllObjects@Base @SVER@ + _Py_Dealloc@Base @SVER@ + _Py_ForgetReference@Base @SVER@ + _Py_GetObjects@Base @SVER@ + _Py_GetRefTotal@Base @SVER@ + _Py_HashSecret_Initialized@Base @SVER@ + _Py_NegativeRefcount@Base @SVER@ + _Py_NewReference@Base @SVER@ + _Py_PrintReferenceAddresses@Base @SVER@ + _Py_PrintReferences@Base @SVER@ + _Py_RefTotal@Base @SVER@ + _Py_dumptree@Base @SVER@ + _Py_printtree@Base @SVER@ + _Py_showtree@Base @SVER@ + _Py_tok_dump@Base @SVER@ + PyModule_Create2TraceRefs@Base @SVER@ --- python3.2-3.2.3.orig/debian/PVER.desktop.in +++ python3.2-3.2.3/debian/PVER.desktop.in @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=Python (v@VER@) +Comment=Python Interpreter (v@VER@) +Exec=/usr/bin/@PVER@ +Icon=/usr/share/pixmaps/@PVER@.xpm +Terminal=true +Type=Application +Categories=Development; +StartupNotify=true +NoDisplay=true --- python3.2-3.2.3.orig/debian/watch +++ python3.2-3.2.3/debian/watch @@ -0,0 +1,3 @@ +version=3 +opts=dversionmangle=s/.*\+//,uversionmangle=s/([abcr]+[1-9])$/~$1/ \ + http://www.python.org/ftp/python/3\.2(\.\d)?/Python-(3\.2[.\dabcr]*)\.tgz --- python3.2-3.2.3.orig/debian/PVER-dbg.overrides.in +++ python3.2-3.2.3/debian/PVER-dbg.overrides.in @@ -0,0 +1,8 @@ +@PVER@-dbg binary: package-name-doesnt-match-sonames +@PVER@-dbg binary: non-dev-pkg-with-shlib-symlink + +# no, it's not unusual +@PVER@-dbg binary: unusual-interpreter + +# just the gdb debug file +@PVER@-dbg binary: python-script-but-no-python-dep --- python3.2-3.2.3.orig/debian/README.Tk +++ python3.2-3.2.3/debian/README.Tk @@ -0,0 +1,8 @@ +Tkinter documentation can be found at + + http://www.pythonware.com/library/index.htm + +more specific: + + http://www.pythonware.com/library/tkinter/introduction/index.htm + http://www.pythonware.com/library/tkinter/an-introduction-to-tkinter.pdf --- python3.2-3.2.3.orig/debian/changelog.shared +++ python3.2-3.2.3/debian/changelog.shared @@ -0,0 +1,3 @@ + * Link the interpreter against the shared runtime library. With + gcc-4.1 the difference in the pystones benchmark dropped from about + 12% to about 5%. --- python3.2-3.2.3.orig/debian/PVER-doc.doc-base.PVER-inst.in +++ python3.2-3.2.3/debian/PVER-doc.doc-base.PVER-inst.in @@ -0,0 +1,12 @@ +Document: @PVER@-inst +Title: Installing Python Modules (v@VER@) +Author: Greg Ward +Abstract: This document describes the Python Distribution Utilities + (``Distutils'') from the end-user's point-of-view, describing how to + extend the capabilities of a standard Python installation by building + and installing third-party Python modules and extensions. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/install/index.html +Files: /usr/share/doc/@PVER@/html/install/*.html --- python3.2-3.2.3.orig/debian/README.python +++ python3.2-3.2.3/debian/README.python @@ -0,0 +1,153 @@ + + Python 2.x for Debian + --------------------- + +This is Python 2.x packaged for Debian. + +This document contains information specific to the Debian packages of +Python 2.x. + + + + [TODO: This document is not yet up-to-date with the packages.] + + + + + + +Currently, it features those two main topics: + + 1. Release notes for the Debian packages: + 2. Notes for developers using the Debian Python packages: + +Release notes and documentation from the upstream package are installed +in /usr/share/doc/python/. + +Up-to-date information regarding Python on Debian systems is also +available as http://www.debian.org/~flight/python/. + +There's a mailing list for discussion of issues related to Python on Debian +systems: debian-python@lists.debian.org. The list is not intended for +general Python problems, but as a forum for maintainers of Python-related +packages and interested third parties. + + + +1. Release notes for the Debian packages: + + +Results of the regression test: +------------------------------ + +The package does successfully run the regression tests for all included +modules. Seven packages are skipped since they are platform-dependent and +can't be used with Linux. + + +Noteworthy changes since the 1.4 packages: +----------------------------------------- + +- Threading support enabled. +- Tkinter for Tcl/Tk 8.x. +- New package python-zlib. +- The dbmmodule was dropped. Use bsddb instead. gdbmmodule is provided + for compatibility's sake. +- python-elisp adheres to the new emacs add-on policy; it now depends + on emacsen. python-elisp probably won't work correctly with emacs19. + Refer to /usr/doc/python-elisp/ for more information. +- Remember that 1.5 has dropped the `ni' interface in favor of a generic + `packages' concept. +- Python 1.5 regression test as additional package python-regrtest. You + don't need to install this package unless you don't trust the + maintainer ;-). +- once again, modified upstream's compileall.py and py_compile.py. + Now they support compilation of optimized byte-code (.pyo) for use + with "python -O", removal of .pyc and .pyo files where the .py source + files are missing (-d) and finally the fake of a installation directory + when .py files have to be compiled out of place for later installation + in a different directory (-i destdir, used in ./debian/rules). +- The Debian packages for python 1.4 do call + /usr/lib/python1.4/compileall.py in their postrm script. Therefore + I had to provide a link from /usr/lib/python1.5/compileall.py, otherwise + the old packages won't be removed completely. THIS IS A SILLY HACK! + + + +2. Notes for developers using the Debian python packages: + + +Embedding python: +---------------- + +The files for embedding python resp. extending the python interpreter +are included in the python-dev package. With the configuration in the +Debian GNU/Linux packages of python 1.5, you will want to use something +like + + -I/usr/include/python1.5 (e.g. for config.h) + -L/usr/lib/python1.5/config -lpython1.5 (... -lpthread) + (also for Makefile.pre.in, Setup etc.) + +Makefile.pre.in automatically gets that right. Note that unlike 1.4, +python 1.5 has only one library, libpython1.5.a. + +Currently, there's no shared version of libpython. Future version of +the Debian python packages will support this. + + +Python extension packages: +------------------------- + +According to www.python.org/doc/essays/packages.html, extension packages +should only install into /usr/lib/python1.5/site-packages/ (resp. +/usr/lib/site-python/ for packages that are definitely version independent). +No extension package should install files directly into /usr/lib/python1.5/. + +But according to the FSSTND, only Debian packages are allowed to use +/usr/lib/python1.5/. Therefore Debian Python additionally by default +searches a second hierarchy in /usr/local/lib/. These directories take +precedence over their equivalents in /usr/lib/. + +a) Locally installed Python add-ons + + /usr/local/lib/python1.5/site-packages/ + /usr/local/lib/site-python/ (version-independent modules) + +b) Python add-ons packaged for Debian + + /usr/lib/python1.5/site-packages/ + /usr/lib/site-python/ (version-independent modules) + +Note that no package must install files directly into /usr/lib/python1.5/ +or /usr/local/lib/python1.5/. Only the site-packages directory is allowed +for third-party extensions. + +Use of the new `package' scheme is strongly encouraged. The `ni' interface +is obsolete in python 1.5. + +Header files for extensions go into /usr/include/python1.5/. + + +Installing extensions for local use only: +---------------------------------------- + +Most extensions use Python's Makefile.pre.in. Note that Makefile.pre.in +by default will install files into /usr/lib/, not into /usr/local/lib/, +which is not allowed for local extensions. You'll have to change the +Makefile accordingly. Most times, "make prefix=/usr/local install" will +work. + + +Packaging python extensions for Debian: +-------------------------------------- + +Maintainers of Python extension packages should read README.maintainers. + + + + + 03/09/98 + Gregor Hoffleit + +Last change: 07/16/1999 --- python3.2-3.2.3.orig/debian/libPVER.symbols.i386.in +++ python3.2-3.2.3/debian/libPVER.symbols.i386.in @@ -0,0 +1,6 @@ +libpython@VER@mu.so.1.0 libpython@VER@ #MINVER# +#include "libpython.symbols" + PyModule_Create2@Base @SVER@ + _Py_force_double@Base @SVER@ + _Py_get_387controlword@Base @SVER@ + _Py_set_387controlword@Base @SVER@ --- python3.2-3.2.3.orig/debian/PVER-minimal.prerm.in +++ python3.2-3.2.3/debian/PVER-minimal.prerm.in @@ -0,0 +1,53 @@ +#! /bin/sh -e + +syssite=/usr/lib/@PVER@/site-packages +localsite=/usr/local/lib/@PVER@/dist-packages + +remove_bytecode() +{ + pkg=$1 + max=$(LANG=C LC_ALL=C xargs --show-limits < /dev/null 2>&1 | awk '/Maximum/ {print int($NF / 4)}') + dpkg -L $pkg \ + | awk -F/ 'BEGIN {OFS="/"} /\.py$/ {$NF=sprintf("__pycache__/%s.*.py[co]", substr($NF,1,length($NF)-3)); print}' \ + | xargs --max-chars="$max" echo \ + | while read files; do rm -f $files; done + find /usr/lib/python3 /usr/lib/@PVER@ -name dist-packages -prune -o -name __pycache__ -empty -print \ + | xargs -r rm -rf +} + +case "$1" in + remove) + if [ "$DEBIAN_FRONTEND" != noninteractive ]; then + echo "Unlinking and removing bytecode for runtime @PVER@" + fi + for hook in /usr/share/python3/runtime.d/*.rtremove; do + [ -x $hook ] || continue + $hook rtremove @PVER@ || continue + done + + remove_bytecode @PVER@-minimal + + if which update-binfmts >/dev/null; then + update-binfmts --package @PVER@ --remove @PVER@ /usr/bin/@PVER@ + fi + + if [ -h $syssite ]; then + rm -f $syssite + fi + [ -d $localsite ] && rmdir $localsite 2>/dev/null || true + [ -d $(dirname $localsite) ] && rmdir $(dirname $localsite) 2>/dev/null || true + ;; + upgrade) + remove_bytecode @PVER@-minimal + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python3.2-3.2.3.orig/debian/python3-config.1 +++ python3.2-3.2.3/debian/python3-config.1 @@ -0,0 +1,102 @@ +.TH PYTHON\-CONFIG 1 "November 27, 2011" +.SH NAME +python\-config \- output build options for python C/C++ extensions or embedding +.SH SYNOPSIS +.BI "python\-config" +[ +.BI "\-\-prefix" +] +[ +.BI "\-\-exec\-prefix" +] +[ +.BI "\-\-includes" +] +[ +.BI "\-\-libs" +] +[ +.BI "\-\-cflags" +] +[ +.BI "\-\-ldflags" +] +[ +.BI "\-\-extension\-suffix" +] +[ +.BI "\-\-abiflags" +] +[ +.BI "\-\-help" +] +.SH DESCRIPTION +.B python\-config +helps compiling and linking programs, which embed the Python interpreter, or +extension modules that can be loaded dynamically (at run time) into +the interpreter. +.SH OPTIONS +.TP +.BI "\-\-abiflags" +print the the ABI flags as specified by PEP 3149. +.TP +.BI "\-\-cflags" +print the C compiler flags. +.TP +.BI "\-\-ldflags" +print the flags that should be passed to the linker. +.TP +.BI "\-\-includes" +similar to \fI\-\-cflags\fP but only with \-I options (path to python header files). +.TP +.BI "\-\-libs" +similar to \fI\-\-ldflags\fP but only with \-l options (used libraries). +.TP +.BI "\-\-prefix" +prints the prefix (base directory) under which python can be found. +.TP +.BI "\-\-exec\-prefix" +print the prefix used for executable program directories (such as bin, sbin, etc). +.TP +.BI "\-\-extension\-suffix" +print the extension suffix used for binary extensions. +.TP +.BI "\-\-help" +print the usage message. +.PP + +.SH EXAMPLES +To build the singe\-file c program \fIprog\fP against the python library, use +.PP +.RS +gcc $(python\-config \-\-cflags \-\-ldflags) progr.cpp \-o progr.cpp +.RE +.PP +The same in a makefile: +.PP +.RS +CFLAGS+=$(shell python\-config \-\-cflags) +.RE +.RS +LDFLAGS+=$(shell python\-config \-\-ldflags) +.RE +.RS +all: progr +.RE + +To build a dynamically loadable python module, use +.PP +.RS +gcc $(python\-config \-\-cflags \-\-ldflags) \-shared \-fPIC progr.cpp \-o progr.so +.RE + +.SH "SEE ALSO" +python (1) +.br +http://docs.python.org/extending/extending.html +.br +/usr/share/doc/python/faq/extending.html + +.SH AUTHORS +This manual page was written by Johann Felix Soden +for the Debian project (and may be used by others). --- python3.2-3.2.3.orig/debian/README.source +++ python3.2-3.2.3/debian/README.source @@ -0,0 +1,7 @@ +The source tarball is lacking the files Lib/profile.py and Lib/pstats.py, +which Debian considers to have a license non-suitable for main (the use +of these modules limited to python). + +The package uses quilt to apply / unapply patches. +See /usr/share/doc/quilt/README.source. The series file is generated +during the build. --- python3.2-3.2.3.orig/debian/idle-PVER.menu.in +++ python3.2-3.2.3/debian/idle-PVER.menu.in @@ -0,0 +1,5 @@ +?package(idle-@PVER@):needs="X11" section="Applications/Programming"\ + title="IDLE (Python v@VER@)"\ + icon="/usr/share/pixmaps/@PVER@.xpm"\ + command="/usr/bin/idle-@PVER@ -n" \ + hints="Environments" --- python3.2-3.2.3.orig/debian/README.Debian.in +++ python3.2-3.2.3/debian/README.Debian.in @@ -0,0 +1,8 @@ +The documentation for this package is in /usr/share/doc/@PVER@/. + +A draft of the "Debian Python Policy" can be found in + + /usr/share/doc/python + +Sometime it will be moved to /usr/share/doc/debian-policy in the +debian-policy package. --- python3.2-3.2.3.orig/debian/PVER-doc.doc-base.PVER-lib.in +++ python3.2-3.2.3/debian/PVER-doc.doc-base.PVER-lib.in @@ -0,0 +1,15 @@ +Document: @PVER@-lib +Title: Python Library Reference (v@VER@) +Author: Guido van Rossum +Abstract: This library reference manual documents Python's standard library, + as well as many optional library modules (which may or may not be + available, depending on whether the underlying platform supports + them and on the configuration choices made at compile time). It + also documents the standard types of the language and its built-in + functions and exceptions, many of which are not or incompletely + documented in the Reference Manual. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/library/index.html +Files: /usr/share/doc/@PVER@/html/library/*.html --- python3.2-3.2.3.orig/debian/pdb.1.in +++ python3.2-3.2.3/debian/pdb.1.in @@ -0,0 +1,16 @@ +.TH PDB@VER@ 1 +.SH NAME +pdb@VER@ \- the Python debugger +.SH SYNOPSIS +.PP +.B pdb@VER@ +.I script [...] +.SH DESCRIPTION +.PP +See /usr/lib/python@VER@/pdb.doc for more information on the use +of pdb. When the debugger is started, help is available via the +help command. +.SH SEE ALSO +python@VER@(1). Chapter 9 of the Python Library Reference +(The Python Debugger). Available in the python@VER@-doc package at +/usr/share/doc/python@VER@/html/lib/module-pdb.html. --- python3.2-3.2.3.orig/debian/_sysconfigdata.py +++ python3.2-3.2.3/debian/_sysconfigdata.py @@ -0,0 +1,6 @@ +import sys + +if hasattr(sys, 'gettotalrefcount'): + from _sysconfigdata_d import * +else: + from _sysconfigdata_nd import * --- python3.2-3.2.3.orig/debian/FAQ.html +++ python3.2-3.2.3/debian/FAQ.html @@ -0,0 +1,8997 @@ + + +The Whole Python FAQ + + + +

The Whole Python FAQ

+Last changed on Wed Feb 12 21:31:08 2003 CET + +

(Entries marked with ** were changed within the last 24 hours; +entries marked with * were changed within the last 7 days.) +

+ +

+


+

1. General information and availability

+ + +

+


+

2. Python in the real world

+ + +

+


+

3. Building Python and Other Known Bugs

+ + +

+


+

4. Programming in Python

+ + +

+


+

5. Extending Python

+ + +

+


+

6. Python's design

+ + +

+


+

7. Using Python on non-UNIX platforms

+ + +

+


+

8. Python on Windows

+ + +
+

1. General information and availability

+ +
+

1.1. What is Python?

+Python is an interpreted, interactive, object-oriented programming +language. It incorporates modules, exceptions, dynamic typing, very +high level dynamic data types, and classes. Python combines +remarkable power with very clear syntax. It has interfaces to many +system calls and libraries, as well as to various window systems, and +is extensible in C or C++. It is also usable as an extension language +for applications that need a programmable interface. Finally, Python +is portable: it runs on many brands of UNIX, on the Mac, and on PCs +under MS-DOS, Windows, Windows NT, and OS/2. +

+To find out more, the best thing to do is to start reading the +tutorial from the documentation set (see a few questions further +down). +

+See also question 1.17 (what is Python good for). +

+ +Edit this entry / +Log info + +/ Last changed on Mon May 26 16:05:18 1997 by +GvR +

+ +


+

1.2. Why is it called Python?

+Apart from being a computer scientist, I'm also a fan of "Monty +Python's Flying Circus" (a BBC comedy series from the seventies, in +the -- unlikely -- case you didn't know). It occurred to me one day +that I needed a name that was short, unique, and slightly mysterious. +And I happened to be reading some scripts from the series at the +time... So then I decided to call my language Python. +

+By now I don't care any more whether you use a Python, some other +snake, a foot or 16-ton weight, or a wood rat as a logo for Python! +

+ +Edit this entry / +Log info + +/ Last changed on Thu Aug 24 00:50:41 2000 by +GvR +

+ +


+

1.3. How do I obtain a copy of the Python source?

+The latest Python source distribution is always available from +python.org, at http://www.python.org/download. The latest development sources can be obtained via anonymous CVS from SourceForge, at http://www.sf.net/projects/python . +

+The source distribution is a gzipped tar file containing the complete C source, LaTeX +documentation, Python library modules, example programs, and several +useful pieces of freely distributable software. This will compile and +run out of the box on most UNIX platforms. (See section 7 for +non-UNIX information.) +

+Older versions of Python are also available from python.org. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Apr 9 17:06:16 2002 by +A.M. Kuchling +

+ +


+

1.4. How do I get documentation on Python?

+All documentation is available on-line, starting at http://www.python.org/doc/. +

+The LaTeX source for the documentation is part of the source +distribution. If you don't have LaTeX, the latest Python +documentation set is available, in various formats like postscript +and html, by anonymous ftp - visit the above URL for links to the +current versions. +

+PostScript for a high-level description of Python is in the file nluug-paper.ps +(a separate file on the ftp site). +

+ +Edit this entry / +Log info + +/ Last changed on Wed Jan 21 12:02:55 1998 by +Ken Manheimer +

+ +


+

1.5. Are there other ftp sites that mirror the Python distribution?

+The following anonymous ftp sites keep mirrors of the Python +distribution: +

+USA: +

+

+        ftp://ftp.python.org/pub/python/
+        ftp://gatekeeper.dec.com/pub/plan/python/
+        ftp://ftp.uu.net/languages/python/
+        ftp://ftp.wustl.edu/graphics/graphics/sgi-stuff/python/
+        ftp://ftp.sterling.com/programming/languages/python/
+        ftp://uiarchive.cso.uiuc.edu/pub/lang/python/
+        ftp://ftp.pht.com/mirrors/python/python/
+	ftp://ftp.cdrom.com/pub/python/
+
+Europe: +

+

+        ftp://ftp.cwi.nl/pub/python/
+        ftp://ftp.funet.fi/pub/languages/python/
+        ftp://ftp.sunet.se/pub/lang/python/
+        ftp://unix.hensa.ac.uk/mirrors/uunet/languages/python/
+        ftp://ftp.lip6.fr/pub/python/
+        ftp://sunsite.cnlab-switch.ch/mirror/python/
+        ftp://ftp.informatik.tu-muenchen.de/pub/comp/programming/languages/python/
+
+Australia: +

+

+        ftp://ftp.dstc.edu.au/pub/python/
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed Mar 24 09:20:49 1999 by +A.M. Kuchling +

+ +


+

1.6. Is there a newsgroup or mailing list devoted to Python?

+There is a newsgroup, comp.lang.python, +and a mailing list. The newsgroup and mailing list are gatewayed into +each other -- if you can read news it's unnecessary to subscribe to +the mailing list. To subscribe to the mailing list +(python-list@python.org) visit its Mailman webpage at +http://www.python.org/mailman/listinfo/python-list +

+More info about the newsgroup and mailing list, and about other lists, +can be found at +http://www.python.org/psa/MailingLists.html. +

+Archives of the newsgroup are kept by Deja News and accessible +through the "Python newsgroup search" web page, +http://www.python.org/search/search_news.html. +This page also contains pointer to other archival collections. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Jun 23 09:29:36 1999 by +GvR +

+ +


+

1.7. Is there a WWW page devoted to Python?

+Yes, http://www.python.org/ is the official Python home page. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 14:42:59 1997 by +Ken Manheimer +

+ +


+

1.8. Is the Python documentation available on the WWW?

+Yes. Python 2.0 documentation is available from +http://www.pythonlabs.com/tech/python2.0/doc/ and from +http://www.python.org/doc/. Note that most documentation +is available for on-line browsing as well as for downloading. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 2 03:14:08 2001 by +Moshe Zadka +

+ +


+

1.9. Are there any books on Python?

+Yes, many, and more are being published. See +the python.org Wiki at http://www.python.org/cgi-bin/moinmoin/PythonBooks for a list. +

+You can also search online bookstores for "Python" +(and filter out the Monty Python references; or +perhaps search for "Python" and "language"). +

+ +Edit this entry / +Log info + +/ Last changed on Mon Aug 5 19:08:49 2002 by +amk +

+ +


+

1.10. Are there any published articles about Python that I can reference?

+If you can't reference the web site, and you don't want to reference the books +(see previous question), there are several articles on Python that you could +reference. +

+Most publications about Python are collected on the Python web site: +

+

+    http://www.python.org/doc/Publications.html
+
+It is no longer recommended to reference this +very old article by Python's author: +

+

+    Guido van Rossum and Jelke de Boer, "Interactively Testing Remote
+    Servers Using the Python Programming Language", CWI Quarterly, Volume
+    4, Issue 4 (December 1991), Amsterdam, pp 283-303.
+
+

+ +Edit this entry / +Log info + +/ Last changed on Sat Jul 4 20:52:31 1998 by +GvR +

+ +


+

1.11. Are there short introductory papers or talks on Python?

+There are several - you can find links to some of them collected at +http://www.python.org/doc/Hints.html#intros. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 15:04:05 1997 by +Ken Manheimer +

+ +


+

1.12. How does the Python version numbering scheme work?

+Python versions are numbered A.B.C or A.B. A is the major version +number -- it is only incremented for really major changes in the +language. B is the minor version number, incremented for less +earth-shattering changes. C is the micro-level -- it is +incremented for each bugfix release. See PEP 6 for more information +about bugfix releases. +

+Not all releases have bugfix releases. +Note that in the past (ending with 1.5.2), +micro releases have added significant changes; +in fact the changeover from 0.9.9 to 1.0.0 was the first time +that either A or B changed! +

+Alpha, beta and release candidate versions have an additional suffixes. +The suffix for an alpha version is "aN" for some small number N, the +suffix for a beta version is "bN" for some small number N, and the +suffix for a release candidate version is "cN" for some small number N. +

+Note that (for instance) all versions labeled 2.0aN precede the +versions labeled 2.0bN, which precede versions labeled 2.0cN, and +those precede 2.0. +

+As a rule, no changes are made between release candidates and the final +release unless there are show-stopper bugs. +

+You may also find version numbers with a "+" suffix, e.g. "2.2+". +These are unreleased versions, built directly from the CVS trunk. +

+See also the documentation for sys.version, sys.hexversion, and +sys.version_info. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jan 14 06:34:17 2002 by +GvR +

+ +


+

1.13. How do I get a beta test version of Python?

+All releases, including alphas, betas and release candidates, are announced on +comp.lang.python and comp.lang.python.announce newsgroups, +which are gatewayed into the python-list@python.org and +python-announce@python.org. In addition, all these announcements appear on +the Python home page, at http://www.python.org. +

+You can also access the development version of Python through CVS. See http://sourceforge.net/cvs/?group_id=5470 for details. If you're not familiar with CVS, documents like http://linux.oreillynet.com/pub/a/linux/2002/01/03/cvs_intro.html +provide an introduction. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 00:57:08 2002 by +Neal Norwitz +

+ +


+

1.14. Are there copyright restrictions on the use of Python?

+Hardly. You can do anything you want with the source, as long as +you leave the copyrights in, and display those copyrights in any +documentation about Python that you produce. Also, don't use the +author's institute's name in publicity without prior written +permission, and don't hold them responsible for anything (read the +actual copyright for a precise legal wording). +

+In particular, if you honor the copyright rules, it's OK to use Python +for commercial use, to sell copies of Python in source or binary form, +or to sell products that enhance Python or incorporate Python (or part +of it) in some form. I would still like to know about all commercial +use of Python! +

+ +Edit this entry / +Log info +

+ +


+

1.15. Why was Python created in the first place?

+Here's a very brief summary of what got me started: +

+I had extensive experience with implementing an interpreted language +in the ABC group at CWI, and from working with this group I had +learned a lot about language design. This is the origin of many +Python features, including the use of indentation for statement +grouping and the inclusion of very-high-level data types (although the +details are all different in Python). +

+I had a number of gripes about the ABC language, but also liked many +of its features. It was impossible to extend the ABC language (or its +implementation) to remedy my complaints -- in fact its lack of +extensibility was one of its biggest problems. +I had some experience with using Modula-2+ and talked with the +designers of Modula-3 (and read the M3 report). M3 is the origin of +the syntax and semantics used for exceptions, and some other Python +features. +

+I was working in the Amoeba distributed operating system group at +CWI. We needed a better way to do system administration than by +writing either C programs or Bourne shell scripts, since Amoeba had +its own system call interface which wasn't easily accessible from the +Bourne shell. My experience with error handling in Amoeba made me +acutely aware of the importance of exceptions as a programming +language feature. +

+It occurred to me that a scripting language with a syntax like ABC +but with access to the Amoeba system calls would fill the need. I +realized that it would be foolish to write an Amoeba-specific +language, so I decided that I needed a language that was generally +extensible. +

+During the 1989 Christmas holidays, I had a lot of time on my hand, +so I decided to give it a try. During the next year, while still +mostly working on it in my own time, Python was used in the Amoeba +project with increasing success, and the feedback from colleagues made +me add many early improvements. +

+In February 1991, after just over a year of development, I decided +to post to USENET. The rest is in the Misc/HISTORY file. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 00:06:23 1997 by +GvR +

+ +


+

1.16. Do I have to like "Monty Python's Flying Circus"?

+No, but it helps. Pythonistas like the occasional reference to SPAM, +and of course, nobody expects the Spanish Inquisition +

+The two main reasons to use Python are: +

+

+ - Portable
+ - Easy to learn
+
+The three main reasons to use Python are: +

+

+ - Portable
+ - Easy to learn
+ - Powerful standard library
+
+(And nice red uniforms.) +

+And remember, there is no rule six. +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 28 10:39:21 1997 by +GvR +

+ +


+

1.17. What is Python good for?

+Python is used in many situations where a great deal of dynamism, +ease of use, power, and flexibility are required. +

+In the area of basic text +manipulation core Python (without any non-core extensions) is easier +to use and is roughly as fast as just about any language, and this makes Python +good for many system administration type tasks and for CGI programming +and other application areas that manipulate text and strings and such. +

+When augmented with +standard extensions (such as PIL, COM, Numeric, oracledb, kjbuckets, +tkinter, win32api, etc.) +or special purpose extensions (that you write, perhaps using helper tools such +as SWIG, or using object protocols such as ILU/CORBA or COM) Python +becomes a very convenient "glue" or "steering" +language that helps make heterogeneous collections of unrelated +software packages work together. +For example by combining Numeric with oracledb you can help your +SQL database do statistical analysis, or even Fourier transforms. +One of the features that makes Python excel in the "glue language" role +is Python's simple, usable, and powerful C language runtime API. +

+Many developers also use Python extensively as a graphical user +interface development aide. +

+ +Edit this entry / +Log info + +/ Last changed on Sat May 24 10:13:11 1997 by +Aaron Watters +

+ +


+

1.18. Can I use the FAQ Wizard software to maintain my own FAQ?

+Sure. It's in Tools/faqwiz/ of the python source tree. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Mar 29 06:50:32 2002 by +Aahz +

+ +


+

1.19. Which editor has good support for editing Python source code?

+On Unix, the first choice is Emacs/XEmacs. There's an elaborate +mode for editing Python code, which is available from the Python +source distribution (Misc/python-mode.el). It's also bundled +with XEmacs (we're still working on legal details to make it possible +to bundle it with FSF Emacs). And it has its own web page: +

+

+    http://www.python.org/emacs/python-mode/index.html
+
+There are many other choices, for Unix, Windows or Macintosh. +Richard Jones compiled a table from postings on the Python newsgroup: +

+

+    http://www.bofh.asn.au/~richard/editors.html
+
+See also FAQ question 7.10 for some more Mac and Win options. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 15 23:21:04 1998 by +Gvr +

+ +


+

1.20. I've never programmed before. Is there a Python tutorial?

+There are several, and at least one book. +All information for beginning Python programmers is collected here: +

+

+    http://www.python.org/doc/Newbies.html
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed Sep 5 05:34:07 2001 by +GvR +

+ +


+

1.21. Where in the world is www.python.org located?

+It's currently in Amsterdam, graciously hosted by XS4ALL: +

+

+    http://www.xs4all.nl
+
+Thanks to Thomas Wouters for setting this up!!!! +

+ +Edit this entry / +Log info + +/ Last changed on Fri Aug 3 21:49:27 2001 by +GvR +

+ +


+

2. Python in the real world

+ +
+

2.1. How many people are using Python?

+Certainly thousands, and quite probably tens of thousands of users. +More are seeing the light each day. The comp.lang.python newsgroup is +very active, but overall there is no accurate estimate of the number of subscribers or Python users. +

+Jacek Artymiak has created a Python Users Counter; you can see the +current count by visiting +http://www.wszechnica.safenet.pl/cgi-bin/checkpythonuserscounter.py +(this will not increment the counter; use the link there if you haven't +added yourself already). Most Python users appear not to have registered themselves. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Feb 21 23:29:18 2002 by +GvR +

+ +


+

2.2. Have any significant projects been done in Python?

+At CWI (the former home of Python), we have written a 20,000 line +authoring environment for transportable hypermedia presentations, a +5,000 line multimedia teleconferencing tool, as well as many many +smaller programs. +

+At CNRI (Python's new home), we have written two large applications: +Grail, a fully featured web browser (see +http://grail.cnri.reston.va.us), +and the Knowbot Operating Environment, +a distributed environment for mobile code. +

+The University of Virginia uses Python to control a virtual reality +engine. See http://alice.cs.cmu.edu. +

+The ILU project at Xerox PARC can generate Python glue for ILU +interfaces. See ftp://ftp.parc.xerox.com/pub/ilu/ilu.html. ILU +is a free CORBA compliant ORB which supplies distributed object +connectivity to a host of platforms using a host of languages. +

+Mark Hammond and Greg Stein and others are interfacing Python to +Microsoft's COM and ActiveX architectures. This means, among other +things, that Python may be used in active server pages or as a COM +controller (for example to automatically extract from or insert information +into Excel or MSAccess or any other COM aware application). +Mark claims Python can even be a ActiveX scripting host (which +means you could embed JScript inside a Python application, if you +had a strange sense of humor). Python/AX/COM is distributed as part +of the PythonWin distribution. +

+The University of California, Irvine uses a student administration +system called TELE-Vision written entirely in Python. Contact: Ray +Price rlprice@uci.edu. +

+The Melbourne Cricket Ground (MCG) in Australia (a 100,000+ person venue) +has it's scoreboard system written largely in Python on MS Windows. +Python expressions are used to create almost every scoring entry that +appears on the board. The move to Python/C++ away from exclusive C++ +has provided a level of functionality that would simply not have been +viable otherwise. +

+See also the next question. +

+Note: this FAQ entry is really old. +See http://www.python.org/psa/Users.html for a more recent list. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Oct 25 13:24:15 2000 by +GvR +

+ +


+

2.3. Are there any commercial projects going on using Python?

+Yes, there's lots of commercial activity using Python. See +http://www.python.org/psa/Users.html for a list. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Oct 14 18:17:33 1998 by +ken +

+ +


+

2.4. How stable is Python?

+Very stable. New, stable releases have been coming out roughly every 3 to 12 months since 1991, and this seems likely to continue. +

+With the introduction of retrospective "bugfix" releases the stability of the language implementations can be, and is being, improved independently of the new features offered by more recent major or minor releases. Bugfix releases, indicated by a third component of the version number, only fix known problems and do not gratuitously introduce new and possibly incompatible features or modified library functionality. +

+Release 2.2 got its first bugfix on April 10, 2002. The new version +number is now 2.2.1. The 2.1 release, at 2.1.3, can probably be +considered the "most stable" platform because it has been bugfixed +twice. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jul 23 10:20:04 2002 by +Jens Kubieziel +

+ +


+

2.5. What new developments are expected for Python in the future?

+See http://www.python.org/peps/ for the Python Enhancement +Proposals (PEPs). PEPs are design +documents +describing a suggested new feature for Python, providing +a concise technical specification and a rationale. +

+Also, follow the discussions on the python-dev mailing list. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Apr 9 17:09:51 2002 by +A.M. Kuchling +

+ +


+

2.6. Is it reasonable to propose incompatible changes to Python?

+In general, no. There are already millions of lines of Python code +around the world, so any changes in the language that invalidates more +than a very small fraction of existing programs has to be frowned +upon. Even if you can provide a conversion program, there still is +the problem of updating all documentation. Providing a gradual +upgrade path is the only way if a feature has to be changed. +

+See http://www.python.org/peps/pep-0005.html for the proposed +mechanism for creating backwards-incompatibilities. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Apr 1 22:13:47 2002 by +Fred Drake +

+ +


+

2.7. What is the future of Python?

+Please see http://www.python.org/peps/ for proposals of future +activities. One of the PEPs (Python Enhancement Proposals) deals +with the PEP process and PEP format -- see +http://www.python.org/peps/pep-0001.html if you want to +submit a PEP. In http://www.python.org/peps/pep-0042.html there +is a list of wishlists the Python Development team plans to tackle. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Apr 1 22:15:46 2002 by +Fred Drake +

+ +


+

2.8. What was the PSA, anyway?

+The Python Software Activity was +created by a number of Python aficionados who want Python to be more +than the product and responsibility of a single individual. +The PSA was not an independent organization, but lived +under the umbrealla of CNRI. +

+The PSA has been superseded by the Python Software Foundation, +an independent non-profit organization. The PSF's home page +is at http://www.python.org/psf/. +

+Some pages created by the PSA still live at +http://www.python.org/psa/ +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jul 25 18:19:44 2002 by +GvR +

+ +


+

2.9. Deleted

+

+

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 2 02:51:30 2001 by +Moshe Zadka +

+ +


+

2.10. Deleted

+

+

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 2 02:52:19 2001 by +Moshe Zadka +

+ +


+

2.11. Is Python Y2K (Year 2000) Compliant?

+As of January, 2001 no major problems have been reported and Y2K +compliance seems to be a non-issue. +

+Since Python is available free of charge, there are no absolute +guarantees. If there are unforeseen problems, liability is the +user's rather than the developers', and there is nobody you can sue for damages. +

+Python does few +date manipulations, and what it does is all based on the Unix +representation for time (even on non-Unix systems) which uses seconds +since 1970 and won't overflow until 2038. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jan 8 17:19:32 2001 by +Steve Holden +

+ +


+

2.12. Is Python a good language in a class for beginning programmers?

+Yes. This long answer attempts to address any concerns you might +have with teaching Python as a programmer's first language. +(If you want to discuss Python's use in education, then +you may be interested in joining the edu-sig mailinglist. +See http://www.python.org/sigs/edu-sig/ ) +

+It is still common to start students with a procedural +(subset of a) statically typed language such as Pascal, C, or +a subset of C++ or Java. I think that students may be better +served by learning Python as their first language. Python has +a very simple and consistent syntax and a large standard library. +Most importantly, using Python in a beginning programming course +permits students to concentrate on important programming skills, +such as problem decomposition and data type design. +

+With Python, students can be quickly introduced to basic concepts +such as loops and procedures. They can even probably work with +user-defined objects in their very first course. They could +implement a tree structure as nested Python lists, for example. +They could be introduced to objects in their first course if +desired. For a student who has never programmed before, using +a statically typed language seems unnatural. It presents +additional complexity that the student must master and slows +the pace of the course. The students are trying to learn to +think like a computer, decompose problems, design consistent +interfaces, and encapsulate data. While learning to use a +statically typed language is important, it is not necessarily the +best topic to address in the students' first programming course. +

+Many other aspects of Python make it a good first language. +Python has a large standard library (like Java) so that +students can be assigned programming projects very early in the +course that do something. Assignments aren't restricted to the +standard four-function calculator and check balancing programs. +By using the standard library, students can gain the satisfaction +of working on realistic applications as they learn the fundamentals +of programming. Using the standard library also teaches students +about code reuse. +

+Python's interactive interpreter also enables students to +test language features while they're programming. They can keep +a window with the interpreter running while they enter their +programs' source in another window. If they can't remember the +methods for a list, they can do something like this: +

+

+ >>> L = []
+ >>> dir(L)
+ ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove',
+ 'reverse', 'sort']
+ >>> print L.append.__doc__
+ L.append(object) -- append object to end
+ >>> L.append(1)
+ >>> L
+ [1]
+
+With the interpreter, documentation is never far from the +student as he's programming. +

+There are also good IDEs for Python. Guido van Rossum's IDLE +is a cross-platform IDE for Python that is written in Python +using Tk. There is also a Windows specific IDE called PythonWin. +Emacs users will be happy to know that there is a very good Python +mode for Emacs. All of these programming environments provide +syntax highlighting, auto-indenting, and access to the interactive +interpreter while coding. For more information about IDEs, see XXX. +

+If your department is currently using Pascal because it was +designed to be a teaching language, then you'll be happy to +know that Guido van Rossum designed Python to be simple to +teach to everyone but powerful enough to implement real world +applications. Python makes a good language for first time +programmers because that was one of Python's design goals. +There are papers at http://www.python.org/doc/essays/ on the Python website +by Python's creator explaining his objectives for the language. +One that may interest you is titled "Computer Programming for Everybody" +http://www.python.org/doc/essays/cp4e.html +

+If you're seriously considering Python as a language for your +school, Guido van Rossum may even be willing to correspond with +you about how the language would fit in your curriculum. +See http://www.python.org/doc/FAQ.html#2.2 for examples of +Python's use in the "real world." +

+While Python, its source code, and its IDEs are freely +available, this consideration should not rule +out other languages. There are other free languages (Java, +free C compilers), and many companies are willing to waive some +or all of their fees for student programming tools if it +guarantees that a whole graduating class will know how to +use their tools. That is, if one of the requirements for +the language that will be taught is that it be freely +available, then Python qualifies, but this requirement +does not preclude other languages. +

+While Python jobs may not be as prevalent as C/C++/Java jobs, +teachers should not worry about teaching students critical job +skills in their first course. The skills that win students a +job are those they learn in their senior classes and internships. +Their first programming courses are there to lay a solid +foundation in programming fundamentals. The primary question +in choosing the language for such a course should be which +language permits the students to learn this material without +hindering or limiting them. +

+Another argument for Python is that there are many tasks for +which something like C++ is overkill. That's where languages +like Python, Perl, Tcl, and Visual Basic thrive. It's critical +for students to know something about these languages. (Every +employer for whom I've worked used at least one such language.) +Of the languages listed above, Python probably makes the best +language in a programming curriculum since its syntax is simple, +consistent, and not unlike other languages (C/C++/Java) that +are probably in the curriculum. By starting students with +Python, a department simultaneously lays the foundations for +other programming courses and introduces students to the type +of language that is often used as a "glue" language. As an +added bonus, Python can be used to interface with Microsoft's +COM components (thanks to Mark Hammond). There is also Jython, +a Java implementation of the Python interpreter, that can be +used to connect Java components. +

+If you currently start students with Pascal or C/C++ or Java, +you may be worried they will have trouble learning a statically +typed language after starting with Python. I think that this +fear most often stems from the fact that the teacher started +with a statically typed language, and we tend to like to teach +others in the same way we were taught. In reality, the +transition from Python to one of these other languages is +quite simple. +

+To motivate a statically typed language such as C++, begin the +course by explaining that unlike Python, their first language, +C++ is compiled to a machine dependent executable. Explain +that the point is to make a very fast executable. To permit +the compiler to make optimizations, programmers must help it +by specifying the "types" of variables. By restricting each +variable to a specific type, the compiler can reduce the +book-keeping it has to do to permit dynamic types. The compiler +also has to resolve references at compile time. Thus, the +language gains speed by sacrificing some of Python's dynamic +features. Then again, the C++ compiler provides type safety +and catches many bugs at compile time instead of run time (a +critical consideration for many commercial applications). C++ +is also designed for very large programs where one may want to +guarantee that others don't touch an object's implementation. +C++ provides very strong language features to separate an object's +implementation from its interface. Explain why this separation +is a good thing. +

+The first day of a C++ course could then be a whirlwind introduction +to what C++ requires and provides. The point here is that after +a semester or two of Python, students are hopefully competent +programmers. They know how to handle loops and write procedures. +They've also worked with objects, thought about the benefits of +consistent interfaces, and used the technique of subclassing to +specialize behavior. Thus, a whirlwind introduction to C++ could +show them how objects and subclassing looks in C++. The +potentially difficult concepts of object-oriented design were +taught without the additional obstacles presented by a language +such as C++ or Java. When learning one of these languages, +the students would already understand the "road map." They +understand objects; they would just be learning how objects +fit in a statically typed languages. Language requirements +and compiler errors that seem unnatural to beginning programmers +make sense in this new context. Many students will find it +helpful to be able to write a fast prototype of their algorithms +in Python. Thus, they can test and debug their ideas before +they attempt to write the code in the new language, saving the +effort of working with C++ types for when they've discovered a +working solution for their assignments. When they get annoyed +with the rigidity of types, they'll be happy to learn about +containers and templates to regain some of the lost flexibility +Python afforded them. Students may also gain an appreciation +for the fact that no language is best for every task. They'll +see that C++ is faster, but they'll know that they can gain +flexibility and development speed with a Python when execution +speed isn't critical. +

+If you have any concerns that weren't addressed here, try +posting to the Python newsgroup. Others there have done some +work with using Python as an instructional tool. Good luck. +We'd love to hear about it if you choose Python for your course. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Dec 2 19:32:35 2002 by +Bill Sconce +

+ +


+

3. Building Python and Other Known Bugs

+ +
+

3.1. Is there a test set?

+Sure. You can run it after building with "make test", or you can +run it manually with this command at the Python prompt: +

+

+ import test.autotest
+
+In Python 1.4 or earlier, use +

+

+ import autotest
+
+The test set doesn't test all features of Python, +but it goes a long way to confirm that Python is actually working. +

+NOTE: if "make test" fails, don't just mail the output to the +newsgroup -- this doesn't give enough information to debug the +problem. Instead, find out which test fails, and run that test +manually from an interactive interpreter. For example, if +"make test" reports that test_spam fails, try this interactively: +

+

+ import test.test_spam
+
+This generally produces more verbose output which can be diagnosed +to debug the problem. If you find a bug in Python or the libraries, or in the tests, please report this in the Python bug tracker at SourceForge: +

+http://sourceforge.net/tracker/?func=add&group_id=5470&atid=105470 +

+ +Edit this entry / +Log info + +/ Last changed on Fri Apr 27 10:29:36 2001 by +Fred Drake +

+ +


+

3.2. When running the test set, I get complaints about floating point operations, but when playing with floating point operations I cannot find anything wrong with them.

+The test set makes occasional unwarranted assumptions about the +semantics of C floating point operations. Until someone donates a +better floating point test set, you will have to comment out the +offending floating point tests and execute similar tests manually. +

+ +Edit this entry / +Log info +

+ +


+

3.3. Link errors after rerunning the configure script.

+It is generally necessary to run "make clean" after a configuration +change. +

+ +Edit this entry / +Log info +

+ +


+

3.4. The python interpreter complains about options passed to a script (after the script name).

+You are probably linking with GNU getopt, e.g. through -liberty. +Don't. The reason for the complaint is that GNU getopt, unlike System +V getopt and other getopt implementations, doesn't consider a +non-option to be the end of the option list. A quick (and compatible) +fix for scripts is to add "--" to the interpreter, like this: +

+

+        #! /usr/local/bin/python --
+
+You can also use this interactively: +

+

+        python -- script.py [options]
+
+Note that a working getopt implementation is provided in the Python +distribution (in Python/getopt.c) but not automatically used. +

+ +Edit this entry / +Log info +

+ +


+

3.5. When building on the SGI, make tries to run python to create glmodule.c, but python hasn't been built or installed yet.

+Comment out the line mentioning glmodule.c in Setup and build a +python without gl first; install it or make sure it is in your $PATH, +then edit the Setup file again to turn on the gl module, and make +again. You don't need to do "make clean"; you do need to run "make +Makefile" in the Modules subdirectory (or just run "make" at the +toplevel). +

+ +Edit this entry / +Log info +

+ +


+

3.6. I use VPATH but some targets are built in the source directory.

+On some systems (e.g. Sun), if the target already exists in the +source directory, it is created there instead of in the build +directory. This is usually because you have previously built without +VPATH. Try running "make clobber" in the source directory. +

+ +Edit this entry / +Log info +

+ +


+

3.7. Trouble building or linking with the GNU readline library.

+You can use the GNU readline library to improve the interactive user +interface: this gives you line editing and command history when +calling python interactively. Its sources are distributed with +Python (at least for 2.0). Uncomment the line +

+#readline readline.c -lreadline -ltermcap +

+in Modules/Setup. The configuration option --with-readline +is no longer supported, at least in Python 2.0. Some hints on +building and using the readline library: +On SGI IRIX 5, you may have to add the following +to rldefs.h: +

+

+        #ifndef sigmask
+        #define sigmask(sig) (1L << ((sig)-1))
+        #endif
+
+On some systems, you will have to add #include "rldefs.h" to the +top of several source files, and if you use the VPATH feature, you +will have to add dependencies of the form foo.o: foo.c to the +Makefile for several values of foo. +The readline library requires use of the termcap library. A +known problem with this is that it contains entry points which +cause conflicts with the STDWIN and SGI GL libraries. The STDWIN +conflict can be solved by adding a line saying '#define werase w_erase' to the +stdwin.h file (in the STDWIN distribution, subdirectory H). The +GL conflict has been solved in the Python configure script by a +hack that forces use of the static version of the termcap library. +Check the newsgroup gnu.bash.bug news:gnu.bash.bug for +specific problems with the readline library (I don't read this group +but I've been told that it is the place for readline bugs). +

+ +Edit this entry / +Log info + +/ Last changed on Sat Dec 2 18:23:48 2000 by +Issac Trotts +

+ +


+

3.8. Trouble with socket I/O on older Linux 1.x versions.

+Once you've built Python, use it to run the regen script in the +Lib/plat-linux2 directory. Apparently the files as distributed don't match the system headers on some Linux versions. +

+Note that this FAQ entry only applies to Linux kernel versions 1.x.y; +these are hardly around any more. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jul 30 20:05:52 2002 by +Jens Kubieziel +

+ +


+

3.9. Trouble with prototypes on Ultrix.

+Ultrix cc seems broken -- use gcc, or edit config.h to #undef +HAVE_PROTOTYPES. +

+ +Edit this entry / +Log info +

+ +


+

3.10. Other trouble building Python on platform X.

+Please submit the details to the SourceForge bug tracker: +

+

+  http://sourceforge.net/tracker/?group_id=5470&atid=105470
+
+and we'll look +into it. Please provide as many details as possible. In particular, +if you don't tell us what type of computer and what operating system +(and version) you are using it will be difficult for us to figure out +what is the matter. If you have compilation output logs, +please use file uploads -- don't paste everything in the message box. +

+In many cases, we won't have access to the same hardware or operating system version, so please, if you have a SourceForge account, log in before filing your report, or if you don't have an account, include an email address at which we can reach you for further questions. Logging in to SourceForge first will also cause SourceForge to send you updates as we act on your report. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Apr 27 10:53:18 2001 by +Fred Drake +

+ +


+

3.11. How to configure dynamic loading on Linux.

+This is now automatic as long as your Linux version uses the ELF +object format (all recent Linuxes do). +

+ +Edit this entry / +Log info +

+ +


+

3.12. I can't get shared modules to work on Linux 2.0 (Slackware96)?

+This is a bug in the Slackware96 release. The fix is simple: Make sure +that there is a link from /lib/libdl.so to /lib/libdl.so.1 so that the +following links are setup: /lib/libdl.so -> /lib/libdl.so.1 +/lib/libdl.so.1 -> /lib/libdl.so.1.7.14 You may have to rerun the +configure script, after rm'ing the config.cache file, before you +attempt to rebuild python after this fix. +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 21 15:45:03 1997 by +GvR +

+ +


+

3.13. Trouble when making modules shared on Linux.

+This happens when you have built Python for static linking and then +enable +
+  *shared*
+
+in the Setup file. Shared library code must be +compiled with "-fpic". If a .o file for the module already exist that +was compiled for static linking, you must remove it or do "make clean" +in the Modules directory. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 13:42:30 1997 by +GvR +

+ +


+

3.14. [deleted]

+[ancient information on threads on linux (when thread support +was not standard) used to be here] +

+ +Edit this entry / +Log info + +/ Last changed on Sun Jun 2 17:27:13 2002 by +Erno Kuusela +

+ +


+

3.15. Errors when linking with a shared library containing C++ code.

+Link the main Python binary with C++. Change the definition of +LINKCC in Modules/Makefile to be your C++ compiler. You may have to +edit config.c slightly to make it compilable with C++. +

+ +Edit this entry / +Log info +

+ +


+

3.16. Deleted

+

+

+ +Edit this entry / +Log info + +/ Last changed on Tue Sep 11 16:02:22 2001 by +GvR +

+ +


+

3.17. Deleted.

+

+

+ +Edit this entry / +Log info + +/ Last changed on Tue Sep 11 15:54:57 2001 by +GvR +

+ +


+

3.18. Compilation or link errors for the _tkinter module

+Most likely, there's a version mismatch between the Tcl/Tk header +files (tcl.h and tk.h) and the Tcl/Tk libraries you are using e.g. +"-ltk8.0" and "-ltcl8.0" arguments for _tkinter in the Setup file). +It is possible to install several versions of the Tcl/Tk libraries, +but there can only be one version of the tcl.h and tk.h header +files. If the library doesn't match the header, you'll get +problems, either when linking the module, or when importing it. +Fortunately, the version number is clearly stated in each file, +so this is easy to find. Reinstalling and using the latest +version usually fixes the problem. +

+(Also note that when compiling unpatched Python 1.5.1 against +Tcl/Tk 7.6/4.2 or older, you get an error on Tcl_Finalize. See +the 1.5.1 patch page at http://www.python.org/1.5/patches-1.5.1/.) +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jun 11 00:49:14 1998 by +Gvr +

+ +


+

3.19. I configured and built Python for Tcl/Tk but "import Tkinter" fails.

+Most likely, you forgot to enable the line in Setup that says +"TKPATH=:$(DESTLIB)/tkinter". +

+ +Edit this entry / +Log info +

+ +


+

3.20. [deleted]

+[ancient information on a gcc+tkinter bug on alpha was here] +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 16:46:23 2002 by +Erno Kuusela +

+ +


+

3.21. Several common system calls are missing from the posix module.

+Most likely, all test compilations run by the configure script +are failing for some reason or another. Have a look in config.log to +see what could be the reason. A common reason is specifying a +directory to the --with-readline option that doesn't contain the +libreadline.a file. +

+ +Edit this entry / +Log info +

+ +


+

3.22. ImportError: No module named string, on MS Windows.

+Most likely, your PYTHONPATH environment variable should be set to +something like: +

+set PYTHONPATH=c:\python;c:\python\lib;c:\python\scripts +

+(assuming Python was installed in c:\python) +

+ +Edit this entry / +Log info +

+ +


+

3.23. Core dump on SGI when using the gl module.

+There are conflicts between entry points in the termcap and curses +libraries and an entry point in the GL library. There's a hack of a +fix for the termcap library if it's needed for the GNU readline +library, but it doesn't work when you're using curses. Concluding, +you can't build a Python binary containing both the curses and gl +modules. +

+ +Edit this entry / +Log info +

+ +


+

3.24. "Initializer not a constant" while building DLL on MS-Windows

+Static type object initializers in extension modules may cause compiles to +fail with an error message like "initializer not a constant". +Fredrik Lundh <Fredrik.Lundh@image.combitech.se> explains: +

+This shows up when building DLL under MSVC. There's two ways to +address this: either compile the module as C++, or change your code to +something like: +

+

+  statichere PyTypeObject bstreamtype = {
+      PyObject_HEAD_INIT(NULL) /* must be set by init function */
+      0,
+      "bstream",
+      sizeof(bstreamobject),
+
+
+  ...
+
+
+  void
+  initbstream()
+  {
+      /* Patch object type */
+      bstreamtype.ob_type = &PyType_Type;
+      Py_InitModule("bstream", functions);
+      ...
+  }
+
+

+ +Edit this entry / +Log info + +/ Last changed on Sun May 25 14:58:05 1997 by +Aaron Watters +

+ +


+

3.25. Output directed to a pipe or file disappears on Linux.

+Some people have reported that when they run their script +interactively, it runs great, but that when they redirect it +to a pipe or file, no output appears. +

+

+    % python script.py
+    ...some output...
+    % python script.py >file
+    % cat file
+    % # no output
+    % python script.py | cat
+    % # no output
+    %
+
+This was a bug in Linux kernel. It is fixed and should not appear anymore. So most Linux users are not affected by this. +

+If redirection doesn't work on your Linux system, check what shell you are using. Shells like (t)csh doesn't support redirection. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jan 16 13:38:30 2003 by +Jens Kubieziel +

+ +


+

3.26. [deleted]

+[ancient libc/linux problem was here] +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 16:48:08 2002 by +Erno Kuusela +

+ +


+

3.27. [deleted]

+[ancient linux + threads + tk problem was described here] +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 16:49:08 2002 by +Erno Kuusela +

+ +


+

3.28. How can I test if Tkinter is working?

+Try the following: +

+

+  python
+  >>> import _tkinter
+  >>> import Tkinter
+  >>> Tkinter._test()
+
+This should pop up a window with two buttons, +one "Click me" and one "Quit". +

+If the first statement (import _tkinter) fails, your Python +installation probably has not been configured to support Tcl/Tk. +On Unix, if you have installed Tcl/Tk, you have to rebuild Python +after editing the Modules/Setup file to enable the _tkinter module +and the TKPATH environment variable. +

+It is also possible to get complaints about Tcl/Tk version +number mismatches or missing TCL_LIBRARY or TK_LIBRARY +environment variables. These have to do with Tcl/Tk installation +problems. +

+A common problem is to have installed versions of tcl.h and tk.h +that don't match the installed version of the Tcl/Tk libraries; +this usually results in linker errors or (when using dynamic +loading) complaints about missing symbols during loading +the shared library. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Aug 28 17:01:46 1997 by +Guido van Rossum +

+ +


+

3.29. Is there a way to get the interactive mode of the python interpreter to perform function/variable name completion?

+(From a posting by Guido van Rossum) +

+On Unix, if you have enabled the readline module (i.e. if Emacs-style +command line editing and bash-style history works for you), you can +add this by importing the undocumented standard library module +"rlcompleter". When completing a simple identifier, it +completes keywords, built-ins and globals in __main__; when completing +NAME.NAME..., it evaluates (!) the expression up to the last dot and +completes its attributes. +

+This way, you can do "import string", type "string.", hit the +completion key twice, and see the list of names defined by the +string module. +

+Tip: to use the tab key as the completion key, call +

+

+    readline.parse_and_bind("tab: complete")
+
+You can put this in a ~/.pythonrc file, and set the PYTHONSTARTUP +environment variable to ~/.pythonrc. This will cause the completion to be enabled +whenever you run Python interactively. +

+Notes (see the docstring for rlcompleter.py for more information): +

+* The evaluation of the NAME.NAME... form may cause arbitrary +application defined code to be executed if an object with a +__getattr__ hook is found. Since it is the responsibility of the +application (or the user) to enable this feature, I consider this an +acceptable risk. More complicated expressions (e.g. function calls or +indexing operations) are not evaluated. +

+* GNU readline is also used by the built-in functions input() and +raw_input(), and thus these also benefit/suffer from the complete +features. Clearly an interactive application can benefit by +specifying its own completer function and using raw_input() for all +its input. +

+* When stdin is not a tty device, GNU readline is never +used, and this module (and the readline module) are silently inactive. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jun 12 09:55:24 1998 by +A.M. Kuchling +

+ +


+

3.30. Why is the Python interpreter not built as a shared library?

+(This is a Unix question; on Mac and Windows, it is a shared +library.) +

+It's just a nightmare to get this to work on all different platforms. +Shared library portability is a pain. And yes, I know about GNU libtool +-- but it requires me to use its conventions for filenames etc, and it +would require a complete and utter rewrite of all the makefile and +config tools I'm currently using. +

+In practice, few applications embed Python -- it's much more common to +have Python extensions, which already are shared libraries. Also, +serious embedders often want total control over which Python version +and configuration they use so they wouldn't want to use a standard +shared library anyway. So while the motivation of saving space +when lots of apps embed Python is nice in theory, I +doubt that it will save much in practice. (Hence the low priority I +give to making a shared library.) +

+For Linux systems, the simplest method of producing libpython1.5.so seems to +be (originally from the Minotaur project web page, +http://www.equi4.com/minotaur/minotaur.html): +

+

+  make distclean 
+  ./configure 
+  make OPT="-fpic -O2" 
+  mkdir .extract 
+  (cd .extract; ar xv ../libpython1.5.a) 
+  gcc -shared -o libpython1.5.so .extract/*.o 
+  rm -rf .extract
+
+In Python 2.3 this will be supported by the standard build routine +(at least on Linux) with --enable-shared. Note however that there +is little advantage, and it slows down Python because of the need +for PIC code and the extra cost at startup time to find the library. +

+ +Edit this entry / +Log info + +/ Last changed on Thu May 30 13:36:55 2002 by +GvR +

+ +


+

3.31. Build with GCC on Solaris 2.6 (SunOS 5.6) fails

+If you have upgraded Solaris 2.5 or 2.5.1 to Solaris 2.6, +but you have not upgraded +your GCC installation, the compile may fail, e.g. like this: +

+

+ In file included from /usr/include/sys/stream.h:26,
+                  from /usr/include/netinet/in.h:38,
+                  from /usr/include/netdb.h:96,
+                  from ./socketmodule.c:121:
+ /usr/include/sys/model.h:32: #error "No DATAMODEL_NATIVE specified"
+
+Solution: rebuild GCC for Solaris 2.6. +You might be able to simply re-run fixincludes, but +people have had mixed success with doing that. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Oct 21 11:18:46 1998 by +GvR +

+ +


+

3.32. Running "make clean" seems to leave problematic files that cause subsequent builds to fail.

+Use "make clobber" instead. +

+Use "make clean" to reduce the size of the source/build directory +after you're happy with your build and installation. +If you have already tried to build python and you'd like to start +over, you should use "make clobber". It does a "make clean" and also +removes files such as the partially built Python library from a previous build. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jun 24 20:39:26 1999 by +TAB +

+ +


+

3.33. Submitting bug reports and patches

+To report a bug or submit a patch, please use the relevant service +from the Python project at SourceForge. +

+Bugs: http://sourceforge.net/tracker/?group_id=5470&atid=105470 +

+Patches: http://sourceforge.net/tracker/?group_id=5470&atid=305470 +

+If you have a SourceForge account, please log in before submitting your bug report; this will make it easier for us to contact you regarding your report in the event we have follow-up questions. It will also enable SourceForge to send you update information as we act on your bug. If you do not have a SourceForge account, please consider leaving your name and email address as part of the report. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Apr 27 10:58:26 2001 by +Fred Drake +

+ +


+

3.34. I can't load shared libraries under Python 1.5.2, Solaris 7, and gcc 2.95.2

+When trying to load shared libraries, you may see errors like: +ImportError: ld.so.1: python: fatal: relocation error: file /usr/local/lib/python1.5/site-packages/Perp/util/du_SweepUtilc.so: +
+ symbol PyExc_RuntimeError: referenced symbol not found
+
+

+There is a problem with the configure script for Python 1.5.2 +under Solaris 7 with gcc 2.95 . configure should set the make variable +LINKFORSHARED=-Xlinker -export-dynamic +

+

+in Modules/Makefile, +

+Manually add this line to the Modules/Makefile. +This builds a Python executable that can load shared library extensions (xxx.so) . +

+ +Edit this entry / +Log info + +/ Last changed on Mon Feb 19 10:37:05 2001 by +GvR +

+ +


+

3.35. In the regression test, test___all__ fails for the profile module. What's wrong?

+If you have been using the profile module, and have properly calibrated a copy of the module as described in the documentation for the profiler: +

+http://www.python.org/doc/current/lib/profile-calibration.html +

+then it is possible that the regression test "test___all__" will fail if you run the regression test manually rather than using "make test" in the Python source directory. This will happen if you have set your PYTHONPATH environment variable to include the directory containing your calibrated profile module. You have probably calibrated the profiler using an older version of the profile module which does not define the __all__ value, added to the module as of Python 2.1. +

+The problem can be fixed by removing the old calibrated version of the profile module and using the latest version to do a fresh calibration. In general, you will need to re-calibrate for each version of Python anyway, since the performance characteristics can change in subtle ways that impact profiling. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Apr 27 10:44:10 2001 by +Fred Drake +

+ +


+

3.36. relocations remain against allocatable but non-writable sections

+This linker error occurs on Solaris if you attempt to build an extension module which incorporates position-dependent (non-PIC) code. A common source of problems is that a static library (.a file), such as libreadline.a or libcrypto.a is linked with the extension module. The error specifically occurs when using gcc as the compiler, but /usr/ccs/bin/ld as the linker. +

+The following solutions and work-arounds are known: +

+1. Rebuild the libraries (libreadline, libcrypto) with -fPIC (-KPIC if using the system compiler). This is recommended; all object files in a shared library should be position-independent. +

+2. Statically link the extension module and its libraries into the Python interpreter, by editing Modules/Setup. +

+3. Use GNU ld instead of /usr/ccs/bin/ld; GNU ld will accept non-PIC code in shared libraries (and mark the section writable) +

+4. Pass -mimpure-text to GCC when linking the module. This will force gcc to not pass -z text to ld; in turn, ld will make all text sections writable. +

+Options 3 and 4 are not recommended, since the ability to share code across processes is lost. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 29 12:05:11 2002 by +Martin v. Löwis +

+ +


+

4. Programming in Python

+ +
+

4.1. Is there a source code level debugger with breakpoints, step, etc.?

+Yes. +

+Module pdb is a rudimentary but adequate console-mode debugger for Python. It is part of the standard Python library, and is documented in the Library Reference Manual. (You can also write your own debugger by using the code for pdb as an example.) +

+The IDLE interactive development environment, which is part of the standard Python distribution (normally available in Tools/idle), includes a graphical debugger. There is documentation for the IDLE debugger at http://www.python.org/idle/doc/idle2.html#Debugger +

+Pythonwin is a Python IDE that includes a GUI debugger based on bdb. The Pythonwin debugger colors breakpoints and has quite a few cool features (including debugging non-Pythonwin programs). A reference can be found at http://www.python.org/ftp/python/pythonwin/pwindex.html +More recent versions of PythonWin are available as a part of the ActivePython distribution (see http://www.activestate.com/Products/ActivePython/index.html). +

+Pydb is a version of the standard Python debugger pdb, modified for use with DDD (Data Display Debugger), a popular graphical debugger front end. Pydb can be found at http://packages.debian.org/unstable/devel/pydb.html +and DDD can be found at http://www.gnu.org/software/ddd/ +

+There are a number of commmercial Python IDEs that include graphical debuggers. They include: +

+

+ * Wing IDE (http://wingide.com/) 
+ * Komodo IDE (http://www.activestate.com/Products/Komodo/)
+
+

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 28 01:43:41 2003 by +Stephen Ferg +

+ +


+

4.2. Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? (Also phrased as: Can I use a built-in type as base class?)

+In Python 2.2, you can inherit from builtin classes such as int, list, dict, etc. +

+In previous versions of Python, you can easily create a Python class which serves as a wrapper around a built-in object, e.g. (for dictionaries): +

+

+        # A user-defined class behaving almost identical
+        # to a built-in dictionary.
+        class UserDict:
+                def __init__(self): self.data = {}
+                def __repr__(self): return repr(self.data)
+                def __cmp__(self, dict):
+                        if type(dict) == type(self.data):
+                                return cmp(self.data, dict)
+                        else:
+                                return cmp(self.data, dict.data)
+                def __len__(self): return len(self.data)
+                def __getitem__(self, key): return self.data[key]
+                def __setitem__(self, key, item): self.data[key] = item
+                def __delitem__(self, key): del self.data[key]
+                def keys(self): return self.data.keys()
+                def items(self): return self.data.items()
+                def values(self): return self.data.values()
+                def has_key(self, key): return self.data.has_key(key)
+
+A2. See Jim Fulton's ExtensionClass for an example of a mechanism +which allows you to have superclasses which you can inherit from in +Python -- that way you can have some methods from a C superclass (call +it a mixin) and some methods from either a Python superclass or your +subclass. ExtensionClass is distributed as a part of Zope (see +http://www.zope.org), but will be phased out with Zope 3, since +Zope 3 uses Python 2.2 or later which supports direct inheritance +from built-in types. Here's a link to the original paper about +ExtensionClass: +http://debian.acm.ndsu.nodak.edu/doc/python-extclass/ExtensionClass.html +

+A3. The Boost Python Library (BPL, http://www.boost.org/libs/python/doc/index.html) +provides a way of doing this from C++ (i.e. you can inherit from an +extension class written in C++ using the BPL). +

+ +Edit this entry / +Log info + +/ Last changed on Tue May 28 21:09:52 2002 by +GvR +

+ +


+

4.3. Is there a curses/termcap package for Python?

+The standard Python source distribution comes with a curses module in +the Modules/ subdirectory, though it's not compiled by default (note +that this is not available in the Windows distribution -- there is +no curses module for Windows). +

+In Python versions before 2.0 the module only supported plain curses; +you couldn't use ncurses features like colors with it (though it would +link with ncurses). +

+In Python 2.0, the curses module has been greatly extended, starting +from Oliver Andrich's enhanced version, to provide many additional +functions from ncurses and SYSV curses, such as colour, alternative +character set support, pads, and mouse support. This means the +module is no longer compatible with operating systems that only +have BSD curses, but there don't seem to be any currently +maintained OSes that fall into this category. +

+ +Edit this entry / +Log info + +/ Last changed on Sun Jun 23 20:24:06 2002 by +Tim Peters +

+ +


+

4.4. Is there an equivalent to C's onexit() in Python?

+For Python 2.0: The new atexit module provides a register function that +is similar to C's onexit. See the Library Reference for details. For +2.0 you should not assign to sys.exitfunc! +

+For Python 1.5.2: You need to import sys and assign a function to +sys.exitfunc, it will be called when your program exits, is +killed by an unhandled exception, or (on UNIX) receives a +SIGHUP or SIGTERM signal. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Dec 28 12:14:55 2000 by +Bjorn Pettersen +

+ +


+

4.5. [deleted]

+[python used to lack nested scopes, it was explained here] +

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 21 05:18:22 2002 by +Erno Kuusela +

+ +


+

4.6. How do I iterate over a sequence in reverse order?

+If it is a list, the fastest solution is +

+

+        list.reverse()
+        try:
+                for x in list:
+                        "do something with x"
+        finally:
+                list.reverse()
+
+This has the disadvantage that while you are in the loop, the list +is temporarily reversed. If you don't like this, you can make a copy. +This appears expensive but is actually faster than other solutions: +

+

+        rev = list[:]
+        rev.reverse()
+        for x in rev:
+                <do something with x>
+
+If it's not a list, a more general but slower solution is: +

+

+        for i in range(len(sequence)-1, -1, -1):
+                x = sequence[i]
+                <do something with x>
+
+A more elegant solution, is to define a class which acts as a sequence +and yields the elements in reverse order (solution due to Steve +Majewski): +

+

+        class Rev:
+                def __init__(self, seq):
+                        self.forw = seq
+                def __len__(self):
+                        return len(self.forw)
+                def __getitem__(self, i):
+                        return self.forw[-(i + 1)]
+
+You can now simply write: +

+

+        for x in Rev(list):
+                <do something with x>
+
+Unfortunately, this solution is slowest of all, due to the method +call overhead... +

+ +Edit this entry / +Log info + +/ Last changed on Sun May 25 21:10:50 1997 by +GvR +

+ +


+

4.7. My program is too slow. How do I speed it up?

+That's a tough one, in general. There are many tricks to speed up +Python code; I would consider rewriting parts in C only as a last +resort. One thing to notice is that function and (especially) method +calls are rather expensive; if you have designed a purely OO interface +with lots of tiny functions that don't do much more than get or set an +instance variable or call another method, you may consider using a +more direct way, e.g. directly accessing instance variables. Also see +the standard module "profile" (described in the Library Reference +manual) which makes it possible to find out where +your program is spending most of its time (if you have some patience +-- the profiling itself can slow your program down by an order of +magnitude). +

+Remember that many standard optimization heuristics you +may know from other programming experience may well apply +to Python. For example it may be faster to send output to output +devices using larger writes rather than smaller ones in order to +avoid the overhead of kernel system calls. Thus CGI scripts +that write all output in "one shot" may be notably faster than +those that write lots of small pieces of output. +

+Also, be sure to use "aggregate" operations where appropriate. +For example the "slicing" feature allows programs to chop up +lists and other sequence objects in a single tick of the interpreter +mainloop using highly optimized C implementations. Thus to +get the same effect as +

+

+  L2 = []
+  for i in range[3]:
+       L2.append(L1[i])
+
+it is much shorter and far faster to use +

+

+  L2 = list(L1[:3]) # "list" is redundant if L1 is a list.
+
+Note that the map() function, particularly used with +builtin methods or builtin functions can be a convenient +accelerator. For example to pair the elements of two +lists together: +

+

+  >>> map(None, [1,2,3], [4,5,6])
+  [(1, 4), (2, 5), (3, 6)]
+
+or to compute a number of sines: +

+

+  >>> map( math.sin, (1,2,3,4))
+  [0.841470984808, 0.909297426826, 0.14112000806,   -0.756802495308]
+
+The map operation completes very quickly in such cases. +

+Other examples of aggregate operations include the join and split +methods of string objects. For example if s1..s7 are large (10K+) strings then +"".join([s1,s2,s3,s4,s5,s6,s7]) may be far faster than +the more obvious s1+s2+s3+s4+s5+s6+s7, since the "summation" +will compute many subexpressions, whereas join does all +copying in one pass. For manipulating strings also consider the +regular expression libraries and the "substitution" operations +String % tuple and String % dictionary. Also be sure to use +the list.sort builtin method to do sorting, and see FAQ's 4.51 +and 4.59 for examples of moderately advanced usage -- list.sort beats +other techniques for sorting in all but the most extreme +circumstances. +

+There are many other aggregate operations +available in the standard libraries and in contributed libraries +and extensions. +

+Another common trick is to "push loops into functions or methods." +For example suppose you have a program that runs slowly and you +use the profiler (profile.run) to determine that a Python function ff +is being called lots of times. If you notice that ff +

+

+   def ff(x):
+       ...do something with x computing result...
+       return result
+
+tends to be called in loops like (A) +

+

+   list = map(ff, oldlist)
+
+or (B) +

+

+   for x in sequence:
+       value = ff(x)
+       ...do something with value...
+
+then you can often eliminate function call overhead by rewriting +ff to +

+

+   def ffseq(seq):
+       resultseq = []
+       for x in seq:
+           ...do something with x computing result...
+           resultseq.append(result)
+       return resultseq
+
+and rewrite (A) to +

+

+    list = ffseq(oldlist)
+
+and (B) to +

+

+    for value in ffseq(sequence):
+        ...do something with value...
+
+Other single calls ff(x) translate to ffseq([x])[0] with little +penalty. Of course this technique is not always appropriate +and there are other variants, which you can figure out. +

+You can gain some performance by explicitly storing the results of +a function or method lookup into a local variable. A loop like +

+

+    for key in token:
+        dict[key] = dict.get(key, 0) + 1
+
+resolves dict.get every iteration. If the method isn't going to +change, a faster implementation is +

+

+    dict_get = dict.get  # look up the method once
+    for key in token:
+        dict[key] = dict_get(key, 0) + 1
+
+Default arguments can be used to determine values once, at +compile time instead of at run time. This can only be done for +functions or objects which will not be changed during program +execution, such as replacing +

+

+    def degree_sin(deg):
+        return math.sin(deg * math.pi / 180.0)
+
+with +

+

+    def degree_sin(deg, factor = math.pi/180.0, sin = math.sin):
+        return sin(deg * factor)
+
+Because this trick uses default arguments for terms which should +not be changed, it should only be used when you are not concerned +with presenting a possibly confusing API to your users. +

+

+For an anecdote related to optimization, see +

+

+	http://www.python.org/doc/essays/list2str.html
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 01:03:54 2002 by +Neal Norwitz +

+ +


+

4.8. When I have imported a module, then edit it, and import it again (into the same Python process), the changes don't seem to take place. What is going on?

+For reasons of efficiency as well as consistency, Python only reads +the module file on the first time a module is imported. (Otherwise a +program consisting of many modules, each of which imports the same +basic module, would read the basic module over and over again.) To +force rereading of a changed module, do this: +

+

+        import modname
+        reload(modname)
+
+Warning: this technique is not 100% fool-proof. In particular, +modules containing statements like +

+

+        from modname import some_objects
+
+will continue to work with the old version of the imported objects. +

+ +Edit this entry / +Log info +

+ +


+

4.9. How do I find the current module name?

+A module can find out its own module name by looking at the +(predefined) global variable __name__. If this has the value +'__main__' you are running as a script. +

+ +Edit this entry / +Log info +

+ +


+

4.10. I have a module in which I want to execute some extra code when it is run as a script. How do I find out whether I am running as a script?

+See the previous question. E.g. if you put the following on the +last line of your module, main() is called only when your module is +running as a script: +

+

+        if __name__ == '__main__': main()
+
+

+ +Edit this entry / +Log info +

+ +


+

4.11. I try to run a program from the Demo directory but it fails with ImportError: No module named ...; what gives?

+This is probably an optional module (written in C!) which hasn't +been configured on your system. This especially happens with modules +like "Tkinter", "stdwin", "gl", "Xt" or "Xm". For Tkinter, STDWIN and +many other modules, see Modules/Setup.in for info on how to add these +modules to your Python, if it is possible at all. Sometimes you will +have to ftp and build another package first (e.g. Tcl and Tk for Tkinter). +Sometimes the module only works on specific platforms (e.g. gl only works +on SGI machines). +

+NOTE: if the complaint is about "Tkinter" (upper case T) and you have +already configured module "tkinter" (lower case t), the solution is +not to rename tkinter to Tkinter or vice versa. There is probably +something wrong with your module search path. Check out the value of +sys.path. +

+For X-related modules (Xt and Xm) you will have to do more work: they +are currently not part of the standard Python distribution. You will +have to ftp the Extensions tar file, i.e. +ftp://ftp.python.org/pub/python/src/X-extension.tar.gz and follow +the instructions there. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Feb 12 21:31:08 2003 by +Jens Kubieziel +

+ +


+

4.12. [deleted]

+[stdwin (long dead windowing library) entry deleted] +

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 21 08:30:13 2002 by +Erno Kuusela +

+ +


+

4.13. What GUI toolkits exist for Python?

+Depending on what platform(s) you are aiming at, there are several. +

+Currently supported solutions: +

+Cross-platform: +

+Tk: +

+There's a neat object-oriented interface to the Tcl/Tk widget set, +called Tkinter. It is part of the standard Python distribution and +well-supported -- all you need to do is build and install Tcl/Tk and +enable the _tkinter module and the TKPATH definition in Modules/Setup +when building Python. This is probably the easiest to install and +use, and the most complete widget set. It is also very likely that in +the future the standard Python GUI API will be based on or at least +look very much like the Tkinter interface. For more info about Tk, +including pointers to the source, see the Tcl/Tk home page at +http://www.scriptics.com. Tcl/Tk is now fully +portable to the Mac and Windows platforms (NT and 95 only); you need +Python 1.4beta3 or later and Tk 4.1patch1 or later. +

+wxWindows: +

+There's an interface to wxWindows called wxPython. wxWindows is a +portable GUI class library written in C++. It supports GTK, Motif, +MS-Windows and Mac as targets. Ports to other platforms are being +contemplated or have already had some work done on them. wxWindows +preserves the look and feel of the underlying graphics toolkit, and +there is quite a rich widget set and collection of GDI classes. +See the wxWindows page at http://www.wxwindows.org/ for more details. +wxPython is a python extension module that wraps many of the wxWindows +C++ classes, and is quickly gaining popularity amongst Python +developers. You can get wxPython as part of the source or CVS +distribution of wxWindows, or directly from its home page at +http://alldunn.com/wxPython/. +

+Gtk+: +

+PyGtk bindings for the Gtk+ Toolkit by James Henstridge exist; see ftp://ftp.daa.com.au/pub/james/python/. Note that there are two incompatible bindings. If you are using Gtk+ 1.2.x you should get the 0.6.x PyGtk bindings from +

+

+    ftp://ftp.gtk.org/pub/python/v1.2
+
+If you plan to use Gtk+ 2.0 with Python (highly recommended if you are just starting with Gtk), get the most recent distribution from +

+

+    ftp://ftp.gtk.org/pub/python/v2.0
+
+If you are adventurous, you can also check out the source from the Gnome CVS repository. Set your CVS directory to :pserver:anonymous@anoncvs.gnome.org:/cvs/gnome and check the gnome-python module out from the repository. +

+Other: +

+There are also bindings available for the Qt toolkit (PyQt), and for KDE (PyKDE); see http://www.thekompany.com/projects/pykde/. +

+For OpenGL bindings, see http://starship.python.net/~da/PyOpenGL. +

+Platform specific: +

+The Mac port has a rich and ever-growing set of modules that support +the native Mac toolbox calls. See the documentation that comes with +the Mac port. See ftp://ftp.python.org/pub/python/mac. Support +by Jack Jansen jack@cwi.nl. +

+Pythonwin by Mark Hammond (MHammond@skippinet.com.au) +includes an interface to the Microsoft Foundation +Classes and a Python programming environment using it that's written +mostly in Python. See http://www.python.org/windows/. +

+There's an object-oriented GUI based on the Microsoft Foundation +Classes model called WPY, supported by Jim Ahlstrom jim@interet.com. +Programs written in WPY run unchanged and with native look and feel on +Windows NT/95, Windows 3.1 (using win32s), and on Unix (using Tk). +Source and binaries for Windows and Linux are available in +ftp://ftp.python.org/pub/python/wpy/. +

+Obsolete or minority solutions: +

+There's an interface to X11, including the Athena and Motif widget +sets (and a few individual widgets, like Mosaic's HTML widget and +SGI's GL widget) available from +ftp://ftp.python.org/pub/python/src/X-extension.tar.gz. +Support by Sjoerd Mullender sjoerd@cwi.nl. +

+On top of the X11 interface there's the vpApp +toolkit by Per Spilling, now also maintained by Sjoerd Mullender +sjoerd@cwi.nl. See ftp://ftp.cwi.nl/pub/sjoerd/vpApp.tar.gz. +

+For SGI IRIX only, there are unsupported interfaces to the complete +GL (Graphics Library -- low level but very good 3D capabilities) as +well as to FORMS (a buttons-and-sliders-etc package built on top of GL +by Mark Overmars -- ftp'able from +ftp://ftp.cs.ruu.nl/pub/SGI/FORMS/). This is probably also +becoming obsolete, as OpenGL takes over (see above). +

+There's an interface to STDWIN, a platform-independent low-level +windowing interface for Mac and X11. This is totally unsupported and +rapidly becoming obsolete. The STDWIN sources are at +ftp://ftp.cwi.nl/pub/stdwin/. +

+There is an interface to WAFE, a Tcl interface to the X11 +Motif and Athena widget sets. WAFE is at +http://www.wu-wien.ac.at/wafe/wafe.html. +

+ +Edit this entry / +Log info + +/ Last changed on Mon May 13 21:40:39 2002 by +Skip Montanaro +

+ +


+

4.14. Are there any interfaces to database packages in Python?

+Yes! See the Database Topic Guide at +http://www.python.org/topics/database/ for details. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 4 20:12:19 2000 by +Barney Warplug +

+ +


+

4.15. Is it possible to write obfuscated one-liners in Python?

+Yes. See the following three examples, due to Ulf Bartelt: +

+

+        # Primes < 1000
+        print filter(None,map(lambda y:y*reduce(lambda x,y:x*y!=0,
+        map(lambda x,y=y:y%x,range(2,int(pow(y,0.5)+1))),1),range(2,1000)))
+
+
+        # First 10 Fibonacci numbers
+        print map(lambda x,f=lambda x,f:(x<=1) or (f(x-1,f)+f(x-2,f)): f(x,f),
+        range(10))
+
+
+        # Mandelbrot set
+        print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y,
+        Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM,
+        Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro,
+        i=i,Sx=Sx,F=lambda xc,yc,x,y,k,f=lambda xc,yc,x,y,k,f:(k<=0)or (x*x+y*y
+        >=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr(
+        64+F(Ru+x*(Ro-Ru)/Sx,yc,0,0,i)),range(Sx))):L(Iu+y*(Io-Iu)/Sy),range(Sy
+        ))))(-2.1, 0.7, -1.2, 1.2, 30, 80, 24)
+        #    \___ ___/  \___ ___/  |   |   |__ lines on screen
+        #        V          V      |   |______ columns on screen
+        #        |          |      |__________ maximum of "iterations"
+        #        |          |_________________ range on y axis
+        #        |____________________________ range on x axis
+
+Don't try this at home, kids! +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 21 15:48:33 1997 by +GvR +

+ +


+

4.16. Is there an equivalent of C's "?:" ternary operator?

+Not directly. 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'. +

+As a last resort it is possible to implement the "?:" operator as a function: +

+

+    def q(cond,on_true,on_false):
+        from inspect import isfunction
+
+
+        if cond:
+            if not isfunction(on_true): return on_true
+            else: return apply(on_true)
+        else:
+            if not isfunction(on_false): return on_false 
+            else: return apply(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, +since most language have one; it is a frequently requested feature. +

+There are several possible answers: just as 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. +

+Nevertheless, in an effort to decide once and for all whether +an if-then-else expression should be added to the language, +PEP 308 (http://www.python.org/peps/pep-0308.html) has been +put forward, proposing a specific syntax. The community can +now vote on this issue. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Feb 7 19:41:13 2003 by +David Goodger +

+ +


+

4.17. My class defines __del__ but it is not called when I delete the object.

+There are several possible reasons for this. +

+The del statement does not necessarily call __del__ -- it simply +decrements the object's reference count, and if this reaches zero +__del__ is called. +

+If your data structures contain circular links (e.g. a tree where +each child has a parent pointer and each parent has a list of +children) the reference counts will never go back to zero. You'll +have to define an explicit close() method which removes those +pointers. Please don't ever call __del__ directly -- __del__ should +call close() and close() should make sure that it can be called more +than once for the same object. +

+If the object has ever been a local variable (or argument, which is +really the same thing) to a function that caught an expression in an +except clause, chances are that a reference to the object still exists +in that function's stack frame as contained in the stack trace. +Normally, deleting (better: assigning None to) sys.exc_traceback will +take care of this. If a stack was printed for an unhandled +exception in an interactive interpreter, delete sys.last_traceback +instead. +

+There is code that deletes all objects when the interpreter exits, +but it is not called if your Python has been configured to support +threads (because other threads may still be active). You can define +your own cleanup function using sys.exitfunc (see question 4.4). +

+Finally, if your __del__ method raises an exception, a warning message is printed to sys.stderr. +

+

+Starting with Python 2.0, a garbage collector periodically reclaims the space used by most cycles with no external references. (See the "gc" module documentation for details.) There are, however, pathological cases where it can be expected to fail. Moreover, the garbage collector runs some time after the last reference to your data structure vanishes, so your __del__ method may be called at an inconvenient and random time. This is inconvenient if you're trying to reproduce a problem. Worse, the order in which object's __del__ methods are executed is arbitrary. +

+Another way to avoid cyclical references is to use the "weakref" module, which allows you to point to objects without incrementing their reference count. Tree data structures, for instance, should use weak references for their parent and sibling pointers (if they need them!). +

+Question 6.14 is intended to explain the new garbage collection algorithm. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 10 15:27:28 2002 by +Matthias Urlichs +

+ +


+

4.18. How do I change the shell environment for programs called using os.popen() or os.system()? Changing os.environ doesn't work.

+You must be using either a version of python before 1.4, or on a +(rare) system that doesn't have the putenv() library function. +

+Before Python 1.4, modifying the environment passed to subshells was +left out of the interpreter because there seemed to be no +well-established portable way to do it (in particular, some systems, +have putenv(), others have setenv(), and some have none at all). As +of Python 1.4, almost all Unix systems do have putenv(), and so does +the Win32 API, and thus the os module was modified so that changes to +os.environ are trapped and the corresponding putenv() call is made. +

+ +Edit this entry / +Log info +

+ +


+

4.19. What is a class?

+A class is the particular object type created by executing +a class statement. Class objects are used as templates, to create +instance objects, which embody both the data structure +(attributes) and program routines (methods) specific to a datatype. +

+A class can be based on one or more other classes, called its base +class(es). It then inherits the attributes and methods of its base classes. This allows an object model to be successively refined +by inheritance. +

+The term "classic class" is used to refer to the original +class implementation in Python. One problem with classic +classes is their inability to use the built-in data types +(such as list and dictionary) as base classes. Starting +with Python 2.2 an attempt is in progress to unify user-defined +classes and built-in types. It is now possible to declare classes +that inherit from built-in types. +

+ +Edit this entry / +Log info + +/ Last changed on Mon May 27 01:31:21 2002 by +Steve Holden +

+ +


+

4.20. What is a method?

+A method is a function that you normally call as +x.name(arguments...) for some object x. The term is used for methods +of classes and class instances as well as for methods of built-in +objects. (The latter have a completely different implementation and +only share the way their calls look in Python code.) Methods of +classes (and class instances) are defined as functions inside the +class definition. +

+ +Edit this entry / +Log info +

+ +


+

4.21. What is self?

+Self is merely a conventional name for the first argument of a +method -- i.e. a function defined inside a class definition. A method +defined as meth(self, a, b, c) should be called as x.meth(a, b, c) for +some instance x of the class in which the definition occurs; +the called method will think it is called as meth(x, a, b, c). +

+ +Edit this entry / +Log info +

+ +


+

4.22. What is an unbound method?

+An unbound method is a method defined in a class that is not yet +bound to an instance. You get an unbound method if you ask for a +class attribute that happens to be a function. You get a bound method +if you ask for an instance attribute. A bound method knows which +instance it belongs to and calling it supplies the instance automatically; +an unbound method only knows which class it wants for its first +argument (a derived class is also OK). Calling an unbound method +doesn't "magically" derive the first argument from the context -- you +have to provide it explicitly. +

+Trivia note regarding bound methods: each reference to a bound +method of a particular object creates a bound method object. If you +have two such references (a = inst.meth; b = inst.meth), they will +compare equal (a == b) but are not the same (a is not b). +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 6 18:07:25 1998 by +Clarence Gardner +

+ +


+

4.23. How do I call a method defined in a base class from a derived class that overrides it?

+If your class definition starts with "class Derived(Base): ..." +then you can call method meth defined in Base (or one of Base's base +classes) as Base.meth(self, arguments...). Here, Base.meth is an +unbound method (see previous question). +

+ +Edit this entry / +Log info +

+ +


+

4.24. How do I call a method from a base class without using the name of the base class?

+DON'T DO THIS. REALLY. I MEAN IT. It appears that you could call +self.__class__.__bases__[0].meth(self, arguments...) but this fails when +a doubly-derived method is derived from your class: for its instances, +self.__class__.__bases__[0] is your class, not its base class -- so +(assuming you are doing this from within Derived.meth) you would start +a recursive call. +

+Often when you want to do this you are forgetting that classes +are first class in Python. You can "point to" the class you want +to delegate an operation to either at the instance or at the +subclass level. For example if you want to use a "glorp" +operation of a superclass you can point to the right superclass +to use. +

+

+  class subclass(superclass1, superclass2, superclass3):
+      delegate_glorp = superclass2
+      ...
+      def glorp(self, arg1, arg2):
+            ... subclass specific stuff ...
+            self.delegate_glorp.glorp(self, arg1, arg2)
+       ...
+
+
+  class subsubclass(subclass):
+       delegate_glorp = superclass3
+       ...
+
+Note, however that setting delegate_glorp to subclass in +subsubclass would cause an infinite recursion on subclass.delegate_glorp. Careful! Maybe you are getting too fancy for your own good. Consider simplifying the design (?). +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jul 28 13:58:22 1997 by +aaron watters +

+ +


+

4.25. How can I organize my code to make it easier to change the base class?

+You could define an alias for the base class, assign the real base +class to it before your class definition, and use the alias throughout +your class. Then all you have to change is the value assigned to the +alias. Incidentally, this trick is also handy if you want to decide +dynamically (e.g. depending on availability of resources) which base +class to use. Example: +

+

+        BaseAlias = <real base class>
+        class Derived(BaseAlias):
+                def meth(self):
+                        BaseAlias.meth(self)
+                        ...
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed May 21 15:49:57 1997 by +GvR +

+ +


+

4.26. How can I find the methods or attributes of an object?

+This depends on the object type. +

+For an instance x of a user-defined class, instance attributes are +found in the dictionary x.__dict__, and methods and attributes defined +by its class are found in x.__class__.__bases__[i].__dict__ (for i in +range(len(x.__class__.__bases__))). You'll have to walk the tree of +base classes to find all class methods and attributes. +

+Many, but not all built-in types define a list of their method names +in x.__methods__, and if they have data attributes, their names may be +found in x.__members__. However this is only a convention. +

+For more information, read the source of the standard (but +undocumented) module newdir. +

+ +Edit this entry / +Log info +

+ +


+

4.27. I can't seem to use os.read() on a pipe created with os.popen().

+os.read() is a low-level function which takes a file descriptor (a +small integer). os.popen() creates a high-level file object -- the +same type used for sys.std{in,out,err} and returned by the builtin +open() function. Thus, to read n bytes from a pipe p created with +os.popen(), you need to use p.read(n). +

+ +Edit this entry / +Log info +

+ +


+

4.28. How can I create a stand-alone binary from a Python script?

+Even though there are Python compilers being developed, +you probably don't need a real compiler, if all you want +is a stand-alone program. There are three solutions to that. +

+One is to use the freeze tool, which is included in the Python +source tree as Tools/freeze. It converts Python byte +code to C arrays. Using a C compiler, you can embed all +your modules into a new program, which is then linked +with the standard Python modules. +

+It works by scanning your source recursively for import statements +(in both forms) and looking for the modules in the standard Python path +as well as in the source directory (for built-in modules). It then +1 the modules written in Python to C code (array initializers +that can be turned into code objects using the marshal module) and +creates a custom-made config file that only contains those built-in +modules which are actually used in the program. It then compiles the +generated C code and links it with the rest of the Python interpreter +to form a self-contained binary which acts exactly like your script. +

+(Hint: the freeze program only works if your script's filename ends in +".py".) +

+There are several utilities which may be helpful. The first is Gordon McMillan's installer at +

+

+    http://www.mcmillan-inc.com/install1.html
+
+which works on Windows, Linux and at least some forms of Unix. +

+Another is Thomas Heller's py2exe (Windows only) at +

+

+    http://starship.python.net/crew/theller/py2exe/
+
+A third is Christian Tismer's SQFREEZE +(http://starship.python.net/crew/pirx/) which appends the byte code +to a specially-prepared Python interpreter, which +will find the byte code in executable. +

+A fourth is Fredrik Lundh's Squeeze +(http://www.pythonware.com/products/python/squeeze/). +

+ +Edit this entry / +Log info + +/ Last changed on Wed Jun 19 14:01:30 2002 by +Gordon McMillan +

+ +


+

4.29. What WWW tools are there for Python?

+See the chapters titled "Internet Protocols and Support" and +"Internet Data Handling" in the Library Reference +Manual. Python is full of good things which will help you build server-side and client-side web systems. +

+A summary of available frameworks is maintained by Paul Boddie at +

+

+    http://thor.prohosting.com/~pboddie/Python/web_modules.html
+
+Cameron Laird maintains a useful set of pages about Python web technologies at +

+

+   http://starbase.neosoft.com/~claird/comp.lang.python/web_python.html/
+
+There was a web browser written in Python, called Grail -- +see http://sourceforge.net/project/grail/. This project has been terminated; http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/grail/grail/README gives more details. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Nov 11 22:48:25 2002 by +GvR +

+ +


+

4.30. How do I run a subprocess with pipes connected to both input and output?

+Use the standard popen2 module. For example: +

+

+	import popen2
+	fromchild, tochild = popen2.popen2("command")
+	tochild.write("input\n")
+	tochild.flush()
+	output = fromchild.readline()
+
+Warning: in general, it is unwise to +do this, because you can easily cause a deadlock where your +process is blocked waiting for output from the child, while the child +is blocked waiting for input from you. This can be caused +because the parent expects the child to output more text than it does, +or it can be caused by data being stuck in stdio buffers due to lack +of flushing. The Python parent can of course explicitly flush the data +it sends to the child before it reads any output, but if the child is +a naive C program it can easily have been written to never explicitly +flush its output, even if it is interactive, since flushing is +normally automatic. +

+Note that a deadlock is also possible if you use popen3 to read +stdout and stderr. If one of the two is too large for the internal +buffer (increasing the buffersize does not help) and you read() +the other one first, there is a deadlock, too. +

+Note on a bug in popen2: unless your program calls wait() +or waitpid(), finished child processes are never removed, +and eventually calls to popen2 will fail because of a limit on +the number of child processes. Calling os.waitpid with the +os.WNOHANG option can prevent this; a good place to insert such +a call would be before calling popen2 again. +

+Another way to produce a deadlock: Call a wait() and there is +still more output from the program than what fits into the +internal buffers. +

+In many cases, all you really need is to run some data through a +command and get the result back. Unless the data is infinite in size, +the easiest (and often the most efficient!) way to do this is to write +it to a temporary file and run the command with that temporary file as +input. The standard module tempfile exports a function mktemp() which +generates unique temporary file names. +

+

+ import tempfile
+ import os
+ class Popen3:
+    """
+    This is a deadlock-save version of popen, that returns
+    an object with errorlevel, out (a string) and err (a string).
+    (capturestderr may not work under windows.)
+    Example: print Popen3('grep spam','\n\nhere spam\n\n').out
+    """
+    def __init__(self,command,input=None,capturestderr=None):
+        outfile=tempfile.mktemp()
+        command="( %s ) > %s" % (command,outfile)
+        if input:
+            infile=tempfile.mktemp()
+            open(infile,"w").write(input)
+            command=command+" <"+infile
+        if capturestderr:
+            errfile=tempfile.mktemp()
+            command=command+" 2>"+errfile
+        self.errorlevel=os.system(command) >> 8
+        self.out=open(outfile,"r").read()
+        os.remove(outfile)
+        if input:
+            os.remove(infile)
+        if capturestderr:
+            self.err=open(errfile,"r").read()
+            os.remove(errfile)
+
+Note that many interactive programs (e.g. vi) don't work well with +pipes substituted for standard input and output. You will have to use +pseudo ttys ("ptys") instead of pipes. There is some undocumented +code to use these in the library module pty.py -- I'm afraid you're on +your own here. +

+A different answer is a Python interface to Don Libes' "expect" +library. A Python extension that interfaces to expect is called "expy" +and available from +http://expectpy.sourceforge.net/. +

+A pure Python solution that works like expect is pexpect of Noah Spurrier. +A beta version is available from +http://pexpect.sourceforge.net/ +

+ +Edit this entry / +Log info + +/ Last changed on Tue Sep 3 16:31:31 2002 by +Tobias Polzin +

+ +


+

4.31. How do I call a function if I have the arguments in a tuple?

+Use the built-in function apply(). For instance, +

+

+    func(1, 2, 3)
+
+is equivalent to +

+

+    args = (1, 2, 3)
+    apply(func, args)
+
+Note that func(args) is not the same -- it calls func() with exactly +one argument, the tuple args, instead of three arguments, the integers +1, 2 and 3. +

+In Python 2.0, you can also use extended call syntax: +

+f(*args) is equivalent to apply(f, args) +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 2 03:42:50 2001 by +Moshe Zadka +

+ +


+

4.32. How do I enable font-lock-mode for Python in Emacs?

+If you are using XEmacs 19.14 or later, any XEmacs 20, FSF Emacs 19.34 +or any Emacs 20, font-lock should work automatically for you if you +are using the latest python-mode.el. +

+If you are using an older version of XEmacs or Emacs you will need +to put this in your .emacs file: +

+

+        (defun my-python-mode-hook ()
+          (setq font-lock-keywords python-font-lock-keywords)
+          (font-lock-mode 1))
+        (add-hook 'python-mode-hook 'my-python-mode-hook)
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Apr 6 16:18:46 1998 by +Barry Warsaw +

+ +


+

4.33. Is there a scanf() or sscanf() equivalent?

+Not as such. +

+For simple input parsing, the easiest approach is usually to split +the line into whitespace-delimited words using string.split(), and to +convert decimal strings to numeric values using int(), +long() or float(). (Python's int() is 32-bit and its +long() is arbitrary precision.) string.split supports an optional +"sep" parameter which is useful if the line uses something other +than whitespace as a delimiter. +

+For more complicated input parsing, regular expressions (see module re) +are better suited and more powerful than C's sscanf(). +

+There's a contributed module that emulates sscanf(), by Steve Clift; +see contrib/Misc/sscanfmodule.c of the ftp site: +

+

+    http://www.python.org/ftp/python/contrib-09-Dec-1999/Misc/
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 01:07:51 2002 by +Neal Norwitz +

+ +


+

4.34. Can I have Tk events handled while waiting for I/O?

+Yes, and you don't even need threads! But you'll have to +restructure your I/O code a bit. Tk has the equivalent of Xt's +XtAddInput() call, which allows you to register a callback function +which will be called from the Tk mainloop when I/O is possible on a +file descriptor. Here's what you need: +

+

+        from Tkinter import tkinter
+        tkinter.createfilehandler(file, mask, callback)
+
+The file may be a Python file or socket object (actually, anything +with a fileno() method), or an integer file descriptor. The mask is +one of the constants tkinter.READABLE or tkinter.WRITABLE. The +callback is called as follows: +

+

+        callback(file, mask)
+
+You must unregister the callback when you're done, using +

+

+        tkinter.deletefilehandler(file)
+
+Note: since you don't know *how many bytes* are available for reading, +you can't use the Python file object's read or readline methods, since +these will insist on reading a predefined number of bytes. For +sockets, the recv() or recvfrom() methods will work fine; for other +files, use os.read(file.fileno(), maxbytecount). +

+ +Edit this entry / +Log info +

+ +


+

4.35. How do I write a function with output parameters (call by reference)?

+[Mark Lutz] The thing to remember is that arguments are passed by +assignment in Python. Since assignment just creates references to +objects, there's no alias between an argument name in the caller and +callee, and so no call-by-reference per se. But you can simulate it +in a number of ways: +

+1) By using global variables; but you probably shouldn't :-) +

+2) By passing a mutable (changeable in-place) object: +

+

+      def func1(a):
+          a[0] = 'new-value'     # 'a' references a mutable list
+          a[1] = a[1] + 1        # changes a shared object
+
+
+      args = ['old-value', 99]
+      func1(args)
+      print args[0], args[1]     # output: new-value 100
+
+3) By returning a tuple, holding the final values of arguments: +

+

+      def func2(a, b):
+          a = 'new-value'        # a and b are local names
+          b = b + 1              # assigned to new objects
+          return a, b            # return new values
+
+
+      x, y = 'old-value', 99
+      x, y = func2(x, y)
+      print x, y                 # output: new-value 100
+
+4) And other ideas that fall-out from Python's object model. For instance, it might be clearer to pass in a mutable dictionary: +

+

+      def func3(args):
+          args['a'] = 'new-value'     # args is a mutable dictionary
+          args['b'] = args['b'] + 1   # change it in-place
+
+
+      args = {'a':' old-value', 'b': 99}
+      func3(args)
+      print args['a'], args['b']
+
+5) Or bundle-up values in a class instance: +

+

+      class callByRef:
+          def __init__(self, **args):
+              for (key, value) in args.items():
+                  setattr(self, key, value)
+
+
+      def func4(args):
+          args.a = 'new-value'        # args is a mutable callByRef
+          args.b = args.b + 1         # change object in-place
+
+
+      args = callByRef(a='old-value', b=99)
+      func4(args)
+      print args.a, args.b
+
+
+   But there's probably no good reason to get this complicated :-).
+
+[Python's author favors solution 3 in most cases.] +

+ +Edit this entry / +Log info + +/ Last changed on Sun Jun 8 23:49:46 1997 by +David Ascher +

+ +


+

4.36. Please explain the rules for local and global variables in Python.

+[Ken Manheimer] In Python, procedure variables are implicitly +global, unless they are assigned anywhere within the block. +In that case +they are implicitly local, and you need to explicitly declare them as +'global'. +

+Though a bit surprising at first, a moment's consideration explains +this. On one hand, requirement of 'global' for assigned vars provides +a bar against unintended side-effects. On the other hand, if global +were required for all global references, you'd be using global all the +time. Eg, you'd have to declare as global every reference to a +builtin function, or to a component of an imported module. This +clutter would defeat the usefulness of the 'global' declaration for +identifying side-effects. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Aug 28 09:53:27 1998 by +GvR +

+ +


+

4.37. How can I have modules that mutually import each other?

+Suppose you have the following modules: +

+foo.py: +

+

+	from bar import bar_var
+	foo_var=1
+
+bar.py: +

+

+	from foo import foo_var
+	bar_var=2
+
+The problem is that the above is processed by the interpreter thus: +

+

+	main imports foo
+	Empty globals for foo are created
+	foo is compiled and starts executing
+	foo imports bar
+	Empty globals for bar are created
+	bar is compiled and starts executing
+	bar imports foo (which is a no-op since there already is a module named foo)
+	bar.foo_var = foo.foo_var
+	...
+
+The last step fails, because Python isn't done with interpreting foo yet and the global symbol dict for foo is still empty. +

+The same thing happens when you use "import foo", and then try to access "foo.one" in global code. +

+

+There are (at least) three possible workarounds for this problem. +

+Guido van Rossum recommends to avoid all uses of "from <module> import ..." (so everything from an imported module is referenced as <module>.<name>) and to place all code inside functions. Initializations of global variables and class variables should use constants or built-in functions only. +

+

+Jim Roskind suggests the following order in each module: +

+

+ exports (globals, functions, and classes that don't need imported base classes)
+ import statements
+ active code (including globals that are initialized from imported values).
+
+Python's author doesn't like this approach much because the imports +appear in a strange place, but has to admit that it works. +

+

+

+Matthias Urlichs recommends to restructure your code so that the recursive import is not necessary in the first place. +

+

+These solutions are not mutually exclusive. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 06:52:51 2002 by +Matthias Urlichs +

+ +


+

4.38. How do I copy an object in Python?

+Try copy.copy() or copy.deepcopy() for the general case. Not all objects can be copied, but most can. +

+Dictionaries have a copy method. Sequences can be copied by slicing: +

+ new_l = l[:]
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 21 05:40:26 2002 by +Erno Kuusela +

+ +


+

4.39. How to implement persistent objects in Python? (Persistent == automatically saved to and restored from disk.)

+The library module "pickle" now solves this in a very general way +(though you still can't store things like open files, sockets or +windows), and the library module "shelve" uses pickle and (g)dbm to +create persistent mappings containing arbitrary Python objects. +For possibly better performance also look for the latest version +of the relatively recent cPickle module. +

+A more awkward way of doing things is to use pickle's little sister, +marshal. The marshal module provides very fast ways to store +noncircular basic Python types to files and strings, and back again. +Although marshal does not do fancy things like store instances or +handle shared references properly, it does run extremely fast. For +example loading a half megabyte of data may take less than a +third of a second (on some machines). This often beats doing +something more complex and general such as using gdbm with +pickle/shelve. +

+ +Edit this entry / +Log info + +/ Last changed on Sun Jun 8 22:59:00 1997 by +David Ascher +

+ +


+

4.40. I try to use __spam and I get an error about _SomeClassName__spam.

+Variables with double leading underscore are "mangled" to provide a +simple but effective way to define class private variables. See the +chapter "New in Release 1.4" in the Python Tutorial. +

+ +Edit this entry / +Log info +

+ +


+

4.41. How do I delete a file? And other file questions.

+Use os.remove(filename) or os.unlink(filename); for documentation, +see the posix section of the library manual. They are the same, +unlink() is simply the Unix name for this function. In earlier +versions of Python, only os.unlink() was available. +

+To remove a directory, use os.rmdir(); use os.mkdir() to create one. +

+To rename a file, use os.rename(). +

+To truncate a file, open it using f = open(filename, "r+"), and use +f.truncate(offset); offset defaults to the current seek position. +(The "r+" mode opens the file for reading and writing.) +There's also os.ftruncate(fd, offset) for files opened with os.open() +-- for advanced Unix hacks only. +

+The shutil module also contains a number of functions to work on files +including copyfile, copytree, and rmtree amongst others. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Dec 28 12:30:01 2000 by +Bjorn Pettersen +

+ +


+

4.42. How to modify urllib or httplib to support HTTP/1.1?

+Recent versions of Python (2.0 and onwards) support HTTP/1.1 natively. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 2 02:56:56 2001 by +Moshe Zadka +

+ +


+

4.43. Unexplicable syntax errors in compile() or exec.

+When a statement suite (as opposed to an expression) is compiled by +compile(), exec or execfile(), it must end in a newline. In some +cases, when the source ends in an indented block it appears that at +least two newlines are required. +

+ +Edit this entry / +Log info +

+ +


+

4.44. How do I convert a string to a number?

+For integers, use the built-in int() function, e.g. int('144') == 144. Similarly, long() converts from string to long integer, e.g. long('144') == 144L; and float() to floating-point, e.g. float('144') == 144.0. +

+Note that these are restricted to decimal interpretation, so +that int('0144') == 144 and int('0x144') raises ValueError. For Python +2.0 int takes the base to convert from as a second optional argument, so +int('0x144', 16) == 324. +

+For greater flexibility, or before Python 1.5, import the module +string and use the string.atoi() function for integers, +string.atol() for long integers, or string.atof() for +floating-point. E.g., +string.atoi('100', 16) == string.atoi('0x100', 0) == 256. +See the library reference manual section for the string module for +more details. +

+While you could use the built-in function eval() instead of +any of those, this is not recommended, because someone could pass you +a Python expression that might have unwanted side effects (like +reformatting your disk). It also has the effect of interpreting numbers +as Python expressions, so that e.g. eval('09') gives a syntax error +since Python regards numbers starting with '0' as octal (base 8). +

+ +Edit this entry / +Log info + +/ Last changed on Thu Dec 28 12:37:34 2000 by +Bjorn Pettersen +

+ +


+

4.45. How do I convert a number to a string?

+To convert, e.g., the number 144 to the string '144', use the +built-in function repr() or the backquote notation (these are +equivalent). If you want a hexadecimal or octal representation, use +the built-in functions hex() or oct(), respectively. For fancy +formatting, use the % operator on strings, just like C printf formats, +e.g. "%04d" % 144 yields '0144' and "%.3f" % (1/3.0) yields '0.333'. +See the library reference manual for details. +

+ +Edit this entry / +Log info +

+ +


+

4.46. How do I copy a file?

+There's the shutil module which contains a copyfile() +function that implements a copy loop; +it isn't good enough for the Macintosh, though: +it doesn't copy the resource fork and Finder info. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 2 02:59:40 2001 by +Moshe Zadka +

+ +


+

4.47. How do I check if an object is an instance of a given class or of a subclass of it?

+If you are developing the classes from scratch it might be better to +program in a more proper object-oriented style -- instead of doing a different +thing based on class membership, why not use a method and define the +method differently in different classes? +

+However, there are some legitimate situations +where you need to test for class membership. +

+In Python 1.5, you can use the built-in function isinstance(obj, cls). +

+The following approaches can be used with earlier Python versions: +

+An unobvious method is to raise the object +as an exception and to try to catch the exception with the class you're +testing for: +

+

+	def is_instance_of(the_instance, the_class):
+	    try:
+		raise the_instance
+	    except the_class:
+		return 1
+	    except:
+		return 0
+
+This technique can be used to distinguish "subclassness" +from a collection of classes as well +

+

+                try:
+                              raise the_instance
+                except Audible:
+                              the_instance.play(largo)
+                except Visual:
+                              the_instance.display(gaudy)
+                except Olfactory:
+                              sniff(the_instance)
+                except:
+                              raise ValueError, "dunno what to do with this!"
+
+This uses the fact that exception catching tests for class or subclass +membership. +

+A different approach is to test for the presence of a class attribute that +is presumably unique for the given class. For instance: +

+

+	class MyClass:
+	    ThisIsMyClass = 1
+	    ...
+
+
+	def is_a_MyClass(the_instance):
+	    return hasattr(the_instance, 'ThisIsMyClass')
+
+This version is easier to inline, and probably faster (inlined it +is definitely faster). The disadvantage is that someone else could cheat: +

+

+	class IntruderClass:
+	    ThisIsMyClass = 1    # Masquerade as MyClass
+	    ...
+
+but this may be seen as a feature (anyway, there are plenty of other ways +to cheat in Python). Another disadvantage is that the class must be +prepared for the membership test. If you do not "control the +source code" for the class it may not be advisable to modify the +class to support testability. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jan 2 15:16:04 1998 by +GvR +

+ +


+

4.48. What is delegation?

+Delegation refers to an object oriented technique Python programmers +may implement with particular ease. Consider the following: +

+

+  from string import upper
+
+
+  class UpperOut:
+        def __init__(self, outfile):
+              self.__outfile = outfile
+        def write(self, str):
+              self.__outfile.write( upper(str) )
+        def __getattr__(self, name):
+              return getattr(self.__outfile, name)
+
+Here the UpperOut class redefines the write method +to convert the argument string to upper case before +calling the underlying self.__outfile.write method, but +all other methods are delegated to the underlying +self.__outfile object. The delegation is accomplished +via the "magic" __getattr__ method. Please see the +language reference for more information on the use +of this method. +

+Note that for more general cases delegation can +get trickier. Particularly when attributes must be set +as well as gotten the class must define a __settattr__ +method too, and it must do so carefully. +

+The basic implementation of __setattr__ is roughly +equivalent to the following: +

+

+   class X:
+        ...
+        def __setattr__(self, name, value):
+             self.__dict__[name] = value
+        ...
+
+Most __setattr__ implementations must modify +self.__dict__ to store local state for self without +causing an infinite recursion. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Aug 13 07:11:24 1997 by +aaron watters +

+ +


+

4.49. How do I test a Python program or component.

+We presume for the purposes of this question you are interested +in standalone testing, rather than testing your components inside +a testing framework. The best-known testing framework for Python +is the PyUnit module, maintained at +

+

+    http://pyunit.sourceforge.net/
+
+For standalone testing, it helps to write the program so that +it may be easily tested by using good modular design. +In particular your program +should have almost all functionality encapsulated in either functions +or class methods -- and this sometimes has the surprising and +delightful effect of making the program run faster (because +local variable accesses are faster than global accesses). +Furthermore the program should avoid depending on mutating +global variables, since this makes testing much more difficult to do. +

+The "global main logic" of your program may be as simple +as +

+

+  if __name__=="__main__":
+       main_logic()
+
+at the bottom of the main module of your program. +

+Once your program is organized as a tractable collection +of functions and class behaviours you should write test +functions that exercise the behaviours. A test suite +can be associated with each module which automates +a sequence of tests. This sounds like a lot of work, but +since Python is so terse and flexible it's surprisingly easy. +You can make coding much more pleasant and fun by +writing your test functions in parallel with the "production +code", since this makes it easy to find bugs and even +design flaws earlier. +

+"Support modules" that are not intended to be the main +module of a program may include a "test script interpretation" +which invokes a self test of the module. +

+

+   if __name__ == "__main__":
+      self_test()
+
+Even programs that interact with complex external +interfaces may be tested when the external interfaces are +unavailable by using "fake" interfaces implemented in +Python. For an example of a "fake" interface, the following +class defines (part of) a "fake" file interface: +

+

+ import string
+ testdata = "just a random sequence of characters"
+
+
+ class FakeInputFile:
+   data = testdata
+   position = 0
+   closed = 0
+
+
+   def read(self, n=None):
+       self.testclosed()
+       p = self.position
+       if n is None:
+          result= self.data[p:]
+       else:
+          result= self.data[p: p+n]
+       self.position = p + len(result)
+       return result
+
+
+   def seek(self, n, m=0):
+       self.testclosed()
+       last = len(self.data)
+       p = self.position
+       if m==0: 
+          final=n
+       elif m==1:
+          final=n+p
+       elif m==2:
+          final=len(self.data)+n
+       else:
+          raise ValueError, "bad m"
+       if final<0:
+          raise IOError, "negative seek"
+       self.position = final
+
+
+   def isatty(self):
+       return 0
+
+
+   def tell(self):
+       return self.position
+
+
+   def close(self):
+       self.closed = 1
+
+
+   def testclosed(self):
+       if self.closed:
+          raise IOError, "file closed"
+
+Try f=FakeInputFile() and test out its operations. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 01:12:10 2002 by +Neal Norwitz +

+ +


+

4.50. My multidimensional list (array) is broken! What gives?

+You probably tried to make a multidimensional array like this. +

+

+   A = [[None] * 2] * 3
+
+This makes a list containing 3 references to the same list of length +two. Changes to one row will show in all rows, which is probably not +what you want. The following works much better: +

+

+   A = [None]*3
+   for i in range(3):
+        A[i] = [None] * 2
+
+This generates a list containing 3 different lists of length two. +

+If you feel weird, you can also do it in the following way: +

+

+   w, h = 2, 3
+   A = map(lambda i,w=w: [None] * w, range(h))
+
+For Python 2.0 the above can be spelled using a list comprehension: +

+

+   w,h = 2,3
+   A = [ [None]*w for i in range(h) ]
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Dec 28 12:18:35 2000 by +Bjorn Pettersen +

+ +


+

4.51. I want to do a complicated sort: can you do a Schwartzian Transform in Python?

+Yes, and in Python you only have to write it once: +

+

+ def st(List, Metric):
+     def pairing(element, M = Metric):
+           return (M(element), element)
+     paired = map(pairing, List)
+     paired.sort()
+     return map(stripit, paired)
+
+
+ def stripit(pair):
+     return pair[1]
+
+This technique, attributed to Randal Schwartz, sorts the elements +of a list by a metric which maps each element to its "sort value". +For example, if L is a list of string then +

+

+   import string
+   Usorted = st(L, string.upper)
+
+
+   def intfield(s):
+         return string.atoi( string.strip(s[10:15] ) )
+
+
+   Isorted = st(L, intfield)
+
+Usorted gives the elements of L sorted as if they were upper +case, and Isorted gives the elements of L sorted by the integer +values that appear in the string slices starting at position 10 +and ending at position 15. In Python 2.0 this can be done more +naturally with list comprehensions: +

+

+  tmp1 = [ (x.upper(), x) for x in L ] # Schwartzian transform
+  tmp1.sort()
+  Usorted = [ x[1] for x in tmp1 ]
+
+
+  tmp2 = [ (int(s[10:15]), s) for s in L ] # Schwartzian transform
+  tmp2.sort()
+  Isorted = [ x[1] for x in tmp2 ]
+
+

+Note that Isorted may also be computed by +

+

+   def Icmp(s1, s2):
+         return cmp( intfield(s1), intfield(s2) )
+
+
+   Isorted = L[:]
+   Isorted.sort(Icmp)
+
+but since this method computes intfield many times for each +element of L, it is slower than the Schwartzian Transform. +

+ +Edit this entry / +Log info + +/ Last changed on Sat Jun 1 19:18:46 2002 by +Neal Norwitz +

+ +


+

4.52. How to convert between tuples and lists?

+The function tuple(seq) converts any sequence into a tuple with +the same items in the same order. +For example, tuple([1, 2, 3]) yields (1, 2, 3) and tuple('abc') +yields ('a', 'b', 'c'). If the argument is +a tuple, it does not make a copy but returns the same object, so +it is cheap to call tuple() when you aren't sure that an object +is already a tuple. +

+The function list(seq) converts any sequence into a list with +the same items in the same order. +For example, list((1, 2, 3)) yields [1, 2, 3] and list('abc') +yields ['a', 'b', 'c']. If the argument is a list, +it makes a copy just like seq[:] would. +

+ +Edit this entry / +Log info + +/ Last changed on Sun Jun 14 14:18:53 1998 by +Tim Peters +

+ +


+

4.53. Files retrieved with urllib contain leading garbage that looks like email headers.

+Extremely old versions of Python supplied libraries which +did not support HTTP/1.1; the vanilla httplib in Python 1.4 +only recognized HTTP/1.0. In Python 2.0 full HTTP/1.1 support is included. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jan 8 17:26:18 2001 by +Steve Holden +

+ +


+

4.54. How do I get a list of all instances of a given class?

+Python does not keep track of all instances of a class (or of a +built-in type). +

+You can program the class's constructor to keep track of all +instances, but unless you're very clever, this has the disadvantage +that the instances never get deleted,because your list of all +instances keeps a reference to them. +

+(The trick is to regularly inspect the reference counts of the +instances you've retained, and if the reference count is below a +certain level, remove it from the list. Determining that level is +tricky -- it's definitely larger than 1.) +

+ +Edit this entry / +Log info + +/ Last changed on Tue May 27 23:52:16 1997 by +GvR +

+ +


+

4.55. A regular expression fails with regex.error: match failure.

+This is usually caused by too much backtracking; the regular +expression engine has a fixed size stack which holds at most 4000 +backtrack points. Every character matched by e.g. ".*" accounts for a +backtrack point, so even a simple search like +

+

+  regex.match('.*x',"x"*5000)
+
+will fail. +

+This is fixed in the re module introduced with +Python 1.5; consult the Library Reference section on re for more information. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jul 30 12:35:49 1998 by +A.M. Kuchling +

+ +


+

4.56. I can't get signal handlers to work.

+The most common problem is that the signal handler is declared +with the wrong argument list. It is called as +

+

+	handler(signum, frame)
+
+so it should be declared with two arguments: +

+

+	def handler(signum, frame):
+		...
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed May 28 09:29:08 1997 by +GvR +

+ +


+

4.57. I can't use a global variable in a function? Help!

+Did you do something like this? +

+

+   x = 1 # make a global
+
+
+   def f():
+         print x # try to print the global
+         ...
+         for j in range(100):
+              if q>3:
+                 x=4
+
+Any variable assigned in a function is local to that function. +unless it is specifically declared global. Since a value is bound +to x as the last statement of the function body, the compiler +assumes that x is local. Consequently the "print x" +attempts to print an uninitialized local variable and will +trigger a NameError. +

+In such cases the solution is to insert an explicit global +declaration at the start of the function, making it +

+

+

+   def f():
+         global x
+         print x # try to print the global
+         ...
+         for j in range(100):
+              if q>3:
+                 x=4
+
+

+In this case, all references to x are interpreted as references +to the x from the module namespace. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Feb 12 15:52:12 2001 by +Steve Holden +

+ +


+

4.58. What's a negative index? Why doesn't list.insert() use them?

+Python sequences are indexed with positive numbers and +negative numbers. For positive numbers 0 is the first index +1 is the second index and so forth. For negative indices -1 +is the last index and -2 is the pentultimate (next to last) index +and so forth. Think of seq[-n] as the same as seq[len(seq)-n]. +

+Using negative indices can be very convenient. For example +if the string Line ends in a newline then Line[:-1] is all of Line except +the newline. +

+Sadly the list builtin method L.insert does not observe negative +indices. This feature could be considered a mistake but since +existing programs depend on this feature it may stay around +forever. L.insert for negative indices inserts at the start of the +list. To get "proper" negative index behaviour use L[n:n] = [x] +in place of the insert method. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Aug 13 07:03:18 1997 by +aaron watters +

+ +


+

4.59. How can I sort one list by values from another list?

+You can sort lists of tuples. +

+

+  >>> list1 = ["what", "I'm", "sorting", "by"]
+  >>> list2 = ["something", "else", "to", "sort"]
+  >>> pairs = map(None, list1, list2)
+  >>> pairs
+  [('what', 'something'), ("I'm", 'else'), ('sorting', 'to'), ('by', 'sort')]
+  >>> pairs.sort()
+  >>> pairs
+  [("I'm", 'else'), ('by', 'sort'), ('sorting', 'to'), ('what', 'something')]
+  >>> result = pairs[:]
+  >>> for i in xrange(len(result)): result[i] = result[i][1]
+  ...
+  >>> result
+  ['else', 'sort', 'to', 'something']
+
+And if you didn't understand the question, please see the +example above ;c). Note that "I'm" sorts before "by" because +uppercase "I" comes before lowercase "b" in the ascii order. +Also see 4.51. +

+In Python 2.0 this can be done like: +

+

+ >>> list1 = ["what", "I'm", "sorting", "by"]
+ >>> list2 = ["something", "else", "to", "sort"]
+ >>> pairs = zip(list1, list2)
+ >>> pairs
+ [('what', 'something'), ("I'm", 'else'), ('sorting', 'to'), ('by', 'sort')]
+ >>> pairs.sort()
+ >>> result = [ x[1] for x in pairs ]
+ >>> result
+ ['else', 'sort', 'to', 'something']
+
+[Followup] +

+Someone asked, why not this for the last steps: +

+

+  result = []
+  for p in pairs: result.append(p[1])
+
+This is much more legible. However, a quick test shows that +it is almost twice as slow for long lists. Why? First of all, +the append() operation has to reallocate memory, and while it +uses some tricks to avoid doing that each time, it still has +to do it occasionally, and apparently that costs quite a bit. +Second, the expression "result.append" requires an extra +attribute lookup. The attribute lookup could be done away +with by rewriting as follows: +

+

+  result = []
+  append = result.append
+  for p in pairs: append(p[1])
+
+which gains back some speed, but is still considerably slower +than the original solution, and hardly less convoluted. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Dec 28 12:56:35 2000 by +Bjorn Pettersen +

+ +


+

4.60. Why doesn't dir() work on builtin types like files and lists?

+It does starting with Python 1.5. +

+Using 1.4, you can find out which methods a given object supports +by looking at its __methods__ attribute: +

+

+    >>> List = []
+    >>> List.__methods__
+    ['append', 'count', 'index', 'insert', 'remove', 'reverse', 'sort']
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Sep 16 14:56:42 1999 by +Skip Montanaro +

+ +


+

4.61. How can I mimic CGI form submission (METHOD=POST)?

+I would like to retrieve web pages that are the result of POSTing a +form. Is there existing code that would let me do this easily? +

+Yes. Here's a simple example that uses httplib. +

+

+    #!/usr/local/bin/python
+
+
+    import httplib, sys, time
+
+
+    ### build the query string
+    qs = "First=Josephine&MI=Q&Last=Public"
+
+
+    ### connect and send the server a path
+    httpobj = httplib.HTTP('www.some-server.out-there', 80)
+    httpobj.putrequest('POST', '/cgi-bin/some-cgi-script')
+    ### now generate the rest of the HTTP headers...
+    httpobj.putheader('Accept', '*/*')
+    httpobj.putheader('Connection', 'Keep-Alive')
+    httpobj.putheader('Content-type', 'application/x-www-form-urlencoded')
+    httpobj.putheader('Content-length', '%d' % len(qs))
+    httpobj.endheaders()
+    httpobj.send(qs)
+    ### find out what the server said in response...
+    reply, msg, hdrs = httpobj.getreply()
+    if reply != 200:
+	sys.stdout.write(httpobj.getfile().read())
+
+Note that in general for "url encoded posts" (the default) query strings must be "quoted" to, for example, change equals signs and spaces to an encoded form when they occur in name or value. Use urllib.quote to perform this quoting. For example to send name="Guy Steele, Jr.": +

+

+   >>> from urllib import quote
+   >>> x = quote("Guy Steele, Jr.")
+   >>> x
+   'Guy%20Steele,%20Jr.'
+   >>> query_string = "name="+x
+   >>> query_string
+   'name=Guy%20Steele,%20Jr.'
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 21 03:47:07 1999 by +TAB +

+ +


+

4.62. If my program crashes with a bsddb (or anydbm) database open, it gets corrupted. How come?

+Databases opened for write access with the bsddb module (and often by +the anydbm module, since it will preferentially use bsddb) must +explicitly be closed using the close method of the database. The +underlying libdb package caches database contents which need to be +converted to on-disk form and written, unlike regular open files which +already have the on-disk bits in the kernel's write buffer, where they +can just be dumped by the kernel with the program exits. +

+If you have initialized a new bsddb database but not written anything to +it before the program crashes, you will often wind up with a zero-length +file and encounter an exception the next time the file is opened. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 01:15:01 2002 by +Neal Norwitz +

+ +


+

4.63. How do I make a Python script executable on Unix?

+You need to do two things: the script file's mode must be executable +(include the 'x' bit), and the first line must begin with #! +followed by the pathname for the Python interpreter. +

+The first is done by executing 'chmod +x scriptfile' or perhaps +'chmod 755 scriptfile'. +

+The second can be done in a number of way. The most straightforward +way is to write +

+

+  #!/usr/local/bin/python
+
+as the very first line of your file - or whatever the pathname is +where the python interpreter is installed on your platform. +

+If you would like the script to be independent of where the python +interpreter lives, you can use the "env" program. On almost all +platforms, the following will work, assuming the python interpreter +is in a directory on the user's $PATH: +

+

+  #! /usr/bin/env python
+
+Note -- *don't* do this for CGI scripts. The $PATH variable for +CGI scripts is often very minimal, so you need to use the actual +absolute pathname of the interpreter. +

+Occasionally, a user's environment is so full that the /usr/bin/env +program fails; or there's no env program at all. +In that case, you can try the following hack (due to Alex Rezinsky): +

+

+  #! /bin/sh
+  """:"
+  exec python $0 ${1+"$@"}
+  """
+
+The disadvantage is that this defines the script's __doc__ string. +However, you can fix that by adding +

+

+  __doc__ = """...Whatever..."""
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Jan 15 09:19:16 2001 by +Neal Norwitz +

+ +


+

4.64. How do you remove duplicates from a list?

+See the Python Cookbook for a long discussion of many cool ways: +

+

+    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560
+
+Generally, if you don't mind reordering the List +

+

+   if List:
+      List.sort()
+      last = List[-1]
+      for i in range(len(List)-2, -1, -1):
+          if last==List[i]: del List[i]
+          else: last=List[i]
+
+If all elements of the list may be used as +dictionary keys (ie, they are all hashable) +this is often faster +

+

+   d = {}
+   for x in List: d[x]=x
+   List = d.values()
+
+Also, for extremely large lists you might +consider more optimal alternatives to the first one. +The second one is pretty good whenever it can +be used. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 24 21:56:33 2002 by +Tim Peters +

+ +


+

4.65. Are there any known year 2000 problems in Python?

+I am not aware of year 2000 deficiencies in Python 1.5. Python does +very few date calculations and for what it does, it relies on the C +library functions. Python generally represent times either as seconds +since 1970 or as a tuple (year, month, day, ...) where the year is +expressed with four digits, which makes Y2K bugs unlikely. So as long +as your C library is okay, Python should be okay. Of course, I cannot +vouch for your Python code! +

+Given the nature of freely available software, I have to add that this statement is not +legally binding. The Python copyright notice contains the following +disclaimer: +

+

+  STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
+  REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+  MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
+  CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+  PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+  PERFORMANCE OF THIS SOFTWARE.
+
+The good news is that if you encounter a problem, you have full +source available to track it down and fix it! +

+ +Edit this entry / +Log info + +/ Last changed on Fri Apr 10 14:59:31 1998 by +GvR +

+ +


+

4.66. I want a version of map that applies a method to a sequence of objects! Help!

+Get fancy! +

+

+  def method_map(objects, method, arguments):
+       """method_map([a,b], "flog", (1,2)) gives [a.flog(1,2), b.flog(1,2)]"""
+       nobjects = len(objects)
+       methods = map(getattr, objects, [method]*nobjects)
+       return map(apply, methods, [arguments]*nobjects)
+
+It's generally a good idea to get to know the mysteries of map and apply +and getattr and the other dynamic features of Python. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jan 5 14:21:14 1998 by +Aaron Watters +

+ +


+

4.67. How do I generate random numbers in Python?

+The standard library module "random" implements a random number +generator. Usage is simple: +

+

+    import random
+
+
+    random.random()
+
+This returns a random floating point number in the range [0, 1). +

+There are also many other specialized generators in this module, such +as +

+

+    randrange(a, b) chooses an integer in the range [a, b)
+    uniform(a, b) chooses a floating point number in the range [a, b)
+    normalvariate(mean, sdev) sample from normal (Gaussian) distribution
+
+Some higher-level functions operate on sequences directly, such as +

+

+    choice(S) chooses random element from a given sequence
+    shuffle(L) shuffles a list in-place, i.e. permutes it randomly
+
+There's also a class, Random, which you can instantiate +to create independent multiple random number generators. +

+All this is documented in the library reference manual. Note that +the module "whrandom" is obsolete. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 01:16:51 2002 by +Neal Norwitz +

+ +


+

4.68. How do I access the serial (RS232) port?

+There's a Windows serial communication module (for communication +over RS 232 serial ports) at +

+

+  ftp://ftp.python.org/pub/python/contrib/sio-151.zip
+  http://www.python.org/ftp/python/contrib/sio-151.zip
+
+For DOS, try Hans Nowak's Python-DX, which supports this, at: +

+

+  http://www.cuci.nl/~hnowak/
+
+For Unix, see a usenet post by Mitch Chapman: +

+

+  http://groups.google.com/groups?selm=34A04430.CF9@ohioee.com
+
+For Win32, POSIX(Linux, BSD, *), Jython, Chris': +

+

+  http://pyserial.sourceforge.net
+
+

+ +Edit this entry / +Log info + +/ Last changed on Tue Jul 2 21:11:07 2002 by +Chris Liechti +

+ +


+

4.69. Images on Tk-Buttons don't work in Py15?

+They do work, but you must keep your own reference to the image +object now. More verbosely, you must make sure that, say, a global +variable or a class attribute refers to the object. +

+Quoting Fredrik Lundh from the mailinglist: +

+

+  Well, the Tk button widget keeps a reference to the internal
+  photoimage object, but Tkinter does not.  So when the last
+  Python reference goes away, Tkinter tells Tk to release the
+  photoimage.  But since the image is in use by a widget, Tk
+  doesn't destroy it.  Not completely.  It just blanks the image,
+  making it completely transparent...
+
+
+  And yes, there was a bug in the keyword argument handling
+  in 1.4 that kept an extra reference around in some cases.  And
+  when Guido fixed that bug in 1.5, he broke quite a few Tkinter
+  programs...
+
+

+ +Edit this entry / +Log info + +/ Last changed on Tue Feb 3 11:31:03 1998 by +Case Roole +

+ +


+

4.70. Where is the math.py (socket.py, regex.py, etc.) source file?

+If you can't find a source file for a module it may be a builtin +or dynamically loaded module implemented in C, C++ or other +compiled language. In this case you may not have the source +file or it may be something like mathmodule.c, somewhere in +a C source directory (not on the Python Path). +

+Fredrik Lundh (fredrik@pythonware.com) explains (on the python-list): +

+There are (at least) three kinds of modules in Python: +1) modules written in Python (.py); +2) modules written in C and dynamically loaded (.dll, .pyd, .so, .sl, etc); +3) modules written in C and linked with the interpreter; to get a list +of these, type: +

+

+    import sys
+    print sys.builtin_module_names
+
+

+ +Edit this entry / +Log info + +/ Last changed on Tue Feb 3 13:55:33 1998 by +Aaron Watters +

+ +


+

4.71. How do I send mail from a Python script?

+The standard library module smtplib does this. +Here's a very simple interactive mail +sender that uses it. This method will work on any host that +supports an SMTP listener. +

+

+    import sys, smtplib
+
+
+    fromaddr = raw_input("From: ")
+    toaddrs  = raw_input("To: ").split(',')
+    print "Enter message, end with ^D:"
+    msg = ''
+    while 1:
+        line = sys.stdin.readline()
+        if not line:
+            break
+        msg = msg + line
+
+
+    # The actual mail send
+    server = smtplib.SMTP('localhost')
+    server.sendmail(fromaddr, toaddrs, msg)
+    server.quit()
+
+If the local host doesn't have an SMTP listener, you need to find one. The simple method is to ask the user. Alternately, you can use the DNS system to find the mail gateway(s) responsible for the source address. +

+A Unix-only alternative uses sendmail. The location of the +sendmail program varies between systems; sometimes it is +/usr/lib/sendmail, sometime /usr/sbin/sendmail. The sendmail manual +page will help you out. Here's some sample code: +

+

+  SENDMAIL = "/usr/sbin/sendmail" # sendmail location
+  import os
+  p = os.popen("%s -t -i" % SENDMAIL, "w")
+  p.write("To: cary@ratatosk.org\n")
+  p.write("Subject: test\n")
+  p.write("\n") # blank line separating headers from body
+  p.write("Some text\n")
+  p.write("some more text\n")
+  sts = p.close()
+  if sts != 0:
+      print "Sendmail exit status", sts
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 07:05:12 2002 by +Matthias Urlichs +

+ +


+

4.72. How do I avoid blocking in connect() of a socket?

+The select module is widely known to help with asynchronous +I/O on sockets once they are connected. However, it is less +than common knowledge how to avoid blocking on the initial +connect() call. Jeremy Hylton has the following advice (slightly +edited): +

+To prevent the TCP connect from blocking, you can set the socket to +non-blocking mode. Then when you do the connect(), you will either +connect immediately (unlikely) or get an exception that contains the +errno. errno.EINPROGRESS indicates that the connection is in +progress, but hasn't finished yet. Different OSes will return +different errnos, so you're going to have to check. I can tell you +that different versions of Solaris return different errno values. +

+In Python 1.5 and later, you can use connect_ex() to avoid +creating an exception. It will just return the errno value. +

+To poll, you can call connect_ex() again later -- 0 or errno.EISCONN +indicate that you're connected -- or you can pass this socket to +select (checking to see if it is writeable). +

+ +Edit this entry / +Log info + +/ Last changed on Tue Feb 24 21:30:45 1998 by +GvR +

+ +


+

4.73. How do I specify hexadecimal and octal integers?

+To specify an octal digit, precede the octal value with a zero. For example, +to set the variable "a" to the octal value "10" (8 in decimal), type: +

+

+    >>> a = 010
+
+To verify that this works, you can type "a" and hit enter while in the +interpreter, which will cause Python to spit out the current value of "a" +in decimal: +

+

+    >>> a
+    8
+
+Hexadecimal is just as easy. Simply precede the hexadecimal number with a +zero, and then a lower or uppercase "x". Hexadecimal digits can be specified +in lower or uppercase. For example, in the Python interpreter: +

+

+    >>> a = 0xa5
+    >>> a
+    165
+    >>> b = 0XB2
+    >>> b
+    178
+
+

+ +Edit this entry / +Log info + +/ Last changed on Tue Mar 3 12:53:16 1998 by +GvR +

+ +


+

4.74. How to get a single keypress at a time?

+For Windows, see question 8.2. Here is an answer for Unix (see also 4.94). +

+There are several solutions; some involve using curses, which is a +pretty big thing to learn. Here's a solution without curses, due +to Andrew Kuchling (adapted from code to do a PGP-style +randomness pool): +

+

+        import termios, sys, os
+        fd = sys.stdin.fileno()
+        old = termios.tcgetattr(fd)
+        new = termios.tcgetattr(fd)
+        new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
+        new[6][termios.VMIN] = 1
+        new[6][termios.VTIME] = 0
+        termios.tcsetattr(fd, termios.TCSANOW, new)
+        s = ''    # We'll save the characters typed and add them to the pool.
+        try:
+            while 1:
+                c = os.read(fd, 1)
+                print "Got character", `c`
+                s = s+c
+        finally:
+            termios.tcsetattr(fd, termios.TCSAFLUSH, old)
+
+You need the termios module for any of this to work, and I've only +tried it on Linux, though it should work elsewhere. It turns off +stdin's echoing and disables canonical mode, and then reads a +character at a time from stdin, noting the time after each keystroke. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Oct 24 00:36:56 2002 by +chris +

+ +


+

4.75. How can I overload constructors (or methods) in Python?

+(This actually applies to all methods, but somehow the question +usually comes up first in the context of constructors.) +

+Where in C++ you'd write +

+

+    class C {
+        C() { cout << "No arguments\n"; }
+        C(int i) { cout << "Argument is " << i << "\n"; }
+    }
+
+in Python you have to write a single constructor that catches all +cases using default arguments. For example: +

+

+    class C:
+        def __init__(self, i=None):
+            if i is None:
+                print "No arguments"
+            else:
+                print "Argument is", i
+
+This is not entirely equivalent, but close enough in practice. +

+You could also try a variable-length argument list, e.g. +

+

+        def __init__(self, *args):
+            ....
+
+The same approach works for all method definitions. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Apr 20 11:55:55 1998 by +GvR +

+ +


+

4.76. How do I pass keyword arguments from one method to another?

+Use apply. For example: +

+

+    class Account:
+        def __init__(self, **kw):
+            self.accountType = kw.get('accountType')
+            self.balance = kw.get('balance')
+
+
+    class CheckingAccount(Account):
+        def __init__(self, **kw):
+            kw['accountType'] = 'checking'
+            apply(Account.__init__, (self,), kw)
+
+
+    myAccount = CheckingAccount(balance=100.00)
+
+In Python 2.0 you can call it directly using the new ** syntax: +

+

+    class CheckingAccount(Account):
+        def __init__(self, **kw):
+            kw['accountType'] = 'checking'
+            Account.__init__(self, **kw)
+
+or more generally: +

+

+ >>> def f(x, *y, **z):
+ ...  print x,y,z
+ ...
+ >>> Y = [1,2,3]
+ >>> Z = {'foo':3,'bar':None}
+ >>> f('hello', *Y, **Z)
+ hello (1, 2, 3) {'foo': 3, 'bar': None}
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Dec 28 13:04:01 2000 by +Bjorn Pettersen +

+ +


+

4.77. What module should I use to help with generating HTML?

+Check out HTMLgen written by Robin Friedrich. It's a class library +of objects corresponding to all the HTML 3.2 markup tags. It's used +when you are writing in Python and wish to synthesize HTML pages for +generating a web or for CGI forms, etc. +

+It can be found in the FTP contrib area on python.org or on the +Starship. Use the search engines there to locate the latest version. +

+It might also be useful to consider DocumentTemplate, which offers clear +separation between Python code and HTML code. DocumentTemplate is part +of the Bobo objects publishing system (http:/www.digicool.com/releases) +but can be used independantly of course! +

+ +Edit this entry / +Log info + +/ Last changed on Fri Aug 28 09:54:58 1998 by +GvR +

+ +


+

4.78. How do I create documentation from doc strings?

+Use gendoc, by Daniel Larson. See +

+http://starship.python.net/crew/danilo/ +

+It can create HTML from the doc strings in your Python source code. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Oct 7 17:15:51 2002 by +Phil Rittenhouse +

+ +


+

4.79. How do I read (or write) binary data?

+For complex data formats, it's best to use +use the struct module. It's documented in the library reference. +It allows you to take a string read from a file containing binary +data (usually numbers) and convert it to Python objects; and vice +versa. +

+For example, the following code reads two 2-byte integers +and one 4-byte integer in big-endian format from a file: +

+

+  import struct
+
+
+  f = open(filename, "rb")  # Open in binary mode for portability
+  s = f.read(8)
+  x, y, z = struct.unpack(">hhl", s)
+
+The '>' in the format string forces bin-endian data; the letter +'h' reads one "short integer" (2 bytes), and 'l' reads one +"long integer" (4 bytes) from the string. +

+For data that is more regular (e.g. a homogeneous list of ints or +floats), you can also use the array module, also documented +in the library reference. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Oct 7 09:16:45 1998 by +GvR +

+ +


+

4.80. I can't get key bindings to work in Tkinter

+An oft-heard complaint is that event handlers bound to events +with the bind() method don't get handled even when the appropriate +key is pressed. +

+The most common cause is that the widget to which the binding applies +doesn't have "keyboard focus". Check out the Tk documentation +for the focus command. Usually a widget is given the keyboard +focus by clicking in it (but not for labels; see the taketocus +option). +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jun 12 09:37:33 1998 by +GvR +

+ +


+

4.81. "import crypt" fails

+[Unix] +

+Starting with Python 1.5, the crypt module is disabled by default. +In order to enable it, you must go into the Python source tree and +edit the file Modules/Setup to enable it (remove a '#' sign in +front of the line starting with '#crypt'). Then rebuild. +You may also have to add the string '-lcrypt' to that same line. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Aug 5 08:57:09 1998 by +GvR +

+ +


+

4.82. Are there coding standards or a style guide for Python programs?

+Yes, Guido has written the "Python Style Guide". See +http://www.python.org/doc/essays/styleguide.html +

+ +Edit this entry / +Log info + +/ Last changed on Tue Sep 29 09:50:27 1998 by +Joseph VanAndel +

+ +


+

4.83. How do I freeze Tkinter applications?

+Freeze is a tool to create stand-alone applications (see 4.28). +

+When freezing Tkinter applications, the applications will not be +truly stand-alone, as the application will still need the tcl and +tk libraries. +

+One solution is to ship the application with the tcl and tk libraries, +and point to them at run-time using the TCL_LIBRARY and TK_LIBRARY +environment variables. +

+To get truly stand-alone applications, the Tcl scripts that form +the library have to be integrated into the application as well. One +tool supporting that is SAM (stand-alone modules), which is part +of the Tix distribution (http://tix.mne.com). Build Tix with SAM +enabled, perform the appropriate call to Tclsam_init etc inside +Python's Modules/tkappinit.c, and link with libtclsam +and libtksam (you might include the Tix libraries as well). +

+ +Edit this entry / +Log info + +/ Last changed on Wed Jan 20 17:35:01 1999 by +Martin v. Löwis +

+ +


+

4.84. How do I create static class data and static class methods?

+[Tim Peters, tim_one@email.msn.com] +

+Static data (in the sense of C++ or Java) is easy; static methods (again in the sense of C++ or Java) are not supported directly. +

+STATIC DATA +

+For example, +

+

+    class C:
+        count = 0   # number of times C.__init__ called
+
+
+        def __init__(self):
+            C.count = C.count + 1
+
+
+        def getcount(self):
+            return C.count  # or return self.count
+
+c.count also refers to C.count for any c such that isinstance(c, C) holds, unless overridden by c itself or by some class on the base-class search path from c.__class__ back to C. +

+Caution: within a method of C, +

+

+    self.count = 42
+
+creates a new and unrelated instance vrbl named "count" in self's own dict. So rebinding of a class-static data name needs the +

+

+    C.count = 314
+
+form whether inside a method or not. +

+

+STATIC METHODS +

+Static methods (as opposed to static data) are unnatural in Python, because +

+

+    C.getcount
+
+returns an unbound method object, which can't be invoked without supplying an instance of C as the first argument. +

+The intended way to get the effect of a static method is via a module-level function: +

+

+    def getcount():
+        return C.count
+
+If your code is structured so as to define one class (or tightly related class hierarchy) per module, this supplies the desired encapsulation. +

+Several tortured schemes for faking static methods can be found by searching DejaNews. Most people feel such cures are worse than the disease. Perhaps the least obnoxious is due to Pekka Pessi (mailto:ppessi@hut.fi): +

+

+    # helper class to disguise function objects
+    class _static:
+        def __init__(self, f):
+            self.__call__ = f
+
+
+    class C:
+        count = 0
+
+
+        def __init__(self):
+            C.count = C.count + 1
+
+
+        def getcount():
+            return C.count
+        getcount = _static(getcount)
+
+
+        def sum(x, y):
+            return x + y
+        sum = _static(sum)
+
+
+    C(); C()
+    c = C()
+    print C.getcount()  # prints 3
+    print c.getcount()  # prints 3
+    print C.sum(27, 15) # prints 42
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Jan 21 21:35:38 1999 by +Tim Peters +

+ +


+

4.85. __import__('x.y.z') returns <module 'x'>; how do I get z?

+Try +

+

+   __import__('x.y.z').y.z
+
+For more realistic situations, you may have to do something like +

+

+   m = __import__(s)
+   for i in string.split(s, ".")[1:]:
+       m = getattr(m, i)
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Jan 28 11:01:43 1999 by +GvR +

+ +


+

4.86. Basic thread wisdom

+Please note that there is no way to take advantage of +multiprocessor hardware using the Python thread model. The interpreter +uses a global interpreter lock (GIL), +which does not allow multiple threads to be concurrently active. +

+If you write a simple test program like this: +

+

+  import thread
+  def run(name, n):
+      for i in range(n): print name, i
+  for i in range(10):
+      thread.start_new(run, (i, 100))
+
+none of the threads seem to run! The reason is that as soon as +the main thread exits, all threads are killed. +

+A simple fix is to add a sleep to the end of the program, +sufficiently long for all threads to finish: +

+

+  import thread, time
+  def run(name, n):
+      for i in range(n): print name, i
+  for i in range(10):
+      thread.start_new(run, (i, 100))
+  time.sleep(10) # <----------------------------!
+
+But now (on many platforms) the threads don't run in parallel, +but appear to run sequentially, one at a time! The reason is +that the OS thread scheduler doesn't start a new thread until +the previous thread is blocked. +

+A simple fix is to add a tiny sleep to the start of the run +function: +

+

+  import thread, time
+  def run(name, n):
+      time.sleep(0.001) # <---------------------!
+      for i in range(n): print name, i
+  for i in range(10):
+      thread.start_new(run, (i, 100))
+  time.sleep(10)
+
+Some more hints: +

+Instead of using a time.sleep() call at the end, it's +better to use some kind of semaphore mechanism. One idea is to +use a the Queue module to create a queue object, let each thread +append a token to the queue when it finishes, and let the main +thread read as many tokens from the queue as there are threads. +

+Use the threading module instead of the thread module. It's part +of Python since version 1.5.1. It takes care of all these details, +and has many other nice features too! +

+ +Edit this entry / +Log info + +/ Last changed on Fri Feb 7 16:21:55 2003 by +GvR +

+ +


+

4.87. Why doesn't closing sys.stdout (stdin, stderr) really close it?

+Python file objects are a high-level layer of abstraction on top of C streams, which in turn are a medium-level layer of abstraction on top of (among other things) low-level C file descriptors. +

+For most file objects f you create in Python via the builtin "open" function, f.close() marks the Python file object as being closed from Python's point of view, and also arranges to close the underlying C stream. This happens automatically too, in f's destructor, when f becomes garbage. +

+But stdin, stdout and stderr are treated specially by Python, because of the special status also given to them by C: doing +

+

+    sys.stdout.close() # ditto for stdin and stderr
+
+marks the Python-level file object as being closed, but does not close the associated C stream (provided sys.stdout is still bound to its default value, which is the stream C also calls "stdout"). +

+To close the underlying C stream for one of these three, you should first be sure that's what you really want to do (e.g., you may confuse the heck out of extension modules trying to do I/O). If it is, use os.close: +

+

+    os.close(0)   # close C's stdin stream
+    os.close(1)   # close C's stdout stream
+    os.close(2)   # close C's stderr stream
+
+

+ +Edit this entry / +Log info + +/ Last changed on Sat Apr 17 02:22:35 1999 by +Tim Peters +

+ +


+

4.88. What kinds of global value mutation are thread-safe?

+[adapted from c.l.py responses by Gordon McMillan & GvR] +

+A global interpreter lock (GIL) is used internally to ensure that only one thread runs in the Python VM at a time. In general, Python offers to switch among threads only between bytecode instructions (how frequently it offers to switch can be set via sys.setcheckinterval). Each bytecode instruction-- and all the C implementation code reached from it --is therefore atomic. +

+In theory, this means an exact accounting requires an exact understanding of the PVM bytecode implementation. In practice, it means that operations on shared vrbls of builtin data types (ints, lists, dicts, etc) that "look atomic" really are. +

+For example, these are atomic (L, L1, L2 are lists, D, D1, D2 are dicts, x, y +are objects, i, j are ints): +

+

+    L.append(x)
+    L1.extend(L2)
+    x = L[i]
+    x = L.pop()
+    L1[i:j] = L2
+    L.sort()
+    x = y
+    x.field = y
+    D[x] = y
+    D1.update(D2)
+    D.keys()
+
+These aren't: +

+

+    i = i+1
+    L.append(L[-1])
+    L[i] = L[j]
+    D[x] = D[x] + 1
+
+Note: operations that replace other objects may invoke those other objects' __del__ method when their reference count reaches zero, and that can affect things. This is especially true for the mass updates to dictionaries and lists. When in doubt, use a mutex! +

+ +Edit this entry / +Log info + +/ Last changed on Fri Feb 7 16:21:03 2003 by +GvR +

+ +


+

4.89. How do I modify a string in place?

+Strings are immutable (see question 6.2) so you cannot modify a string +directly. If you need an object with this ability, try converting the +string to a list or take a look at the array module. +

+

+    >>> s = "Hello, world"
+    >>> a = list(s)
+    >>> print a
+    ['H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd']
+    >>> a[7:] = list("there!")
+    >>> import string
+    >>> print string.join(a, '')
+    'Hello, there!'
+
+
+    >>> import array
+    >>> a = array.array('c', s)
+    >>> print a
+    array('c', 'Hello, world')
+    >>> a[0] = 'y' ; print a
+    array('c', 'yello world')
+    >>> a.tostring()
+    'yello, world'
+
+

+ +Edit this entry / +Log info + +/ Last changed on Tue May 18 01:22:47 1999 by +Andrew Dalke +

+ +


+

4.90. How to pass on keyword/optional parameters/arguments

+Q: How can I pass on optional or keyword parameters from one function to another? +

+

+	def f1(a, *b, **c):
+		...
+
+A: In Python 2.0 and above: +

+

+	def f2(x, *y, **z):
+		...
+		z['width']='14.3c'
+		...
+		f1(x, *y, **z)
+
+
+   Note: y can be any sequence (e.g., list or tuple) and z must be a dict.
+
+

+A: For versions prior to 2.0, use 'apply', like: +

+

+	def f2(x, *y, **z):
+		...
+		z['width']='14.3c'
+		...
+		apply(f1, (x,)+y, z)
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 07:20:56 2002 by +Matthias Urlichs +

+ +


+

4.91. How can I get a dictionary to display its keys in a consistent order?

+In general, dictionaries store their keys in an unpredictable order, +so the display order of a dictionary's elements will be similarly +unpredictable. +(See +Question 6.12 +to understand why this is so.) +

+This can be frustrating if you want to save a printable version to a +file, make some changes and then compare it with some other printed +dictionary. If you have such needs you can subclass UserDict.UserDict +to create a SortedDict class that prints itself in a predictable order. +Here's one simpleminded implementation of such a class: +

+

+  import UserDict, string
+
+
+  class SortedDict(UserDict.UserDict):
+    def __repr__(self):
+      result = []
+      append = result.append
+      keys = self.data.keys()
+      keys.sort()
+      for k in keys:
+        append("%s: %s" % (`k`, `self.data[k]`))
+      return "{%s}" % string.join(result, ", ")
+
+
+    ___str__ = __repr__
+
+

+This will work for many common situations you might encounter, though +it's far from a perfect solution. (It won't have any effect on the +pprint module and does not transparently handle values that are or +contain dictionaries. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Sep 16 17:31:06 1999 by +Skip Montanaro +

+ +


+

4.92. Is there a Python tutorial?

+Yes. See question 1.20 at +http://www.python.org/doc/FAQ.html#1.20 +

+ +Edit this entry / +Log info + +/ Last changed on Sat Dec 4 16:04:00 1999 by +TAB +

+ +


+

4.93. Deleted

+See 4.28 +

+ +Edit this entry / +Log info + +/ Last changed on Tue May 28 20:40:37 2002 by +GvR +

+ +


+

4.94. How do I get a single keypress without blocking?

+There are several solutions; some involve using curses, which is a +pretty big thing to learn. Here's a solution without curses. (see also 4.74, for Windows, see question 8.2) +

+

+  import termios, fcntl, sys, os
+  fd = sys.stdin.fileno()
+
+
+  oldterm = termios.tcgetattr(fd)
+  newattr = termios.tcgetattr(fd)
+  newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
+  termios.tcsetattr(fd, termios.TCSANOW, newattr)
+
+
+  oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
+  fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)
+
+
+  try:
+      while 1:
+          try:
+              c = sys.stdin.read(1)
+              print "Got character", `c`
+          except IOError: pass
+  finally:
+      termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
+      fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
+
+

+You need the termios and the fcntl module for any of this to work, +and I've only tried it on Linux, though it should work elsewhere. +

+In this code, characters are read and printed one at a time. +

+termios.tcsetattr() turns off stdin's echoing and disables canonical +mode. fcntl.fnctl() is used to obtain stdin's file descriptor flags +and modify them for non-blocking mode. Since reading stdin when it is +empty results in an IOError, this error is caught and ignored. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Oct 24 00:39:06 2002 by +chris +

+ +


+

4.95. Is there an equivalent to Perl chomp()? (Remove trailing newline from string)

+There are two partial substitutes. If you want to remove all trailing +whitespace, use the method string.rstrip(). Otherwise, if there is only +one line in the string, use string.splitlines()[0]. +

+

+ -----------------------------------------------------------------------
+
+
+ rstrip() is too greedy, it strips all trailing white spaces.
+ splitlines() takes ControlM as line boundary.
+ Consider these strings as input:
+   "python python    \r\n"
+   "python\rpython\r\n"
+   "python python   \r\r\r\n"
+ The results from rstrip()/splitlines() are perhaps not what we want.
+
+
+ It seems re can perform this task.
+
+

+

+ #!/usr/bin/python 
+ # requires python2                                                             
+
+
+ import re, os, StringIO
+
+
+ lines=StringIO.StringIO(
+   "The Python Programming Language\r\n"
+   "The Python Programming Language \r \r \r\r\n"
+   "The\rProgramming\rLanguage\r\n"
+   "The\rProgramming\rLanguage\r\r\r\r\n"
+   "The\r\rProgramming\r\rLanguage\r\r\r\r\n"
+ )
+
+
+ ln=re.compile("(?:[\r]?\n|\r)$") # dos:\r\n, unix:\n, mac:\r, others: unknown
+ # os.linesep does not work if someone ftps(in binary mode) a dos/mac text file
+ # to your unix box
+ #ln=re.compile(os.linesep + "$")
+
+
+ while 1:
+   s=lines.readline()
+   if not s: break
+   print "1.(%s)" % `s.rstrip()`
+   print "2.(%s)" % `ln.sub( "", s, 1)`
+   print "3.(%s)" % `s.splitlines()[0]`
+   print "4.(%s)" % `s.splitlines()`
+   print
+
+
+ lines.close()
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed Aug 8 09:51:34 2001 by +Crystal +

+ +


+

4.96. Why is join() a string method when I'm really joining the elements of a (list, tuple, sequence)?

+Strings became much more like other standard types starting in release 1.6, when methods were added which give the same functionality that has always been available using the functions of the string module. These new methods have been widely accepted, but the one which appears to make (some) programmers feel uncomfortable is: +

+

+    ", ".join(['1', '2', '4', '8', '16'])
+
+which gives the result +

+

+    "1, 2, 4, 8, 16"
+
+There are two usual arguments against this usage. +

+The first runs along the lines of: "It looks really ugly using a method of a string literal (string constant)", to which the answer is that it might, but a string literal is just a fixed value. If the methods are to be allowed on names bound to strings there is no logical reason to make them unavailable on literals. Get over it! +

+The second objection is typically cast as: "I am really telling a sequence to join its members together with a string constant". Sadly, you aren't. For some reason there seems to be much less difficulty with having split() as a string method, since in that case it is easy to see that +

+

+    "1, 2, 4, 8, 16".split(", ")
+
+is an instruction to a string literal to return the substrings delimited by the given separator (or, by default, arbitrary runs of white space). In this case a Unicode string returns a list of Unicode strings, an ASCII string returns a list of ASCII strings, and everyone is happy. +

+join() is a string method because in using it you are telling the separator string to iterate over an arbitrary sequence, forming string representations of each of the elements, and inserting itself between the elements' representations. This method can be used with any argument which obeys the rules for sequence objects, inluding any new classes you might define yourself. +

+Because this is a string method it can work for Unicode strings as well as plain ASCII strings. If join() were a method of the sequence types then the sequence types would have to decide which type of string to return depending on the type of the separator. +

+If none of these arguments persuade you, then for the moment you can continue to use the join() function from the string module, which allows you to write +

+

+    string.join(['1', '2', '4', '8', '16'], ", ")
+
+You will just have to try and forget that the string module actually uses the syntax you are compaining about to implement the syntax you prefer! +

+ +Edit this entry / +Log info + +/ Last changed on Fri Aug 2 15:51:58 2002 by +Steve Holden +

+ +


+

4.97. How can my code discover the name of an object?

+Generally speaking, it can't, because objects don't really have names. The assignment statement does not store the assigned value in the name but a reference to it. Essentially, assignment creates a binding of a name to a value. The same is true of def and class statements, but in that case the value is a callable. Consider the following code: +

+

+    class A:
+        pass
+
+
+    B = A
+
+
+    a = B()
+    b = a
+    print b
+    <__main__.A instance at 016D07CC>
+    print a
+    <__main__.A instance at 016D07CC>
+
+

+Arguably the class has a name: even though it is bound to two names and invoked through the name B the created instance is still reported as an instance of class A. However, it is impossible to say whether the instance's name is a or b, since both names are bound to the same value. +

+Generally speaking it should not be necessary for your code to "know the names" of particular values. Unless you are deliberately writing introspective programs, this is usually an indication that a change of approach might be beneficial. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 8 03:53:39 2001 by +Steve Holden +

+ +


+

4.98. Why are floating point calculations so inaccurate?

+The development version of the Python Tutorial now contains an Appendix with more info: +
+    http://www.python.org/doc/current/tut/node14.html
+
+People are often very surprised by results like this: +

+

+ >>> 1.2-1.0
+ 0.199999999999999996
+
+And think it is a bug in Python. It's not. It's a problem caused by +the internal representation of a floating point number. A floating point +number is stored as a fixed number of binary digits. +

+In decimal math, there are many numbers that can't be represented +with a fixed number of decimal digits, i.e. +1/3 = 0.3333333333....... +

+In the binary case, 1/2 = 0.1, 1/4 = 0.01, 1/8 = 0.001, etc. There are +a lot of numbers that can't be represented. The digits are cut off at +some point. +

+Since Python 1.6, a floating point's repr() function prints as many +digits are necessary to make eval(repr(f)) == f true for any float f. +The str() function prints the more sensible number that was probably +intended: +

+

+ >>> 0.2
+ 0.20000000000000001
+ >>> print 0.2
+ 0.2
+
+Again, this has nothing to do with Python, but with the way the +underlying C platform handles floating points, and ultimately with +the inaccuracy you'll always have when writing down numbers of fixed +number of digit strings. +

+One of the consequences of this is that it is dangerous to compare +the result of some computation to a float with == ! +Tiny inaccuracies may mean that == fails. +

+Instead try something like this: +

+

+ epsilon = 0.0000000000001 # Tiny allowed error
+ expected_result = 0.4
+
+
+ if expected_result-epsilon <= computation() <= expected_result+epsilon:
+    ...
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Apr 1 22:18:47 2002 by +Fred Drake +

+ +


+

4.99. I tried to open Berkeley DB file, but bsddb produces bsddb.error: (22, 'Invalid argument'). Help! How can I restore my data?

+Don't panic! Your data are probably intact. The most frequent cause +for the error is that you tried to open an earlier Berkeley DB file +with a later version of the Berkeley DB library. +

+Many Linux systems now have all three versions of Berkeley DB +available. If you are migrating from version 1 to a newer version use +db_dump185 to dump a plain text version of the database. +If you are migrating from version 2 to version 3 use db2_dump to create +a plain text version of the database. In either case, use db_load to +create a new native database for the latest version installed on your +computer. If you have version 3 of Berkeley DB installed, you should +be able to use db2_load to create a native version 2 database. +

+You should probably move away from Berkeley DB version 1 files because +the hash file code contains known bugs that can corrupt your data. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Aug 29 16:04:29 2001 by +Skip Montanaro +

+ +


+

4.100. What are the "best practices" for using import in a module?

+First, the standard modules are great. Use them! The standard Python library is large and varied. Using modules can save you time and effort and will reduce maintainenance cost of your code. (Other programs are dedicated to supporting and fixing bugs in the standard Python modules. Coworkers may also be familiar with themodules that you use, reducing the amount of time it takes them to understand your code.) +

+The rest of this answer is largely a matter of personal preference, but here's what some newsgroup posters said (thanks to all who responded) +

+In general, don't use +

+ from modulename import *
+
+Doing so clutters the importer's namespace. Some avoid this idiom even with the few modules that were designed to be imported in this manner. (Modules designed in this manner include Tkinter, thread, and wxPython.) +

+Import modules at the top of a file, one module per line. Doing so makes it clear what other modules your code requires and avoids questions of whether the module name is in scope. Using one import per line makes it easy to add and delete module imports. +

+Move imports into a local scope (such as at the top of a function definition) if there are a lot of imports, and you're trying to avoid the cost (lots of initialization time) of many imports. This technique is especially helpful if many of the imports are unnecessary depending on how the program executes. You may also want to move imports into a function if the modules are only ever used in that function. Note that loading a module the first time may be expensive (because of the one time initialization of the module) but that loading a module multiple times is virtually free (a couple of dictionary lookups). Even if the module name has gone out of scope, the module is probably available in sys.modules. Thus, there isn't really anything wrong with putting no imports at the module level (if they aren't needed) and putting all of the imports at the function level. +

+It is sometimes necessary to move imports to a function or class to avoid problems with circular imports. Gordon says: +

+ Circular imports are fine where both modules use the "import <module>"
+ form of import. They fail when the 2nd module wants to grab a name
+ out of the first ("from module import name") and the import is at
+ the top level. That's because names in the 1st are not yet available,
+ (the first module is busy importing the 2nd).  
+
+In this case, if the 2nd module is only used in one function, then the import can easily be moved into that function. By the time the import is called, the first module will have finished initializing, and the second module can do its import. +

+It may also be necessary to move imports out of the top level of code +if some of the modules are platform-specific. In that case, it may not even be possible to import all of the modules at the top of the file. In this case, importing the correct modules in the corresponding platform-specific code is a good option. +

+If only instances of a specific class uses a module, then it is reasonable to import the module in the class's __init__ method and then assign the module to an instance variable so that the module is always available (via that instance variable) during the life of the object. Note that to delay an import until the class is instantiated, the import must be inside a method. Putting the import inside the class but outside of any method still causes the import to occur when the module is initialized. +

+ +Edit this entry / +Log info + +/ Last changed on Sat Aug 4 04:44:47 2001 by +TAB +

+ +


+

4.101. Is there a tool to help find bugs or perform static analysis?

+Yes. PyChecker is a static analysis tool for finding bugs +in Python source code as well as warning about code complexity +and style. +

+You can get PyChecker from: http://pychecker.sf.net. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Aug 10 15:42:11 2001 by +Neal +

+ +


+

4.102. UnicodeError: ASCII [decoding,encoding] error: ordinal not in range(128)

+This error indicates that your Python installation can handle +only 7-bit ASCII strings. There are a couple ways to fix or +workaround the problem. +

+If your programs must handle data in arbitary character set encodings, the environment the application runs in will generally identify the encoding of the data it is handing you. You need to convert the input to Unicode data using that encoding. For instance, a program that handles email or web input will typically find character set encoding information in Content-Type headers. This can then be used to properly convert input data to Unicode. Assuming the string referred to by "value" is encoded as UTF-8: +

+

+    value = unicode(value, "utf-8")
+
+will return a Unicode object. If the data is not correctly encoded as UTF-8, the above call will raise a UnicodeError. +

+If you only want strings coverted to Unicode which have non-ASCII data, you can try converting them first assuming an ASCII encoding, and then generate Unicode objects if that fails: +

+

+    try:
+        x = unicode(value, "ascii")
+    except UnicodeError:
+        value = unicode(value, "utf-8")
+    else:
+        # value was valid ASCII data
+        pass
+
+

+If you normally use a character set encoding other than US-ASCII and only need to handle data in that encoding, the simplest way to fix the problem may be simply to set the encoding in sitecustomize.py. The following code is just a modified version of the encoding setup code from site.py with the relevant lines uncommented. +

+

+    # Set the string encoding used by the Unicode implementation.
+    # The default is 'ascii'
+    encoding = "ascii" # <= CHANGE THIS if you wish
+
+
+    # Enable to support locale aware default string encodings.
+    import locale
+    loc = locale.getdefaultlocale()
+    if loc[1]:
+        encoding = loc[1]
+    if encoding != "ascii":
+        import sys
+        sys.setdefaultencoding(encoding)
+
+

+Also note that on Windows, there is an encoding known as "mbcs", which uses an encoding specific to your current locale. In many cases, and particularly when working with COM, this may be an appropriate default encoding to use. +

+ +Edit this entry / +Log info + +/ Last changed on Sat Apr 13 04:45:41 2002 by +Skip Montanaro +

+ +


+

4.103. Using strings to call functions/methods

+There are various techniques: +

+* Use a dictionary pre-loaded with strings and functions. The primary +advantage of this technique is that the strings do not need to match the +names of the functions. This is also the primary technique used to +emulate a case construct: +

+

+    def a():
+        pass
+
+
+    def b():
+        pass
+
+
+    dispatch = {'go': a, 'stop': b}  # Note lack of parens for funcs
+
+
+    dispatch[get_input()]()  # Note trailing parens to call function
+
+* Use the built-in function getattr(): +

+

+    import foo
+    getattr(foo, 'bar')()
+
+Note that getattr() works on any object, including classes, class +instances, modules, and so on. +

+This is used in several places in the standard library, like +this: +

+

+    class Foo:
+        def do_foo(self):
+            ...
+
+
+        def do_bar(self):
+            ...
+
+
+     f = getattr(foo_instance, 'do_' + opname)
+     f()
+
+

+* Use locals() or eval() to resolve the function name: +

+def myFunc(): +

+    print "hello"
+
+fname = "myFunc" +

+f = locals()[fname] +f() +

+f = eval(fname) +f() +

+Note: Using eval() can be dangerous. If you don't have absolute control +over the contents of the string, all sorts of things could happen... +

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 21 08:14:58 2002 by +Erno Kuusela +

+ +


+

4.104. How fast are exceptions?

+A try/except block is extremely efficient. Actually executing an +exception is expensive. In older versions of Python (prior to 2.0), it +was common to code this idiom: +

+

+    try:
+        value = dict[key]
+    except KeyError:
+        dict[key] = getvalue(key)
+        value = dict[key]
+
+This idiom only made sense when you expected the dict to have the key +95% of the time or more; other times, you coded it like this: +

+

+    if dict.has_key(key):
+        value = dict[key]
+    else:
+        dict[key] = getvalue(key)
+        value = dict[key]
+
+In Python 2.0 and higher, of course, you can code this as +

+

+    value = dict.setdefault(key, getvalue(key))
+
+However this evaluates getvalue(key) always, regardless of whether it's needed or not. So if it's slow or has a side effect you should use one of the above variants. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Dec 9 10:12:30 2002 by +Yeti +

+ +


+

4.105. Sharing global variables across modules

+The canonical way to share information across modules within a single +program is to create a special module (often called config or cfg). +Just import the config module in all modules of your application; the +module then becomes available as a global name. Because there is only +one instance of each module, any changes made to the module object get +reflected everywhere. For example: +

+config.py: +

+

+    pass
+
+mod.py: +

+

+    import config
+    config.x = 1
+
+main.py: +

+

+    import config
+    import mod
+    print config.x
+
+Note that using a module is also the basis for implementing the +Singleton design pattern, for the same reason. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Apr 23 23:07:19 2002 by +Aahz +

+ +


+

4.106. Why is cPickle so slow?

+Use the binary option. We'd like to make that the default, but it would +break backward compatibility: +

+

+    largeString = 'z' * (100 * 1024)
+    myPickle = cPickle.dumps(largeString, 1)
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Aug 22 19:54:25 2002 by +Aahz +

+ +


+

4.107. When importing module XXX, why do I get "undefined symbol: PyUnicodeUCS2_..." ?

+You are using a version of Python that uses a 4-byte representation for +Unicode characters, but the extension module you are importing (possibly +indirectly) was compiled using a Python that uses a 2-byte representation +for Unicode characters (the default). +

+If instead the name of the undefined symbol starts with PyUnicodeUCS4_, +the problem is the same by the relationship is reversed: Python was +built using 2-byte Unicode characters, and the extension module was +compiled using a Python with 4-byte Unicode characters. +

+This can easily occur when using pre-built extension packages. RedHat +Linux 7.x, in particular, provides a "python2" binary that is compiled +with 4-byte Unicode. This only causes the link failure if the extension +uses any of the PyUnicode_*() functions. It is also a problem if if an +extension uses any of the Unicode-related format specifiers for +Py_BuildValue (or similar) or parameter-specifications for +PyArg_ParseTuple(). +

+You can check the size of the Unicode character a Python interpreter is +using by checking the value of sys.maxunicode: +

+

+  >>> import sys
+  >>> if sys.maxunicode > 65535:
+  ...     print 'UCS4 build'
+  ... else:
+  ...     print 'UCS2 build'
+
+The only way to solve this problem is to use extension modules compiled +with a Python binary built using the same size for Unicode characters. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Aug 27 15:00:17 2002 by +Fred Drake +

+ +


+

4.108. How do I create a .pyc file?

+QUESTION: +

+I have a module and I wish to generate a .pyc file. +How do I do it? Everything I read says that generation of a .pyc file is +"automatic", but I'm not getting anywhere. +

+

+ANSWER: +

+When a module is imported for the first time (or when the source is more +recent than the current compiled file) a .pyc file containing the compiled code should be created in the +same directory as the .py file. +

+One reason that a .pyc file may not be created is permissions problems with the directory. This can happen, for example, if you develop as one user but run as another, such as if you are testing with a web server. +

+However, in most cases, that's not the problem. +

+Creation of a .pyc file is "automatic" if you are importing a module and Python has the +ability (permissions, free space, etc...) to write the compiled module +back to the directory. But note that running Python on a top level script is not considered an +import and so no .pyc will be created automatically. For example, if you have a top-level module abc.py that imports another module xyz.py, when you run abc, xyz.pyc will be created since xyz is imported, but no abc.pyc file will be created since abc isn't imported. +

+If you need to create abc.pyc -- that is, to create a .pyc file for a +module that is not imported -- you can. (Look up +the py_compile and compileall modules in the Library Reference.) +

+You can manually compile any module using the "py_compile" module. One +way is to use the compile() function in that module interactively: +

+

+    >>> import py_compile
+    >>> py_compile.compile('abc.py')
+
+This will write the .pyc to the same location as abc.py (or you +can override that with the optional parameter cfile). +

+You can also automatically compile all files in a directory or +directories using the "compileall" module, which can also be run +straight from the command line. +

+You can do it from the shell (or DOS) prompt by entering: +

+       python compile.py abc.py
+
+or +
+       python compile.py *
+
+Or you can write a script to do it on a list of filenames that you enter. +

+

+     import sys
+     from py_compile import compile
+
+
+     if len(sys.argv) <= 1:
+        sys.exit(1)
+
+
+     for file in sys.argv[1:]:
+        compile(file)
+
+ACKNOWLEDGMENTS: +

+Steve Holden, David Bolen, Rich Somerfield, Oleg Broytmann, Steve Ferg +

+ +Edit this entry / +Log info + +/ Last changed on Wed Feb 12 15:58:25 2003 by +Stephen Ferg +

+ +


+

5. Extending Python

+ +
+

5.1. Can I create my own functions in C?

+Yes, you can create built-in modules containing functions, +variables, exceptions and even new types in C. This is explained in +the document "Extending and Embedding the Python Interpreter" (http://www.python.org/doc/current/ext/ext.html). Also read the chapter +on dynamic loading. +

+There's more information on this in each of the Python books: +Programming Python, Internet Programming with Python, and Das Python-Buch +(in German). +

+ +Edit this entry / +Log info + +/ Last changed on Mon Dec 10 05:18:57 2001 by +Fred L. Drake, Jr. +

+ +


+

5.2. Can I create my own functions in C++?

+Yes, using the C-compatibility features found in C++. Basically +you place extern "C" { ... } around the Python include files and put +extern "C" before each function that is going to be called by the +Python interpreter. Global or static C++ objects with constructors +are probably not a good idea. +

+ +Edit this entry / +Log info +

+ +


+

5.3. How can I execute arbitrary Python statements from C?

+The highest-level function to do this is PyRun_SimpleString() which takes +a single string argument which is executed in the context of module +__main__ and returns 0 for success and -1 when an exception occurred +(including SyntaxError). If you want more control, use PyRun_String(); +see the source for PyRun_SimpleString() in Python/pythonrun.c. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 20:08:14 1997 by +Bill Tutt +

+ +


+

5.4. How can I evaluate an arbitrary Python expression from C?

+Call the function PyRun_String() from the previous question with the +start symbol eval_input (Py_eval_input starting with 1.5a1); it +parses an expression, evaluates it and returns its value. +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 21 22:23:18 1997 by +David Ascher +

+ +


+

5.5. How do I extract C values from a Python object?

+That depends on the object's type. If it's a tuple, +PyTupleSize(o) returns its length and PyTuple_GetItem(o, i) +returns its i'th item; similar for lists with PyListSize(o) +and PyList_GetItem(o, i). For strings, PyString_Size(o) returns +its length and PyString_AsString(o) a pointer to its value +(note that Python strings may contain null bytes so strlen() +is not safe). To test which type an object is, first make sure +it isn't NULL, and then use PyString_Check(o), PyTuple_Check(o), +PyList_Check(o), etc. +

+There is also a high-level API to Python objects which is +provided by the so-called 'abstract' interface -- read +Include/abstract.h for further details. It allows for example +interfacing with any kind of Python sequence (e.g. lists and tuples) +using calls like PySequence_Length(), PySequence_GetItem(), etc.) +as well as many other useful protocols. +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 21 22:34:20 1997 by +David Ascher +

+ +


+

5.6. How do I use Py_BuildValue() to create a tuple of arbitrary length?

+You can't. Use t = PyTuple_New(n) instead, and fill it with +objects using PyTuple_SetItem(t, i, o) -- note that this "eats" a +reference count of o. Similar for lists with PyList_New(n) and +PyList_SetItem(l, i, o). Note that you must set all the tuple items to +some value before you pass the tuple to Python code -- +PyTuple_New(n) initializes them to NULL, which isn't a valid Python +value. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jul 31 18:15:29 1997 by +Guido van Rossum +

+ +


+

5.7. How do I call an object's method from C?

+The PyObject_CallMethod() function can be used to call an arbitrary +method of an object. The parameters are the object, the name of the +method to call, a format string like that used with Py_BuildValue(), and the argument values: +

+

+    PyObject *
+    PyObject_CallMethod(PyObject *object, char *method_name,
+                        char *arg_format, ...);
+
+This works for any object that has methods -- whether built-in or +user-defined. You are responsible for eventually DECREF'ing the +return value. +

+To call, e.g., a file object's "seek" method with arguments 10, 0 +(assuming the file object pointer is "f"): +

+

+        res = PyObject_CallMethod(f, "seek", "(ii)", 10, 0);
+        if (res == NULL) {
+                ... an exception occurred ...
+        }
+        else {
+                Py_DECREF(res);
+        }
+
+Note that since PyObject_CallObject() always wants a tuple for the +argument list, to call a function without arguments, pass "()" for the +format, and to call a function with one argument, surround the argument +in parentheses, e.g. "(i)". +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jun 6 16:15:46 2002 by +Neal Norwitz +

+ +


+

5.8. How do I catch the output from PyErr_Print() (or anything that prints to stdout/stderr)?

+(Due to Mark Hammond): +

+In Python code, define an object that supports the "write()" method. +Redirect sys.stdout and sys.stderr to this object. +Call print_error, or just allow the standard traceback mechanism to +work. Then, the output will go wherever your write() method sends it. +

+The easiest way to do this is to use the StringIO class in the standard +library. +

+Sample code and use for catching stdout: +

+	>>> class StdoutCatcher:
+	...  def __init__(self):
+	...   self.data = ''
+	...  def write(self, stuff):
+	...   self.data = self.data + stuff
+	...  
+	>>> import sys
+	>>> sys.stdout = StdoutCatcher()
+	>>> print 'foo'
+	>>> print 'hello world!'
+	>>> sys.stderr.write(sys.stdout.data)
+	foo
+	hello world!
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed Dec 16 18:34:25 1998 by +Richard Jones +

+ +


+

5.9. How do I access a module written in Python from C?

+You can get a pointer to the module object as follows: +

+

+        module = PyImport_ImportModule("<modulename>");
+
+If the module hasn't been imported yet (i.e. it is not yet present in +sys.modules), this initializes the module; otherwise it simply returns +the value of sys.modules["<modulename>"]. Note that it doesn't enter +the module into any namespace -- it only ensures it has been +initialized and is stored in sys.modules. +

+You can then access the module's attributes (i.e. any name defined in +the module) as follows: +

+

+        attr = PyObject_GetAttrString(module, "<attrname>");
+
+Calling PyObject_SetAttrString(), to assign to variables in the module, also works. +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 21 22:56:40 1997 by +david ascher +

+ +


+

5.10. How do I interface to C++ objects from Python?

+Depending on your requirements, there are many approaches. To do +this manually, begin by reading the "Extending and Embedding" document +(Doc/ext.tex, see also http://www.python.org/doc/). Realize +that for the Python run-time system, there isn't a whole lot of +difference between C and C++ -- so the strategy to build a new Python +type around a C structure (pointer) type will also work for C++ +objects. +

+A useful automated approach (which also works for C) is SWIG: +http://www.swig.org/. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Oct 15 05:14:01 1999 by +Sjoerd Mullender +

+ +


+

5.11. mSQLmodule (or other old module) won't build with Python 1.5 (or later)

+Since python-1.4 "Python.h" will have the file includes needed in an +extension module. +Backward compatibility is dropped after version 1.4 and therefore +mSQLmodule.c will not build as "allobjects.h" cannot be found. +The following change in mSQLmodule.c is harmless when building it with +1.4 and necessary when doing so for later python versions: +

+Remove lines: +

+

+	#include "allobjects.h"
+	#include "modsupport.h"
+
+And insert instead: +

+

+	#include "Python.h"
+
+You may also need to add +

+

+                #include "rename2.h"
+
+if the module uses "old names". +

+This may happen with other ancient python modules as well, +and the same fix applies. +

+ +Edit this entry / +Log info + +/ Last changed on Sun Dec 21 02:03:35 1997 by +GvR +

+ +


+

5.12. I added a module using the Setup file and the make fails! Huh?

+Setup must end in a newline, if there is no newline there it gets +very sad. Aside from this possibility, maybe you have other +non-Python-specific linkage problems. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jun 24 15:54:01 1997 by +aaron watters +

+ +


+

5.13. I want to compile a Python module on my Red Hat Linux system, but some files are missing.

+Red Hat's RPM for Python doesn't include the +/usr/lib/python1.x/config/ directory, which contains various files required +for compiling Python extensions. +Install the python-devel RPM to get the necessary files. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 26 13:44:04 1999 by +A.M. Kuchling +

+ +


+

5.14. What does "SystemError: _PyImport_FixupExtension: module yourmodule not loaded" mean?

+This means that you have created an extension module named "yourmodule", but your module init function does not initialize with that name. +

+Every module init function will have a line similar to: +

+

+  module = Py_InitModule("yourmodule", yourmodule_functions);
+
+If the string passed to this function is not the same name as your extenion module, the SystemError will be raised. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 25 07:16:08 1999 by +Mark Hammond +

+ +


+

5.15. How to tell "incomplete input" from "invalid input"?

+Sometimes you want to emulate the Python interactive interpreter's +behavior, where it gives you a continuation prompt when the input +is incomplete (e.g. you typed the start of an "if" statement +or you didn't close your parentheses or triple string quotes), +but it gives you a syntax error message immediately when the input +is invalid. +

+In Python you can use the codeop module, which approximates the +parser's behavior sufficiently. IDLE uses this, for example. +

+The easiest way to do it in C is to call PyRun_InteractiveLoop() +(in a separate thread maybe) and let the Python interpreter handle +the input for you. You can also set the PyOS_ReadlineFunctionPointer +to point at your custom input function. See Modules/readline.c and +Parser/myreadline.c for more hints. +

+However sometimes you have to run the embedded Python interpreter +in the same thread as your rest application and you can't allow the +PyRun_InteractiveLoop() to stop while waiting for user input. +The one solution then is to call PyParser_ParseString() +and test for e.error equal to E_EOF (then the input is incomplete). +Sample code fragment, untested, inspired by code from Alex Farber: +

+

+  #include <Python.h>
+  #include <node.h>
+  #include <errcode.h>
+  #include <grammar.h>
+  #include <parsetok.h>
+  #include <compile.h>
+
+
+  int testcomplete(char *code)
+    /* code should end in \n */
+    /* return -1 for error, 0 for incomplete, 1 for complete */
+  {
+    node *n;
+    perrdetail e;
+
+
+    n = PyParser_ParseString(code, &_PyParser_Grammar,
+                             Py_file_input, &e);
+    if (n == NULL) {
+      if (e.error == E_EOF) 
+        return 0;
+      return -1;
+    }
+
+
+    PyNode_Free(n);
+    return 1;
+  }
+
+Another solution is trying to compile the received string with +Py_CompileString(). If it compiles fine - try to execute the returned +code object by calling PyEval_EvalCode(). Otherwise save the input for +later. If the compilation fails, find out if it's an error or just +more input is required - by extracting the message string from the +exception tuple and comparing it to the "unexpected EOF while parsing". +Here is a complete example using the GNU readline library (you may +want to ignore SIGINT while calling readline()): +

+

+  #include <stdio.h>
+  #include <readline.h>
+
+
+  #include <Python.h>
+  #include <object.h>
+  #include <compile.h>
+  #include <eval.h>
+
+
+  int main (int argc, char* argv[])
+  {
+    int i, j, done = 0;                          /* lengths of line, code */
+    char ps1[] = ">>> ";
+    char ps2[] = "... ";
+    char *prompt = ps1;
+    char *msg, *line, *code = NULL;
+    PyObject *src, *glb, *loc;
+    PyObject *exc, *val, *trb, *obj, *dum;
+
+
+    Py_Initialize ();
+    loc = PyDict_New ();
+    glb = PyDict_New ();
+    PyDict_SetItemString (glb, "__builtins__", PyEval_GetBuiltins ());
+
+
+    while (!done)
+    {
+      line = readline (prompt);
+
+
+      if (NULL == line)                          /* CTRL-D pressed */
+      {
+        done = 1;
+      }
+      else
+      {
+        i = strlen (line);
+
+
+        if (i > 0)
+          add_history (line);                    /* save non-empty lines */
+
+
+        if (NULL == code)                        /* nothing in code yet */
+          j = 0;
+        else
+          j = strlen (code);
+
+
+        code = realloc (code, i + j + 2);
+        if (NULL == code)                        /* out of memory */
+          exit (1);
+
+
+        if (0 == j)                              /* code was empty, so */
+          code[0] = '\0';                        /* keep strncat happy */
+
+
+        strncat (code, line, i);                 /* append line to code */
+        code[i + j] = '\n';                      /* append '\n' to code */
+        code[i + j + 1] = '\0';
+
+
+        src = Py_CompileString (code, "<stdin>", Py_single_input);       
+
+
+        if (NULL != src)                         /* compiled just fine - */
+        {
+          if (ps1  == prompt ||                  /* ">>> " or */
+              '\n' == code[i + j - 1])           /* "... " and double '\n' */
+          {                                               /* so execute it */
+            dum = PyEval_EvalCode ((PyCodeObject *)src, glb, loc);
+            Py_XDECREF (dum);
+            Py_XDECREF (src);
+            free (code);
+            code = NULL;
+            if (PyErr_Occurred ())
+              PyErr_Print ();
+            prompt = ps1;
+          }
+        }                                        /* syntax error or E_EOF? */
+        else if (PyErr_ExceptionMatches (PyExc_SyntaxError))           
+        {
+          PyErr_Fetch (&exc, &val, &trb);        /* clears exception! */
+
+
+          if (PyArg_ParseTuple (val, "sO", &msg, &obj) &&
+              !strcmp (msg, "unexpected EOF while parsing")) /* E_EOF */
+          {
+            Py_XDECREF (exc);
+            Py_XDECREF (val);
+            Py_XDECREF (trb);
+            prompt = ps2;
+          }
+          else                                   /* some other syntax error */
+          {
+            PyErr_Restore (exc, val, trb);
+            PyErr_Print ();
+            free (code);
+            code = NULL;
+            prompt = ps1;
+          }
+        }
+        else                                     /* some non-syntax error */
+        {
+          PyErr_Print ();
+          free (code);
+          code = NULL;
+          prompt = ps1;
+        }
+
+
+        free (line);
+      }
+    }
+
+
+    Py_XDECREF(glb);
+    Py_XDECREF(loc);
+    Py_Finalize();
+    exit(0);
+  }
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed Mar 15 09:47:24 2000 by +Alex Farber +

+ +


+

5.16. How do I debug an extension?

+When using gdb with dynamically loaded extensions, you can't set a +breakpoint in your extension until your extension is loaded. +

+In your .gdbinit file (or interactively), add the command +

+br _PyImport_LoadDynamicModule +

+

+$ gdb /local/bin/python +

+gdb) run myscript.py +

+gdb) continue # repeat until your extension is loaded +

+gdb) finish # so that your extension is loaded +

+gdb) br myfunction.c:50 +

+gdb) continue +

+ +Edit this entry / +Log info + +/ Last changed on Fri Oct 20 11:10:32 2000 by +Joe VanAndel +

+ +


+

5.17. How do I find undefined Linux g++ symbols, __builtin_new or __pure_virtural

+To dynamically load g++ extension modules, you must recompile python, relink python using g++ (change LINKCC in the python Modules Makefile), and link your extension module using g++ (e.g., "g++ -shared -o mymodule.so mymodule.o"). +

+ +Edit this entry / +Log info + +/ Last changed on Sun Jan 14 18:03:51 2001 by +douglas orr +

+ +


+

5.18. How do I define and create objects corresponding to built-in/extension types

+Usually you would like to be able to inherit from a Python type when +you ask this question. The bottom line for Python 2.2 is: types and classes are miscible. You build instances by calling classes, and you can build subclasses to your heart's desire. +

+You need to be careful when instantiating immutable types like integers or strings. See http://www.amk.ca/python/2.2/, section 2, for details. +

+Prior to version 2.2, Python (like Java) insisted that there are first-class and second-class objects (the former are types, the latter classes), and never the twain shall meet. +

+The library has, however, done a good job of providing class wrappers for the more commonly desired objects (see UserDict, UserList and UserString for examples), and more are always welcome if you happen to be in the mood to write code. These wrappers still exist in Python 2.2. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 10 15:14:07 2002 by +Matthias Urlichs +

+ +


+

6. Python's design

+ +
+

6.1. Why isn't there a switch or case statement in Python?

+You can do this easily enough with a sequence of +if... elif... elif... else. There have been some proposals for switch +statement syntax, but there is no consensus (yet) on whether and how +to do range tests. +

+ +Edit this entry / +Log info +

+ +


+

6.2. Why does Python use indentation for grouping of statements?

+Basically I believe that using indentation for grouping is +extremely elegant and contributes a lot to the clarity of the average +Python program. Most people learn to love this feature after a while. +Some arguments for it: +

+Since there are no begin/end brackets there cannot be a disagreement +between grouping perceived by the parser and the human reader. I +remember long ago seeing a C fragment like this: +

+

+        if (x <= y)
+                x++;
+                y--;
+        z++;
+
+and staring a long time at it wondering why y was being decremented +even for x > y... (And I wasn't a C newbie then either.) +

+Since there are no begin/end brackets, Python is much less prone to +coding-style conflicts. In C there are loads of different ways to +place the braces (including the choice whether to place braces around +single statements in certain cases, for consistency). If you're used +to reading (and writing) code that uses one style, you will feel at +least slightly uneasy when reading (or being required to write) +another style. +Many coding styles place begin/end brackets on a line by themself. +This makes programs considerably longer and wastes valuable screen +space, making it harder to get a good overview over a program. +Ideally, a function should fit on one basic tty screen (say, 20 +lines). 20 lines of Python are worth a LOT more than 20 lines of C. +This is not solely due to the lack of begin/end brackets (the lack of +declarations also helps, and the powerful operations of course), but +it certainly helps! +

+ +Edit this entry / +Log info + +/ Last changed on Wed May 21 16:00:15 1997 by +GvR +

+ +


+

6.3. Why are Python strings immutable?

+There are two advantages. One is performance: knowing that a +string is immutable makes it easy to lay it out at construction time +-- fixed and unchanging storage requirements. (This is also one of +the reasons for the distinction between tuples and lists.) The +other is that strings in Python are considered as "elemental" as +numbers. No amount of activity will change the value 8 to anything +else, and in Python, no amount of activity will change the string +"eight" to anything else. (Adapted from Jim Roskind) +

+ +Edit this entry / +Log info +

+ +


+

6.4. Delete

+

+

+ +Edit this entry / +Log info + +/ Last changed on Tue Jan 2 03:05:25 2001 by +Moshe Zadka +

+ +


+

6.5. Why does Python use methods for some functionality (e.g. list.index()) but functions for other (e.g. len(list))?

+The major reason is history. Functions were used for those +operations that were generic for a group of types and which +were intended to work even for objects that didn't have +methods at all (e.g. numbers before type/class unification +began, or 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). +

+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 quibble about individual cases but it's a part of Python, +and it's too late to change such things fundamentally now. The +functions have to remain to avoid massive code breakage. +

+Note that for string operations Python has moved from external functions +(the string module) to methods. However, len() is still a function. +

+ +Edit this entry / +Log info + +/ Last changed on Thu May 30 14:08:58 2002 by +Steve Holden +

+ +


+

6.6. Why can't I derive a class from built-in types (e.g. lists or files)?

+As of Python 2.2, you can derive from built-in types. For previous versions, the answer is: +

+This is caused by the relatively late addition of (user-defined) +classes to the language -- the implementation framework doesn't easily +allow it. See the answer to question 4.2 for a work-around. This +may be fixed in the (distant) future. +

+ +Edit this entry / +Log info + +/ Last changed on Thu May 23 02:53:22 2002 by +Neal Norwitz +

+ +


+

6.7. Why must 'self' be declared and used explicitly in method definitions and calls?

+So, is your current programming language C++ or Java? :-) +When classes were added to Python, this was (again) the simplest way of +implementing methods without too many changes to the interpreter. The +idea was borrowed from Modula-3. It turns out to be very useful, for +a variety of reasons. +

+First, it makes it more obvious that you are using a method or +instance attribute instead of a local variable. Reading "self.x" or +"self.meth()" makes it absolutely clear that an instance variable or +method is used even if you don't know the class definition by heart. +In C++, you can sort of tell by the lack of a local variable +declaration (assuming globals are rare or easily recognizable) -- but +in Python, there are no local variable declarations, so you'd have to +look up the class definition to be sure. +

+Second, it means that no special syntax is necessary if you want to +explicitly reference or call the method from a particular class. In +C++, if you want to use a method from base class that is overridden in +a derived class, you have to use the :: operator -- in Python you can +write baseclass.methodname(self, <argument list>). This is +particularly useful for __init__() methods, and in general in cases +where a derived class method wants to extend the base class method of +the same name and thus has to call the base class method somehow. +

+Lastly, for instance variables, it solves a syntactic problem with +assignment: since local variables in Python are (by definition!) those +variables to which a value assigned in a function body (and that +aren't explicitly declared global), there has to be some way to tell +the interpreter that an assignment was meant to assign to an instance +variable instead of to a local variable, and it should preferably be +syntactic (for efficiency reasons). C++ does this through +declarations, but Python doesn't have declarations and it would be a +pity having to introduce them just for this purpose. Using the +explicit "self.var" solves this nicely. Similarly, for using instance +variables, having to write "self.var" means that references to +unqualified names inside a method don't have to search the instance's +directories. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jan 12 08:01:50 2001 by +Steve Holden +

+ +


+

6.8. Can't you emulate threads in the interpreter instead of relying on an OS-specific thread implementation?

+Answer 1: Unfortunately, the interpreter pushes at least one C stack +frame for each Python stack frame. Also, extensions can call back into +Python at almost random moments. Therefore a complete threads +implementation requires thread support for C. +

+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. Stackless Python currently lives here: http://www.stackless.com. A microthread implementation that uses it can be found here: http://world.std.com/~wware/uthread.html. +

+ +Edit this entry / +Log info + +/ Last changed on Sat Apr 15 08:18:16 2000 by +Just van Rossum +

+ +


+

6.9. Why can't lambda forms contain statements?

+Python lambda forms cannot contain statements because Python's +syntactic framework can't handle statements nested inside expressions. +

+However, in Python, this is not a serious problem. Unlike lambda +forms in other languages, where they add functionality, Python lambdas +are only a shorthand notation if you're too lazy to define a function. +

+Functions are already first class objects in Python, and can be +declared in a local scope. Therefore the only advantage of using a +lambda form instead of a locally-defined function is that you don't need to invent a name for the function -- but that's just a local variable to which the function object (which is exactly the same type of object that a lambda form yields) is assigned! +

+ +Edit this entry / +Log info + +/ Last changed on Sun Jun 14 14:15:17 1998 by +Tim Peters +

+ +


+

6.10. [deleted]

+[lambda vs non-nested scopes used to be here] +

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 21 05:20:56 2002 by +Erno Kuusela +

+ +


+

6.11. [deleted]

+[recursive functions vs non-nested scopes used to be here] +

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 21 05:22:04 2002 by +Erno Kuusela +

+ +


+

6.12. Why is there no more efficient way of iterating over a dictionary than first constructing the list of keys()?

+As of Python 2.2, you can now iterate over a dictionary directly, +using the new implied dictionary iterator: +

+

+    for k in d: ...
+
+There are also methods returning iterators over the values and items: +

+

+    for k in d.iterkeys(): # same as above
+    for v in d.itervalues(): # iterate over values
+    for k, v in d.iteritems(): # iterate over items
+
+All these require that you do not modify the dictionary during the loop. +

+For previous Python versions, the following defense should do: +

+Have you tried it? I bet it's fast enough for your purposes! In +most cases such a list takes only a few percent of the space occupied +by the dictionary. Apart from the fixed header, +the list needs only 4 bytes (the size of a pointer) per +key. A dictionary uses 12 bytes per key plus between 30 and 70 +percent hash table overhead, plus the space for the keys and values. +By necessity, all keys are distinct objects, and a string object (the most +common key type) costs at least 20 bytes plus the length of the +string. Add to that the values contained in the dictionary, and you +see that 4 bytes more per item really isn't that much more memory... +

+A call to dict.keys() makes one fast scan over the dictionary +(internally, the iteration function does exist) copying the pointers +to the key objects into a pre-allocated list object of the right size. +The iteration time isn't lost (since you'll have to iterate anyway -- +unless in the majority of cases your loop terminates very prematurely +(which I doubt since you're getting the keys in random order). +

+I don't expose the dictionary iteration operation to Python +programmers because the dictionary shouldn't be modified during the +entire iteration -- if it is, there's a small chance that the +dictionary is reorganized because the hash table becomes too full, and +then the iteration may miss some items and see others twice. Exactly +because this only occurs rarely, it would lead to hidden bugs in +programs: it's easy never to have it happen during test runs if you +only insert or delete a few items per iteration -- but your users will +surely hit upon it sooner or later. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 24 21:24:08 2002 by +GvR +

+ +


+

6.13. Can Python be compiled to machine code, C or some other language?

+Not easily. Python's high level data types, dynamic typing of +objects and run-time invocation of the interpreter (using eval() or +exec) together mean that a "compiled" Python program would probably +consist mostly of calls into the Python run-time system, even for +seemingly simple operations like "x+1". +

+Several projects described in the Python newsgroup or at past +Python conferences have shown that this approach is feasible, +although the speedups reached so far are only modest (e.g. 2x). +JPython uses the same strategy for compiling to Java bytecode. +(Jim Hugunin has demonstrated that in combination with whole-program +analysis, speedups of 1000x are feasible for small demo programs. +See the website for the 1997 Python conference.) +

+Internally, Python source code is always translated into a "virtual +machine code" or "byte code" representation before it is interpreted +(by the "Python virtual machine" or "bytecode interpreter"). In order +to avoid the overhead of parsing and translating modules that rarely +change over and over again, this byte code is written on a file whose +name ends in ".pyc" whenever a module is parsed (from a file whose +name ends in ".py"). When the corresponding .py file is changed, it +is parsed and translated again and the .pyc file is rewritten. +

+There is no performance difference once the .pyc file has been loaded +(the bytecode read from the .pyc file is exactly the same as the bytecode +created by direct translation). The only difference is that loading +code from a .pyc file is faster than parsing and translating a .py +file, so the presence of precompiled .pyc files will generally improve +start-up time of Python scripts. If desired, the Lib/compileall.py +module/script can be used to force creation of valid .pyc files for a +given set of modules. +

+Note that the main script executed by Python, even if its filename +ends in .py, is not compiled to a .pyc file. It is compiled to +bytecode, but the bytecode is not saved to a file. +

+If you are looking for a way to translate Python programs in order to +distribute them in binary form, without the need to distribute the +interpreter and library as well, have a look at the freeze.py script +in the Tools/freeze directory. This creates a single binary file +incorporating your program, the Python interpreter, and those parts of +the Python library that are needed by your program. Of course, the +resulting binary will only run on the same type of platform as that +used to create it. +

+Newsflash: there are now several programs that do this, to some extent. +Look for Psyco, Pyrex, PyInline, Py2Cmod, and Weave. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 24 21:26:19 2002 by +GvR +

+ +


+

6.14. How does Python manage memory?

+The details of Python memory management depend on the implementation. +The standard Python implementation (the C implementation) uses reference +counting and another mechanism to collect reference cycles. +

+Jython relies on the Java runtime; so it uses +the JVM's garbage collector. This difference can cause some subtle +porting problems if your Python code depends on the behavior of +the reference counting implementation. +

+The reference cycle collector was added in CPython 2.0. It +periodically executes a cycle detection algorithm which looks for inaccessible cycles and deletes the objects involved. A new gc module provides functions to perform a garbage collection, obtain debugging statistics, and tuning the collector's parameters. +

+The detection of cycles can be disabled when Python is compiled, if you can't afford even a tiny speed penalty or suspect that the cycle collection is buggy, by specifying the "--without-cycle-gc" switch when running the configure script. +

+Sometimes objects get stuck in "tracebacks" temporarily and hence are not deallocated when you might expect. Clear the tracebacks via +

+

+       import sys
+       sys.exc_traceback = sys.last_traceback = None
+
+Tracebacks are used for reporting errors and implementing debuggers and related things. They contain a portion of the program state extracted during the handling of an exception (usually the most recent exception). +

+In the absence of circularities and modulo tracebacks, Python programs need not explicitly manage memory. +

+Why python doesn't use a more traditional garbage collection +scheme? For one thing, unless this were +added to C as a standard feature, it's a portability pain in the ass. +And yes, I know about the Xerox library. It has bits of assembler +code for most common platforms. Not for all. And although it is +mostly transparent, it isn't completely transparent (when I once +linked Python with it, it dumped core). +

+Traditional GC also becomes a problem when Python gets embedded into +other applications. While in a stand-alone Python it may be fine to +replace the standard malloc() and free() with versions provided by the +GC library, an application embedding Python may want to have its own +substitute for malloc() and free(), and may not want Python's. Right +now, Python works with anything that implements malloc() and free() +properly. +

+In Jython, the following code (which is +fine in C Python) will probably run out of file descriptors long before +it runs out of memory: +

+

+        for file in <very long list of files>:
+                f = open(file)
+                c = f.read(1)
+
+Using the current reference counting and destructor scheme, each new +assignment to f closes the previous file. Using GC, this is not +guaranteed. Sure, you can think of ways to fix this. But it's not +off-the-shelf technology. If you want to write code that will +work with any Python implementation, you should explicitly close +the file; this will work regardless of GC: +

+

+       for file in <very long list of files>:
+                f = open(file)
+                c = f.read(1)
+                f.close()
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Mar 21 05:35:38 2002 by +Erno Kuusela +

+ +


+

6.15. Why are there separate tuple and list data types?

+This is done so that tuples can be immutable while lists are mutable. +

+Immutable tuples are useful in situations where you need to pass a few +items to a function and don't want the function to modify the tuple; +for example, +

+

+	point1 = (120, 140)
+	point2 = (200, 300)
+	record(point1, point2)
+	draw(point1, point2)
+
+You don't want to have to think about what would happen if record() +changed the coordinates -- it can't, because the tuples are immutable. +

+On the other hand, when creating large lists dynamically, it is +absolutely crucial that they are mutable -- adding elements to a tuple +one by one requires using the concatenation operator, which makes it +quadratic in time. +

+As a general guideline, use tuples like you would use structs in C or +records in Pascal, use lists like (variable length) arrays. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 15:26:03 1997 by +GvR +

+ +


+

6.16. How are lists implemented?

+Despite what a Lisper might think, Python's lists are really +variable-length arrays. The implementation uses a contiguous +array of references to other objects, and keeps a pointer +to this array (as well as its length) in a list head structure. +

+This makes indexing a list (a[i]) an operation whose cost is +independent of the size of the list or the value of the index. +

+When items are appended or inserted, the array of references is resized. +Some cleverness is applied to improve the performance of appending +items repeatedly; when the array must be grown, some extra space +is allocated so the next few times don't require an actual resize. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 15:32:24 1997 by +GvR +

+ +


+

6.17. How are dictionaries implemented?

+Python's dictionaries are implemented as resizable hash tables. +

+Compared to B-trees, this gives better performance for lookup +(the most common operation by far) under most circumstances, +and the implementation is simpler. +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 23:51:14 1997 by +Vladimir Marangozov +

+ +


+

6.18. Why must dictionary keys be immutable?

+The hash table implementation of dictionaries uses a hash value +calculated from the key value to find the key. If the key were +a mutable object, its value could change, and thus its hash could +change. But since whoever changes the key object can't tell that +is incorporated in a dictionary, it can't move the entry around in +the dictionary. Then, when you try to look up the same object +in the dictionary, it won't be found, since its hash value is different; +and if you try to look up the old value, it won't be found either, +since the value of the object found in that hash bin differs. +

+If you think you need to have a dictionary indexed with a list, +try to use a tuple instead. The function tuple(l) creates a tuple +with the same entries as the list l. +

+Some unacceptable solutions that have been proposed: +

+- Hash lists by their address (object ID). This doesn't work because +if you construct a new list with the same value it won't be found; +e.g., +

+

+  d = {[1,2]: '12'}
+  print d[[1,2]]
+
+will raise a KeyError exception because the id of the [1,2] used +in the second line differs from that in the first line. +In other words, dictionary keys should be compared using '==', not using 'is'. +

+- Make a copy when using a list as a key. This doesn't work because +the list (being a mutable object) could contain a reference to itself, +and then the copying code would run into an infinite loop. +

+- Allow lists as keys but tell the user not to modify them. This would +allow a class of hard-to-track bugs in programs that I'd rather not see; +it invalidates an important invariant of dictionaries (every value in +d.keys() is usable as a key of the dictionary). +

+- Mark lists as read-only once they are used as a dictionary key. +The problem is that it's not just the top-level object that could change +its value; you could use a tuple containing a list as a key. Entering +anything as a key into a dictionary would require marking all objects +reachable from there as read-only -- and again, self-referential objects +could cause an infinite loop again (and again and again). +

+There is a trick to get around this if you need to, but +use it at your own risk: You +can wrap a mutable structure inside a class instance which +has both a __cmp__ and a __hash__ method. +

+

+   class listwrapper:
+        def __init__(self, the_list):
+              self.the_list = the_list
+        def __cmp__(self, other):
+              return self.the_list == other.the_list
+        def __hash__(self):
+              l = self.the_list
+              result = 98767 - len(l)*555
+              for i in range(len(l)):
+                   try:
+                        result = result + (hash(l[i]) % 9999999) * 1001 + i
+                   except:
+                        result = (result % 7777777) + i * 333
+              return result
+
+Note that the hash computation is complicated by the +possibility that some members of the list may be unhashable +and also by the possibility of arithmetic overflow. +

+You must make +sure that the hash value for all such wrapper objects that reside in a +dictionary (or other hash based structure), remain fixed while +the object is in the dictionary (or other structure). +

+Furthermore it must always be the case that if +o1 == o2 (ie o1.__cmp__(o2)==0) then hash(o1)==hash(o2) +(ie, o1.__hash__() == o2.__hash__()), regardless of whether +the object is in a dictionary or not. +If you fail to meet these restrictions dictionaries and other +hash based structures may misbehave! +

+In the case of listwrapper above whenever the wrapper +object is in a dictionary the wrapped list must not change +to avoid anomalies. Don't do this unless you are prepared +to think hard about the requirements and the consequences +of not meeting them correctly. You've been warned! +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jul 10 10:08:40 1997 by +aaron watters +

+ +


+

6.19. How the heck do you make an array in Python?

+["this", 1, "is", "an", "array"] +

+Lists are arrays in the C or Pascal sense of the word (see question +6.16). The array module also provides methods for creating arrays +of fixed types with compact representations (but they are slower to +index than lists). Also note that the Numerics extensions and others +define array-like structures with various characteristics as well. +

+To get Lisp-like lists, emulate cons cells +

+

+    lisp_list = ("like",  ("this",  ("example", None) ) )
+
+using tuples (or lists, if you want mutability). Here the analogue +of lisp car is lisp_list[0] and the analogue of cdr is lisp_list[1]. +Only do this if you're sure you really need to (it's usually a lot +slower than using Python lists). +

+Think of Python lists as mutable heterogeneous arrays of +Python objects (say that 10 times fast :) ). +

+ +Edit this entry / +Log info + +/ Last changed on Wed Aug 13 07:08:27 1997 by +aaron watters +

+ +


+

6.20. Why doesn't list.sort() return the sorted list?

+In situations where performance matters, making a copy of the list +just to sort it would be wasteful. Therefore, list.sort() sorts +the list in place. In order to remind you of that fact, it does +not return the sorted list. This way, you won't be fooled into +accidentally overwriting a list when you need a sorted copy but also +need to keep the unsorted version around. +

+As a result, here's the idiom to iterate over the keys of a dictionary +in sorted order: +

+

+	keys = dict.keys()
+	keys.sort()
+	for key in keys:
+		...do whatever with dict[key]...
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Dec 2 17:01:52 1999 by +Fred L. Drake, Jr. +

+ +


+

6.21. How do you specify and enforce an interface spec in Python?

+An interfaces specification for a module as provided +by languages such as C++ and java describes the prototypes +for the methods and functions of the module. Many feel +that compile time enforcement of interface specifications +help aid in the construction of large programs. Python +does not support interface specifications directly, but many +of their advantages can be obtained by an appropriate +test discipline for components, which can often be very +easily accomplished in Python. There is also a tool, PyChecker, +which can be used to find problems due to subclassing. +

+A good test suite for a module can at +once provide a regression test and serve as a module interface +specification (even better since it also gives example usage). Look to +many of the standard libraries which often have a "script +interpretation" which provides a simple "self test." Even +modules which use complex external interfaces can often +be tested in isolation using trivial "stub" emulations of the +external interface. +

+An appropriate testing discipline (if enforced) can help +build large complex applications in Python as well as having interface +specifications would do (or better). Of course Python allows you +to get sloppy and not do it. Also you might want to design +your code with an eye to make it easily tested. +

+ +Edit this entry / +Log info + +/ Last changed on Thu May 23 03:05:29 2002 by +Neal Norwitz +

+ +


+

6.22. Why do all classes have the same type? Why do instances all have the same type?

+The Pythonic use of the word "type" is quite different from +common usage in much of the rest of the programming language +world. A "type" in Python is a description for an object's operations +as implemented in C. All classes have the same operations +implemented in C which sometimes "call back" to differing program +fragments implemented in Python, and hence all classes have the +same type. Similarly at the C level all class instances have the +same C implementation, and hence all instances have the same +type. +

+Remember that in Python usage "type" refers to a C implementation +of an object. To distinguish among instances of different classes +use Instance.__class__, and also look to 4.47. Sorry for the +terminological confusion, but at this point in Python's development +nothing can be done! +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jul 1 12:35:47 1997 by +aaron watters +

+ +


+

6.23. Why isn't all memory freed when Python exits?

+Objects referenced from Python module global name spaces are +not always deallocated when Python exits. +

+This may happen if there are circular references (see question +4.17). There are also certain bits of memory that are allocated +by the C library that are impossible to free (e.g. a tool +like Purify will complain about these). +

+But in general, Python 1.5 and beyond +(in contrast with earlier versions) is quite agressive about +cleaning up memory on exit. +

+If you want to force Python to delete certain things on deallocation +use the sys.exitfunc hook to force those deletions. For example +if you are debugging an extension module using a memory analysis +tool and you wish to make Python deallocate almost everything +you might use an exitfunc like this one: +

+

+  import sys
+
+
+  def my_exitfunc():
+       print "cleaning up"
+       import sys
+       # do order dependant deletions here
+       ...
+       # now delete everything else in arbitrary order
+       for x in sys.modules.values():
+            d = x.__dict__
+            for name in d.keys():
+                 del d[name]
+
+
+  sys.exitfunc = my_exitfunc
+
+Other exitfuncs can be less drastic, of course. +

+(In fact, this one just does what Python now already does itself; +but the example of using sys.exitfunc to force cleanups is still +useful.) +

+ +Edit this entry / +Log info + +/ Last changed on Tue Sep 29 09:46:26 1998 by +GvR +

+ +


+

6.24. Why no class methods or mutable class variables?

+The notation +

+

+    instance.attribute(arg1, arg2)
+
+usually translates to the equivalent of +

+

+    Class.attribute(instance, arg1, arg2)
+
+where Class is a (super)class of instance. Similarly +

+

+    instance.attribute = value
+
+sets an attribute of an instance (overriding any attribute of a class +that instance inherits). +

+Sometimes programmers want to have +different behaviours -- they want a method which does not bind +to the instance and a class attribute which changes in place. +Python does not preclude these behaviours, but you have to +adopt a convention to implement them. One way to accomplish +this is to use "list wrappers" and global functions. +

+

+   def C_hello():
+         print "hello"
+
+
+   class C:
+        hello = [C_hello]
+        counter = [0]
+
+
+    I = C()
+
+Here I.hello[0]() acts very much like a "class method" and +I.counter[0] = 2 alters C.counter (and doesn't override it). +If you don't understand why you'd ever want to do this, that's +because you are pure of mind, and you probably never will +want to do it! This is dangerous trickery, not recommended +when avoidable. (Inspired by Tim Peter's discussion.) +

+In Python 2.2, you can do this using the new built-in operations +classmethod and staticmethod. +See http://www.python.org/2.2/descrintro.html#staticmethods +

+ +Edit this entry / +Log info + +/ Last changed on Tue Sep 11 15:59:37 2001 by +GvR +

+ +


+

6.25. Why are default values sometimes shared between objects?

+It is often expected that a function CALL creates new objects for default +values. This is not what happens. Default values are created when the +function is DEFINED, that is, there is only one such object that all +functions refer to. If that object is changed, subsequent calls to the +function will refer to this changed object. By definition, immutable objects +(like numbers, strings, tuples, None) are safe from change. Changes to mutable +objects (like dictionaries, lists, class instances) is what causes the +confusion. +

+Because of this feature it is good programming practice not to use mutable +objects as default values, but to introduce them in the function. +Don't write: +

+

+	def foo(dict={}):  # XXX shared reference to one dict for all calls
+	    ...
+
+but: +
+	def foo(dict=None):
+		if dict is None:
+			dict = {} # create a new dict for local namespace
+
+See page 182 of "Internet Programming with Python" for one discussion +of this feature. Or see the top of page 144 or bottom of page 277 in +"Programming Python" for another discussion. +

+ +Edit this entry / +Log info + +/ Last changed on Sat Aug 16 07:03:35 1997 by +Case Roole +

+ +


+

6.26. Why no goto?

+Actually, you can use exceptions to provide a "structured goto" +that even works across function calls. Many feel that exceptions +can conveniently emulate all reasonable uses of the "go" or "goto" +constructs of C, Fortran, and other languages. For example: +

+

+   class label: pass # declare a label
+   try:
+        ...
+        if (condition): raise label() # goto label
+        ...
+   except label: # where to goto
+        pass
+   ...
+
+This doesn't allow you to jump into the middle of a loop, but +that's usually considered an abuse of goto anyway. Use sparingly. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Sep 10 07:16:44 1997 by +aaron watters +

+ +


+

6.27. How do you make a higher order function in Python?

+You have two choices: you can use default arguments and override +them or you can use "callable objects." For example suppose you +wanted to define linear(a,b) which returns a function f where f(x) +computes the value a*x+b. Using default arguments: +

+

+     def linear(a,b):
+         def result(x, a=a, b=b):
+             return a*x + b
+         return result
+
+Or using callable objects: +

+

+     class linear:
+        def __init__(self, a, b):
+            self.a, self.b = a,b
+        def __call__(self, x):
+            return self.a * x + self.b
+
+In both cases: +

+

+     taxes = linear(0.3,2)
+
+gives a callable object where taxes(10e6) == 0.3 * 10e6 + 2. +

+The defaults strategy has the disadvantage that the default arguments +could be accidentally or maliciously overridden. The callable objects +approach has the disadvantage that it is a bit slower and a bit +longer. Note however that a collection of callables can share +their signature via inheritance. EG +

+

+      class exponential(linear):
+         # __init__ inherited
+         def __call__(self, x):
+             return self.a * (x ** self.b)
+
+On comp.lang.python, zenin@bawdycaste.org points out that +an object can encapsulate state for several methods in order +to emulate the "closure" concept from functional programming +languages, for example: +

+

+    class counter:
+        value = 0
+        def set(self, x): self.value = x
+        def up(self): self.value=self.value+1
+        def down(self): self.value=self.value-1
+
+
+    count = counter()
+    inc, dec, reset = count.up, count.down, count.set
+
+Here inc, dec and reset act like "functions which share the +same closure containing the variable count.value" (if you +like that way of thinking). +

+ +Edit this entry / +Log info + +/ Last changed on Fri Sep 25 08:38:35 1998 by +Aaron Watters +

+ +


+

6.28. Why do I get a SyntaxError for a 'continue' inside a 'try'?

+This is an implementation limitation, +caused by the extremely simple-minded +way Python generates bytecode. The try block pushes something on the +"block stack" which the continue would have to pop off again. The +current code generator doesn't have the data structures around so that +'continue' can generate the right code. +

+Note that JPython doesn't have this restriction! +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 22 15:01:07 1998 by +GvR +

+ +


+

6.29. Why can't raw strings (r-strings) end with a backslash?

+More precisely, they can't end with an odd number of backslashes: +the unpaired backslash at the end escapes the closing quote character, +leaving an unterminated string. +

+Raw strings were designed to ease creating input for processors (chiefly +regular expression engines) that want to do their own backslash escape processing. Such processors consider an unmatched trailing backslash to be an error anyway, so raw strings disallow that. In return, they allow you to pass on the string quote character by escaping it with a backslash. These rules work well when r-strings are used for their intended purpose. +

+If you're trying to build Windows pathnames, note that all Windows system calls accept forward slashes too: +

+

+    f = open("/mydir/file.txt") # works fine!
+
+If you're trying to build a pathname for a DOS command, try e.g. one of +

+

+    dir = r"\this\is\my\dos\dir" "\\"
+    dir = r"\this\is\my\dos\dir\ "[:-1]
+    dir = "\\this\\is\\my\\dos\\dir\\"
+
+

+ +Edit this entry / +Log info + +/ Last changed on Mon Jul 13 20:50:20 1998 by +Tim Peters +

+ +


+

6.30. Why can't I use an assignment in an expression?

+Many people used to C or Perl complain that they want to be able to +use e.g. this C idiom: +

+

+    while (line = readline(f)) {
+        ...do something with line...
+    }
+
+where in Python you're forced to write this: +

+

+    while 1:
+        line = f.readline()
+        if not line:
+            break
+        ...do something with line...
+
+This issue comes up in the Python newsgroup with alarming frequency +-- search Deja News for past messages about assignment expression. +The reason for not allowing assignment in Python expressions +is a common, hard-to-find bug in those other languages, +caused by this construct: +

+

+    if (x = 0) {
+        ...error handling...
+    }
+    else {
+        ...code that only works for nonzero x...
+    }
+
+Many alternatives have been proposed. Most are hacks that save some +typing but use arbitrary or cryptic syntax or keywords, +and fail the simple criterion that I use for language change proposals: +it should intuitively suggest the proper meaning to a human reader +who has not yet been introduced with the construct. +

+The earliest time something can be done about this will be with +Python 2.0 -- if it is decided that it is worth fixing. +An interesting phenomenon is that most experienced Python programmers +recognize the "while 1" idiom and don't seem to be missing the +assignment in expression construct much; it's only the newcomers +who express a strong desire to add this to the language. +

+One fairly elegant solution would be to introduce a new operator +for assignment in expressions spelled ":=" -- this avoids the "=" +instead of "==" problem. It would have the same precedence +as comparison operators but the parser would flag combination with +other comparisons (without disambiguating parentheses) as an error. +

+Finally -- there's an alternative way of spelling this that seems +attractive but is generally less robust than the "while 1" solution: +

+

+    line = f.readline()
+    while line:
+        ...do something with line...
+        line = f.readline()
+
+The problem with this is that if you change your mind about exactly +how you get the next line (e.g. you want to change it into +sys.stdin.readline()) you have to remember to change two places +in your program -- the second one hidden at the bottom of the loop. +

+ +Edit this entry / +Log info + +/ Last changed on Tue May 18 00:57:41 1999 by +Andrew Dalke +

+ +


+

6.31. Why doesn't Python have a "with" statement like some other languages?

+Basically, because such a construct would be terribly ambiguous. Thanks to Carlos Ribeiro for the following remarks: +

+Some languages, such as Object Pascal, Delphi, and C++, use static types. So it is possible to know, in an unambiguous way, what member is being assigned in a "with" clause. This is the main point - the compiler always knows the scope of every variable at compile time. +

+Python uses dynamic types. It is impossible to know in advance which +attribute will be referenced at runtime. Member attributes may be added or removed from objects on the fly. This would make it impossible to know, from a simple reading, what attribute is being referenced - a local one, a global one, or a member attribute. +

+For instance, take the following snippet (it is incomplete btw, just to +give you the idea): +

+

+   def with_is_broken(a):
+      with a:
+         print x
+
+The snippet assumes that "a" must have a member attribute called "x". +However, there is nothing in Python that guarantees that. What should +happen if "a" is, let us say, an integer? And if I have a global variable named "x", will it end up being used inside the with block? As you see, the dynamic nature of Python makes such choices much harder. +

+The primary benefit of "with" and similar language features (reduction of code volume) can, however, easily be achieved in Python by assignment. Instead of: +

+

+    function(args).dict[index][index].a = 21
+    function(args).dict[index][index].b = 42
+    function(args).dict[index][index].c = 63
+
+would become: +

+

+    ref = function(args).dict[index][index]
+    ref.a = 21
+    ref.b = 42
+    ref.c = 63
+
+This also has the happy side-effect of increasing execution speed, since name bindings are resolved at run-time in Python, and the second method only needs to perform the resolution once. If the referenced object does not have a, b and c attributes, of course, the end result is still a run-time exception. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jan 11 14:32:58 2002 by +Steve Holden +

+ +


+

6.32. Why are colons required for if/while/def/class?

+The colon is required primarily to enhance readability (one of the +results of the experimental ABC language). Consider this: +

+

+    if a==b
+        print a
+
+versus +

+

+    if a==b:
+        print a
+
+Notice how the second one is slightly easier to read. Notice further how +a colon sets off the example in the second line of this FAQ answer; it's +a standard usage in English. Finally, the colon makes it easier for +editors with syntax highlighting. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Jun 3 07:22:57 2002 by +Matthias Urlichs +

+ +


+

6.33. Can't we get rid of the Global Interpreter Lock?

+The Global Interpreter Lock (GIL) is often seen as a hindrance to +Python's deployment on high-end multiprocessor server machines, +because a multi-threaded Python program effectively only uses +one CPU, due to the insistence that (almost) all Python code +can only run while the GIL is held. +

+Back in the days of Python 1.5, Greg Stein actually implemented +a comprehensive patch set ("free threading") +that removed the GIL, replacing it with +fine-grained locking. Unfortunately, even on Windows (where locks +are very efficient) this ran ordinary Python code about twice as +slow as the interpreter using the GIL. On Linux the performance +loss was even worse (pthread locks aren't as efficient). +

+Since then, the idea of getting rid of the GIL has occasionally +come up but nobody has found a way to deal with the expected slowdown; +Greg's free threading patch set has not been kept up-to-date for +later Python versions. +

+This doesn't mean that you can't make good use of Python on +multi-CPU machines! You just have to be creative with dividing +the work up between multiple processes rather than multiple +threads. +

+

+It has been suggested that the GIL should be a per-interpreter-state +lock rather than truly global; interpreters then wouldn't be able +to share objects. Unfortunately, this isn't likely to happen either. +

+It would be a tremendous amount of work, because many object +implementations currently have global state. E.g. small ints and +small strings are cached; these caches would have to be moved to the +interpreter state. Other object types have their own free list; these +free lists would have to be moved to the interpreter state. And so +on. +

+And I doubt that it can even be done in finite time, because the same +problem exists for 3rd party extensions. It is likely that 3rd party +extensions are being written at a faster rate than you can convert +them to store all their global state in the interpreter state. +

+And finally, once you have multiple interpreters not sharing any +state, what have you gained over running each interpreter +in a separate process? +

+ +Edit this entry / +Log info + +/ Last changed on Fri Feb 7 16:34:01 2003 by +GvR +

+ +


+

7. Using Python on non-UNIX platforms

+ +
+

7.1. Is there a Mac version of Python?

+Yes, it is maintained by Jack Jansen. See Jack's MacPython Page: +

+

+  http://www.cwi.nl/~jack/macpython.html
+
+

+ +Edit this entry / +Log info + +/ Last changed on Fri May 4 09:33:42 2001 by +GvR +

+ +


+

7.2. Are there DOS and Windows versions of Python?

+Yes. The core windows binaries are available from http://www.python.org/windows/. There is a plethora of Windows extensions available, including a large number of not-always-compatible GUI toolkits. The core binaries include the standard Tkinter GUI extension. +

+Most windows extensions can be found (or referenced) at http://www.python.org/windows/ +

+Windows 3.1/DOS support seems to have dropped off recently. You may need to settle for an old version of Python one these platforms. One such port is WPY +

+WPY: Ports to DOS, Windows 3.1(1), Windows 95, Windows NT and OS/2. +Also contains a GUI package that offers portability between Windows +(not DOS) and Unix, and native look and feel on both. +ftp://ftp.python.org/pub/python/wpy/. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Jun 2 20:21:57 1998 by +Mark Hammond +

+ +


+

7.3. Is there an OS/2 version of Python?

+Yes, see http://www.python.org/download/download_os2.html. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Sep 7 11:33:16 1999 by +GvR +

+ +


+

7.4. Is there a VMS version of Python?

+Jean-François Piéronne has ported 2.1.3 to OpenVMS. It can be found at +<http://vmspython.dyndns.org/>. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Sep 19 15:40:38 2002 by +Skip Montanaro +

+ +


+

7.5. What about IBM mainframes, or other non-UNIX platforms?

+I haven't heard about these, except I remember hearing about an +OS/9 port and a port to Vxworks (both operating systems for embedded +systems). If you're interested in any of this, go directly to the +newsgroup and ask there, you may find exactly what you need. For +example, a port to MPE/iX 5.0 on HP3000 computers was just announced, +see http://www.allegro.com/software/. +

+On the IBM mainframe side, for Z/OS there's a port of python 1.4 that goes with their open-unix package, formely OpenEdition MVS, (http://www-1.ibm.com/servers/eserver/zseries/zos/unix/python.html). On a side note, there's also a java vm ported - so, in theory, jython could run too. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Nov 18 03:18:39 2002 by +Bruno Jessen +

+ +


+

7.6. Where are the source or Makefiles for the non-UNIX versions?

+The standard sources can (almost) be used. Additional sources can +be found in the platform-specific subdirectories of the distribution. +

+ +Edit this entry / +Log info +

+ +


+

7.7. What is the status and support for the non-UNIX versions?

+I don't have access to most of these platforms, so in general I am +dependent on material submitted by volunteers. However I strive to +integrate all changes needed to get it to compile on a particular +platform back into the standard sources, so porting of the next +version to the various non-UNIX platforms should be easy. +(Note that Linux is classified as a UNIX platform here. :-) +

+Some specific platforms: +

+Windows: all versions (95, 98, ME, NT, 2000, XP) are supported, +all python.org releases come with a Windows installer. +

+MacOS: Jack Jansen does an admirable job of keeping the Mac version +up to date (both MacOS X and older versions); +see http://www.cwi.nl/~jack/macpython.html +

+For all supported platforms, see http://www.python.org/download/ +(follow the link to "Other platforms" for less common platforms) +

+ +Edit this entry / +Log info + +/ Last changed on Fri May 24 21:34:24 2002 by +GvR +

+ +


+

7.8. I have a PC version but it appears to be only a binary. Where's the library?

+If you are running any version of Windows, then you have the wrong distribution. The FAQ lists current Windows versions. Notably, Pythonwin and wpy provide fully functional installations. +

+But if you are sure you have the only distribution with a hope of working on +your system, then... +

+You still need to copy the files from the distribution directory +"python/Lib" to your system. If you don't have the full distribution, +you can get the file lib<version>.tar.gz from most ftp sites carrying +Python; this is a subset of the distribution containing just those +files, e.g. ftp://ftp.python.org/pub/python/src/lib1.4.tar.gz. +

+Once you have installed the library, you need to point sys.path to it. +Assuming the library is in C:\misc\python\lib, the following commands +will point your Python interpreter to it (note the doubled backslashes +-- you can also use single forward slashes instead): +

+

+        >>> import sys
+        >>> sys.path.insert(0, 'C:\\misc\\python\\lib')
+        >>>
+
+For a more permanent effect, set the environment variable PYTHONPATH, +as follows (talking to a DOS prompt): +

+

+        C> SET PYTHONPATH=C:\misc\python\lib
+
+

+ +Edit this entry / +Log info + +/ Last changed on Fri May 23 16:28:27 1997 by +Ken Manheimer +

+ +


+

7.9. Where's the documentation for the Mac or PC version?

+The documentation for the Unix version also applies to the Mac and +PC versions. Where applicable, differences are indicated in the text. +

+ +Edit this entry / +Log info +

+ +


+

7.10. How do I create a Python program file on the Mac or PC?

+Use an external editor. On the Mac, BBEdit seems to be a popular +no-frills text editor. I work like this: start the interpreter; edit +a module file using BBedit; import and test it in the interpreter; +edit again in BBedit; then use the built-in function reload() to +re-read the imported module; etc. In the 1.4 distribution +you will find a BBEdit extension that makes life a little easier: +it can tell the interpreter to execute the current window. +See :Mac:Tools:BBPy:README. +

+Regarding the same question for the PC, Kurt Wm. Hemr writes: "While +anyone with a pulse could certainly figure out how to do the same on +MS-Windows, I would recommend the NotGNU Emacs clone for MS-Windows. +Not only can you easily resave and "reload()" from Python after making +changes, but since WinNot auto-copies to the clipboard any text you +select, you can simply select the entire procedure (function) which +you changed in WinNot, switch to QWPython, and shift-ins to reenter +the changed program unit." +

+If you're using Windows95 or Windows NT, you should also know about +PythonWin, which provides a GUI framework, with an mouse-driven +editor, an object browser, and a GUI-based debugger. See +

+       http://www.python.org/ftp/python/pythonwin/
+
+for details. +

+ +Edit this entry / +Log info + +/ Last changed on Sun May 25 10:04:25 1997 by +GvR +

+ +


+

7.11. How can I use Tkinter on Windows 95/NT?

+Starting from Python 1.5, it's very easy -- just download and install +Python and Tcl/Tk and you're in business. See +

+

+  http://www.python.org/download/download_windows.html
+
+One warning: don't attempt to use Tkinter from PythonWin +(Mark Hammond's IDE). Use it from the command line interface +(python.exe) or the windowless interpreter (pythonw.exe). +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jun 12 09:32:48 1998 by +GvR +

+ +


+

7.12. cgi.py (or other CGI programming) doesn't work sometimes on NT or win95!

+Be sure you have the latest python.exe, that you are using +python.exe rather than a GUI version of python and that you +have configured the server to execute +

+

+     "...\python.exe -u ..."
+
+for the cgi execution. The -u (unbuffered) option on NT and +win95 prevents the interpreter from altering newlines in the +standard input and output. Without it post/multipart requests +will seem to have the wrong length and binary (eg, GIF) +responses may get garbled (resulting in, eg, a "broken image"). +

+ +Edit this entry / +Log info + +/ Last changed on Wed Jul 30 10:48:02 1997 by +aaron watters +

+ +


+

7.13. Why doesn't os.popen() work in PythonWin on NT?

+The reason that os.popen() doesn't work from within PythonWin is due to a bug in Microsoft's C Runtime Library (CRT). The CRT assumes you have a Win32 console attached to the process. +

+You should use the win32pipe module's popen() instead which doesn't depend on having an attached Win32 console. +

+Example: +

+ import win32pipe
+ f = win32pipe.popen('dir /c c:\\')
+ print f.readlines()
+ f.close()
+
+

+ +Edit this entry / +Log info + +/ Last changed on Thu Jul 31 15:34:09 1997 by +Bill Tutt +

+ +


+

7.14. How do I use different functionality on different platforms with the same program?

+Remember that Python is extremely dynamic and that you +can use this dynamism to configure a program at run-time to +use available functionality on different platforms. For example +you can test the sys.platform and import different modules based +on its value. +

+

+   import sys
+   if sys.platform == "win32":
+      import win32pipe
+      popen = win32pipe.popen
+   else:
+      import os
+      popen = os.popen
+
+(See FAQ 7.13 for an explanation of why you might want to +do something like this.) Also you can try to import a module +and use a fallback if the import fails: +

+

+    try:
+         import really_fast_implementation
+         choice = really_fast_implementation
+    except ImportError:
+         import slower_implementation
+         choice = slower_implementation
+
+

+ +Edit this entry / +Log info + +/ Last changed on Wed Aug 13 07:39:06 1997 by +aaron watters +

+ +


+

7.15. Is there an Amiga version of Python?

+Yes. See the AmigaPython homepage at http://www.bigfoot.com/~irmen/python.html. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Dec 14 06:53:32 1998 by +Irmen de Jong +

+ +


+

7.16. Why doesn't os.popen()/win32pipe.popen() work on Win9x?

+There is a bug in Win9x that prevents os.popen/win32pipe.popen* from working. The good news is there is a way to work around this problem. +The Microsoft Knowledge Base article that you need to lookup is: Q150956. You will find links to the knowledge base at: +http://www.microsoft.com/kb. +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jun 25 10:45:38 1999 by +Bill Tutt +

+ +


+

8. Python on Windows

+ +
+

8.1. Using Python for CGI on Microsoft Windows

+** Setting up the Microsoft IIS Server/Peer Server +

+On the Microsoft IIS +server or on the Win95 MS Personal Web Server +you set up python in the same way that you +would set up any other scripting engine. +

+Run regedt32 and go to: +

+HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\ScriptMap +

+and enter the following line (making any specific changes that your system may need) +

+.py :REG_SZ: c:\<path to python>\python.exe -u %s %s +

+This line will allow you to call your script with a simple reference like: +http://yourserver/scripts/yourscript.py +provided "scripts" is an "executable" directory for your server (which +it usually is by default). +The "-u" flag specifies unbuffered and binary mode for stdin - needed when working with binary data +

+In addition, it is recommended by people who would know that using ".py" may +not be a good idea for the file extensions when used in this context +(you might want to reserve *.py for support modules and use *.cgi or *.cgp +for "main program" scripts). +However, that issue is beyond this Windows FAQ entry. +

+

+** Apache configuration +

+In the Apache configuration file httpd.conf, add the following line at +the end of the file: +

+ScriptInterpreterSource Registry +

+Then, give your Python CGI-scripts the extension .py and put them in the cgi-bin directory. +

+

+** Netscape Servers: +Information on this topic exists at: +http://home.netscape.com/comprod/server_central/support/fasttrack_man/programs.htm#1010870 +

+ +Edit this entry / +Log info + +/ Last changed on Wed Mar 27 12:25:54 2002 by +Gerhard Häring +

+ +


+

8.2. How to check for a keypress without blocking?

+Use the msvcrt module. This is a standard Windows-specific extensions +in Python 1.5 and beyond. It defines a function kbhit() which checks +whether a keyboard hit is present; also getch() which gets one +character without echo. Plus a few other goodies. +

+(Search for "keypress" to find an answer for Unix as well.) +

+ +Edit this entry / +Log info + +/ Last changed on Mon Mar 30 16:21:46 1998 by +GvR +

+ +


+

8.3. $PYTHONPATH

+In MS-DOS derived environments, a unix variable such as $PYTHONPATH is +set as PYTHONPATH, without the dollar sign. PYTHONPATH is useful for +specifying the location of library files. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jun 11 00:41:26 1998 by +Gvr +

+ +


+

8.4. dedent syntax errors

+The FAQ does not recommend using tabs, and Guido's Python Style Guide recommends 4 spaces for distributed Python code; this is also the Emacs python-mode default; see +

+

+    http://www.python.org/doc/essays/styleguide.html
+
+Under any editor mixing tabs and spaces is a bad idea. MSVC is no different in this respect, and is easily configured to use spaces: Take Tools -> Options -> Tabs, and for file type "Default" set "Tab size" and "Indent size" to 4, and select the "Insert spaces" radio button. +

+If you suspect mixed tabs and spaces are causing problems in leading whitespace, run Python with the -t switch or, run Tools/Scripts/tabnanny.py to check a directory tree in batch mode. +

+ +Edit this entry / +Log info + +/ Last changed on Mon Feb 12 15:04:14 2001 by +Steve Holden +

+ +


+

8.5. How do I emulate os.kill() in Windows?

+Use win32api: +

+

+    def kill(pid):
+        """kill function for Win32"""
+        import win32api
+        handle = win32api.OpenProcess(1, 0, pid)
+        return (0 != win32api.TerminateProcess(handle, 0))
+
+

+ +Edit this entry / +Log info + +/ Last changed on Sat Aug 8 18:55:06 1998 by +Jeff Bauer +

+ +


+

8.6. Why does os.path.isdir() fail on NT shared directories?

+The solution appears to be always append the "\\" on +the end of shared drives. +

+

+  >>> import os
+  >>> os.path.isdir( '\\\\rorschach\\public')
+  0
+  >>> os.path.isdir( '\\\\rorschach\\public\\')
+  1
+
+[Blake Winton responds:] +I've had the same problem doing "Start >> Run" and then a +directory on a shared drive. If I use "\\rorschach\public", +it will fail, but if I use "\\rorschach\public\", it will +work. For that matter, os.stat() does the same thing (well, +it gives an error for "\\\\rorschach\\public", but you get +the idea)... +

+I've got a theory about why this happens, but it's only +a theory. NT knows the difference between shared directories, +and regular directories. "\\rorschach\public" isn't a +directory, it's _really_ an IPC abstraction. This is sort +of lended credence to by the fact that when you're mapping +a network drive, you can't map "\\rorschach\public\utils", +but only "\\rorschach\public". +

+[Clarification by funkster@midwinter.com] +It's not actually a Python +question, as Python is working just fine; it's clearing up something +a bit muddled about Windows networked drives. +

+It helps to think of share points as being like drive letters. +Example: +

+        k: is not a directory
+        k:\ is a directory
+        k:\media is a directory
+        k:\media\ is not a directory
+
+The same rules apply if you substitute "k:" with "\\conky\foo": +
+        \\conky\foo  is not a directory
+        \\conky\foo\ is a directory
+        \\conky\foo\media is a directory
+        \\conky\foo\media\ is not a directory
+
+

+ +Edit this entry / +Log info + +/ Last changed on Sun Jan 31 08:44:48 1999 by +GvR +

+ +


+

8.7. PyRun_SimpleFile() crashes on Windows but not on Unix

+I've seen a number of reports of PyRun_SimpleFile() failing +in a Windows port of an application embedding Python that worked +fine on Unix. PyRun_SimpleString() works fine on both platforms. +

+I think this happens because the application was compiled with a +different set of compiler flags than Python15.DLL. It seems that some +compiler flags affect the standard I/O library in such a way that +using different flags makes calls fail. You need to set it for +the non-debug multi-threaded DLL (/MD on the command line, or can be set via MSVC under Project Settings->C++/Code Generation then the "Use rum-time library" dropdown.) +

+Also note that you can not mix-and-match Debug and Release versions. If you wish to use the Debug Multithreaded DLL, then your module _must_ have an "_d" appended to the base name. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Nov 17 17:37:07 1999 by +Mark Hammond +

+ +


+

8.8. Import of _tkinter fails on Windows 95/98

+Sometimes, the import of _tkinter fails on Windows 95 or 98, +complaining with a message like the following: +

+

+  ImportError: DLL load failed: One of the library files needed
+  to run this application cannot be found.
+
+It could be that you haven't installed Tcl/Tk, but if you did +install Tcl/Tk, and the Wish application works correctly, +the problem may be that its installer didn't +manage to edit the autoexec.bat file correctly. It tries to add a +statement that changes the PATH environment variable to include +the Tcl/Tk 'bin' subdirectory, but sometimes this edit doesn't +quite work. Opening it with notepad usually reveals what the +problem is. +

+(One additional hint, noted by David Szafranski: you can't use +long filenames here; e.g. use C:\PROGRA~1\Tcl\bin instead of +C:\Program Files\Tcl\bin.) +

+ +Edit this entry / +Log info + +/ Last changed on Wed Dec 2 22:32:41 1998 by +GvR +

+ +


+

8.9. Can't extract the downloaded documentation on Windows

+Sometimes, when you download the documentation package to a Windows +machine using a web browser, the file extension of the saved file +ends up being .EXE. This is a mistake; the extension should be .TGZ. +

+Simply rename the downloaded file to have the .TGZ extension, and +WinZip will be able to handle it. (If your copy of WinZip doesn't, +get a newer one from http://www.winzip.com.) +

+ +Edit this entry / +Log info + +/ Last changed on Sat Nov 21 13:41:35 1998 by +GvR +

+ +


+

8.10. Can't get Py_RunSimpleFile() to work.

+This is very sensitive to the compiler vendor, version and (perhaps) +even options. If the FILE* structure in your embedding program isn't +the same as is assumed by the Python interpreter it won't work. +

+The Python 1.5.* DLLs (python15.dll) are all compiled +with MS VC++ 5.0 and with multithreading-DLL options (/MD, I think). +

+If you can't change compilers or flags, try using Py_RunSimpleString(). +A trick to get it to run an arbitrary file is to construct a call to +execfile() with the name of your file as argument. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Jan 13 10:58:14 1999 by +GvR +

+ +


+

8.11. Where is Freeze for Windows?

+("Freeze" is a program that allows you to ship a Python program +as a single stand-alone executable file. It is not a compiler, +your programs don't run any faster, but they are more easily +distributable (to platforms with the same OS and CPU). Read the +README file of the freeze program for more disclaimers.) +

+You can use freeze on Windows, but you must download the source +tree (see http://www.python.org/download/download_source.html). +This is recommended for Python 1.5.2 (and betas thereof) only; +older versions don't quite work. +

+You need the Microsoft VC++ 5.0 compiler (maybe it works with +6.0 too). You probably need to build Python -- the project files +are all in the PCbuild directory. +

+The freeze program is in the Tools\freeze subdirectory of the source +tree. +

+ +Edit this entry / +Log info + +/ Last changed on Wed Feb 17 18:47:24 1999 by +GvR +

+ +


+

8.12. Is a *.pyd file the same as a DLL?

+Yes, .pyd files are dll's. But there are a few differences. If you +have a DLL named foo.pyd, then it must have a function initfoo(). You +can then write Python "import foo", and Python will search for foo.pyd +(as well as foo.py, foo.pyc) and if it finds it, will attempt to call +initfoo() to initialize it. You do not link your .exe with foo.lib, +as that would cause Windows to require the DLL to be present. +

+Note that the search path for foo.pyd is PYTHONPATH, not the same as +the path that Windows uses to search for foo.dll. Also, foo.pyd need +not be present to run your program, whereas if you linked your program +with a dll, the dll is required. Of course, foo.pyd is required if +you want to say "import foo". In a dll, linkage is declared in the +source code with __declspec(dllexport). In a .pyd, linkage is defined +in a list of available functions. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Nov 23 02:40:08 1999 by +Jameson Quinn +

+ +


+

8.13. Missing cw3215mt.dll (or missing cw3215.dll)

+Sometimes, when using Tkinter on Windows, you get an error that +cw3215mt.dll or cw3215.dll is missing. +

+Cause: you have an old Tcl/Tk DLL built with cygwin in your path +(probably C:\Windows). You must use the Tcl/Tk DLLs from the +standard Tcl/Tk installation (Python 1.5.2 comes with one). +

+ +Edit this entry / +Log info + +/ Last changed on Fri Jun 11 00:54:13 1999 by +GvR +

+ +


+

8.14. How to make python scripts executable:

+[Blake Coverett] +

+Win2K: +

+The standard installer already associates the .py extension with a file type +(Python.File) and gives that file type an open command that runs the +interpreter (D:\Program Files\Python\python.exe "%1" %*). This is enough to +make scripts executable from the command prompt as 'foo.py'. If you'd +rather be able to execute the script by simple typing 'foo' with no +extension you need to add .py to the PATHEXT environment variable. +

+WinNT: +

+The steps taken by the installed as described above allow you do run a +script with 'foo.py', but a long time bug in the NT command processor +prevents you from redirecting the input or output of any script executed in +this way. This is often important. +

+An appropriate incantation for making a Python script executable under WinNT +is to give the file an extension of .cmd and add the following as the first +line: +

+

+    @setlocal enableextensions & python -x %~f0 %* & goto :EOF
+
+Win9x: +

+[Due to Bruce Eckel] +

+

+  @echo off
+  rem = """
+  rem run python on this bat file. Needs the full path where
+  rem you keep your python files. The -x causes python to skip
+  rem the first line of the file:
+  python -x c:\aaa\Python\\"%0".bat %1 %2 %3 %4 %5 %6 %7 %8 %9
+  goto endofpython
+  rem """
+
+
+  # The python program goes here:
+
+
+  print "hello, Python"
+
+
+  # For the end of the batch file:
+  rem = """
+  :endofpython
+  rem """
+
+

+ +Edit this entry / +Log info + +/ Last changed on Tue Nov 30 10:25:17 1999 by +GvR +

+ +


+

8.15. Warning about CTL3D32 version from installer

+The Python installer issues a warning like this: +

+

+  This version uses CTL3D32.DLL whitch is not the correct version.
+  This version is used for windows NT applications only.
+
+[Tim Peters] +This is a Microsoft DLL, and a notorious +source of problems. The msg means what it says: you have the wrong version +of this DLL for your operating system. The Python installation did not +cause this -- something else you installed previous to this overwrote the +DLL that came with your OS (probably older shareware of some sort, but +there's no way to tell now). If you search for "CTL3D32" using any search +engine (AltaVista, for example), you'll find hundreds and hundreds of web +pages complaining about the same problem with all sorts of installation +programs. They'll point you to ways to get the correct version reinstalled +on your system (since Python doesn't cause this, we can't fix it). +

+David A Burton has written a little program to fix this. Go to +http://www.burtonsys.com/download.html and click on "ctl3dfix.zip" +

+ +Edit this entry / +Log info + +/ Last changed on Thu Oct 26 15:42:00 2000 by +GvR +

+ +


+

8.16. How can I embed Python into a Windows application?

+Edward K. Ream <edream@tds.net> writes +

+When '##' appears in a file name below, it is an abbreviated version number. For example, for Python 2.1.1, ## will be replaced by 21. +

+Embedding the Python interpreter in a Windows app can be summarized as +follows: +

+1. Do _not_ build Python into your .exe file directly. On Windows, +Python must be a DLL to handle importing modules that are themselves +DLL's. (This is the first key undocumented fact.) Instead, link to +python##.dll; it is typically installed in c:\Windows\System. +

+You can link to Python statically or dynamically. Linking statically +means linking against python##.lib The drawback is that your app won't +run if python##.dll does not exist on your system. +

+General note: python##.lib is the so-called "import lib" corresponding +to python.dll. It merely defines symbols for the linker. +

+Borland note: convert python##.lib to OMF format using Coff2Omf.exe +first. +

+Linking dynamically greatly simplifies link options; everything happens +at run time. Your code must load python##.dll using the Windows +LoadLibraryEx() routine. The code must also use access routines and +data in python##.dll (that is, Python's C API's) using pointers +obtained by the Windows GetProcAddress() routine. Macros can make +using these pointers transparent to any C code that calls routines in +Python's C API. +

+2. If you use SWIG, it is easy to create a Python "extension module" +that will make the app's data and methods available to Python. SWIG +will handle just about all the grungy details for you. The result is C +code that you link _into your .exe file_ (!) You do _not_ have to +create a DLL file, and this also simplifies linking. +

+3. SWIG will create an init function (a C function) whose name depends +on the name of the extension module. For example, if the name of the +module is leo, the init function will be called initleo(). If you use +SWIG shadow classes, as you should, the init function will be called +initleoc(). This initializes a mostly hidden helper class used by the +shadow class. +

+The reason you can link the C code in step 2 into your .exe file is that +calling the initialization function is equivalent to importing the +module into Python! (This is the second key undocumented fact.) +

+4. In short, you can use the following code to initialize the Python +interpreter with your extension module. +

+

+    #include "python.h"
+    ...
+    Py_Initialize();  // Initialize Python.
+    initmyAppc();  // Initialize (import) the helper class. 
+    PyRun_SimpleString("import myApp") ;  // Import the shadow class.
+
+5. There are two problems with Python's C API which will become apparent +if you use a compiler other than MSVC, the compiler used to build +python##.dll. +

+Problem 1: The so-called "Very High Level" functions that take FILE * +arguments will not work in a multi-compiler environment; each compiler's +notion of a struct FILE will be different. From an implementation +standpoint these are very _low_ level functions. +

+Problem 2: SWIG generates the following code when generating wrappers to +void functions: +

+

+    Py_INCREF(Py_None);
+    _resultobj = Py_None;
+    return _resultobj;
+
+Alas, Py_None is a macro that expands to a reference to a complex data +structure called _Py_NoneStruct inside python##.dll. Again, this code +will fail in a mult-compiler environment. Replace such code by: +

+

+    return Py_BuildValue("");
+
+It may be possible to use SWIG's %typemap command to make the change +automatically, though I have not been able to get this to work (I'm a +complete SWIG newbie). +

+6. Using a Python shell script to put up a Python interpreter window +from inside your Windows app is not a good idea; the resulting window +will be independent of your app's windowing system. Rather, you (or the +wxPythonWindow class) should create a "native" interpreter window. It +is easy to connect that window to the Python interpreter. You can +redirect Python's i/o to _any_ object that supports read and write, so +all you need is a Python object (defined in your extension module) that +contains read() and write() methods. +

+ +Edit this entry / +Log info + +/ Last changed on Thu Jan 31 16:29:34 2002 by +Victor Kryukov +

+ +


+

8.17. Setting up IIS 5 to use Python for CGI

+In order to set up Internet Information Services 5 to use Python for CGI processing, please see the following links: +

+http://www.e-coli.net/pyiis_server.html (for Win2k Server) +http://www.e-coli.net/pyiis.html (for Win2k pro) +

+ +Edit this entry / +Log info + +/ Last changed on Fri Mar 22 22:05:51 2002 by +douglas savitsky +

+ +


+

8.18. How do I run a Python program under Windows?

+This is not necessarily quite the straightforward question it appears +to be. If you are already familiar with running programs from the +Windows command line then everything will seem really easy and +obvious. If your computer experience is limited then you might need a +little more guidance. Also there are differences between Windows 95, +98, NT, ME, 2000 and XP which can add to the confusion. You might +think of this as "why I pay software support charges" if you have a +helpful and friendly administrator to help you set things up without +having to understand all this yourself. If so, then great! Show them +this page and it should be a done deal. +

+Unless you use some sort of integrated development environment (such +as PythonWin or IDLE, to name only two in a growing family) then you +will end up typing Windows commands into what is variously referred +to as a "DOS window" or "Command prompt window". Usually you can +create such a window from your Start menu (under Windows 2000 I use +"Start | Programs | Accessories | Command Prompt"). You should be +able to recognize when you have started such a window because you will +see a Windows "command prompt", which usually looks like this: +

+

+    C:\>
+
+The letter may be different, and there might be other things after it, +so you might just as easily see something like: +

+

+    D:\Steve\Projects\Python>
+
+depending on how your computer has been set up and what else you have +recently done with it. Once you have started such a window, you are +well on the way to running Python programs. +

+You need to realize that your Python scripts have to be processed by +another program, usually called the "Python interpreter". The +interpreter reads your script, "compiles" it into "Python bytecodes" +(which are instructions for an imaginary computer known as the "Python +Virtual Machine") and then executes the bytecodes to run your +program. So, how do you arrange for the interpreter to handle your +Python? +

+First, you need to make sure that your command window recognises the +word "python" as an instruction to start the interpreter. If you have +opened a command window, you should try entering the command: +

+

+    python
+
+and hitting return. If you then see something like: +

+

+    Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32
+    Type "help", "copyright", "credits" or "license" for more information.
+    >>>
+
+then this part of the job has been correctly managed during Python's +installation process, and you have started the interpreter in +"interactive mode". That means you can enter Python statements or +expressions interactively and have them executed or evaluated while +you wait. This is one of Python's strongest features, but it takes a +little getting used to. Check it by entering a few expressions of your +choice and seeing the results... +

+

+    >>> print "Hello"
+    Hello
+    >>> "Hello" * 3
+    HelloHelloHello
+
+When you want to end your interactive Python session, enter a +terminator (hold the Ctrl key down while you enter a Z, then hit the +"Enter" key) to get back to your Windows command prompt. You may also +find that you have a Start-menu entry such as "Start | Programs | +Python 2.2 | Python (command line)" that results in you seeing the +">>>" prompt in a new window. If so, the window will disappear after +you enter the terminator -- Windows runs a single "python" command in +the window, which terminates when you terminate the interpreter. +

+If the "python" command, instead of displaying the interpreter prompt ">>>", gives you a message like +

+

+    'python' is not recognized as an internal or external command,
+    operable program or batch file.
+
+or +

+

+    Bad command or filename
+
+then you need to make sure that your computer knows where to find the +Python interpreter. To do this you will have to modify a setting +called the PATH, which is a just list of directories where Windows +will look for programs. Rather than just enter the right command every +time you create a command window, you should arrange for Python's +installation directory to be added to the PATH of every command window +as it starts. If you installed Python fairly recently then the command +

+

+    dir C:\py*
+
+will probably tell you where it is installed. Alternatively, perhaps +you made a note. Otherwise you will be reduced to a search of your +whole disk ... break out the Windows explorer and use "Tools | Find" +or hit the "Search" button and look for "python.exe". Suppose you +discover that Python is installed in the C:\Python22 directory (the +default at the time of writing) then you should make sure that +entering the command +

+

+    c:\Python22\python
+
+starts up the interpreter as above (and don't forget you'll need a +"CTRL-Z" and an "Enter" to get out of it). Once you have verified the +directory, you need to add it to the start-up routines your computer +goes through. For older versions of Windows the easiest way to do +this is to edit the C:\AUTOEXEC.BAT file. You would want to add a line +like the following to AUTOEXEC.BAT: +

+

+    PATH C:\Python22;%PATH%
+
+For Windows NT, 2000 and (I assume) XP, you will need to add a string +such as +

+

+    ;C:\Python22
+
+to the current setting for the PATH environment variable, which you +will find in the properties window of "My Computer" under the +"Advanced" tab. Note that if you have sufficient privilege you might +get a choice of installing the settings either for the Current User or +for System. The latter is preferred if you want everybody to be able +to run Python on the machine. +

+If you aren't confident doing any of these manipulations yourself, ask +for help! At this stage you may or may not want to reboot your system +to make absolutely sure the new setting has "taken" (don't you love +the way Windows gives you these freqeuent coffee breaks). You probably +won't need to for Windows NT, XP or 2000. You can also avoid it in +earlier versions by editing the file C:\WINDOWS\COMMAND\CMDINIT.BAT +instead of AUTOEXEC.BAT. +

+You should now be able to start a new command window, enter +

+

+    python
+
+at the "C:>" (or whatever) prompt, and see the ">>>" prompt that +indicates the Python interpreter is reading interactive commands. +

+Let's suppose you have a program called "pytest.py" in directory +"C:\Steve\Projects\Python". A session to run that program might look +like this: +

+

+    C:\> cd \Steve\Projects\Python
+    C:\Steve\Projects\Python> python pytest.py
+
+Because you added a file name to the command to start the interpreter, +when it starts up it reads the Python script in the named file, +compiles it, executes it, and terminates (so you see another "C:\>" +prompt). You might also have entered +

+

+    C:\> python \Steve\Projects\Python\pytest.py
+
+if you hadn't wanted to change your current directory. +

+Under NT, 2000 and XP you may well find that the installation process +has also arranged that the command +

+

+    pytest.py
+
+(or, if the file isn't in the current directory) +

+

+    C:\Steve\Projects\Python\pytest.py
+
+will automatically recognize the ".py" extension and run the Python +interpreter on the named file. Using this feature is fine, but some +versions of Windows have bugs which mean that this form isn't exactly +equivalent to using the interpreter explicitly, so be careful. Easier +to remember, for now, that +

+

+    python C:\Steve\Projects\Python\pytest.py
+
+works pretty close to the same, and redirection will work (more) +reliably. +

+The important things to remember are: +

+1. Start Python from the Start Menu, or make sure the PATH is set +correctly so Windows can find the Python interpreter. +

+

+    python
+
+should give you a '>>>" prompt from the Python interpreter. Don't +forget the CTRL-Z and ENTER to terminate the interpreter (and, if you +started the window from the Start Menu, make the window disappear). +

+2. Once this works, you run programs with commands: +

+

+    python {program-file}
+
+3. When you know the commands to use you can build Windows shortcuts +to run the Python interpreter on any of your scripts, naming +particular working directories, and adding them to your menus, but +that's another lessFAQ. Take a look at +

+

+    python --help
+
+if your needs are complex. +

+4. Interactive mode (where you see the ">>>" prompt) is best used +not for running programs, which are better executed as in steps 2 +and 3, but for checking that individual statements and expressions do +what you think they will, and for developing code by experiment. +

+ +Edit this entry / +Log info + +/ Last changed on Tue Aug 20 16:19:53 2002 by +GvR +

+ +


+Python home / +Python FAQ Wizard 1.0.3 / +Feedback to GvR +

Python Powered
+ + --- python3.2-3.2.3.orig/debian/README.idle-PVER.in +++ python3.2-3.2.3/debian/README.idle-PVER.in @@ -0,0 +1,14 @@ + + The Python IDLE package for Debian + ---------------------------------- + +This package contains Python @VER@'s Integrated DeveLopment Environment, IDLE. + +IDLE is included in the Python @VER@ upstream distribution (Tools/idle) and +depends on Tkinter (available as @PVER@-tk package). + +I have written a simple man page. + + + 06/16/1999 + Gregor Hoffleit --- python3.2-3.2.3.orig/debian/2to3-3.2.1 +++ python3.2-3.2.3/debian/2to3-3.2.1 @@ -0,0 +1,41 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.40.4. +.TH 2TO3-3.2 "1" "January 2012" "2to3-3.2 3.2" "User Commands" +.SH NAME +2to3-3.2 \- Python2 to Python3 converter +.SH SYNOPSIS +.B 2to3 +[\fIoptions\fR] \fIfile|dir \fR... +.SH OPTIONS +.TP +\fB\-h\fR, \fB\-\-help\fR +show this help message and exit +.TP +\fB\-d\fR, \fB\-\-doctests_only\fR +Fix up doctests only +.TP +\fB\-f\fR FIX, \fB\-\-fix\fR=\fIFIX\fR +Each FIX specifies a transformation; default: all +.TP +\fB\-j\fR PROCESSES, \fB\-\-processes\fR=\fIPROCESSES\fR +Run 2to3 concurrently +.TP +\fB\-x\fR NOFIX, \fB\-\-nofix\fR=\fINOFIX\fR +Prevent a transformation from being run +.TP +\fB\-l\fR, \fB\-\-list\-fixes\fR +List available transformations +.TP +\fB\-p\fR, \fB\-\-print\-function\fR +Modify the grammar so that print() is a function +.TP +\fB\-v\fR, \fB\-\-verbose\fR +More verbose logging +.TP +\fB\-\-no\-diffs\fR +Don't show diffs of the refactoring +.TP +\fB\-w\fR, \fB\-\-write\fR +Write back modified files +.TP +\fB\-n\fR, \fB\-\-nobackups\fR +Don't write backups for modified files --- python3.2-3.2.3.orig/debian/PVER-dev.postinst.in +++ python3.2-3.2.3/debian/PVER-dev.postinst.in @@ -0,0 +1,24 @@ +#! /bin/sh -e + +if [ "$1" = configure ]; then + if [ -d /usr/include/@PVER@ ] && [ ! -h /usr/include/@PVER@ ]; then + if rmdir /usr/include/@PVER@ 2> /dev/null; then + ln -sf @PVER@mu /usr/include/@PVER@ + else + echo >&2 "WARNING: non-empty directory on upgrade: /usr/include/@PVER@" + ls -l /usr/include/@PVER@ + fi + fi + if [ -d /usr/lib/@PVER@/config ] && [ ! -h /usr/lib/@PVER@/config ]; then + if rmdir /usr/lib/@PVER@/config 2> /dev/null; then + ln -sf config-@VER@mu /usr/lib/@PVER@/config + else + echo >&2 "WARNING: non-empty directory on upgrade: /usr/lib/@PVER@/config" + ls -l /usr/lib/@PVER@/config + fi + fi +fi + +#DEBHELPER# + +exit 0 --- python3.2-3.2.3.orig/debian/PVER-minimal.postinst.in +++ python3.2-3.2.3/debian/PVER-minimal.postinst.in @@ -0,0 +1,87 @@ +#! /bin/sh + +set -e + +if [ ! -f /etc/@PVER@/sitecustomize.py ]; then + cat <<-EOF + # Empty sitecustomize.py to avoid a dangling symlink +EOF +fi + +if [ "$1" = configure ]; then + if [ -d /usr/lib/@PVER@/config ] && [ ! -h /usr/lib/@PVER@/config ]; then + if rmdir /usr/lib/@PVER@/config 2> /dev/null; then + ln -sf config-@VER@mu /usr/lib/@PVER@/config + else + echo >&2 "WARNING: non-empty directory on upgrade: /usr/lib/@PVER@/config" + ls -l /usr/lib/@PVER@/config + fi + fi +fi + +syssite=/usr/lib/@PVER@/site-packages +localsite=/usr/local/lib/@PVER@/dist-packages +syslink=../../${localsite#/usr/*} + +case "$1" in + configure) + # Create empty directories in /usr/local + if [ ! -e /usr/local/lib/@PVER@ ]; then + mkdir -p /usr/local/lib/@PVER@ 2> /dev/null || true + chmod 2775 /usr/local/lib/@PVER@ 2> /dev/null || true + chown root:staff /usr/local/lib/@PVER@ 2> /dev/null || true + fi + if [ ! -e $localsite ]; then + mkdir -p $localsite 2> /dev/null || true + chmod 2775 $localsite 2> /dev/null || true + chown root:staff $localsite 2> /dev/null || true + fi + #if [ ! -h $syssite ]; then + # ln -s $syslink $syssite + #fi + + if which update-binfmts >/dev/null; then + update-binfmts --import @PVER@ + fi + + ;; +esac + +if [ "$1" = configure ]; then + ( + files=$(dpkg -L @PVER@-minimal | sed -n '/^\/usr\/lib\/@PVER@\/.*\.py$/p') + @PVER@ /usr/lib/@PVER@/py_compile.py $files + if grep -sq '^byte-compile[^#]*optimize' /etc/python/debian_config; then + @PVER@ -O /usr/lib/@PVER@/py_compile.py $files + fi + ) + bc=no + #if [ -z "$2" ] || dpkg --compare-versions "$2" lt 2.5-3 \ + # || [ -f /var/lib/python/@PVER@_installed ]; then + # bc=yes + #fi + if ! grep -sq '^supported-versions[^#]*@PVER@' /usr/share/python/debian_defaults + then + # FIXME: byte compile anyway? + bc=no + fi + if [ "$bc" = yes ]; then + # new installation or installation of first version with hook support + if [ "$DEBIAN_FRONTEND" != noninteractive ]; then + echo "Linking and byte-compiling packages for runtime @PVER@..." + fi + version=$(dpkg -s @PVER@-minimal | awk '/^Version:/ {print $2}') + for hook in /usr/share/python3/runtime.d/*.rtinstall; do + [ -x $hook ] || continue + $hook rtinstall @PVER@ "$2" "$version" + done + if [ -f /var/lib/python/@PVER@_installed ]; then + rm -f /var/lib/python/@PVER@_installed + rmdir --ignore-fail-on-non-empty /var/lib/python 2>/dev/null + fi + fi +fi + +#DEBHELPER# + +exit 0 --- python3.2-3.2.3.orig/debian/libpython.symbols.in +++ python3.2-3.2.3/debian/libpython.symbols.in @@ -0,0 +1,1331 @@ + PyAST_Check@Base @SVER@ + PyAST_Compile@Base @SVER@ + PyAST_CompileEx@Base @SVER@ + PyAST_FromNode@Base @SVER@ + PyAST_mod2obj@Base @SVER@ + PyAST_obj2mod@Base @SVER@ + PyArena_AddPyObject@Base @SVER@ + PyArena_Free@Base @SVER@ + PyArena_Malloc@Base @SVER@ + PyArena_New@Base @SVER@ + PyArg_Parse@Base @SVER@ + PyArg_ParseTuple@Base @SVER@ + PyArg_ParseTupleAndKeywords@Base @SVER@ + PyArg_UnpackTuple@Base @SVER@ + PyArg_VaParse@Base @SVER@ + PyArg_VaParseTupleAndKeywords@Base @SVER@ + PyArg_ValidateKeywordArguments@Base @SVER@ + PyBaseObject_Type@Base @SVER@ + PyBool_FromLong@Base @SVER@ + PyBool_Type@Base @SVER@ + PyBuffer_FillContiguousStrides@Base @SVER@ + PyBuffer_FillInfo@Base @SVER@ + PyBuffer_FromContiguous@Base @SVER@ + PyBuffer_GetPointer@Base @SVER@ + PyBuffer_IsContiguous@Base @SVER@ + PyBuffer_Release@Base @SVER@ + PyBuffer_ToContiguous@Base @SVER@ + PyBufferedIOBase_Type@Base @SVER@ + PyBufferedRWPair_Type@Base @SVER@ + PyBufferedRandom_Type@Base @SVER@ + PyBufferedReader_Type@Base @SVER@ + PyBufferedWriter_Type@Base @SVER@ + PyByteArrayIter_Type@Base @SVER@ + PyByteArray_AsString@Base @SVER@ + PyByteArray_Concat@Base @SVER@ + PyByteArray_Fini@Base @SVER@ + PyByteArray_FromObject@Base @SVER@ + PyByteArray_FromStringAndSize@Base @SVER@ + PyByteArray_Init@Base @SVER@ + PyByteArray_Resize@Base @SVER@ + PyByteArray_Size@Base @SVER@ + PyByteArray_Type@Base @SVER@ + PyBytesIO_Type@Base @SVER@ + PyBytesIter_Type@Base @SVER@ + PyBytes_AsString@Base @SVER@ + PyBytes_AsStringAndSize@Base @SVER@ + PyBytes_Concat@Base @SVER@ + PyBytes_ConcatAndDel@Base @SVER@ + PyBytes_DecodeEscape@Base @SVER@ + PyBytes_Fini@Base @SVER@ + PyBytes_FromFormat@Base @SVER@ + PyBytes_FromFormatV@Base @SVER@ + PyBytes_FromObject@Base @SVER@ + PyBytes_FromString@Base @SVER@ + PyBytes_FromStringAndSize@Base @SVER@ + PyBytes_Repr@Base @SVER@ + PyBytes_Size@Base @SVER@ + PyBytes_Type@Base @SVER@ + (optional)PyCArgObject_new@Base @SVER@ + (optional)PyCArg_Type@Base @SVER@ + (optional)PyCArrayType_Type@Base @SVER@ + (optional)PyCArrayType_from_ctype@Base @SVER@ + (optional)PyCArray_Type@Base @SVER@ + (optional)PyCData_AtAddress@Base @SVER@ + (optional)PyCData_FromBaseObj@Base @SVER@ + (optional)PyCData_Type@Base @SVER@ + (optional)PyCData_get@Base @SVER@ + (optional)PyCData_set@Base @SVER@ + (optional)PyCField_FromDesc@Base @SVER@ + (optional)PyCField_Type@Base @SVER@ + (optional)PyCFuncPtrType_Type@Base @SVER@ + (optional)PyCFuncPtr_Type@Base @SVER@ + PyCFunction_Call@Base @SVER@ + PyCFunction_ClearFreeList@Base @SVER@ + PyCFunction_Fini@Base @SVER@ + PyCFunction_GetFlags@Base @SVER@ + PyCFunction_GetFunction@Base @SVER@ + PyCFunction_GetSelf@Base @SVER@ + PyCFunction_New@Base @SVER@ + PyCFunction_NewEx@Base @SVER@ + PyCFunction_Type@Base @SVER@ + (optional)PyCPointerType_Type@Base @SVER@ + (optional)PyCPointer_Type@Base @SVER@ + (optional)PyCSimpleType_Type@Base @SVER@ + (optional)PyCStgDict_Type@Base @SVER@ + (optional)PyCStgDict_clone@Base @SVER@ + (optional)PyCStructType_Type@Base @SVER@ + (optional)PyCStructUnionType_update_stgdict@Base @SVER@ + (optional)PyCThunk_Type@Base @SVER@ + PyCallIter_New@Base @SVER@ + PyCallIter_Type@Base @SVER@ + PyCallable_Check@Base @SVER@ + PyCapsule_GetContext@Base @SVER@ + PyCapsule_GetDestructor@Base @SVER@ + PyCapsule_GetName@Base @SVER@ + PyCapsule_GetPointer@Base @SVER@ + PyCapsule_Import@Base @SVER@ + PyCapsule_IsValid@Base @SVER@ + PyCapsule_New@Base @SVER@ + PyCapsule_SetContext@Base @SVER@ + PyCapsule_SetDestructor@Base @SVER@ + PyCapsule_SetName@Base @SVER@ + PyCapsule_SetPointer@Base @SVER@ + PyCapsule_Type@Base @SVER@ + PyCell_Get@Base @SVER@ + PyCell_New@Base @SVER@ + PyCell_Set@Base @SVER@ + PyCell_Type@Base @SVER@ + PyClassMethodDescr_Type@Base @SVER@ + PyClassMethod_New@Base @SVER@ + PyClassMethod_Type@Base @SVER@ + PyCode_Addr2Line@Base @SVER@ + PyCode_New@Base @SVER@ + PyCode_NewEmpty@Base @SVER@ + PyCode_Optimize@Base @SVER@ + PyCode_Type@Base @SVER@ + PyCodec_BackslashReplaceErrors@Base @SVER@ + PyCodec_Decode@Base @SVER@ + PyCodec_Decoder@Base @SVER@ + PyCodec_Encode@Base @SVER@ + PyCodec_Encoder@Base @SVER@ + PyCodec_IgnoreErrors@Base @SVER@ + PyCodec_IncrementalDecoder@Base @SVER@ + PyCodec_IncrementalEncoder@Base @SVER@ + PyCodec_KnownEncoding@Base @SVER@ + PyCodec_LookupError@Base @SVER@ + PyCodec_Register@Base @SVER@ + PyCodec_RegisterError@Base @SVER@ + PyCodec_ReplaceErrors@Base @SVER@ + PyCodec_StreamReader@Base @SVER@ + PyCodec_StreamWriter@Base @SVER@ + PyCodec_StrictErrors@Base @SVER@ + PyCodec_XMLCharRefReplaceErrors@Base @SVER@ + PyCompileString@Base @SVER@ + PyComplex_AsCComplex@Base @SVER@ + PyComplex_FromCComplex@Base @SVER@ + PyComplex_FromDoubles@Base @SVER@ + PyComplex_ImagAsDouble@Base @SVER@ + PyComplex_RealAsDouble@Base @SVER@ + PyComplex_Type@Base @SVER@ + PyDescr_NewClassMethod@Base @SVER@ + PyDescr_NewGetSet@Base @SVER@ + PyDescr_NewMember@Base @SVER@ + PyDescr_NewMethod@Base @SVER@ + PyDescr_NewWrapper@Base @SVER@ + PyDictItems_Type@Base @SVER@ + PyDictIterItem_Type@Base @SVER@ + PyDictIterKey_Type@Base @SVER@ + PyDictIterValue_Type@Base @SVER@ + PyDictKeys_Type@Base @SVER@ + PyDictProxy_New@Base @SVER@ + PyDictProxy_Type@Base @SVER@ + PyDictValues_Type@Base @SVER@ + PyDict_Clear@Base @SVER@ + PyDict_Contains@Base @SVER@ + PyDict_Copy@Base @SVER@ + PyDict_DelItem@Base @SVER@ + PyDict_DelItemString@Base @SVER@ + PyDict_Fini@Base @SVER@ + PyDict_GetItem@Base @SVER@ + (optional)PyDict_GetItemProxy@Base @SVER@ + PyDict_GetItemString@Base @SVER@ + PyDict_GetItemWithError@Base @SVER@ + PyDict_Items@Base @SVER@ + PyDict_Keys@Base @SVER@ + PyDict_Merge@Base @SVER@ + PyDict_MergeFromSeq2@Base @SVER@ + PyDict_New@Base @SVER@ + PyDict_Next@Base @SVER@ + PyDict_SetItem@Base @SVER@ + (optional)PyDict_SetItemProxy@Base @SVER@ + PyDict_SetItemString@Base @SVER@ + PyDict_Size@Base @SVER@ + PyDict_Type@Base @SVER@ + PyDict_Update@Base @SVER@ + PyDict_Values@Base @SVER@ + PyEllipsis_Type@Base @SVER@ + PyEnum_Type@Base @SVER@ + PyErr_BadArgument@Base @SVER@ + PyErr_BadInternalCall@Base @SVER@ + PyErr_CheckSignals@Base @SVER@ + PyErr_Clear@Base @SVER@ + PyErr_Display@Base @SVER@ + PyErr_ExceptionMatches@Base @SVER@ + PyErr_Fetch@Base @SVER@ + PyErr_Format@Base @SVER@ + PyErr_GivenExceptionMatches@Base @SVER@ + PyErr_NewException@Base @SVER@ + PyErr_NewExceptionWithDoc@Base @SVER@ + PyErr_NoMemory@Base @SVER@ + PyErr_NormalizeException@Base @SVER@ + PyErr_Occurred@Base @SVER@ + PyErr_Print@Base @SVER@ + PyErr_PrintEx@Base @SVER@ + PyErr_ProgramText@Base @SVER@ + PyErr_Restore@Base @SVER@ + PyErr_SetFromErrno@Base @SVER@ + PyErr_SetFromErrnoWithFilename@Base @SVER@ + PyErr_SetFromErrnoWithFilenameObject@Base @SVER@ + PyErr_SetInterrupt@Base @SVER@ + PyErr_SetNone@Base @SVER@ + PyErr_SetObject@Base @SVER@ + PyErr_SetString@Base @SVER@ + PyErr_SyntaxLocation@Base @SVER@ + PyErr_SyntaxLocationEx@Base @SVER@ + PyErr_Warn@Base @SVER@ + PyErr_WarnEx@Base @SVER@ + PyErr_WarnExplicit@Base @SVER@ + PyErr_WarnFormat@Base @SVER@ + PyErr_WriteUnraisable@Base @SVER@ + PyEval_AcquireLock@Base @SVER@ + PyEval_AcquireThread@Base @SVER@ + PyEval_CallFunction@Base @SVER@ + PyEval_CallMethod@Base @SVER@ + PyEval_CallObjectWithKeywords@Base @SVER@ + PyEval_EvalCode@Base @SVER@ + PyEval_EvalCodeEx@Base @SVER@ + PyEval_EvalFrame@Base @SVER@ + PyEval_EvalFrameEx@Base @SVER@ + PyEval_GetBuiltins@Base @SVER@ + PyEval_GetCallStats@Base @SVER@ + PyEval_GetFrame@Base @SVER@ + PyEval_GetFuncDesc@Base @SVER@ + PyEval_GetFuncName@Base @SVER@ + PyEval_GetGlobals@Base @SVER@ + PyEval_GetLocals@Base @SVER@ + PyEval_InitThreads@Base @SVER@ + PyEval_MergeCompilerFlags@Base @SVER@ + PyEval_ReInitThreads@Base @SVER@ + PyEval_ReleaseLock@Base @SVER@ + PyEval_ReleaseThread@Base @SVER@ + PyEval_RestoreThread@Base @SVER@ + PyEval_SaveThread@Base @SVER@ + PyEval_SetProfile@Base @SVER@ + PyEval_SetTrace@Base @SVER@ + PyEval_ThreadsInitialized@Base @SVER@ + (optional)PyExc_ArgError@Base @SVER@ + PyExc_ArithmeticError@Base @SVER@ + PyExc_AssertionError@Base @SVER@ + PyExc_AttributeError@Base @SVER@ + PyExc_BaseException@Base @SVER@ + PyExc_BlockingIOError@Base @SVER@ + PyExc_BufferError@Base @SVER@ + PyExc_BytesWarning@Base @SVER@ + PyExc_DeprecationWarning@Base @SVER@ + PyExc_EOFError@Base @SVER@ + PyExc_EnvironmentError@Base @SVER@ + PyExc_Exception@Base @SVER@ + PyExc_FloatingPointError@Base @SVER@ + PyExc_FutureWarning@Base @SVER@ + PyExc_GeneratorExit@Base @SVER@ + PyExc_IOError@Base @SVER@ + PyExc_ImportError@Base @SVER@ + PyExc_ImportWarning@Base @SVER@ + PyExc_IndentationError@Base @SVER@ + PyExc_IndexError@Base @SVER@ + PyExc_KeyError@Base @SVER@ + PyExc_KeyboardInterrupt@Base @SVER@ + PyExc_LookupError@Base @SVER@ + PyExc_MemoryError@Base @SVER@ + PyExc_NameError@Base @SVER@ + PyExc_NotImplementedError@Base @SVER@ + PyExc_OSError@Base @SVER@ + PyExc_OverflowError@Base @SVER@ + PyExc_PendingDeprecationWarning@Base @SVER@ + PyExc_RecursionErrorInst@Base @SVER@ + PyExc_ReferenceError@Base @SVER@ + PyExc_ResourceWarning@Base @SVER@ + PyExc_RuntimeError@Base @SVER@ + PyExc_RuntimeWarning@Base @SVER@ + PyExc_StopIteration@Base @SVER@ + PyExc_SyntaxError@Base @SVER@ + PyExc_SyntaxWarning@Base @SVER@ + PyExc_SystemError@Base @SVER@ + PyExc_SystemExit@Base @SVER@ + PyExc_TabError@Base @SVER@ + PyExc_TypeError@Base @SVER@ + PyExc_UnboundLocalError@Base @SVER@ + PyExc_UnicodeDecodeError@Base @SVER@ + PyExc_UnicodeEncodeError@Base @SVER@ + PyExc_UnicodeError@Base @SVER@ + PyExc_UnicodeTranslateError@Base @SVER@ + PyExc_UnicodeWarning@Base @SVER@ + PyExc_UserWarning@Base @SVER@ + PyExc_ValueError@Base @SVER@ + PyExc_Warning@Base @SVER@ + PyExc_ZeroDivisionError@Base @SVER@ + PyException_GetCause@Base @SVER@ + PyException_GetContext@Base @SVER@ + PyException_GetTraceback@Base @SVER@ + PyException_SetCause@Base @SVER@ + PyException_SetContext@Base @SVER@ + PyException_SetTraceback@Base @SVER@ + PyFPE_counter@Base @SVER@ + PyFPE_dummy@Base @SVER@ + PyFPE_jbuf@Base @SVER@ + PyFileIO_Type@Base @SVER@ + PyFile_FromFd@Base @SVER@ + PyFile_GetLine@Base @SVER@ + PyFile_NewStdPrinter@Base @SVER@ + PyFile_WriteObject@Base @SVER@ + PyFile_WriteString@Base @SVER@ + PyFilter_Type@Base @SVER@ + PyFloat_AsDouble@Base @SVER@ + PyFloat_ClearFreeList@Base @SVER@ + PyFloat_Fini@Base @SVER@ + PyFloat_FromDouble@Base @SVER@ + PyFloat_FromString@Base @SVER@ + PyFloat_GetInfo@Base @SVER@ + PyFloat_GetMax@Base @SVER@ + PyFloat_GetMin@Base @SVER@ + PyFloat_Type@Base @SVER@ + PyFrame_BlockPop@Base @SVER@ + PyFrame_BlockSetup@Base @SVER@ + PyFrame_ClearFreeList@Base @SVER@ + PyFrame_FastToLocals@Base @SVER@ + PyFrame_Fini@Base @SVER@ + PyFrame_GetLineNumber@Base @SVER@ + PyFrame_LocalsToFast@Base @SVER@ + PyFrame_New@Base @SVER@ + PyFrame_Type@Base @SVER@ + PyFrozenSet_New@Base @SVER@ + PyFrozenSet_Type@Base @SVER@ + PyFunction_GetAnnotations@Base @SVER@ + PyFunction_GetClosure@Base @SVER@ + PyFunction_GetCode@Base @SVER@ + PyFunction_GetDefaults@Base @SVER@ + PyFunction_GetGlobals@Base @SVER@ + PyFunction_GetKwDefaults@Base @SVER@ + PyFunction_GetModule@Base @SVER@ + PyFunction_New@Base @SVER@ + PyFunction_SetAnnotations@Base @SVER@ + PyFunction_SetClosure@Base @SVER@ + PyFunction_SetDefaults@Base @SVER@ + PyFunction_SetKwDefaults@Base @SVER@ + PyFunction_Type@Base @SVER@ + PyFuture_FromAST@Base @SVER@ + PyGC_Collect@Base @SVER@ + PyGILState_Ensure@Base @SVER@ + PyGILState_GetThisThreadState@Base @SVER@ + PyGILState_Release@Base @SVER@ + PyGen_NeedsFinalizing@Base @SVER@ + PyGen_New@Base @SVER@ + PyGen_Type@Base @SVER@ + PyGetSetDescr_Type@Base @SVER@ + PyGrammar_AddAccelerators@Base @SVER@ + PyGrammar_FindDFA@Base @SVER@ + PyGrammar_LabelRepr@Base @SVER@ + PyGrammar_RemoveAccelerators@Base @SVER@ + PyIOBase_Type@Base @SVER@ + PyImport_AddModule@Base @SVER@ + PyImport_AppendInittab@Base @SVER@ + PyImport_Cleanup@Base @SVER@ + PyImport_ExecCodeModule@Base @SVER@ + PyImport_ExecCodeModuleEx@Base @SVER@ + PyImport_ExecCodeModuleWithPathnames@Base @SVER@ + PyImport_ExtendInittab@Base @SVER@ + PyImport_FrozenModules@Base @SVER@ + PyImport_GetImporter@Base @SVER@ + PyImport_GetMagicNumber@Base @SVER@ + PyImport_GetMagicTag@Base @SVER@ + PyImport_GetModuleDict@Base @SVER@ + PyImport_Import@Base @SVER@ + PyImport_ImportFrozenModule@Base @SVER@ + PyImport_ImportModule@Base @SVER@ + PyImport_ImportModuleLevel@Base @SVER@ + PyImport_ImportModuleNoBlock@Base @SVER@ + PyImport_Inittab@Base @SVER@ + PyImport_ReloadModule@Base @SVER@ + PyIncrementalNewlineDecoder_Type@Base @SVER@ + PyInstanceMethod_Function@Base @SVER@ + PyInstanceMethod_New@Base @SVER@ + PyInstanceMethod_Type@Base @SVER@ + PyInterpreterState_Clear@Base @SVER@ + PyInterpreterState_Delete@Base @SVER@ + PyInterpreterState_Head@Base @SVER@ + PyInterpreterState_New@Base @SVER@ + PyInterpreterState_Next@Base @SVER@ + PyInterpreterState_ThreadHead@Base @SVER@ + PyIter_Next@Base @SVER@ + PyListIter_Type@Base @SVER@ + PyListRevIter_Type@Base @SVER@ + PyList_Append@Base @SVER@ + PyList_AsTuple@Base @SVER@ + PyList_Fini@Base @SVER@ + PyList_GetItem@Base @SVER@ + PyList_GetSlice@Base @SVER@ + PyList_Insert@Base @SVER@ + PyList_New@Base @SVER@ + PyList_Reverse@Base @SVER@ + PyList_SetItem@Base @SVER@ + PyList_SetSlice@Base @SVER@ + PyList_Size@Base @SVER@ + PyList_Sort@Base @SVER@ + PyList_Type@Base @SVER@ + PyLongRangeIter_Type@Base @SVER@ + PyLong_AsDouble@Base @SVER@ + PyLong_AsLong@Base @SVER@ + PyLong_AsLongAndOverflow@Base @SVER@ + PyLong_AsLongLong@Base @SVER@ + PyLong_AsLongLongAndOverflow@Base @SVER@ + PyLong_AsSize_t@Base @SVER@ + PyLong_AsSsize_t@Base @SVER@ + PyLong_AsUnsignedLong@Base @SVER@ + PyLong_AsUnsignedLongLong@Base @SVER@ + PyLong_AsUnsignedLongLongMask@Base @SVER@ + PyLong_AsUnsignedLongMask@Base @SVER@ + PyLong_AsVoidPtr@Base @SVER@ + PyLong_Fini@Base @SVER@ + PyLong_FromDouble@Base @SVER@ + PyLong_FromLong@Base @SVER@ + PyLong_FromLongLong@Base @SVER@ + PyLong_FromSize_t@Base @SVER@ + PyLong_FromSsize_t@Base @SVER@ + PyLong_FromString@Base @SVER@ + PyLong_FromUnicode@Base @SVER@ + PyLong_FromUnsignedLong@Base @SVER@ + PyLong_FromUnsignedLongLong@Base @SVER@ + PyLong_FromVoidPtr@Base @SVER@ + PyLong_GetInfo@Base @SVER@ + PyLong_Type@Base @SVER@ + PyMap_Type@Base @SVER@ + PyMapping_Check@Base @SVER@ + PyMapping_GetItemString@Base @SVER@ + PyMapping_HasKey@Base @SVER@ + PyMapping_HasKeyString@Base @SVER@ + PyMapping_Items@Base @SVER@ + PyMapping_Keys@Base @SVER@ + PyMapping_Length@Base @SVER@ + PyMapping_SetItemString@Base @SVER@ + PyMapping_Size@Base @SVER@ + PyMapping_Values@Base @SVER@ + PyMarshal_Init@Base @SVER@ + PyMarshal_ReadLastObjectFromFile@Base @SVER@ + PyMarshal_ReadLongFromFile@Base @SVER@ + PyMarshal_ReadObjectFromFile@Base @SVER@ + PyMarshal_ReadObjectFromString@Base @SVER@ + PyMarshal_ReadShortFromFile@Base @SVER@ + PyMarshal_WriteLongToFile@Base @SVER@ + PyMarshal_WriteObjectToFile@Base @SVER@ + PyMarshal_WriteObjectToString@Base @SVER@ + PyMem_Free@Base @SVER@ + PyMem_Malloc@Base @SVER@ + PyMem_Realloc@Base @SVER@ + PyMemberDescr_Type@Base @SVER@ + PyMember_GetOne@Base @SVER@ + PyMember_SetOne@Base @SVER@ + PyMemoryView_FromBuffer@Base @SVER@ + PyMemoryView_FromObject@Base @SVER@ + PyMemoryView_GetContiguous@Base @SVER@ + PyMemoryView_Type@Base @SVER@ + PyMethodDescr_Type@Base @SVER@ + PyMethod_ClearFreeList@Base @SVER@ + PyMethod_Fini@Base @SVER@ + PyMethod_Function@Base @SVER@ + PyMethod_New@Base @SVER@ + PyMethod_Self@Base @SVER@ + PyMethod_Type@Base @SVER@ + PyModule_AddIntConstant@Base @SVER@ + PyModule_AddObject@Base @SVER@ + PyModule_AddStringConstant@Base @SVER@ + PyModule_GetDef@Base @SVER@ + PyModule_GetDict@Base @SVER@ + PyModule_GetFilename@Base @SVER@ + PyModule_GetFilenameObject@Base @SVER@ + PyModule_GetName@Base @SVER@ + PyModule_GetState@Base @SVER@ + PyModule_GetWarningsModule@Base @SVER@ + PyModule_New@Base @SVER@ + PyModule_Type@Base @SVER@ + PyNode_AddChild@Base @SVER@ + PyNode_Compile@Base @SVER@ + PyNode_Free@Base @SVER@ + PyNode_ListTree@Base @SVER@ + PyNode_New@Base @SVER@ + PyNullImporter_Type@Base @SVER@ + PyNumber_Absolute@Base @SVER@ + PyNumber_Add@Base @SVER@ + PyNumber_And@Base @SVER@ + PyNumber_AsOff_t@Base @SVER@ + PyNumber_AsSsize_t@Base @SVER@ + PyNumber_Check@Base @SVER@ + PyNumber_Divmod@Base @SVER@ + PyNumber_Float@Base @SVER@ + PyNumber_FloorDivide@Base @SVER@ + PyNumber_InPlaceAdd@Base @SVER@ + PyNumber_InPlaceAnd@Base @SVER@ + PyNumber_InPlaceFloorDivide@Base @SVER@ + PyNumber_InPlaceLshift@Base @SVER@ + PyNumber_InPlaceMultiply@Base @SVER@ + PyNumber_InPlaceOr@Base @SVER@ + PyNumber_InPlacePower@Base @SVER@ + PyNumber_InPlaceRemainder@Base @SVER@ + PyNumber_InPlaceRshift@Base @SVER@ + PyNumber_InPlaceSubtract@Base @SVER@ + PyNumber_InPlaceTrueDivide@Base @SVER@ + PyNumber_InPlaceXor@Base @SVER@ + PyNumber_Index@Base @SVER@ + PyNumber_Invert@Base @SVER@ + PyNumber_Long@Base @SVER@ + PyNumber_Lshift@Base @SVER@ + PyNumber_Multiply@Base @SVER@ + PyNumber_Negative@Base @SVER@ + PyNumber_Or@Base @SVER@ + PyNumber_Positive@Base @SVER@ + PyNumber_Power@Base @SVER@ + PyNumber_Remainder@Base @SVER@ + PyNumber_Rshift@Base @SVER@ + PyNumber_Subtract@Base @SVER@ + PyNumber_ToBase@Base @SVER@ + PyNumber_TrueDivide@Base @SVER@ + PyNumber_Xor@Base @SVER@ + PyOS_AfterFork@Base @SVER@ + PyOS_FiniInterrupts@Base @SVER@ + PyOS_InitInterrupts@Base @SVER@ + PyOS_InputHook@Base @SVER@ + PyOS_InterruptOccurred@Base @SVER@ + PyOS_Readline@Base @SVER@ + PyOS_ReadlineFunctionPointer@Base @SVER@ + PyOS_StdioReadline@Base @SVER@ + PyOS_double_to_string@Base @SVER@ + PyOS_getsig@Base @SVER@ + PyOS_mystricmp@Base @SVER@ + PyOS_mystrnicmp@Base @SVER@ + PyOS_setsig@Base @SVER@ + PyOS_snprintf@Base @SVER@ + PyOS_string_to_double@Base @SVER@ + PyOS_strtol@Base @SVER@ + PyOS_strtoul@Base @SVER@ + PyOS_vsnprintf@Base @SVER@ + PyObject_ASCII@Base @SVER@ + PyObject_AsCharBuffer@Base @SVER@ + PyObject_AsFileDescriptor@Base @SVER@ + PyObject_AsReadBuffer@Base @SVER@ + PyObject_AsWriteBuffer@Base @SVER@ + PyObject_Bytes@Base @SVER@ + PyObject_Call@Base @SVER@ + PyObject_CallFunction@Base @SVER@ + PyObject_CallFunctionObjArgs@Base @SVER@ + PyObject_CallMethod@Base @SVER@ + PyObject_CallMethodObjArgs@Base @SVER@ + PyObject_CallObject@Base @SVER@ + PyObject_CheckReadBuffer@Base @SVER@ + PyObject_ClearWeakRefs@Base @SVER@ + PyObject_CopyData@Base @SVER@ + PyObject_DelItem@Base @SVER@ + PyObject_DelItemString@Base @SVER@ + PyObject_Dir@Base @SVER@ + PyObject_Format@Base @SVER@ + PyObject_Free@Base @SVER@ + PyObject_GC_Del@Base @SVER@ + PyObject_GC_Track@Base @SVER@ + PyObject_GC_UnTrack@Base @SVER@ + PyObject_GenericGetAttr@Base @SVER@ + PyObject_GenericSetAttr@Base @SVER@ + PyObject_GetAttr@Base @SVER@ + PyObject_GetAttrString@Base @SVER@ + PyObject_GetBuffer@Base @SVER@ + PyObject_GetItem@Base @SVER@ + PyObject_GetIter@Base @SVER@ + PyObject_HasAttr@Base @SVER@ + PyObject_HasAttrString@Base @SVER@ + PyObject_Hash@Base @SVER@ + PyObject_HashNotImplemented@Base @SVER@ + PyObject_Init@Base @SVER@ + PyObject_InitVar@Base @SVER@ + PyObject_IsInstance@Base @SVER@ + PyObject_IsSubclass@Base @SVER@ + PyObject_IsTrue@Base @SVER@ + PyObject_Length@Base @SVER@ + PyObject_Malloc@Base @SVER@ + PyObject_Not@Base @SVER@ + PyObject_Print@Base @SVER@ + PyObject_Realloc@Base @SVER@ + PyObject_Repr@Base @SVER@ + PyObject_RichCompare@Base @SVER@ + PyObject_RichCompareBool@Base @SVER@ + PyObject_SelfIter@Base @SVER@ + PyObject_SetAttr@Base @SVER@ + PyObject_SetAttrString@Base @SVER@ + PyObject_SetItem@Base @SVER@ + PyObject_Size@Base @SVER@ + PyObject_Str@Base @SVER@ + PyObject_Type@Base @SVER@ + (optional)PyObject_stgdict@Base @SVER@ + PyParser_ASTFromFile@Base @SVER@ + PyParser_ASTFromString@Base @SVER@ + PyParser_AddToken@Base @SVER@ + PyParser_Delete@Base @SVER@ + PyParser_New@Base @SVER@ + PyParser_ParseFile@Base @SVER@ + PyParser_ParseFileFlags@Base @SVER@ + PyParser_ParseFileFlagsEx@Base @SVER@ + PyParser_ParseString@Base @SVER@ + PyParser_ParseStringFlags@Base @SVER@ + PyParser_ParseStringFlagsFilename@Base @SVER@ + PyParser_ParseStringFlagsFilenameEx@Base @SVER@ + PyParser_SetError@Base @SVER@ + PyParser_SimpleParseFile@Base @SVER@ + PyParser_SimpleParseFileFlags@Base @SVER@ + PyParser_SimpleParseString@Base @SVER@ + PyParser_SimpleParseStringFilename@Base @SVER@ + PyParser_SimpleParseStringFlags@Base @SVER@ + PyParser_SimpleParseStringFlagsFilename@Base @SVER@ + PyProperty_Type@Base @SVER@ + PyRangeIter_Type@Base @SVER@ + PyRange_Type@Base @SVER@ + PyRawIOBase_Type@Base @SVER@ + PyReversed_Type@Base @SVER@ + PyRun_AnyFile@Base @SVER@ + PyRun_AnyFileEx@Base @SVER@ + PyRun_AnyFileExFlags@Base @SVER@ + PyRun_AnyFileFlags@Base @SVER@ + PyRun_File@Base @SVER@ + PyRun_FileEx@Base @SVER@ + PyRun_FileExFlags@Base @SVER@ + PyRun_FileFlags@Base @SVER@ + PyRun_InteractiveLoop@Base @SVER@ + PyRun_InteractiveLoopFlags@Base @SVER@ + PyRun_InteractiveOne@Base @SVER@ + PyRun_InteractiveOneFlags@Base @SVER@ + PyRun_SimpleFile@Base @SVER@ + PyRun_SimpleFileEx@Base @SVER@ + PyRun_SimpleFileExFlags@Base @SVER@ + PyRun_SimpleString@Base @SVER@ + PyRun_SimpleStringFlags@Base @SVER@ + PyRun_String@Base @SVER@ + PyRun_StringFlags@Base @SVER@ + PySTEntry_Type@Base @SVER@ + PyST_GetScope@Base @SVER@ + PySeqIter_New@Base @SVER@ + PySeqIter_Type@Base @SVER@ + PySequence_Check@Base @SVER@ + PySequence_Concat@Base @SVER@ + PySequence_Contains@Base @SVER@ + PySequence_Count@Base @SVER@ + PySequence_DelItem@Base @SVER@ + PySequence_DelSlice@Base @SVER@ + PySequence_Fast@Base @SVER@ + PySequence_GetItem@Base @SVER@ + PySequence_GetSlice@Base @SVER@ + PySequence_In@Base @SVER@ + PySequence_InPlaceConcat@Base @SVER@ + PySequence_InPlaceRepeat@Base @SVER@ + PySequence_Index@Base @SVER@ + PySequence_Length@Base @SVER@ + PySequence_List@Base @SVER@ + PySequence_Repeat@Base @SVER@ + PySequence_SetItem@Base @SVER@ + PySequence_SetSlice@Base @SVER@ + PySequence_Size@Base @SVER@ + PySequence_Tuple@Base @SVER@ + PySetIter_Type@Base @SVER@ + PySet_Add@Base @SVER@ + PySet_Clear@Base @SVER@ + PySet_Contains@Base @SVER@ + PySet_Discard@Base @SVER@ + PySet_Fini@Base @SVER@ + PySet_New@Base @SVER@ + PySet_Pop@Base @SVER@ + PySet_Size@Base @SVER@ + PySet_Type@Base @SVER@ + PySignal_SetWakeupFd@Base @SVER@ + PySlice_GetIndices@Base @SVER@ + PySlice_GetIndicesEx@Base @SVER@ + PySlice_New@Base @SVER@ + PySlice_Type@Base @SVER@ + PyState_FindModule@Base @SVER@ + PyStaticMethod_New@Base @SVER@ + PyStaticMethod_Type@Base @SVER@ + PyStdPrinter_Type@Base @SVER@ + PyStringIO_Type@Base @SVER@ + PyStructSequence_GetItem@Base @SVER@ + PyStructSequence_InitType@Base @SVER@ + PyStructSequence_New@Base @SVER@ + PyStructSequence_NewType@Base @SVER@ + PyStructSequence_SetItem@Base @SVER@ + PyStructSequence_UnnamedField@Base @SVER@ + PySuper_Type@Base @SVER@ + PySymtable_Build@Base @SVER@ + PySymtable_Free@Base @SVER@ + PySymtable_Lookup@Base @SVER@ + PySys_AddWarnOption@Base @SVER@ + PySys_AddWarnOptionUnicode@Base @SVER@ + PySys_AddXOption@Base @SVER@ + PySys_FormatStderr@Base @SVER@ + PySys_FormatStdout@Base @SVER@ + PySys_GetObject@Base @SVER@ + PySys_GetXOptions@Base @SVER@ + PySys_HasWarnOptions@Base @SVER@ + PySys_ResetWarnOptions@Base @SVER@ + PySys_SetArgv@Base @SVER@ + PySys_SetArgvEx@Base @SVER@ + PySys_SetObject@Base @SVER@ + PySys_SetPath@Base @SVER@ + PySys_WriteStderr@Base @SVER@ + PySys_WriteStdout@Base @SVER@ + PyTextIOBase_Type@Base @SVER@ + PyTextIOWrapper_Type@Base @SVER@ + PyThreadState_Clear@Base @SVER@ + PyThreadState_Delete@Base @SVER@ + PyThreadState_DeleteCurrent@Base @SVER@ + PyThreadState_Get@Base @SVER@ + PyThreadState_GetDict@Base @SVER@ + PyThreadState_New@Base @SVER@ + PyThreadState_Next@Base @SVER@ + PyThreadState_SetAsyncExc@Base @SVER@ + PyThreadState_Swap@Base @SVER@ + PyThread_ReInitTLS@Base @SVER@ + PyThread_acquire_lock@Base @SVER@ + PyThread_acquire_lock_timed@Base @SVER@ + PyThread_allocate_lock@Base @SVER@ + PyThread_create_key@Base @SVER@ + PyThread_delete_key@Base @SVER@ + PyThread_delete_key_value@Base @SVER@ + PyThread_exit_thread@Base @SVER@ + PyThread_free_lock@Base @SVER@ + PyThread_get_key_value@Base @SVER@ + PyThread_get_stacksize@Base @SVER@ + PyThread_get_thread_ident@Base @SVER@ + PyThread_init_thread@Base @SVER@ + PyThread_release_lock@Base @SVER@ + PyThread_set_key_value@Base @SVER@ + PyThread_set_stacksize@Base @SVER@ + PyThread_start_new_thread@Base @SVER@ + PyToken_OneChar@Base @SVER@ + PyToken_ThreeChars@Base @SVER@ + PyToken_TwoChars@Base @SVER@ + PyTokenizer_FindEncoding@Base @SVER@ + PyTokenizer_Free@Base @SVER@ + PyTokenizer_FromFile@Base @SVER@ + PyTokenizer_FromString@Base @SVER@ + PyTokenizer_FromUTF8@Base @SVER@ + PyTokenizer_Get@Base @SVER@ + PyTraceBack_Here@Base @SVER@ + PyTraceBack_Print@Base @SVER@ + PyTraceBack_Type@Base @SVER@ + PyTupleIter_Type@Base @SVER@ + PyTuple_ClearFreeList@Base @SVER@ + PyTuple_Fini@Base @SVER@ + PyTuple_GetItem@Base @SVER@ + PyTuple_GetSlice@Base @SVER@ + PyTuple_New@Base @SVER@ + PyTuple_Pack@Base @SVER@ + PyTuple_SetItem@Base @SVER@ + PyTuple_Size@Base @SVER@ + PyTuple_Type@Base @SVER@ + PyType_ClearCache@Base @SVER@ + PyType_FromSpec@Base @SVER@ + PyType_GenericAlloc@Base @SVER@ + PyType_GenericNew@Base @SVER@ + PyType_GetFlags@Base @SVER@ + PyType_IsSubtype@Base @SVER@ + PyType_Modified@Base @SVER@ + PyType_Ready@Base @SVER@ + PyType_Type@Base @SVER@ + (optional)PyType_stgdict@Base @SVER@ + PyUnicodeDecodeError_Create@Base @SVER@ + PyUnicodeDecodeError_GetEncoding@Base @SVER@ + PyUnicodeDecodeError_GetEnd@Base @SVER@ + PyUnicodeDecodeError_GetObject@Base @SVER@ + PyUnicodeDecodeError_GetReason@Base @SVER@ + PyUnicodeDecodeError_GetStart@Base @SVER@ + PyUnicodeDecodeError_SetEnd@Base @SVER@ + PyUnicodeDecodeError_SetReason@Base @SVER@ + PyUnicodeDecodeError_SetStart@Base @SVER@ + PyUnicodeEncodeError_Create@Base @SVER@ + PyUnicodeEncodeError_GetEncoding@Base @SVER@ + PyUnicodeEncodeError_GetEnd@Base @SVER@ + PyUnicodeEncodeError_GetObject@Base @SVER@ + PyUnicodeEncodeError_GetReason@Base @SVER@ + PyUnicodeEncodeError_GetStart@Base @SVER@ + PyUnicodeEncodeError_SetEnd@Base @SVER@ + PyUnicodeEncodeError_SetReason@Base @SVER@ + PyUnicodeEncodeError_SetStart@Base @SVER@ + PyUnicodeIter_Type@Base @SVER@ + PyUnicodeTranslateError_Create@Base @SVER@ + PyUnicodeTranslateError_GetEnd@Base @SVER@ + PyUnicodeTranslateError_GetObject@Base @SVER@ + PyUnicodeTranslateError_GetReason@Base @SVER@ + PyUnicodeTranslateError_GetStart@Base @SVER@ + PyUnicodeTranslateError_SetEnd@Base @SVER@ + PyUnicodeTranslateError_SetReason@Base @SVER@ + PyUnicodeTranslateError_SetStart@Base @SVER@ + PyUnicodeUCS4_Append@Base @SVER@ + PyUnicodeUCS4_AppendAndDel@Base @SVER@ + PyUnicodeUCS4_AsASCIIString@Base @SVER@ + PyUnicodeUCS4_AsCharmapString@Base @SVER@ + PyUnicodeUCS4_AsDecodedObject@Base @SVER@ + PyUnicodeUCS4_AsDecodedUnicode@Base @SVER@ + PyUnicodeUCS4_AsEncodedObject@Base @SVER@ + PyUnicodeUCS4_AsEncodedString@Base @SVER@ + PyUnicodeUCS4_AsEncodedUnicode@Base @SVER@ + PyUnicodeUCS4_AsLatin1String@Base @SVER@ + PyUnicodeUCS4_AsRawUnicodeEscapeString@Base @SVER@ + PyUnicodeUCS4_AsUTF16String@Base @SVER@ + PyUnicodeUCS4_AsUTF32String@Base @SVER@ + PyUnicodeUCS4_AsUTF8String@Base @SVER@ + PyUnicodeUCS4_AsUnicode@Base @SVER@ + PyUnicodeUCS4_AsUnicodeEscapeString@Base @SVER@ + PyUnicodeUCS4_AsWideChar@Base @SVER@ + PyUnicodeUCS4_AsWideCharString@Base @SVER@ + PyUnicodeUCS4_ClearFreelist@Base @SVER@ + PyUnicodeUCS4_Compare@Base @SVER@ + PyUnicodeUCS4_CompareWithASCIIString@Base @SVER@ + PyUnicodeUCS4_Concat@Base @SVER@ + PyUnicodeUCS4_Contains@Base @SVER@ + PyUnicodeUCS4_Count@Base @SVER@ + PyUnicodeUCS4_Decode@Base @SVER@ + PyUnicodeUCS4_DecodeASCII@Base @SVER@ + PyUnicodeUCS4_DecodeCharmap@Base @SVER@ + PyUnicodeUCS4_DecodeFSDefault@Base @SVER@ + PyUnicodeUCS4_DecodeFSDefaultAndSize@Base @SVER@ + PyUnicodeUCS4_DecodeLatin1@Base @SVER@ + PyUnicodeUCS4_DecodeRawUnicodeEscape@Base @SVER@ + PyUnicodeUCS4_DecodeUTF16@Base @SVER@ + PyUnicodeUCS4_DecodeUTF16Stateful@Base @SVER@ + PyUnicodeUCS4_DecodeUTF32@Base @SVER@ + PyUnicodeUCS4_DecodeUTF32Stateful@Base @SVER@ + PyUnicodeUCS4_DecodeUTF8@Base @SVER@ + PyUnicodeUCS4_DecodeUTF8Stateful@Base @SVER@ + PyUnicodeUCS4_DecodeUnicodeEscape@Base @SVER@ + PyUnicodeUCS4_Encode@Base @SVER@ + PyUnicodeUCS4_EncodeASCII@Base @SVER@ + PyUnicodeUCS4_EncodeCharmap@Base @SVER@ + PyUnicodeUCS4_EncodeDecimal@Base @SVER@ + PyUnicodeUCS4_EncodeLatin1@Base @SVER@ + PyUnicodeUCS4_EncodeRawUnicodeEscape@Base @SVER@ + PyUnicodeUCS4_EncodeUTF16@Base @SVER@ + PyUnicodeUCS4_EncodeUTF32@Base @SVER@ + PyUnicodeUCS4_EncodeUTF8@Base @SVER@ + PyUnicodeUCS4_EncodeUnicodeEscape@Base @SVER@ + PyUnicodeUCS4_FSConverter@Base @SVER@ + PyUnicodeUCS4_FSDecoder@Base @SVER@ + PyUnicodeUCS4_Find@Base @SVER@ + PyUnicodeUCS4_Format@Base @SVER@ + PyUnicodeUCS4_FromEncodedObject@Base @SVER@ + PyUnicodeUCS4_FromFormat@Base @SVER@ + PyUnicodeUCS4_FromFormatV@Base @SVER@ + PyUnicodeUCS4_FromObject@Base @SVER@ + PyUnicodeUCS4_FromOrdinal@Base @SVER@ + PyUnicodeUCS4_FromString@Base @SVER@ + PyUnicodeUCS4_FromStringAndSize@Base @SVER@ + PyUnicodeUCS4_FromUnicode@Base @SVER@ + PyUnicodeUCS4_FromWideChar@Base @SVER@ + PyUnicodeUCS4_GetDefaultEncoding@Base @SVER@ + PyUnicodeUCS4_GetMax@Base @SVER@ + PyUnicodeUCS4_GetSize@Base @SVER@ + PyUnicodeUCS4_IsIdentifier@Base @SVER@ + PyUnicodeUCS4_Join@Base @SVER@ + PyUnicodeUCS4_Partition@Base @SVER@ + PyUnicodeUCS4_RPartition@Base @SVER@ + PyUnicodeUCS4_RSplit@Base @SVER@ + PyUnicodeUCS4_Replace@Base @SVER@ + PyUnicodeUCS4_Resize@Base @SVER@ + PyUnicodeUCS4_RichCompare@Base @SVER@ + PyUnicodeUCS4_Split@Base @SVER@ + PyUnicodeUCS4_Splitlines@Base @SVER@ + PyUnicodeUCS4_Tailmatch@Base @SVER@ + PyUnicodeUCS4_Translate@Base @SVER@ + PyUnicodeUCS4_TranslateCharmap@Base @SVER@ + PyUnicode_AsUnicodeCopy@Base @SVER@ + PyUnicode_BuildEncodingMap@Base @SVER@ + PyUnicode_DecodeUTF7@Base @SVER@ + PyUnicode_DecodeUTF7Stateful@Base @SVER@ + PyUnicode_EncodeFSDefault@Base @SVER@ + PyUnicode_EncodeUTF7@Base @SVER@ + PyUnicode_InternFromString@Base @SVER@ + PyUnicode_InternImmortal@Base @SVER@ + PyUnicode_InternInPlace@Base @SVER@ + PyUnicode_TransformDecimalToASCII@Base @SVER@ + PyUnicode_Type@Base @SVER@ + PyWeakref_GetObject@Base @SVER@ + PyWeakref_NewProxy@Base @SVER@ + PyWeakref_NewRef@Base @SVER@ + PyWrapperDescr_Type@Base @SVER@ + PyWrapper_New@Base @SVER@ + PyZip_Type@Base @SVER@ + Py_AddPendingCall@Base @SVER@ + Py_AtExit@Base @SVER@ + Py_BuildValue@Base @SVER@ + Py_BytesWarningFlag@Base @SVER@ + Py_CompileString@Base @SVER@ + Py_CompileStringExFlags@Base @SVER@ + Py_CompileStringFlags@Base @SVER@ + Py_DebugFlag@Base @SVER@ + Py_DecRef@Base @SVER@ + Py_DivisionWarningFlag@Base @SVER@ + Py_DontWriteBytecodeFlag@Base @SVER@ + Py_EndInterpreter@Base @SVER@ + Py_Exit@Base @SVER@ + Py_FatalError@Base @SVER@ + Py_FdIsInteractive@Base @SVER@ + Py_FileSystemDefaultEncoding@Base @SVER@ + Py_Finalize@Base @SVER@ + Py_FrozenFlag@Base @SVER@ + Py_FrozenMain@Base @SVER@ + Py_GetArgcArgv@Base @SVER@ + Py_GetBuildInfo@Base @SVER@ + Py_GetCompiler@Base @SVER@ + Py_GetCopyright@Base @SVER@ + Py_GetExecPrefix@Base @SVER@ + Py_GetPath@Base @SVER@ + Py_GetPlatform@Base @SVER@ + Py_GetPrefix@Base @SVER@ + Py_GetProgramFullPath@Base @SVER@ + Py_GetProgramName@Base @SVER@ + Py_GetPythonHome@Base @SVER@ + Py_GetRecursionLimit@Base @SVER@ + Py_GetVersion@Base @SVER@ + Py_HasFileSystemDefaultEncoding@Base @SVER@ + Py_HashRandomizationFlag@Base @SVER@ + Py_IgnoreEnvironmentFlag@Base @SVER@ + Py_IncRef@Base @SVER@ + Py_Initialize@Base @SVER@ + Py_InitializeEx@Base @SVER@ + Py_InspectFlag@Base @SVER@ + Py_InteractiveFlag@Base @SVER@ + Py_IsInitialized@Base @SVER@ + Py_Main@Base @SVER@ + Py_MakePendingCalls@Base @SVER@ + Py_NewInterpreter@Base @SVER@ + Py_NoSiteFlag@Base @SVER@ + Py_NoUserSiteDirectory@Base @SVER@ + Py_OptimizeFlag@Base @SVER@ + Py_QuietFlag@Base @SVER@ + Py_ReprEnter@Base @SVER@ + Py_ReprLeave@Base @SVER@ + Py_SetPath@Base @SVER@ + Py_SetProgramName@Base @SVER@ + Py_SetPythonHome@Base @SVER@ + Py_SetRecursionLimit@Base @SVER@ + Py_SubversionRevision@Base @SVER@ + Py_SubversionShortBranch@Base @SVER@ + Py_SymtableString@Base @SVER@ + Py_UNICODE_strcat@Base @SVER@ + Py_UNICODE_strchr@Base @SVER@ + Py_UNICODE_strcmp@Base @SVER@ + Py_UNICODE_strcpy@Base @SVER@ + Py_UNICODE_strlen@Base @SVER@ + Py_UNICODE_strncmp@Base @SVER@ + Py_UNICODE_strncpy@Base @SVER@ + Py_UNICODE_strrchr@Base @SVER@ + Py_UnbufferedStdioFlag@Base @SVER@ + Py_UniversalNewlineFgets@Base @SVER@ + Py_UseClassExceptionsFlag@Base @SVER@ + Py_VaBuildValue@Base @SVER@ + Py_VerboseFlag@Base @SVER@ + Py_meta_grammar@Base @SVER@ + Py_pgen@Base @SVER@ + _PyAccu_Accumulate@Base 3.2.2 + _PyAccu_Destroy@Base 3.2.2 + _PyAccu_Finish@Base 3.2.2 + _PyAccu_FinishAsList@Base 3.2.2 + _PyAccu_Init@Base 3.2.2 + _PyArg_NoKeywords@Base @SVER@ + _PyArg_ParseTupleAndKeywords_SizeT@Base @SVER@ + _PyArg_ParseTuple_SizeT@Base @SVER@ + _PyArg_Parse_SizeT@Base @SVER@ + _PyArg_VaParseTupleAndKeywords_SizeT@Base @SVER@ + _PyArg_VaParse_SizeT@Base @SVER@ + _PyBuiltin_Init@Base @SVER@ + _PyByteArray_empty_string@Base @SVER@ + _PyBytesIOBuffer_Type@Base @SVER@ + _PyBytes_FormatLong@Base @SVER@ + _PyBytes_Join@Base @SVER@ + _PyBytes_Resize@Base @SVER@ + _PyCapsule_hack@Base @SVER@ + _PyCode_CheckLineNumber@Base @SVER@ + _PyCodec_Lookup@Base @SVER@ + _PyComplex_FormatAdvanced@Base @SVER@ + _PyDict_Contains@Base @SVER@ + _PyDict_HasOnlyStringKeys@Base @SVER@ + _PyDict_MaybeUntrack@Base @SVER@ + _PyDict_NewPresized@Base @SVER@ + _PyDict_Next@Base @SVER@ + _PyErr_BadInternalCall@Base @SVER@ + _PyEval_CallTracing@Base @SVER@ + _PyEval_FiniThreads@Base @SVER@ + _PyEval_GetSwitchInterval@Base @SVER@ + _PyEval_SetSwitchInterval@Base @SVER@ + _PyEval_SignalAsyncExc@Base @SVER@ + _PyEval_SliceIndex@Base @SVER@ + _PyExc_Fini@Base @SVER@ + _PyExc_Init@Base @SVER@ + _PyFileIO_closed@Base @SVER@ + _PyFloat_FormatAdvanced@Base @SVER@ + _PyFloat_Init@Base @SVER@ + _PyFloat_Pack4@Base @SVER@ + _PyFloat_Pack8@Base @SVER@ + _PyFloat_Unpack4@Base @SVER@ + _PyFloat_Unpack8@Base @SVER@ + _PyFrame_Init@Base @SVER@ + _PyGC_Dump@Base @SVER@ + _PyGC_Fini@Base @SVER@ + _PyGC_generation0@Base @SVER@ + _PyGILState_Fini@Base @SVER@ + _PyGILState_Init@Base @SVER@ + _PyGILState_Reinit@Base @SVER@ + _PyIOBase_check_closed@Base @SVER@ + _PyIOBase_check_readable@Base @SVER@ + _PyIOBase_check_seekable@Base @SVER@ + _PyIOBase_check_writable@Base @SVER@ + _PyIOBase_finalize@Base @SVER@ + _PyIO_ConvertSsize_t@Base @SVER@ + _PyIO_Module@Base @SVER@ + _PyIO_empty_bytes@Base @SVER@ + _PyIO_empty_str@Base @SVER@ + _PyIO_find_line_ending@Base @SVER@ + _PyIO_str_close@Base @SVER@ + _PyIO_str_closed@Base @SVER@ + _PyIO_str_decode@Base @SVER@ + _PyIO_str_encode@Base @SVER@ + _PyIO_str_fileno@Base @SVER@ + _PyIO_str_flush@Base @SVER@ + _PyIO_str_getstate@Base @SVER@ + _PyIO_str_isatty@Base @SVER@ + _PyIO_str_newlines@Base @SVER@ + _PyIO_str_nl@Base @SVER@ + _PyIO_str_read1@Base @SVER@ + _PyIO_str_read@Base @SVER@ + _PyIO_str_readable@Base @SVER@ + _PyIO_str_readinto@Base @SVER@ + _PyIO_str_readline@Base @SVER@ + _PyIO_str_reset@Base @SVER@ + _PyIO_str_seek@Base @SVER@ + _PyIO_str_seekable@Base @SVER@ + _PyIO_str_setstate@Base @SVER@ + _PyIO_str_tell@Base @SVER@ + _PyIO_str_truncate@Base @SVER@ + _PyIO_str_writable@Base @SVER@ + _PyIO_str_write@Base @SVER@ + _PyIO_trap_eintr@Base @SVER@ + _PyIO_zero@Base @SVER@ + _PyImportHooks_Init@Base @SVER@ + _PyImport_AcquireLock@Base @SVER@ + _PyImport_DynLoadFiletab@Base @SVER@ + _PyImport_Filetab@Base @SVER@ + _PyImport_FindBuiltin@Base @SVER@ + _PyImport_FindExtensionUnicode@Base @SVER@ + _PyImport_Fini@Base @SVER@ + _PyImport_FixupBuiltin@Base @SVER@ + _PyImport_FixupExtensionUnicode@Base @SVER@ + _PyImport_GetDynLoadFunc@Base @SVER@ + _PyImport_Init@Base @SVER@ + _PyImport_Inittab@Base @SVER@ + _PyImport_LoadDynamicModule@Base @SVER@ + _PyImport_ReInitLock@Base @SVER@ + _PyImport_ReleaseLock@Base @SVER@ + _PyIncrementalNewlineDecoder_decode@Base @SVER@ + _PyList_Extend@Base @SVER@ + _PyLong_AsByteArray@Base @SVER@ + _PyLong_Copy@Base @SVER@ + _PyLong_DigitValue@Base @SVER@ + _PyLong_DivmodNear@Base @SVER@ + _PyLong_Format@Base @SVER@ + _PyLong_FormatAdvanced@Base @SVER@ + _PyLong_Frexp@Base @SVER@ + _PyLong_FromByteArray@Base @SVER@ + _PyLong_Init@Base @SVER@ + _PyLong_New@Base @SVER@ + _PyLong_NumBits@Base @SVER@ + _PyLong_Sign@Base @SVER@ + _PyMethodWrapper_Type@Base 3.2.2 + _PyModule_Clear@Base @SVER@ + _PyNumber_ConvertIntegralToInt@Base @SVER@ + _PyOS_GetOpt@Base @SVER@ + _PyOS_ReadlineTState@Base @SVER@ + _PyOS_ResetGetOpt@Base @SVER@ + _PyOS_URandom@Base @SVER@ + _PyOS_optarg@Base @SVER@ + _PyOS_opterr@Base @SVER@ + _PyOS_optind@Base @SVER@ + _PyObject_CallFunction_SizeT@Base @SVER@ + _PyObject_CallMethod_SizeT@Base @SVER@ + _PyObject_Dump@Base @SVER@ + _PyObject_GC_Malloc@Base @SVER@ + _PyObject_GC_New@Base @SVER@ + _PyObject_GC_NewVar@Base @SVER@ + _PyObject_GC_Resize@Base @SVER@ + _PyObject_GC_Track@Base @SVER@ + _PyObject_GC_UnTrack@Base @SVER@ + _PyObject_GenericGetAttrWithDict@Base @SVER@ + _PyObject_GenericSetAttrWithDict@Base @SVER@ + _PyObject_GetDictPtr@Base @SVER@ + _PyObject_LengthHint@Base @SVER@ + _PyObject_LookupSpecial@Base @SVER@ + _PyObject_New@Base @SVER@ + _PyObject_NewVar@Base @SVER@ + _PyObject_NextNotImplemented@Base @SVER@ + _PyObject_RealIsInstance@Base @SVER@ + _PyObject_RealIsSubclass@Base @SVER@ + _PyParser_Grammar@Base @SVER@ + _PyParser_TokenNames@Base @SVER@ + _PyRandom_Init@Base @SVER@ + _PySequence_BytesToCharpArray@Base @SVER@ + _PySequence_IterSearch@Base @SVER@ + _PySet_NextEntry@Base @SVER@ + _PySet_Update@Base @SVER@ + _PySlice_FromIndices@Base @SVER@ + _PyState_AddModule@Base @SVER@ + _PySys_Init@Base @SVER@ + _PyThreadState_Current@Base @SVER@ + _PyThreadState_GetFrame@Base @SVER@ + _PyThreadState_Init@Base @SVER@ + _PyThreadState_Prealloc@Base @SVER@ + _PyThread_CurrentFrames@Base @SVER@ + _PyTime_DoubleToTimet@Base @SVER@ + _PyTime_Init@Base @SVER@ + _PyTime_gettimeofday@Base @SVER@ + _PyTrash_delete_later@Base @SVER@ + _PyTrash_delete_nesting@Base @SVER@ + _PyTrash_deposit_object@Base @SVER@ + _PyTrash_destroy_chain@Base @SVER@ + _PyTuple_MaybeUntrack@Base @SVER@ + _PyTuple_Resize@Base @SVER@ + _PyType_CalculateMetaclass@Base 3.2.2 + _PyType_Lookup@Base @SVER@ + _PyUnicodeUCS4_AsDefaultEncodedString@Base @SVER@ + _PyUnicodeUCS4_Fini@Base @SVER@ + _PyUnicodeUCS4_Init@Base @SVER@ + _PyUnicode_AsString@Base @SVER@ + _PyUnicode_AsStringAndSize@Base @SVER@ + _PyUnicode_BidirectionalNames@Base @SVER@ + _PyUnicode_CategoryNames@Base @SVER@ + _PyUnicode_Database_Records@Base @SVER@ + _PyUnicode_DecodeUnicodeInternal@Base @SVER@ + _PyUnicode_EastAsianWidthNames@Base @SVER@ + _PyUnicode_FormatAdvanced@Base @SVER@ + _PyUnicode_HasNULChars@Base @SVER@ + _PyUnicode_InsertThousandsGrouping@Base @SVER@ + _PyUnicode_InsertThousandsGroupingLocale@Base @SVER@ + _PyUnicode_IsAlpha@Base @SVER@ + _PyUnicode_IsDecimalDigit@Base @SVER@ + _PyUnicode_IsDigit@Base @SVER@ + _PyUnicode_IsLinebreak@Base @SVER@ + _PyUnicode_IsLowercase@Base @SVER@ + _PyUnicode_IsNumeric@Base @SVER@ + _PyUnicode_IsPrintable@Base @SVER@ + _PyUnicode_IsTitlecase@Base @SVER@ + _PyUnicode_IsUppercase@Base @SVER@ + _PyUnicode_IsWhitespace@Base @SVER@ + _PyUnicode_IsXidContinue@Base @SVER@ + _PyUnicode_IsXidStart@Base @SVER@ + _PyUnicode_ToDecimalDigit@Base @SVER@ + _PyUnicode_ToDigit@Base @SVER@ + _PyUnicode_ToLowercase@Base @SVER@ + _PyUnicode_ToNumeric@Base @SVER@ + _PyUnicode_ToTitlecase@Base @SVER@ + _PyUnicode_ToUppercase@Base @SVER@ + _PyUnicode_TypeRecords@Base @SVER@ + _PyUnicode_XStrip@Base @SVER@ + _PyWarnings_Init@Base @SVER@ + _PyWeakref_CallableProxyType@Base @SVER@ + _PyWeakref_ClearRef@Base @SVER@ + _PyWeakref_GetWeakrefCount@Base @SVER@ + _PyWeakref_ProxyType@Base @SVER@ + _PyWeakref_RefType@Base @SVER@ + _Py_Assert@Base @SVER@ + _Py_Assign@Base @SVER@ + _Py_Attribute@Base @SVER@ + _Py_AugAssign@Base @SVER@ + _Py_BinOp@Base @SVER@ + _Py_BoolOp@Base @SVER@ + _Py_Break@Base @SVER@ + _Py_BreakPoint@Base @SVER@ + _Py_BuildValue_SizeT@Base @SVER@ + _Py_Bytes@Base @SVER@ + _Py_Call@Base @SVER@ + _Py_CheckRecursionLimit@Base @SVER@ + _Py_CheckRecursiveCall@Base @SVER@ + _Py_ClassDef@Base @SVER@ + _Py_Compare@Base @SVER@ + _Py_Continue@Base @SVER@ + _Py_Dealloc@Base @SVER@ + _Py_Delete@Base @SVER@ + _Py_Dict@Base @SVER@ + _Py_DictComp@Base @SVER@ + _Py_DisplaySourceLine@Base @SVER@ + _Py_Ellipsis@Base @SVER@ + _Py_EllipsisObject@Base @SVER@ + _Py_ExceptHandler@Base @SVER@ + _Py_Expr@Base @SVER@ + _Py_Expression@Base @SVER@ + _Py_ExtSlice@Base @SVER@ + _Py_FalseStruct@Base @SVER@ + _Py_Finalizing@Base @SVER@ + _Py_For@Base @SVER@ + _Py_FreeCharPArray@Base @SVER@ + _Py_FunctionDef@Base @SVER@ + _Py_GeneratorExp@Base @SVER@ + _Py_Global@Base @SVER@ + _Py_HashDouble@Base @SVER@ + _Py_HashPointer@Base @SVER@ + _Py_HashSecret@Base @SVER@ + _Py_If@Base @SVER@ + _Py_IfExp@Base @SVER@ + _Py_Import@Base @SVER@ + _Py_ImportFrom@Base @SVER@ + _Py_Index@Base @SVER@ + _Py_Interactive@Base @SVER@ + _Py_Lambda@Base @SVER@ + _Py_List@Base @SVER@ + _Py_ListComp@Base @SVER@ + _Py_Mangle@Base @SVER@ + _Py_Module@Base @SVER@ + _Py_Name@Base @SVER@ + _Py_NoneStruct@Base @SVER@ + _Py_Nonlocal@Base @SVER@ + _Py_NotImplementedStruct@Base @SVER@ + _Py_Num@Base @SVER@ + _Py_PackageContext@Base @SVER@ + _Py_Pass@Base @SVER@ + _Py_PyAtExit@Base @SVER@ + _Py_Raise@Base @SVER@ + _Py_ReadyTypes@Base @SVER@ + _Py_ReleaseInternedUnicodeStrings@Base @SVER@ + _Py_RestoreSignals@Base @SVER@ + _Py_Return@Base @SVER@ + _Py_Set@Base @SVER@ + _Py_SetComp@Base @SVER@ + _Py_Slice@Base @SVER@ + _Py_Starred@Base @SVER@ + _Py_Str@Base @SVER@ + _Py_Subscript@Base @SVER@ + _Py_Suite@Base @SVER@ + _Py_SwappedOp@Base @SVER@ + _Py_TrueStruct@Base @SVER@ + _Py_TryExcept@Base @SVER@ + _Py_TryFinally@Base @SVER@ + _Py_Tuple@Base @SVER@ + _Py_UnaryOp@Base @SVER@ + _Py_VaBuildValue_SizeT@Base @SVER@ + _Py_While@Base @SVER@ + _Py_With@Base @SVER@ + _Py_Yield@Base @SVER@ + _Py_abstract_hack@Base @SVER@ + _Py_acosh@Base @SVER@ + _Py_add_one_to_index_C@Base @SVER@ + _Py_add_one_to_index_F@Base @SVER@ + _Py_addarc@Base @SVER@ + _Py_addbit@Base @SVER@ + _Py_adddfa@Base @SVER@ + _Py_addfirstsets@Base @SVER@ + _Py_addlabel@Base @SVER@ + _Py_addstate@Base @SVER@ + _Py_alias@Base @SVER@ + _Py_arg@Base @SVER@ + _Py_arguments@Base @SVER@ + _Py_ascii_whitespace@Base @SVER@ + _Py_asinh@Base @SVER@ + _Py_atanh@Base @SVER@ + _Py_bytes_capitalize@Base @SVER@ + _Py_hgidentifier@Base @SVER@ + _Py_hgversion@Base @SVER@ + _Py_bytes_isalnum@Base @SVER@ + _Py_bytes_isalpha@Base @SVER@ + _Py_bytes_isdigit@Base @SVER@ + _Py_bytes_islower@Base @SVER@ + _Py_bytes_isspace@Base @SVER@ + _Py_bytes_istitle@Base @SVER@ + _Py_bytes_isupper@Base @SVER@ + _Py_bytes_lower@Base @SVER@ + _Py_bytes_maketrans@Base @SVER@ + _Py_bytes_swapcase@Base @SVER@ + _Py_bytes_title@Base @SVER@ + _Py_bytes_upper@Base @SVER@ + _Py_c_abs@Base @SVER@ + _Py_c_diff@Base @SVER@ + _Py_c_neg@Base @SVER@ + _Py_c_pow@Base @SVER@ + _Py_c_prod@Base @SVER@ + _Py_c_quot@Base @SVER@ + _Py_c_sum@Base @SVER@ + _Py_capitalize__doc__@Base @SVER@ + _Py_char2wchar@Base @SVER@ + _Py_comprehension@Base @SVER@ + _Py_ctype_table@Base @SVER@ + _Py_ctype_tolower@Base @SVER@ + _Py_ctype_toupper@Base @SVER@ + _Py_delbitset@Base @SVER@ + (arch=!m68k)_Py_dg_dtoa@Base @SVER@ + (arch=!m68k)_Py_dg_freedtoa@Base @SVER@ + (arch=!m68k)_Py_dg_strtod@Base @SVER@ + _Py_expm1@Base @SVER@ + _Py_findlabel@Base @SVER@ + _Py_fopen@Base @SVER@ + (arch=i386 lpia m68k)_Py_force_double@Base @SVER@ + (arch=amd64 i386 lpia)_Py_get_387controlword@Base @SVER@ + _Py_isalnum__doc__@Base @SVER@ + _Py_isalpha__doc__@Base @SVER@ + _Py_isdigit__doc__@Base @SVER@ + _Py_islower__doc__@Base @SVER@ + _Py_isspace__doc__@Base @SVER@ + _Py_istitle__doc__@Base @SVER@ + _Py_isupper__doc__@Base @SVER@ + _Py_keyword@Base @SVER@ + _Py_log1p@Base @SVER@ + _Py_lower__doc__@Base @SVER@ + _Py_maketrans__doc__@Base @SVER@ + _Py_mergebitset@Base @SVER@ + _Py_meta_grammar@Base @SVER@ + _Py_newbitset@Base @SVER@ + _Py_newgrammar@Base @SVER@ + _Py_parse_inf_or_nan@Base @SVER@ + _Py_pgen@Base @SVER@ + _Py_samebitset@Base @SVER@ + (arch=amd64 i386 lpia)_Py_set_387controlword@Base @SVER@ + _Py_stat@Base @SVER@ + _Py_svnversion@Base @SVER@ + _Py_swapcase__doc__@Base @SVER@ + _Py_title__doc__@Base @SVER@ + _Py_translatelabels@Base @SVER@ + _Py_upper__doc__@Base @SVER@ + _Py_wchar2char@Base @SVER@ + _Py_wfopen@Base @SVER@ + _Py_wgetcwd@Base @SVER@ + _Py_wreadlink@Base @SVER@ + _Py_wrealpath@Base @SVER@ + _Py_wstat@Base @SVER@ + + (optional)__gnu_lto_v1@Base 3.2.2 + + asdl_int_seq_new@Base @SVER@ + asdl_seq_new@Base @SVER@ + + (optional|regex)"^_ctypes_.*@Base$" @SVER@ + (optional|regex)"^ffi_type_.*@Base$" @SVER@ + (optional|regex)"^ffi_closure_.*@Base$" @SVER@ + + (optional|regex)"^PyInit_.*@Base$" @SVER@ --- python3.2-3.2.3.orig/debian/PVER-doc.doc-base.PVER-tut.in +++ python3.2-3.2.3/debian/PVER-doc.doc-base.PVER-tut.in @@ -0,0 +1,13 @@ +Document: @PVER@-tut +Title: Python Tutorial (v@VER@) +Author: Guido van Rossum, Fred L. Drake, Jr., editor +Abstract: This tutorial introduces the reader informally to the basic + concepts and features of the Python language and system. It helps + to have a Python interpreter handy for hands-on experience, but + all examples are self-contained, so the tutorial can be read + off-line as well. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/tutorial/index.html +Files: /usr/share/doc/@PVER@/html/tutorial/*.html --- python3.2-3.2.3.orig/debian/PVER-doc.overrides.in +++ python3.2-3.2.3/debian/PVER-doc.overrides.in @@ -0,0 +1,2 @@ +# this is referenced by the html docs +@PVER@-doc binary: extra-license-file --- python3.2-3.2.3.orig/debian/README.maintainers.in +++ python3.2-3.2.3/debian/README.maintainers.in @@ -0,0 +1,88 @@ + +Hints for maintainers of Debian packages of Python extensions +------------------------------------------------------------- + +Most of the content of this README can be found in the Debian Python policy. +See /usr/share/doc/python/python-policy.txt.gz. + +Documentation Tools +------------------- + +If your package ships documentation produced in the Python +documentation format, you can generate it at build-time by +build-depending on @PVER@-dev, and you will find the +templates, tools and scripts in /usr/lib/@PVER@/doc/tools -- +adjust your build scripts accordingly. + + +Makefile.pre.in issues +---------------------- + +Python comes with a `universal Unix Makefile for Python extensions' in +/usr/lib/@PVER@/config/Makefile.pre.in (with Debian, this is included +in the python-dev package), which is used by most Python extensions. + +In general, packages using the Makefile.pre.in approach can be packaged +simply by running dh_make or by using one of debhelper's rules' templates +(see /usr/doc/debhelper/examples/). Makefile.pre.in works fine with e.g. +"make prefix=debian/tmp/usr install". + +One glitch: You may be running into the problem that Makefile.pre.in +doesn't try to create all the directories when they don't exist. Therefore, +you may have to create them manually before "make install". In most cases, +the following should work: + + ... + dh_installdirs /usr/lib/@PVER@ + $(MAKE) prefix=debian/tmp/usr install + ... + + +Byte-compilation +---------------- + +For speed reasons, Python internally compiles source files into a byte-code. +To speed up subsequent imports, it tries to save the byte-code along with +the source with an extension .pyc (resp. pyo). This will fail if the +libraries are installed in a non-writable directory, which may be the +case for /usr/lib/@PVER@/. + +Not that .pyc and .pyo files should not be relocated, since for debugging +purposes the path of the source for is hard-coded into them. + +To precompile files in batches after installation, Python has a script +compileall.py, which compiles all files in a given directory tree. The +Debian version of compileall has been enhanced to support incremental +compilation and to feature a ddir (destination dir) option. ddir is +used to compile files in debian/usr/lib/python/ when they will be +installed into /usr/lib/python/. + + +Currently, there are two ways to use compileall for Debian packages. The +first has a speed penalty, the second has a space penalty in the package. + +1.) Compiling and removing .pyc files in postinst/prerm: + + Use dh_python(1) from the debhelper packages to add commands to byte- + compile on installation and to remove the byte-compiled files on removal. + Your package has to build-depend on: debhelper (>= 4.1.67), python. + + In /usr/share/doc/@PVER@, you'll find sample.postinst and sample.prerm. + If you set the directory where the .py files are installed, these + scripts will install and remove the .pyc and .pyo files for your + package after unpacking resp. before removing the package. + +2.) Compiling the .pyc files `out of place' during installation: + + As of 1.5.1, compileall.py allows you to specify a faked installation + directory using the "-d destdir" option, so that you can precompile + the files in their temporary directory + (e.g. debian/tmp/usr/lib/python2.1/site-packages/PACKAGE). + + + + 11/02/98 + Gregor Hoffleit + + +Last modified: 2007-10-14 --- python3.2-3.2.3.orig/debian/PVER.postinst.in +++ python3.2-3.2.3/debian/PVER.postinst.in @@ -0,0 +1,30 @@ +#! /bin/sh -e + +if [ "$1" = configure ]; then + ( + files=$(dpkg -L @PVER@ | sed -n '/^\/usr\/lib\/@PVER@\/.*\.py$/p') + @PVER@ /usr/lib/@PVER@/py_compile.py $files + if grep -sq '^byte-compile[^#]*optimize' /etc/python/debian_config; then + @PVER@ -O /usr/lib/@PVER@/py_compile.py $files + fi + ) +fi + +oldlocalsite=/usr/local/lib/@PVER@/site-packages +case "$1" in + configure|abort-upgrade|abort-remove|abort-deconfigure) + # issue #623057 + if [ -d $oldlocalsite -a ! -h $oldlocalsite ]; then + rmdir --ignore-fail-on-non-empty $oldlocalsite 2>/dev/null || true + fi + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 --- python3.2-3.2.3.orig/debian/PVER-examples.overrides.in +++ python3.2-3.2.3/debian/PVER-examples.overrides.in @@ -0,0 +1,2 @@ +# don't care about permissions of the example files +@PVER@-examples binary: executable-not-elf-or-script --- python3.2-3.2.3.orig/debian/pylogo.xpm +++ python3.2-3.2.3/debian/pylogo.xpm @@ -0,0 +1,351 @@ +/* XPM */ +static char * pylogo_xpm[] = { +"32 32 316 2", +" c None", +". c #8DB0CE", +"+ c #6396BF", +"@ c #4985B7", +"# c #4181B5", +"$ c #417EB2", +"% c #417EB1", +"& c #4D83B0", +"* c #6290B6", +"= c #94B2CA", +"- c #70A1C8", +"; c #3D83BC", +"> c #3881BD", +", c #387DB6", +"' c #387CB5", +") c #387BB3", +"! c #3779B0", +"~ c #3778AE", +"{ c #3776AB", +"] c #3776AA", +"^ c #3775A9", +"/ c #4A7FAC", +"( c #709FC5", +"_ c #3A83BE", +": c #5795C7", +"< c #94B9DB", +"[ c #73A4CE", +"} c #3D80B7", +"| c #387CB4", +"1 c #377AB2", +"2 c #377AB0", +"3 c #3777AC", +"4 c #3774A7", +"5 c #3773A5", +"6 c #3C73A5", +"7 c #4586BB", +"8 c #4489C1", +"9 c #A7C7E1", +"0 c #F7F9FD", +"a c #E1E9F1", +"b c #4C89BC", +"c c #3779AF", +"d c #3778AD", +"e c #3873A5", +"f c #4B7CA4", +"g c #3982BE", +"h c #4389C1", +"i c #A6C6E1", +"j c #F6F9FC", +"k c #D6E4F0", +"l c #4A88BB", +"m c #3773A6", +"n c #366F9F", +"o c #366E9D", +"p c #376E9C", +"q c #4A8BC0", +"r c #79A7CD", +"s c #548EBD", +"t c #387AB0", +"u c #3773A4", +"v c #366D9C", +"w c #387FBA", +"x c #387DB7", +"y c #387BB4", +"z c #3775A8", +"A c #366FA0", +"B c #4981AF", +"C c #427BAA", +"D c #3772A4", +"E c #376B97", +"F c #77A3C8", +"G c #4586BC", +"H c #3882BE", +"I c #3B76A7", +"J c #3B76A6", +"K c #366E9E", +"L c #376B98", +"M c #376B96", +"N c #5681A3", +"O c #F5EEB8", +"P c #FFED60", +"Q c #FFE85B", +"R c #FFE659", +"S c #FDE55F", +"T c #5592C4", +"U c #3A83BF", +"V c #3882BD", +"W c #387FB9", +"X c #3779AE", +"Y c #366F9E", +"Z c #366C98", +"` c #376A94", +" . c #5D85A7", +".. c #F5EDB7", +"+. c #FFEA5D", +"@. c #FFE75A", +"#. c #FFE354", +"$. c #FDDD56", +"%. c #669DC8", +"&. c #3885C3", +"*. c #3884C2", +"=. c #387EB8", +"-. c #387CB6", +";. c #377AB1", +">. c #3772A3", +",. c #366D9B", +"'. c #F5EBB5", +"). c #FFE557", +"!. c #FFE455", +"~. c #FFDF50", +"{. c #FFDB4C", +"]. c #FAD862", +"^. c #8EB4D2", +"/. c #3C86C1", +"(. c #3883C0", +"_. c #3882BF", +":. c #3881BC", +"<. c #3880BB", +"[. c #3775AA", +"}. c #F5EAB3", +"|. c #FFE051", +"1. c #FFDE4F", +"2. c #FFDA4A", +"3. c #FED446", +"4. c #F5DF9D", +"5. c #77A5CA", +"6. c #3885C2", +"7. c #387BB2", +"8. c #6B8EA8", +"9. c #F8E7A1", +"0. c #FFE153", +"a. c #FFDD4E", +"b. c #FFDB4B", +"c. c #FFD746", +"d. c #FFD645", +"e. c #FFD342", +"f. c #F6DB8D", +"g. c #508DBE", +"h. c #3771A3", +"i. c #376A95", +"j. c #3D6F97", +"k. c #C3CBC2", +"l. c #FBD964", +"m. c #FFDC4D", +"n. c #FFD544", +"o. c #FFD040", +"p. c #F9CF58", +"q. c #3F83BB", +"r. c #376B95", +"s. c #3A6C95", +"t. c #4E7BA0", +"u. c #91AABC", +"v. c #F6E4A3", +"w. c #FFDA4B", +"x. c #FFD646", +"y. c #FFD443", +"z. c #FFD241", +"A. c #FFCE3D", +"B. c #FFCC3B", +"C. c #FCC83E", +"D. c #3880BC", +"E. c #3C79AC", +"F. c #5F8DB4", +"G. c #7AA0C0", +"H. c #82A6C3", +"I. c #82A3BF", +"J. c #82A2BE", +"K. c #82A1BB", +"L. c #82A1B9", +"M. c #8BA4B5", +"N. c #C1C5AE", +"O. c #F2E19F", +"P. c #FDD74C", +"Q. c #FFD94A", +"R. c #FFD343", +"S. c #FFCE3E", +"T. c #FFCB39", +"U. c #FFC937", +"V. c #FEC636", +"W. c #3D79AB", +"X. c #9DB6C6", +"Y. c #D0CFA2", +"Z. c #EFE598", +"`. c #F8EE9B", +" + c #F8EB97", +".+ c #F8E996", +"++ c #F8E894", +"@+ c #FAE489", +"#+ c #FCDB64", +"$+ c #FFDA4D", +"%+ c #FFCF3E", +"&+ c #FFCB3A", +"*+ c #FFC734", +"=+ c #FFC532", +"-+ c #3F82B7", +";+ c #387EB9", +">+ c #9EB9D0", +",+ c #F2E287", +"'+ c #FDEB69", +")+ c #FEEC60", +"!+ c #FFEB5E", +"~+ c #FFE254", +"{+ c #FFE152", +"]+ c #FFD747", +"^+ c #FFC633", +"/+ c #FCC235", +"(+ c #578FBE", +"_+ c #6996BC", +":+ c #DED9A8", +"<+ c #FEEC62", +"[+ c #FFE658", +"}+ c #FFDF51", +"|+ c #FFDE50", +"1+ c #FFD03F", +"2+ c #FFCD3C", +"3+ c #FFC431", +"4+ c #FFBF2C", +"5+ c #FAC244", +"6+ c #85AACA", +"7+ c #A1BBD2", +"8+ c #F7E47C", +"9+ c #FFE456", +"0+ c #FFC735", +"a+ c #FFBC29", +"b+ c #F7D280", +"c+ c #9DBAD2", +"d+ c #3B7CB2", +"e+ c #ABC2D6", +"f+ c #FDEB7B", +"g+ c #FFC12E", +"h+ c #FDBD30", +"i+ c #F4DEA8", +"j+ c #5F91BA", +"k+ c #ABC1D4", +"l+ c #FDEE7E", +"m+ c #FFE253", +"n+ c #FFCC3C", +"o+ c #FFBA27", +"p+ c #FAC75B", +"q+ c #4A82B0", +"r+ c #3877AB", +"s+ c #3774A6", +"t+ c #AAC0D4", +"u+ c #FDEE7D", +"v+ c #FFEC5F", +"w+ c #FFE255", +"x+ c #FFD848", +"y+ c #FFD444", +"z+ c #FFCF3F", +"A+ c #FFBC2A", +"B+ c #FFBB28", +"C+ c #FDBA32", +"D+ c #447AA8", +"E+ c #4379A7", +"F+ c #FFE95C", +"G+ c #FFE558", +"H+ c #FFE355", +"I+ c #FED84B", +"J+ c #FCD149", +"K+ c #FBCE47", +"L+ c #FBCD46", +"M+ c #FBC840", +"N+ c #FBC63E", +"O+ c #FBC037", +"P+ c #FAC448", +"Q+ c #FDD44C", +"R+ c #FCD14E", +"S+ c #FFC836", +"T+ c #FFC22F", +"U+ c #FFC02D", +"V+ c #FFE052", +"W+ c #FFC636", +"X+ c #FFCF5C", +"Y+ c #FFD573", +"Z+ c #FFC33E", +"`+ c #FEBD2D", +" @ c #FFDB4D", +".@ c #FFD949", +"+@ c #FFD545", +"@@ c #FFD140", +"#@ c #FFCB48", +"$@ c #FFF7E4", +"%@ c #FFFCF6", +"&@ c #FFE09D", +"*@ c #FFBA2E", +"=@ c #FDBE2F", +"-@ c #FFD748", +";@ c #FFCA38", +">@ c #FFC844", +",@ c #FFF2D7", +"'@ c #FFF9EC", +")@ c #FFDB94", +"!@ c #FFB92D", +"~@ c #FAC54D", +"{@ c #FDD54E", +"]@ c #FFBD2D", +"^@ c #FFC858", +"/@ c #FFD174", +"(@ c #FFBF3E", +"_@ c #FCBD3C", +":@ c #FAD66A", +"<@ c #FECD3F", +"[@ c #FFC330", +"}@ c #FFBD2A", +"|@ c #FFB724", +"1@ c #FFB521", +"2@ c #FFB526", +"3@ c #FBC457", +"4@ c #F7E09E", +"5@ c #F8D781", +"6@ c #FAC349", +"7@ c #FCC134", +"8@ c #FEBE2C", +"9@ c #FBBE3F", +"0@ c #F7CF79", +"a@ c #F5D795", +" . + @ # $ % % & * = ", +" - ; > > , ' ) ! ~ { ] ^ / ", +" ( _ : < [ } | 1 2 ~ 3 4 5 5 6 ", +" 7 8 9 0 a b 2 c d 3 { 5 5 5 e f ", +" g h i j k l c ~ { { m 5 5 n o p ", +" > > q r s t c c d 4 5 u n v v v ", +" w x ' y 2 c d d z 5 u A v v v v ", +" B C 5 D v v v v E ", +" F G H H H x ' ) c c c d I J 5 K v v L M N O P Q R S ", +" T U H V V W ' ) c c X ~ 5 5 5 Y v v Z ` ` ...+.@.#.#.$. ", +" %.&.*.> w W =.-.;.c 3 { ^ 5 5 >.o v ,.E ` ` .'.).!.#.~.{.]. ", +"^./.(._.:.<., ' ) ;.X d [.5 5 >.K v ,.E ` ` ` .}.#.|.1.{.2.3.4.", +"5.6.(.H H x ' 7.c c 3 3 4 5 D K v v ,.` ` ` ` 8.9.0.a.b.c.d.e.f.", +"g._.> <.w ' ' | 2 3 { z 5 5 h.v v v i.` ` ` j.k.l.m.{.d.n.e.o.p.", +"q.> > :.-.' 1 c c c ] 5 5 >.v v ,.r.` ` s.t.u.v.{.w.x.y.z.A.B.C.", +"D.D.w -.' 1 c c c E.F.G.H.I.J.J.K.L.L.L.M.N.O.P.Q.c.R.S.B.T.U.V.", +"D.D.=.' ' 1 c c W.X.Y.Z.`.`.`.`.`. +.+++@+#+$+Q.d.R.%+B.&+*+=+=+", +"-+;+-.' ;.2 c c >+,+'+)+P P P !+Q R ~+{+1.{.]+d.y.%+B.&+^+=+=+/+", +"(+' ' ;.c X X _+:+<+P P P P !+R [+~+}+|+{.]+n.R.1+2+&+^+=+3+4+5+", +"6+' ) ! ~ { { 7+8+P P P P !+R 9+#.{+{.w.]+y.z.S.&+0+=+=+3+4+a+b+", +"c+d+7.! d 3 z e+f+P P P !+R 9+#.{+m.{.]+y.1+B.&+0+=+=+g+4+a+h+i+", +" j+c d 3 { 4 k+l+P P !+@.9+m+1.m.{.]+y.1+n+B.*+=+=+g+a+a+o+p+ ", +" q+r+{ s+m t+u+v+@.R w+{+}+{.x+d.y+z+n+B.0+=+=+g+A+a+B+C+ ", +" * D+E+E+ +.F+G+H+}+}+{.I+J+K+L+M+M+M+M+N+O+O+O+O+P+ ", +" ).).#.{+a.{.x+Q+R+ ", +" #.m+1.a.{.x+y.o.2+B.S+=+=+T+U+O+ ", +" 0.V+{.{.x+n.o.2+B.B.W+X+Y+Z+a+`+ ", +" @{..@+@n.@@B.B.S+^+#@$@%@&@*@=@ ", +" ].-@x.y.o.%+;@S+=+=+>@,@'@)@!@~@ ", +" {@z.z+2+U.=+=+=+T+]@^@/@(@_@ ", +" :@<@U.=+=+[@4+}@|@1@2@3@ ", +" 4@5@6@7@8@a+a+9@0@a@ "}; --- python3.2-3.2.3.orig/debian/PVER.overrides.in +++ python3.2-3.2.3/debian/PVER.overrides.in @@ -0,0 +1,14 @@ +# idlelib images +@PVER@ binary: image-file-in-usr-lib + +# yes, we have to +@PVER@ binary: depends-on-python-minimal + +@PVER@ binary: desktop-command-not-in-package +@PVER@ binary: menu-command-not-in-package + +# license file referred by the standard library +@PVER@ binary: extra-license-file + +# no, not useless +@PVER@ binary: manpage-has-useless-whatis-entry --- python3.2-3.2.3.orig/debian/PVER-dbg.symbols.i386.in +++ python3.2-3.2.3/debian/PVER-dbg.symbols.i386.in @@ -0,0 +1,35 @@ +libpython@VER@dmu.so.1.0 python@VER@-dbg #MINVER# +#include "libpython.symbols" + _Py_force_double@Base @SVER@ + _Py_get_387controlword@Base @SVER@ + _Py_set_387controlword@Base @SVER@ + _PyDict_Dummy@Base @SVER@ + _PyMem_DebugFree@Base @SVER@ + _PyMem_DebugMalloc@Base @SVER@ + _PyMem_DebugRealloc@Base @SVER@ + _PyObject_DebugCheckAddress@Base @SVER@ + _PyObject_DebugCheckAddressApi@Base @SVER@ + _PyObject_DebugDumpAddress@Base @SVER@ + _PyObject_DebugFree@Base @SVER@ + _PyObject_DebugFreeApi@Base @SVER@ + _PyObject_DebugMalloc@Base @SVER@ + _PyObject_DebugMallocApi@Base @SVER@ + _PyObject_DebugMallocStats@Base @SVER@ + _PyObject_DebugRealloc@Base @SVER@ + _PyObject_DebugReallocApi@Base @SVER@ + _PySet_Dummy@Base @SVER@ + _Py_AddToAllObjects@Base @SVER@ + _Py_Dealloc@Base @SVER@ + _Py_ForgetReference@Base @SVER@ + _Py_GetObjects@Base @SVER@ + _Py_GetRefTotal@Base @SVER@ + _Py_NegativeRefcount@Base @SVER@ + _Py_NewReference@Base @SVER@ + _Py_PrintReferenceAddresses@Base @SVER@ + _Py_PrintReferences@Base @SVER@ + _Py_RefTotal@Base @SVER@ + _Py_dumptree@Base @SVER@ + _Py_printtree@Base @SVER@ + _Py_showtree@Base @SVER@ + _Py_tok_dump@Base @SVER@ + PyModule_Create2TraceRefs@Base @SVER@ --- python3.2-3.2.3.orig/debian/pydoc.1.in +++ python3.2-3.2.3/debian/pydoc.1.in @@ -0,0 +1,53 @@ +.TH PYDOC@VER@ 1 +.SH NAME +pydoc@VER@ \- the Python documentation tool +.SH SYNOPSIS +.PP +.B pydoc@VER@ +.I name +.PP +.B pydoc@VER@ -k +.I keyword +.PP +.B pydoc@VER@ -p +.I port +.PP +.B pydoc@VER@ -g +.PP +.B pydoc@VER@ -w +.I module [...] +.SH DESCRIPTION +.PP +.B pydoc@VER@ +.I name +Show text documentation on something. +.I name +may be the name of a +Python keyword, topic, function, module, or package, or a dotted +reference to a class or function within a module or module in a +package. If +.I name +contains a '/', it is used as the path to a +Python source file to document. If name is 'keywords', 'topics', +or 'modules', a listing of these things is displayed. +.PP +.B pydoc@VER@ -k +.I keyword +Search for a keyword in the synopsis lines of all available modules. +.PP +.B pydoc@VER@ -p +.I port +Start an HTTP server on the given port on the local machine. +.PP +.B pydoc@VER@ -g +Pop up a graphical interface for finding and serving documentation. +.PP +.B pydoc@VER@ -w +.I name [...] +Write out the HTML documentation for a module to a file in the current +directory. If +.I name +contains a '/', it is treated as a filename; if +it names a directory, documentation is written for all the contents. +.SH AUTHOR +Moshe Zadka, based on "pydoc --help" --- python3.2-3.2.3.orig/debian/libPVER.symbols.lpia.in +++ python3.2-3.2.3/debian/libPVER.symbols.lpia.in @@ -0,0 +1,6 @@ +libpython@VER@mu.so.1.0 libpython@VER@ #MINVER# +#include "libpython.symbols" + PyModule_Create2@Base @SVER@ + _Py_force_double@Base @SVER@ + _Py_get_387controlword@Base @SVER@ + _Py_set_387controlword@Base @SVER@ --- python3.2-3.2.3.orig/debian/libPVER.overrides.in +++ python3.2-3.2.3/debian/libPVER.overrides.in @@ -0,0 +1 @@ +lib@PVER@ binary: package-name-doesnt-match-sonames --- python3.2-3.2.3.orig/debian/locale-gen +++ python3.2-3.2.3/debian/locale-gen @@ -0,0 +1,31 @@ +#!/bin/sh + +LOCPATH=`pwd`/locales +export LOCPATH + +[ -d $LOCPATH ] || mkdir -p $LOCPATH + +umask 022 + +echo "Generating locales..." +while read locale charset; do + case $locale in \#*) continue;; esac + [ -n "$locale" -a -n "$charset" ] || continue + echo -n " `echo $locale | sed 's/\([^.\@]*\).*/\1/'`" + echo -n ".$charset" + echo -n `echo $locale | sed 's/\([^\@]*\)\(\@.*\)*/\2/'` + echo -n '...' + if [ -f $LOCPATH/$locale ]; then + input=$locale + else + input=`echo $locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'` + fi + localedef -i $input -c -f $charset $LOCPATH/$locale #-A /etc/locale.alias + echo ' done'; \ +done <", callee + if caller != callee: + self._depgraph.setdefault(caller,{})[callee] = 1 + return m + + def find_module(self, name, path, parent=None): + if parent is not None: + # assert path is not None + fullname = parent.__name__+'.'+name + elif name == "__init__": + fullname = os.path.basename(path[0]) + else: + fullname = name + if self._last_caller: + caller = self._last_caller.__name__ + if fullname in excluded_imports.get(caller, []): + #self.msgout(3, "find_module -> Excluded", fullname) + raise ImportError(name) + + if fullname in self.excludes: + #self.msgout(3, "find_module -> Excluded", fullname) + raise ImportError(name) + + if path is None: + if name in sys.builtin_module_names: + return (None, None, ("", "", imp.C_BUILTIN)) + + path = self.path + return imp.find_module(name, path) + + def load_module(self, fqname, fp, pathname, file_info): + suffix, mode, type = file_info + m = modulefinder.ModuleFinder.load_module(self, fqname, + fp, pathname, file_info) + if m is not None: + self._types[m.__name__] = type + return m + + def load_package(self, fqname, pathname): + m = modulefinder.ModuleFinder.load_package(self, fqname,pathname) + if m is not None: + self._types[m.__name__] = imp.PKG_DIRECTORY + return m + +def reduce_depgraph(dg): + pass + +# guarded imports, which don't need to be included in python-minimal +excluded_imports = { + 'argparse': set(('gettext',)), + 'codecs': set(('encodings',)), + 'collections': set(('cPickle', 'pickle', 'doctest')), + 'copy': set(('reprlib',)), + 'functools': set(('_dummy_thread',)), + 'hashlib': set(('logging',)), + #'hashlib': set(('_hashlib', '_md5', '_sha', '_sha256','_sha512',)), + 'heapq': set(('doctest',)), + 'io': set(('_dummy_thread',)), + 'logging': set(('multiprocessing',)), + 'os': set(('nt', 'ntpath', 'os2', 'os2emxpath', 'mac', 'macpath', + 'riscos', 'riscospath', 'riscosenviron')), + 'optparse': set(('gettext',)), + 'pickle': set(('argparse', 'doctest', 'pprint')), + 'platform': set(('plistlib', 'tempfile')), + #'socket': set(('_ssl',)), + 'subprocess': set(('threading',)), + 'sysconfig': set(('pprint',)), + } + +def main(argv): + # Parse command line + import getopt + try: + opts, args = getopt.getopt(sys.argv[1:], "dmp:qx:") + except getopt.error as msg: + print(msg) + return + + # Process options + debug = 1 + domods = 0 + addpath = [] + exclude = [] + for o, a in opts: + if o == '-d': + debug = debug + 1 + if o == '-m': + domods = 1 + if o == '-p': + addpath = addpath + a.split(os.pathsep) + if o == '-q': + debug = 0 + if o == '-x': + exclude.append(a) + + path = sys.path[:] + path = addpath + path + + if debug > 1: + print("version:", sys.version) + print("path:") + for item in path: + print(" ", repr(item)) + + #exclude = ['__builtin__', 'sys', 'os'] + exclude = [] + mf = mymf(path, debug, exclude) + for arg in args: + mf.run_script(arg) + + depgraph = reduce_depgraph(mf._depgraph) + + pprint.pprint({'depgraph':mf._depgraph, 'types':mf._types}) + +if __name__=='__main__': + main(sys.argv[1:]) --- python3.2-3.2.3.orig/debian/PVER-minimal.README.Debian.in +++ python3.2-3.2.3/debian/PVER-minimal.README.Debian.in @@ -0,0 +1,150 @@ +Contents of the @PVER@-minimal package +----------------------------------------- + +@PVER@-minimal consists of a minimum set of modules which may be needed +for python scripts used during the boot process. If other packages +are needed in these scripts, don't work around the missing module, but +file a bug report against this package. The modules in this package +are: + + __builtin__ builtin + __future__ module + _abcoll module + _bisect extension + _bytesio builtin + _codecs builtin + _collections extension + _compat_pickle module + _datetime extension + _elementtree extension + _fileio builtin + _functools extension + _hashlib extensionx + _heapq extension + _io builtin + _locale extension + _pickle extension + _posixsubprocess extension + _random extension + _socket extension + _sre builtin + _ssl extensionx + _stringio extension + _struct extension + _string builtin + _stringio builtin + _symtable builtin + _sysconfigdata module + _sysconfigdata_nd module + _thread builtin + _types builtin + _weakref builtin + _weakrefset module + _warnings builtin + configparser module + abc module + argparse module + array extension + atexit extension + base64 module + binascii extension + bisect module + builtins builtin + codecs module + collections module + compileall module + copy module + copyreg module + dis module + errno builtin + exceptions builtin + fcntl extension + fnmatch module + functools module + gc builtin + genericpath module + getopt module + glob module + grp extension + hashlib module + heapq module + imp builtin + inspect module + io module + itertools extension + keyword module + linecache module + locale module + logging package + marshal builtin + math extension + opcode module + operator extension + optparse module + os module + pickle module + pkgutil module + platform module + posix builtin + posixpath module + pwd builtin + pyexpat extension + py_compile module + random module + re module + reprlib module + runpy module + select extension + signal builtin + socket module + spwd extension + sre_compile module + sre_constants module + sre_parse module + ssl module + stat module + string module + struct module + subprocess module + sys builtin + sysconfig module + syslog extension + tempfile module + textwrap module + time extension + token module + tokenize module + traceback module + types module + unicodedata extension + warnings module + weakref module + zipimport extension + zlib extension + +Included are as well the codecs and stringprep modules, and the encodings +modules for all encodings except the multibyte encodings and the bz2 codec. + +The following modules are excluded, their import is guarded from the +importing module: + + Used in Excluded + ------------ ------------------------------------ + io _dummy_thread + os nt ntpath os2 os2emxpath mac macpath + riscos riscospath riscosenviron + optparse gettext + pickle doctest + subprocess threading + +This list was derived by looking at the modules in the perl-base package, +then adding python specific "core modules". + +TODO's +------ + +- time.strptime cannot be used. The required _strptime module is not + included in the -minimal package yet. _strptime, locale, _locale and + calendar have to be added. + +- modules used very often in the testsuite: copy, cPickle, operator. --- python3.2-3.2.3.orig/debian/depgraph.py +++ python3.2-3.2.3/debian/depgraph.py @@ -0,0 +1,199 @@ +#! /usr/bin/python + +# Copyright 2004 Toby Dickenson +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject +# to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +import sys, getopt, colorsys, imp, md5 + +class pydepgraphdot: + + def main(self,argv): + opts,args = getopt.getopt(argv,'',['mono']) + self.colored = 1 + for o,v in opts: + if o=='--mono': + self.colored = 0 + self.render() + + def fix(self,s): + # Convert a module name to a syntactically correct node name + return s.replace('.','_') + + def render(self): + p,t = self.get_data() + + # normalise our input data + for k,d in p.items(): + for v in d.keys(): + if not p.has_key(v): + p[v] = {} + + f = self.get_output_file() + + f.write('digraph G {\n') + #f.write('concentrate = true;\n') + #f.write('ordering = out;\n') + f.write('ranksep=1.0;\n') + f.write('node [style=filled,fontname=Helvetica,fontsize=10];\n') + allkd = p.items() + allkd.sort() + for k,d in allkd: + tk = t.get(k) + if self.use(k,tk): + allv = d.keys() + allv.sort() + for v in allv: + tv = t.get(v) + if self.use(v,tv) and not self.toocommon(v,tv): + f.write('%s -> %s' % ( self.fix(k),self.fix(v) ) ) + self.write_attributes(f,self.edge_attributes(k,v)) + f.write(';\n') + f.write(self.fix(k)) + self.write_attributes(f,self.node_attributes(k,tk)) + f.write(';\n') + f.write('}\n') + + def write_attributes(self,f,a): + if a: + f.write(' [') + f.write(','.join(a)) + f.write(']') + + def node_attributes(self,k,type): + a = [] + a.append('label="%s"' % self.label(k)) + if self.colored: + a.append('fillcolor="%s"' % self.color(k,type)) + else: + a.append('fillcolor=white') + if self.toocommon(k,type): + a.append('peripheries=2') + return a + + def edge_attributes(self,k,v): + a = [] + weight = self.weight(k,v) + if weight!=1: + a.append('weight=%d' % weight) + length = self.alien(k,v) + if length: + a.append('minlen=%d' % length) + return a + + def get_data(self): + t = eval(sys.stdin.read()) + return t['depgraph'],t['types'] + + def get_output_file(self): + return sys.stdout + + def use(self,s,type): + # Return true if this module is interesting and should be drawn. Return false + # if it should be completely omitted. This is a default policy - please override. + if s=='__main__': + return 0 + #if s in ('os','sys','time','__future__','types','re','string'): + if s in ('sys'): + # nearly all modules use all of these... more or less. They add nothing to + # our diagram. + return 0 + if s.startswith('encodings.'): + return 0 + if self.toocommon(s,type): + # A module where we dont want to draw references _to_. Dot doesnt handle these + # well, so it is probably best to not draw them at all. + return 0 + return 1 + + def toocommon(self,s,type): + # Return true if references to this module are uninteresting. Such references + # do not get drawn. This is a default policy - please override. + # + if s=='__main__': + # references *to* __main__ are never interesting. omitting them means + # that main floats to the top of the page + return 1 + #if type==imp.PKG_DIRECTORY: + # # dont draw references to packages. + # return 1 + return 0 + + def weight(self,a,b): + # Return the weight of the dependency from a to b. Higher weights + # usually have shorter straighter edges. Return 1 if it has normal weight. + # A value of 4 is usually good for ensuring that a related pair of modules + # are drawn next to each other. This is a default policy - please override. + # + if b.split('.')[-1].startswith('_'): + # A module that starts with an underscore. You need a special reason to + # import these (for example random imports _random), so draw them close + # together + return 4 + return 1 + + def alien(self,a,b): + # Return non-zero if references to this module are strange, and should be drawn + # extra-long. the value defines the length, in rank. This is also good for putting some + # vertical space between seperate subsystems. This is a default policy - please override. + # + return 0 + + def label(self,s): + # Convert a module name to a formatted node label. This is a default policy - please override. + # + return '\\.\\n'.join(s.split('.')) + + def color(self,s,type): + # Return the node color for this module name. This is a default policy - please override. + # + # Calculate a color systematically based on the hash of the module name. Modules in the + # same package have the same color. Unpackaged modules are grey + t = self.normalise_module_name_for_hash_coloring(s,type) + return self.color_from_name(t) + + def normalise_module_name_for_hash_coloring(self,s,type): + if type==imp.PKG_DIRECTORY: + return s + else: + i = s.rfind('.') + if i<0: + return '' + else: + return s[:i] + + def color_from_name(self,name): + n = md5.md5(name).digest() + hf = float(ord(n[0])+ord(n[1])*0xff)/0xffff + sf = float(ord(n[2]))/0xff + vf = float(ord(n[3]))/0xff + r,g,b = colorsys.hsv_to_rgb(hf, 0.3+0.6*sf, 0.8+0.2*vf) + return '#%02x%02x%02x' % (r*256,g*256,b*256) + + +def main(): + pydepgraphdot().main(sys.argv[1:]) + +if __name__=='__main__': + main() + + + --- python3.2-3.2.3.orig/debian/libPVER.symbols.in +++ python3.2-3.2.3/debian/libPVER.symbols.in @@ -0,0 +1,3 @@ +libpython@VER@mu.so.1.0 libpython@VER@ #MINVER# +#include "libpython.symbols" + PyModule_Create2@Base @SVER@ --- python3.2-3.2.3.orig/debian/PVER-dbg.prerm.in +++ python3.2-3.2.3/debian/PVER-dbg.prerm.in @@ -0,0 +1,35 @@ +#! /bin/sh + +set -e + +remove_bytecode() +{ + pkg=$1 + max=$(LANG=C LC_ALL=C xargs --show-limits < /dev/null 2>&1 | awk '/Maximum/ {print int($NF / 4)}') + dpkg -L $pkg \ + | awk -F/ 'BEGIN {OFS="/"} /\.py$/ {$NF=sprintf("__pycache__/%s.*.py[co]", substr($NF,1,length($NF)-3)); print}' \ + | xargs --max-chars=$max echo \ + | while read files; do rm -f $files; done + if [ -d /usr/bin/__pycache__ ]; then + rmdir --ignore-fail-on-non-empty /usr/bin/__pycache__ + fi +} + +case "$1" in + remove) + remove_bytecode @PVER@-dbg + ;; + upgrade) + remove_bytecode @PVER@-dbg + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python3.2-3.2.3.orig/debian/rules +++ python3.2-3.2.3/debian/rules @@ -0,0 +1,1136 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. + +unexport LANG LC_ALL LC_CTYPE LC_COLLATE LC_TIME LC_NUMERIC LC_MESSAGES +unexport CFLAGS CXXFLAGS CPPFLAGS + +export SHELL = /bin/bash + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +vafilt = $(subst $(2)=,,$(filter $(2)=%,$(1))) +DPKG_VARS := $(shell dpkg-architecture) +DEB_HOST_ARCH ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH) +DEB_HOST_ARCH_OS ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH_OS) + +CHANGELOG_VARS := $(shell dpkg-parsechangelog | \ + sed -n 's/ /_/g;/^[^_]/s/^\([^:]*\):_\(.*\)/\1=\2/p') +PKGSOURCE := $(call vafilt,$(CHANGELOG_VARS),Source) +PKGVERSION := $(call vafilt,$(CHANGELOG_VARS),Version) + +on_buildd := $(shell [ -f /CurrentlyBuilding -o "$$LOGNAME" = buildd ] && echo yes) + +ifneq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS))) + WITHOUT_CHECK := yes +endif +WITHOUT_BENCH := +ifneq (,$(findstring nobench, $(DEB_BUILD_OPTIONS))) + WITHOUT_BENCH := yes +endif +ifneq (,$(filter $(DEB_HOST_ARCH), hurd-i386)) + WITHOUT_BENCH := disabled on $(DEB_HOST_ARCH) +endif +ifeq ($(on_buildd),yes) + ifneq (,$(findstring $(DEB_HOST_ARCH), armel hppa mips mipsel s390)) + WITHOUT_CHECK := yes + endif + ifneq (,$(findstring $(DEB_HOST_ARCH), armel hppa mips mipsel s390)) + WITHOUT_BENCH := yes + endif +endif + +COMMA = , +ifneq (,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) + NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS)))) +endif + +distribution := $(shell lsb_release -is) + +VER=3.2 +SVER=3.2~a4 +NVER=3.3 +PVER=python3.2 +PRIORITY=$(shell echo $(VER) | tr -d '.')0 + +PREVVER := $(shell awk '/^python/ && NR > 1 {print substr($$2,2,length($$2)-2); exit}' debian/changelog) + +# default versions are built from the python-defaults source package +# keep the definition to adjust package priorities. +DEFAULT_VERSION = no +STATIC_PYTHON=yes + +MIN_MODS := $(shell awk '/^ / && $$2 == "module" { print $$1 }' \ + debian/PVER-minimal.README.Debian.in) +MIN_EXTS := $(shell awk '/^ / && $$2 ~ /^extension/ { print $$1 }' \ + debian/PVER-minimal.README.Debian.in) +MIN_BUILTINS := $(shell awk '/^ / && $$2 == "builtin" { print $$1 }' \ + debian/PVER-minimal.README.Debian.in) +MIN_PACKAGES := $(shell awk '/^ / && $$2 == "package" { print $$1 }' \ + debian/PVER-minimal.README.Debian.in) +MIN_ENCODINGS := $(foreach i, \ + $(filter-out \ + big5% bz2% cp932.py cp949.py cp950.py euc_% \ + gb% iso2022% johab.py shift_jis% , \ + $(shell cd Lib/encodings && echo *.py)), \ + encodings/$(i)) \ + codecs.py stringprep.py + +with_tk := no +with_interp := static +#with_interp := shared + +PY_INTERPRETER = /usr/bin/python$(VER) + +ifeq ($(DEFAULT_VERSION),yes) + PY_PRIO = standard + #PYSTDDEP = , python (>= $(VER)) +else + PY_PRIO = optional +endif +ifeq ($(distribution),Ubuntu) + PY_MINPRIO = required + PY_MINPRIO = optional + with_fpectl = yes + with_udeb = yes +else + PY_MINPRIO = $(PY_PRIO) + with_fpectl = yes +endif + +CC = gcc + +DPKG_CFLAGS := $(shell dpkg-buildflags --get CFLAGS) +DPKG_LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS) +OPT_CFLAGS := $(filter-out -O%,$(DPKG_CFLAGS)) # default is -O3 +DEBUG_CFLAGS := $(patsubst -O%,-O0,$(DPKG_CFLAGS)) + +# on alpha, use -O2 only, use -mieee +ifeq ($(DEB_HOST_ARCH),alpha) + OPT_CFLAGS += -mieee + DEBUG_CFLAGS += -mieee + EXTRA_OPT_FLAGS += -O2 +endif +ifeq ($(DEB_HOST_ARCH),m68k) + EXTRA_OPT_FLAGS += -O2 +endif + +ifeq ($(DEB_HOST_ARCH_OS),linux) + ifneq (,$(findstring $(DEB_HOST_ARCH), amd64 armel armhf i386 powerpc ppc64)) + with_pgo := yes + endif +endif + +ifneq (,$(findstring $(DEB_HOST_ARCH), amd64 armel armhf i386)) + with_lto := yes +endif + +ifneq (,$(findstring noopt, $(DEB_BUILD_OPTIONS))) + OPT_CFLAGS := $(filter-out -O%, $(OPT_CFLAGS)) + EXTRA_OPT_CFLAGS = -O0 + with_pgo = + with_lto = +endif + +ifeq ($(with_lto),yes) + LTO_CFLAGS = -g -flto -fuse-linker-plugin + EXTRA_OPT_CFLAGS += $(LTO_CFLAGS) +endif + +make_build_target = $(if $(with_pgo),profile-opt) + +buildd_static := $(CURDIR)/build-static +buildd_shared := $(CURDIR)/build-shared +buildd_debug := $(CURDIR)/build-debug +buildd_shdebug := $(CURDIR)/build-shdebug + +d := debian/tmp +scriptdir = usr/share/lib/python$(VER) +scriptdir = usr/share/python$(VER) +scriptdir = usr/lib/python$(VER) + +# package names and directories +p_base := $(PVER) +p_min := $(PVER)-minimal +p_lib := lib$(PVER) +p_tk := $(PVER)-tk +p_dev := $(PVER)-dev +p_exam := $(PVER)-examples +p_idle := idle-$(PVER) +p_doc := $(PVER)-doc +p_dbg := $(PVER)-dbg +p_udeb := $(PVER)-udeb + +d_base := debian/$(p_base) +d_min := debian/$(p_min) +d_lib := debian/$(p_lib) +d_tk := debian/$(p_tk) +d_dev := debian/$(p_dev) +d_exam := debian/$(p_exam) +d_idle := debian/$(p_idle) +d_doc := debian/$(p_doc) +d_dbg := debian/$(p_dbg) +d_udeb := debian/$(p_udeb) + +build-arch: stamps/stamp-build +build-indep: stamps/stamp-build-doc +build: build-arch +stamps/stamp-build: stamps/stamp-build-static stamps/stamp-mincheck \ + stamps/stamp-build-shared stamps/stamp-build-debug \ + stamps/stamp-build-shared-debug \ + stamps/stamp-check stamps/stamp-pystone stamps/stamp-pybench + touch $@ + +PROFILE_EXCLUDES = test_compiler test_distutils test_platform test_subprocess \ + test_multiprocessing test_socketserver \ + test_thread test_threaded_import test_threadedtempfile \ + test_threading test_threading_local test_threadsignals \ + test_dbm_dumb test_dbm_ndbm test_pydoc test_sundry \ + test_signal test_ioctl test_gdb +# FIXME: test_mailxbox breaks, 20090703 +PROFILE_EXCLUDES += test_mailbox +# FIXME: test_xmlrpc breaks, 20090818 +PROFILE_EXCLUDES += test_xmlrpc +# FIXME: test_telnetlib uses network resources +PROFILE_EXCLUDES += test_telnetlib + +PROFILE_TASK = ../Lib/test/regrtest.py \ + -x $(sort $(TEST_EXCLUDES) $(PROFILE_EXCLUDES)) + +stamps/stamp-build-static: stamps/stamp-configure-static + dh_testdir + $(MAKE) $(NJOBS) -C $(buildd_static) \ + EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)" \ + PROFILE_TASK='$(PROFILE_TASK)' $(make_build_target) + touch stamps/stamp-build-static + +stamps/stamp-build-shared: stamps/stamp-configure-shared + dh_testdir + $(MAKE) $(NJOBS) -C $(buildd_shared) \ + EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)" + : # build a static library with PIC objects + $(MAKE) $(NJOBS) -C $(buildd_shared) \ + EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)" \ + LIBRARY=libpython$(VER)mu-pic.a libpython$(VER)mu-pic.a + touch stamps/stamp-build-shared + +stamps/stamp-build-debug: stamps/stamp-configure-debug + dh_testdir + $(MAKE) $(NJOBS) -C $(buildd_debug) + touch stamps/stamp-build-debug + +stamps/stamp-build-shared-debug: stamps/stamp-configure-shared-debug + dh_testdir + : # build the shared debug library + $(MAKE) $(NJOBS) -C $(buildd_shdebug) \ + libpython$(VER)dmu.so + touch stamps/stamp-build-shared-debug + +common_configure_args = \ + --prefix=/usr \ + --enable-ipv6 \ + --enable-loadable-sqlite-extensions \ + --with-dbmliborder=bdb:gdbm \ + --with-wide-unicode \ + --with-computed-gotos \ + --with-system-expat \ + +ifeq ($(DEB_HOST_ARCH), avr32) + common_configure_args += --without-ffi +else + common_configure_args += --with-system-ffi +endif + +ifeq ($(with_fpectl),yes) + common_configure_args += \ + --with-fpectl +endif + +stamps/stamp-configure-shared: stamps/stamp-patch + rm -rf $(buildd_shared) + mkdir -p $(buildd_shared) + cd $(buildd_shared) && \ + CC="$(CC)" CFLAGS="$(OPT_CFLAGS)" LDFLAGS="$(DPKG_LDFLAGS)" \ + ../configure \ + --enable-shared \ + $(common_configure_args) + + $(call __post_configure,$(buildd_shared)) + + @echo XXXXXXX pyconfig.h + -cat $(buildd_shared)/pyconfig.h + + touch $@ + +stamps/stamp-configure-static: stamps/stamp-patch + rm -rf $(buildd_static) + mkdir -p $(buildd_static) + cd $(buildd_static) && \ + CC="$(CC)" CFLAGS="$(OPT_CFLAGS)" LDFLAGS="$(DPKG_LDFLAGS)" \ + ../configure \ + $(common_configure_args) + + $(call __post_configure,$(buildd_static)) + touch $@ + +stamps/stamp-configure-debug: stamps/stamp-patch + rm -rf $(buildd_debug) + mkdir -p $(buildd_debug) + cd $(buildd_debug) && \ + CC="$(CC)" CFLAGS="$(DEBUG_CFLAGS)" LDFLAGS="$(DPKG_LDFLAGS)" \ + ../configure \ + $(common_configure_args) \ + --with-pydebug + + $(call __post_configure,$(buildd_debug)) + touch $@ + +stamps/stamp-configure-shared-debug: stamps/stamp-patch + rm -rf $(buildd_shdebug) + mkdir -p $(buildd_shdebug) + cd $(buildd_shdebug) && \ + CC="$(CC)" CFLAGS="$(DEBUG_CFLAGS)" LDFLAGS="$(DPKG_LDFLAGS)" \ + ../configure \ + $(common_configure_args) \ + --enable-shared \ + --with-pydebug + + $(call __post_configure,$(buildd_shdebug)) + touch $@ + +define __post_configure + egrep \ + "^#($$(awk -v ORS='|' '$$2 ~ /^extension$$/ {print $$1}' debian/PVER-minimal.README.Debian.in)XX)" \ + Modules/Setup.dist \ + | sed -e 's/^#//' -e 's/-Wl,-Bdynamic//;s/-Wl,-Bstatic//' \ + >> $(1)/Modules/Setup.local + + : # unconditionally run makesetup + cd $(1) && \ + ../Modules/makesetup -c ../Modules/config.c.in -s Modules \ + Modules/Setup.config Modules/Setup.local Modules/Setup + mv $(1)/config.c $(1)/Modules/ + + : # and fix the timestamps + $(MAKE) -C $(1) Makefile Modules/config.c + + : # apply workaround for missing os.fsync + sed 's/HAVE_SYNC/HAVE_FSYNC/g' $(1)/pyconfig.h \ + > $(1)/pyconfig.h.new + touch -r $(1)/pyconfig.h $(1)/pyconfig.h.new + mv -f $(1)/pyconfig.h.new $(1)/pyconfig.h +endef + +stamps/stamp-mincheck: stamps/stamp-build-static debian/PVER-minimal.README.Debian.in + for m in $(MIN_MODS) $(MIN_PACKAGES) $(MIN_EXTS) $(MIN_BUILTINS); do \ + echo "import $$m"; \ + done > $(buildd_static)/minmods.py + cd $(buildd_static) && ./python ../debian/pymindeps.py minmods.py \ + > $(buildd_static)/mindeps.txt + if [ -x /usr/bin/dot ]; then \ + python debian/depgraph.py < $(buildd_static)/mindeps.txt \ + > $(buildd_static)/mindeps.dot; \ + dot -Tpng -o $(buildd_static)/mindeps.png \ + $(buildd_static)/mindeps.dot; \ + else true; fi + cd $(buildd_static) && ./python ../debian/mincheck.py \ + minmods.py mindeps.txt + touch stamps/stamp-mincheck + +TEST_RESOURCES = all +ifeq ($(on_buildd),yes) + TEST_RESOURCES := $(TEST_RESOURCES),-network,-urlfetch +endif +TESTOPTS = $(NJOBS) -w -u$(TEST_RESOURCES) +TEST_EXCLUDES = +ifeq ($(on_buildd),yes) + TEST_EXCLUDES += test_tcl test_codecmaps_cn test_codecmaps_hk \ + test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw \ + test_normalization test_ossaudiodev +endif +ifeq (,$(wildcard /dev/dsp)) + TEST_EXCLUDES += test_linuxaudiodev test_ossaudiodev +endif +ifneq (,$(filter $(DEB_HOST_ARCH), hppa)) + TEST_EXCLUDES += test_fork1 test_multiprocessing test_socketserver test_threading test_wait3 test_wait4 test_gdb +endif +ifneq (,$(filter $(DEB_HOST_ARCH), arm avr32)) + TEST_EXCLUDES += test_ctypes +endif +ifneq (,$(filter $(DEB_HOST_ARCH), arm armel avr32 m68k)) + ifeq ($(on_buildd),yes) + TEST_EXCLUDES += test_compiler + endif +endif +ifneq (,$(filter $(DEB_HOST_ARCH), sparc sparc64)) + TEST_EXCLUDES += test_gdb +endif +ifneq (,$(filter $(DEB_HOST_ARCH), hurd-i386)) + TEST_EXCLUDES += test_imaplib test_io test_logging test_random test_signal test_socket test_socketserver test_ssl test_threading test_threadsignals test_threadedtempfile +endif +# issues with 3.2~a4 +TEST_EXCLUDES += test_sysconfig + +# for debug builds only +TEST_EXCLUDES += test_gdb + +ifneq (,$(TEST_EXCLUDES)) + TESTOPTS += -x $(sort $(TEST_EXCLUDES)) + ifneq (,$(filter $(DEB_HOST_ARCH), mips mipsel)) + TESTOPTS_DEBUG := $(TESTOPTS) + else + TESTOPTS_DEBUG := $(filter-out test_gdb,$(TESTOPTS)) + endif +endif + +ifneq (,$(wildcard /usr/bin/localedef)) + SET_LOCPATH = LOCPATH=$(CURDIR)/locales +endif + +stamps/stamp-check: +ifeq ($(WITHOUT_CHECK),yes) + echo "check run disabled for this build" > $(buildd_static)/test_results +else + : # build locales needed by the testsuite + rm -rf locales + mkdir locales + if which localedef >/dev/null 2>&1; then \ + sh debian/locale-gen; \ + fi + + @echo ========== test environment ============ + @env + @echo ======================================== + + ifeq (,$(findstring $(DEB_HOST_ARCH), alpha)) + ( \ + echo '#! /bin/sh'; \ + echo 'set -x'; \ + echo 'export $(SET_LOCPATH)'; \ + echo '$(buildd_static)/python $(CURDIR)/debian/script.py test_results '\''make test TESTOPTS="$(TESTOPTS_DEBUG)"'\'; \ + echo 'echo DONE'; \ + ) > $(buildd_debug)/run_tests + chmod 755 $(buildd_debug)/run_tests + @echo "BEGIN test debug" + -cd $(buildd_debug) && time xvfb-run -a -e xvfb-run.log ./run_tests + @echo "END test debug" + endif + + ( \ + echo '#! /bin/sh'; \ + echo 'set -x'; \ + echo 'export $(SET_LOCPATH)'; \ + echo '$(buildd_static)/python $(CURDIR)/debian/script.py test_results '\''make test EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)" TESTOPTS="$(TESTOPTS)"'\'; \ + echo 'echo DONE'; \ + ) > $(buildd_static)/run_tests + chmod 755 $(buildd_static)/run_tests + @echo "BEGIN test static" + -cd $(buildd_static) && time xvfb-run -a -e xvfb-run.log ./run_tests + @echo "END test static" + + ( \ + echo '#! /bin/sh'; \ + echo 'set -x'; \ + echo 'export $(SET_LOCPATH)'; \ + echo '$(buildd_static)/python $(CURDIR)/debian/script.py test_results '\''make test EXTRA_CFLAGS="$(EXTRA_OPT_CFLAGS)" TESTOPTS="$(TESTOPTS)"'\'; \ + echo 'echo DONE'; \ + ) > $(buildd_shared)/run_tests + chmod 755 $(buildd_shared)/run_tests + @echo "BEGIN test shared" + -cd $(buildd_shared) && time xvfb-run -a -e xvfb-run.log ./run_tests + @echo "END test shared" +endif + cp -p $(buildd_static)/test_results debian/ + touch stamps/stamp-check + +stamps/stamp-pystone: + @echo "BEGIN pystone static" + cd $(buildd_static) && ./python ../Lib/test/pystone.py + cd $(buildd_static) && ./python ../Lib/test/pystone.py + @echo "END pystone static" + @echo "BEGIN pystone shared" + cd $(buildd_shared) \ + && LD_LIBRARY_PATH=. ./python ../Lib/test/pystone.py + cd $(buildd_shared) \ + && LD_LIBRARY_PATH=. ./python ../Lib/test/pystone.py + @echo "END pystone shared" + @echo "BEGIN pystone debug" + cd $(buildd_debug) && ./python ../Lib/test/pystone.py + cd $(buildd_debug) && ./python ../Lib/test/pystone.py + @echo "END pystone debug" + touch stamps/stamp-pystone + +stamps/stamp-pybench: + echo "pybench run disabled for this build" > $(buildd_static)/pybench.log + +#ifeq (,$(filter $(DEB_HOST_ARCH), arm armel avr32 hppa mips mipsel m68k)) + pybench_options = -C 2 -n 5 -w 4 +#endif + +stamps/stamp-pybenchx: +ifeq ($(WITHOUT_BENCH),yes) + echo "pybench run disabled for this build" > $(buildd_static)/pybench.log +else + @echo "BEGIN pybench static" + cd $(buildd_static) \ + && time ./python ../Tools/pybench/pybench.py -f run1.pybench $(pybench_options) + cd $(buildd_static) \ + && ./python ../Tools/pybench/pybench.py -f run2.pybench -c run1.pybench $(pybench_options) + @echo "END pybench static" + @echo "BEGIN pybench shared" + cd $(buildd_shared) \ + && LD_LIBRARY_PATH=. ./python ../Tools/pybench/pybench.py -f run1.pybench $(pybench_options) + cd $(buildd_shared) \ + && LD_LIBRARY_PATH=. ./python ../Tools/pybench/pybench.py -f run2.pybench -c run1.pybench $(pybench_options) + @echo "END pybench shared" + @echo "BEGIN shared/static comparision" + $(buildd_static)/python Tools/pybench/pybench.py \ + -s $(buildd_static)/run2.pybench -c $(buildd_shared)/run2.pybench \ + | tee $(buildd_static)/pybench.log + @echo "END shared/static comparision" +endif + touch stamps/stamp-pybench + +minimal-test: + rm -rf mintest + mkdir -p mintest/lib mintest/dynlib mintest/testlib mintest/all-lib + cp -p $(buildd_static)/python mintest/ + cp -p $(foreach i,$(MIN_MODS),Lib/$(i).py) \ + mintest/lib/ + cp -a $(foreach i,$(MIN_PACKAGES),Lib/$(i)) \ + mintest/lib/ + cp -p $(wildcard $(foreach i,$(MIN_EXTS),$(buildd_static)/build/lib*/$(i).*.so)) \ + mintest/dynlib/ + cp -p Lib/unittest.py mintest/lib/ + cp -pr Lib/test mintest/lib/ + cp -pr Lib mintest/all-lib + cp -p $(buildd_static)/build/lib*/*.so mintest/all-lib/ + ( \ + echo "import sys"; \ + echo "sys.path = ["; \ + echo " '$(CURDIR)/mintest/lib',"; \ + echo " '$(CURDIR)/mintest/dynlib',"; \ + echo "]"; \ + cat Lib/test/regrtest.py; \ + ) > mintest/lib/test/mintest.py + cd mintest && ./python -E -S lib/test/mintest.py \ + -x test_codecencodings_cn test_codecencodings_hk \ + test_codecencodings_jp test_codecencodings_kr \ + test_codecencodings_tw test_codecs test_multibytecodec \ + +stamps/stamp-doc-html: + dh_testdir + $(MAKE) -C Doc html + touch stamps/stamp-doc-html + +build-doc: stamps/stamp-patch stamps/stamp-build-doc +stamps/stamp-build-doc: stamps/stamp-doc-html + touch stamps/stamp-build-doc + +control-file: + sed -e "s/@PVER@/$(PVER)/g" \ + -e "s/@VER@/$(VER)/g" \ + -e "s/@PYSTDDEP@/$(PYSTDDEP)/g" \ + -e "s/@PRIO@/$(PY_PRIO)/g" \ + -e "s/@MINPRIO@/$(PY_MINPRIO)/g" \ + debian/control.in \ + $(if $(with_udeb),debian/control.udeb) \ + > debian/control.tmp +ifeq ($(distribution),Ubuntu) + ifneq (,$(findstring ubuntu, $(PKGVERSION))) + m='Ubuntu Core Developers '; \ + sed -i "/^Maintainer:/s/\(.*\)/Maintainer: $$m\nXSBC-Original-\1/" \ + debian/control.tmp + endif +endif + [ -e debian/control ] \ + && cmp -s debian/control debian/control.tmp \ + && rm -f debian/control.tmp && exit 0; \ + mv debian/control.tmp debian/control + + + +clean: control-file + dh_testdir + dh_testroot + $(MAKE) -f debian/rules unpatch + rm -rf stamps .pc + rm -f debian/test_results + + $(MAKE) -C Doc clean + sed 's/^@/#/' Makefile.pre.in | $(MAKE) -f - srcdir=. distclean + rm -rf $(buildd_static) $(buildd_shared) $(buildd_debug) $(buildd_shdebug) + find -name '*.py[co]' | xargs -r rm -f + rm -f Lib/lib2to3/*.pickle + rm -rf locales + rm -rf $(d)-dbg + + for f in debian/*.in; do \ + f2=`echo $$f | sed "s,PVER,$(PVER),g;s/@VER@/$(VER)/g;s,\.in$$,,"`; \ + if [ $$f2 != debian/control ] && [ $$f2 != debian/source.lintian-overrides ]; then \ + rm -f $$f2; \ + fi; \ + done + dh_clean + +stamps/stamp-control: + : # We have to prepare the various control files + + for f in debian/*.in; do \ + f2=`echo $$f | sed "s,PVER,$(PVER),g;s/@VER@/$(VER)/g;s,\.in$$,,"`; \ + if [ $$f2 != debian/control ]; then \ + sed -e "s/@PVER@/$(PVER)/g;s/@VER@/$(VER)/g;s/@SVER@/$(SVER)/g" \ + -e "s/@PRIORITY@/$(PRIORITY)/g" \ + -e "s,@SCRIPTDIR@,/$(scriptdir),g" \ + -e "s,@INFO@,$(info_docs),g" \ + <$$f >$$f2; \ + fi; \ + done + +2to3-man: + help2man --no-info --version-string=$(VER) --no-discard-stderr \ + --name 'Python2 to Python3 converter' \ + 2to3-$(VER) > debian/2to3-$(VER).1 + +install: build-arch stamps/stamp-install +stamps/stamp-install: stamps/stamp-build control-file stamps/stamp-control + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + : # make install into tmp and subsequently move the files into + : # their packages' directories. + install -d $(d)/usr +ifeq ($(with_interp),static) + $(MAKE) -C $(buildd_static) install prefix=$(CURDIR)/$(d)/usr +else + $(MAKE) -C $(buildd_shared) install prefix=$(CURDIR)/$(d)/usr +endif + rm -f $(d)/$(scriptdir)/lib-dynload/*.py + mv $(d)/$(scriptdir)/_sysconfigdata.py \ + $(d)/$(scriptdir)/_sysconfigdata_nd.py + sed -i 's/ -O3 / -O2 /g;s/$(LTO_CFLAGS)//g' \ + $(d)/$(scriptdir)/_sysconfigdata_nd.py + cp -p debian/_sysconfigdata.py $(d)/$(scriptdir)/ + + -find $(d)/usr/lib/python$(VER) -name '*_failed*.so' + find $(d)/usr/lib/python$(VER) -name '*_failed*.so' | xargs -r rm -f + + mkdir -p $(d)/usr/lib/python3 + mv $(d)/usr/lib/python$(VER)/site-packages \ + $(d)/usr/lib/python3/dist-packages + rm -f $(d)/usr/lib/python3/dist-packages/README + + : # remove files, which are not packaged + rm -rf $(d)/usr/lib/python$(VER)/ctypes/macholib + + : # cannot build it, zlib maintainer won't provide a mingw build + find $(d) -name 'wininst*.exe' | xargs -r rm -f + + : # fix some file permissions + chmod a-x $(d)/$(scriptdir)/{runpy,fractions,lib2to3/refactor,tkinter/tix}.py + +# : # move manpages to new names +# if [ -d $(d)/usr/man/man1 ]; then \ +# mkdir -p $(d)/usr/share/man +# mv $(d)/usr/man/man1/* $(d)/usr/share/man/man1/; \ +# rm -rf $(d)/usr/man/; \ +# fi + + mkdir -p $(d)/usr/share/man/man1 + cp -p Misc/python.man $(d)/usr/share/man/man1/python$(VER).1 + ln -sf python$(VER).1 $(d)/usr/share/man/man1/python$(VER)mu.1 + cp -p debian/pydoc.1 $(d)/usr/share/man/man1/pydoc$(VER).1 + + : # Symlinks to /usr/bin for some tools + ln -sf ../lib/python$(VER)/pdb.py $(d)/usr/bin/pdb$(VER) + cp -p debian/pdb.1 $(d)/usr/share/man/man1/pdb$(VER).1 + cp -p debian/2to3-$(VER).1 $(d)/usr/share/man/man1/2to3-$(VER).1 + + : # versioned install only + rm -f $(d)/usr/bin/{2to3,idle3,pydoc3,python3,python3-config} + rm -f $(d)/usr/lib/pkgconfig/python3.pc + + : # Remove version information from the egg-info file + mv $(d)/$(scriptdir)/lib-dynload/Python-3*.egg-info \ + $(d)/$(scriptdir)/lib-dynload/Python.egg-info + + dh_installdirs -p$(p_lib) \ + $(scriptdir)/config-$(VER)mu \ + usr/share/doc + : # install the shared library + cp -p $(buildd_shared)/libpython$(VER)mu.so.1.0 $(d_lib)/usr/lib/ + ln -sf libpython$(VER)mu.so.1.0 $(d_lib)/usr/lib/libpython$(VER)mu.so.1 + ln -sf ../../libpython$(VER)mu.so \ + $(d_lib)/$(scriptdir)/config-$(VER)mu/libpython$(VER)mu.so + ln -sf libpython$(VER)mu.so \ + $(d_lib)/$(scriptdir)/config-$(VER)mu/libpython$(VER).so + ln -sf $(p_base) $(d_lib)/usr/share/doc/$(p_lib) + + ln -sf libpython$(VER)mu.so.1 $(d)/usr/lib/libpython$(VER)mu.so + +ifeq ($(with_interp),shared) + : # install the statically linked runtime + install -m755 $(buildd_static)/python $(d)/usr/bin/python$(VER)-static +endif + + cp -p Tools/i18n/pygettext.py $(d)/usr/bin/pygettext$(VER) + cp -p debian/pygettext.1 $(d)/usr/share/man/man1/pygettext$(VER).1 + + : # install the Makefile of the shared python build + sed -e '/^OPT/s,-O3,-O2,' \ + -e 's/$(LTO_CFLAGS)//g' \ + -e 's,^RUNSHARED *=.*,RUNSHARED=,' \ + build-shared/Makefile > $(d)/$(scriptdir)/config-$(VER)mu/Makefile + + : # Move the binary and the minimal libraries into $(p_min). + dh_installdirs -p$(p_min) \ + etc/$(PVER) \ + usr/bin \ + usr/share/man/man1 \ + $(scriptdir)/lib-dynload \ + $(scriptdir)/config-$(VER)mu \ + usr/include/python$(VER)mu + DH_COMPAT=2 dh_movefiles -p$(p_min) --sourcedir=$(d) \ + usr/bin/python$(VER) \ + usr/bin/python$(VER)mu \ + usr/share/man/man1/python$(VER).1 \ + usr/share/man/man1/python$(VER)mu.1 \ + $(foreach i,$(MIN_MODS),$(scriptdir)/$(i).py) \ + $(foreach i,$(MIN_PACKAGES),$(scriptdir)/$(i)) \ + $(foreach i,$(MIN_ENCODINGS),$(scriptdir)/$(i)) \ + $(scriptdir)/config-$(VER)mu/Makefile \ + $(scriptdir)/site.py \ + usr/include/python$(VER)mu/pyconfig.h \ + $(shell cd $(d); for i in $(MIN_EXTS); do \ + test -e $(scriptdir)/lib-dynload/$$i.*.so \ + && echo $(scriptdir)/lib-dynload/$$i.*.so; \ + done; true) + + ln -sf python$(VER)mu $(d_min)/usr/bin/python$(VER) + : # symlinks for the "old" config directory name + ln -sf config-$(VER)mu $(d_min)/$(scriptdir)/config + + rv=0; \ + for i in $(MIN_EXTS); do \ + if [ -f $(d)/$(scriptdir)/lib-dynload/$$i.so ]; then \ + echo >&2 "extension $$i not mentioned in Setup.dist"; \ + rv=1; \ + fi; \ + done; \ + exit $$rv; + + : # Install sitecustomize.py. + cp -p debian/sitecustomize.py $(d_min)/etc/$(PVER)/ + dh_link -p$(p_min) /etc/$(PVER)/sitecustomize.py \ + /$(scriptdir)/sitecustomize.py + + : # Move the static library and the header files into $(p_dev). +# mv $(d)/usr/share/include/python$(VER)/* $(d)/usr/include/python$(VER)/. +# rm -rf $(d)/usr/share/include + dh_installdirs -p$(p_dev) \ + usr/share/doc/python$(VER) \ + usr/share/man/man1 \ + $(scriptdir) \ + $(scriptdir)/doc/html \ + usr/include \ + usr/lib + cp -p Misc/HISTORY Misc/README.valgrind Misc/gdbinit \ + debian/README.maintainers \ + debian/test_results $(buildd_static)/pybench.log \ + $(d_dev)/usr/share/doc/python$(VER)/ + + DH_COMPAT=2 dh_movefiles -p$(p_dev) --sourcedir=$(d) \ + usr/lib/python$(VER)/config-$(VER)mu \ + usr/include/python$(VER)mu \ + usr/lib/libpython$(VER)mu.{a,so} \ + usr/lib/pkgconfig/python-$(VER)*.pc \ + usr/bin/python$(VER)*-config \ + usr/lib/python$(VER)/distutils/command/wininst-*.exe + + ln -sf $(PVER)/config-$(VER)mu/libpython$(VER)mu.a \ + $(d_dev)/usr/lib/libpython$(VER)mu.a + + cp -p debian/python3-config.1 \ + $(d_dev)/usr/share/man/man1/python$(VER)-config.1 + ln -sf python$(VER)-config.1 \ + $(d_dev)/usr/share/man/man1/python$(VER)mu-config.1 + + cp -p $(buildd_shared)/libpython$(VER)mu-pic.a \ + $(d_dev)/usr/lib/python$(VER)/config-$(VER)mu/ + + : # symlinks for the "old" include directory name + ln -sf python$(VER)mu $(d_dev)/usr/include/python$(VER) + +ifeq ($(with_tk),yes) + : # Move the Tkinter files into $(p_tk). + dh_installdirs -p$(p_tk) \ + $(scriptdir) \ + usr/lib/python$(VER)/lib-dynload + DH_COMPAT=2 dh_movefiles -p$(p_tk) --sourcedir=$(d) \ + usr/lib/python$(VER)/lib-dynload/_tkinter*.so +endif + +# : # The test framework into $(p_base), regression tests dropped + DH_COMPAT=2 dh_movefiles -p$(p_base) --sourcedir=$(d) \ + $(scriptdir)/test/{regrtest.py,support.py,__init__.py,pystone.py} + rm -rf $(d)/$(scriptdir)/test + rm -rf $(d)/$(scriptdir)/ctypes/test + rm -rf $(d)/$(scriptdir)/bsddb/test + rm -rf $(d)/$(scriptdir)/distutils/tests + rm -rf $(d)/$(scriptdir)/email/test + rm -rf $(d)/$(scriptdir)/importlib/test + rm -rf $(d)/$(scriptdir)/json/tests + rm -rf $(d)/$(scriptdir)/lib2to3/tests + rm -rf $(d)/$(scriptdir)/sqlite3/test + rm -rf $(d)/$(scriptdir)/distutils/tests + rm -rf $(d)/$(scriptdir)/lib2to3/tests + rm -rf $(d)/$(scriptdir)/tkinter/test + rm -rf $(d)/$(scriptdir)/unittest/test + + : # IDLE + mv $(d)/usr/bin/idle$(VER) $(d)/usr/bin/idle-python$(VER) + rm -f $(d)/usr/lib/python$(VER)/idlelib/idle.bat + dh_installdirs -p$(p_idle) \ + usr/bin \ + usr/share/man/man1 + DH_COMPAT=2 dh_movefiles -p$(p_idle) \ + usr/bin/idle-python$(VER) + cp -p debian/idle-$(PVER).1 $(d_idle)/usr/share/man/man1/ + + : # Move the demos and tools into $(p_exam)'s doc directory + dh_installdirs -p$(p_exam) \ + usr/share/doc/python$(VER)/examples + + cp -rp Tools/* $(d_exam)/usr/share/doc/python$(VER)/examples/ + rm -rf $(d_exam)/usr/share/doc/python$(VER)/examples/Tools/{buildbot,msi} + : # XXX: We don't need rgb.txt, we'll use our own: + rm -rf $(d_exam)/usr/share/doc/python$(VER)/examples/Tools/pynche/X + + : # Replace all '#!' calls to python with $(PY_INTERPRETER) + : # and make them executable + for i in `find debian -mindepth 3 -type f ! -name '*.dpatch'`; do \ + sed '1s,#!.*python[^ ]*\(.*\),#! $(PY_INTERPRETER)\1,' \ + $$i > $$i.temp; \ + if cmp --quiet $$i $$i.temp; then \ + rm -f $$i.temp; \ + else \ + mv -f $$i.temp $$i; \ + chmod 755 $$i; \ + echo "fixed interpreter: $$i"; \ + fi; \ + done + + : # Move the docs into $(p_base)'s /usr/share/doc/$(PVER) directory, + : # all other packages only have a copyright file. + dh_installdocs -p$(p_base) \ + README Misc/NEWS Misc/ACKS + ln -sf NEWS.gz $(d_base)/usr/share/doc/$(p_base)/changelog.gz + dh_installdocs --all -N$(p_base) -N$(p_dev) -N$(p_dbg) -N$(p_lib) debian/README.Debian + + : # IDLE has its own changelogs, docs... + dh_installchangelogs -p$(p_idle) Lib/idlelib/ChangeLog + dh_installdocs -p$(p_idle) Lib/idlelib/{NEWS,README,TODO,extend}.txt + + mkdir -p $(d_idle)/usr/share/applications + cp -p debian/idle.desktop \ + $(d_idle)/usr/share/applications/idle-$(PVER).desktop + + : # those packages have own README.Debian's + install -m 644 -p debian/README.$(p_base) \ + $(d_base)/usr/share/doc/$(PVER)/README.Debian + install -m 644 -p debian/README.$(p_idle) \ + $(d_idle)/usr/share/doc/$(p_idle)/README.Debian +ifeq ($(with_tk),yes) + cp -p debian/README.Tk $(d_tk)/usr/share/doc/$(p_tk)/ +endif + + : # The rest goes into $(p_base) + mkdir -p $(d)/usr/lib/python3/dist-packages + (cd $(d) && tar cf - .) | (cd $(d_base) && tar xpf -) + rm -f $(d_base)/usr/bin/python + + : # Install menu icon + dh_installdirs -p$(p_base) usr/share/pixmaps + cp -p debian/pylogo.xpm $(d_base)/usr/share/pixmaps/$(PVER).xpm + + : # generate binfmt file + mkdir -p $(d_min)/usr/share/binfmts + $(buildd_static)/python debian/mkbinfmt.py $(PVER) \ + > $(d_min)/usr/share/binfmts/$(PVER) + + : # desktop entry + mkdir -p $(d_base)/usr/share/applications + cp -p debian/$(PVER).desktop \ + $(d_base)/usr/share/applications/$(PVER).desktop + + : # remove some things + -find debian -name .cvsignore | xargs rm -f + -find debian -name '*.py[co]' | xargs rm -f + + : # remove empty directories, when all components are in place + -find debian ! -name lib-dynload ! -name dist-packages -type d -empty -delete + + : # install debug package + rm -rf $(d)-dbg + $(MAKE) -C $(buildd_debug) install DESTDIR=$(CURDIR)/$(d)-dbg + mv $(d)-dbg/$(scriptdir)/_sysconfigdata.py \ + $(d)-dbg/$(scriptdir)/_sysconfigdata_d.py + + dh_installdirs -p$(p_dbg) \ + usr/bin \ + usr/share/man/man1 \ + $(scriptdir)/lib-dynload \ + usr/include/$(PVER)dmu \ + usr/lib/pkgconfig \ + usr/share/doc/$(p_base) + cp -p Misc/SpecialBuilds.txt $(d_dbg)/usr/share/doc/$(p_base)/ + cp -p debian/$(PVER)-dbg.README.Debian \ + $(d_dbg)/usr/share/doc/$(p_base)/README.debug + cp -p $(buildd_debug)/python $(d_dbg)/usr/bin/$(PVER)dmu + ln -sf python$(VER)dmu $(d_dbg)/usr/bin/$(PVER)-dbg + sed '1s,#!.*python[^ ]*\(.*\),#! $(PY_INTERPRETER)-dbg\1,' \ + $(d)-dbg/usr/bin/$(PVER)-config \ + > $(d_dbg)/usr/bin/$(PVER)dmu-config + chmod 755 $(d_dbg)/usr/bin/$(PVER)dmu-config + ln -sf $(PVER)dmu-config $(d_dbg)/usr/bin/$(PVER)-dbg-config + cp -p $(buildd_debug)/build/lib*/*.so \ + $(d_dbg)/$(scriptdir)/lib-dynload/ + cp -p $(d)-dbg/$(scriptdir)/_sysconfigdata_d.py \ + $(d_dbg)/$(scriptdir)/ + cp -p $(buildd_shdebug)/libpython$(VER)dmu.so.1.0 $(d_dbg)/usr/lib/ + ln -sf libpython$(VER)dmu.so.1.0 $(d_dbg)/usr/lib/libpython$(VER)dmu.so.1 + ln -sf libpython$(VER)dmu.so.1 $(d_dbg)/usr/lib/libpython$(VER)dmu.so + sed -e '/^Libs:/s,-lpython$(VER),-lpython$(VER)dmu,' \ + -e '/^Cflags:/s,python$(VER),python$(VER)_d,' \ + $(d)-dbg/usr/lib/pkgconfig/python-$(VER).pc \ + > $(d_dbg)/usr/lib/pkgconfig/python-$(VER)-dbg.pc +ifneq ($(with_tk),yes) + rm -f $(d_dbg)/$(scriptdir)/lib-dynload/_tkinter*.so + rm -f $(d_dbg)/usr/lib/debug/$(scriptdir)/lib-dynload/_tkinter*.so +endif +ifneq ($(with_gdbm),yes) + rm -f $(d_dbg)/$(scriptdir)/lib-dynload/_gdbm*.so + rm -f $(d_dbg)/usr/lib/debug/$(scriptdir)/lib-dynload/_gdbm*.so +endif + + cp -a $(d)-dbg/$(scriptdir)/config-$(VER)dmu $(d_dbg)/$(scriptdir)/ + ln -sf ../../libpython$(VER)dmu.so \ + $(d_dbg)/$(scriptdir)/config-$(VER)dmu/libpython$(VER)dmu.so + ln -sf libpython$(VER)dmu.so \ + $(d_dbg)/$(scriptdir)/config-$(VER)dmu/libpython$(VER).so + ln -sf libpython$(VER)dmu.a \ + $(d_dbg)/$(scriptdir)/config-$(VER)dmu/libpython$(VER).a + + for i in $(d_dev)/usr/include/$(PVER)mu/*; do \ + i=$$(basename $$i); \ + case $$i in pyconfig.h) continue; esac; \ + ln -sf ../$(PVER)mu/$$i $(d_dbg)/usr/include/$(PVER)dmu/$$i; \ + done + cp -p $(buildd_debug)/pyconfig.h $(d_dbg)/usr/include/$(PVER)dmu/ + ln -sf $(PVER).1.gz $(d_dbg)/usr/share/man/man1/$(PVER)-dbg.1.gz + ln -sf $(PVER)-config.1.gz $(d_dbg)/usr/share/man/man1/$(PVER)-dbg-config.1.gz + ln -sf $(PVER).1.gz $(d_dbg)/usr/share/man/man1/$(PVER)dmu.1.gz + ln -sf $(PVER)-config.1.gz $(d_dbg)/usr/share/man/man1/$(PVER)dmu-config.1.gz + + : # symlinks for the "old" include / config directory names + ln -sf python$(VER)dmu $(d_dbg)/usr/include/python$(VER)_d + ln -sf config-$(VER)dmu $(d_dbg)/$(scriptdir)/config_d + +ifeq ($(with_udeb),yes) + : # Copy the most important files from $(p_min) into $(p_udeb). + dh_installdirs -p$(p_udeb) \ + etc/$(PVER) \ + usr/bin \ + usr/include/$(PVER)mu \ + $(scriptdir)/lib-dynload \ + $(scriptdir)/config-$(VER)mu + cp -p $(d_min)/usr/bin/python$(VER) $(d_udeb)/usr/bin/ + ln -sf python$(VER)mu $(d_udeb)/usr/bin/python$(VER) + ln -sf python$(VER) $(d_udeb)/usr/bin/python3 + cp -p $(foreach i,$(MIN_MODS),$(d_min)/$(scriptdir)/$(i).py) \ + $(d_udeb)/$(scriptdir)/ + cp -a $(foreach i,$(MIN_PACKAGES),$(d_min)/$(scriptdir)/$(i)) \ + $(d_udeb)/$(scriptdir)/ + cp -p $(foreach i,$(MIN_ENCODINGS),$(d_min)/$(scriptdir)/$(i)) \ + $(d_udeb)/$(scriptdir)/ + cp -p $(d_min)/$(scriptdir)/config-$(VER)mu/Makefile \ + $(d_udeb)/$(scriptdir)/config-$(VER)mu/ + cp -p $(d_min)/usr/include/$(PVER)mu/pyconfig.h \ + $(d_udeb)/usr/include/$(PVER)mu/ + cp -p $(d_min)/$(scriptdir)/site.py $(d_udeb)/$(scriptdir)/ + cp -p debian/sitecustomize.py $(d_udeb)/etc/$(PVER)/ + dh_link -p$(p_udeb) /etc/$(PVER)/sitecustomize.py \ + /$(scriptdir)/sitecustomize.py +endif + + for i in debian/*.overrides; do \ + b=$$(basename $$i .overrides); \ + install -D -m 644 $$i debian/$$b/usr/share/lintian/overrides/$$b; \ + done + + touch stamps/stamp-install + +# Build architecture-independent files here. +binary-indep: build-indep install stamps/stamp-control + dh_testdir -i + dh_testroot -i + + : # $(p_doc) package + dh_installdirs -p$(p_doc) \ + usr/share/doc/$(p_base) \ + usr/share/doc/$(p_doc) + dh_installdocs -p$(p_doc) + cp -a Doc/build/html $(d_doc)/usr/share/doc/$(p_base)/ + rm -f $(d_doc)/usr/share/doc/$(p_base)/html/_static/jquery.js \ + $(d_doc)/usr/share/doc/$(p_base)/html/_static/underscore.js + dh_link -p$(p_doc) \ + /usr/share/doc/$(p_base)/html /usr/share/doc/$(p_doc)/html \ + /usr/share/javascript/jquery/jquery.js /usr/share/doc/$(p_base)/html/_static/jquery.js \ + /usr/share/javascript/underscore/underscore.js /usr/share/doc/$(p_base)/html/_static/underscore.js + + : # devhelp docs + python debian/pyhtml2devhelp.py \ + $(d_doc)/usr/share/doc/$(p_base)/html index.html $(VER) \ + > $(d_doc)/usr/share/doc/$(p_base)/html/$(PVER).devhelp + gzip -9v $(d_doc)/usr/share/doc/$(p_base)/html/$(PVER).devhelp + dh_link -p$(p_doc) \ + /usr/share/doc/$(p_base)/html /usr/share/devhelp/books/$(PVER) + + dh_installdebconf -i $(dh_args) + dh_installexamples -i $(dh_args) + dh_installmenu -i $(dh_args) + -dh_icons -i $(dh_args) || dh_iconcache -i $(dh_args) + dh_installchangelogs -i $(dh_args) + dh_link -i $(dh_args) + dh_compress -i $(dh_args) -X.py -X.cls -X.css -X.txt -X.json -X.js -Xobjects.inv -Xgdbinit + dh_fixperms -i $(dh_args) + + : # make python scripts starting with '#!' executable + for i in `find debian -mindepth 3 -type f ! -name '*.dpatch' ! -perm 755`; do \ + if head -1 $$i | grep -q '^#!'; then \ + chmod 755 $$i; \ + echo "make executable: $$i"; \ + fi; \ + done + -find $(d_doc) -name '*.txt' -perm 755 -exec chmod 644 {} \; + + dh_installdeb -i $(dh_args) + dh_gencontrol -i $(dh_args) + dh_md5sums -i $(dh_args) + dh_builddeb -i $(dh_args) + +# Build architecture-dependent files here. +binary-arch: build-arch install + dh_testdir -a + dh_testroot -a +# dh_installdebconf -a + dh_installexamples -a + dh_installmenu -a + -dh_icons -a || dh_iconcache -a +# dh_installmime -a + dh_installchangelogs -a + for i in $(p_dev) $(p_dbg) $(p_lib); do \ + rm -rf debian/$$i/usr/share/doc/$$i; \ + ln -s $(p_base) debian/$$i/usr/share/doc/$$i; \ + done + -find debian ! -perm -200 -print -exec chmod +w {} \; +ifneq ($(with_tk),yes) + rm -f $(d_base)/$(scriptdir)/lib-dynload/_tkinter*.so +endif +ifneq ($(with_gdbm),yes) + rm -f $(d_base)/$(scriptdir)/lib-dynload/_gdbm*.so +endif + + dh_strip -a -N$(p_dbg) -Xdebug -Xdbg --dbg-package=$(p_dbg) + cp Tools/gdb/libpython.py $(d_dbg)/usr/lib/debug/usr/bin/$(PVER)mu-gdb.py + ln -sf $(PVER)mu-gdb.py $(d_dbg)/usr/lib/debug/usr/bin/$(PVER)dmu-gdb.py + ln -sf $(PVER)mu-gdb.py $(d_dbg)/usr/lib/debug/usr/bin/$(PVER)-dbg-gdb.py + ln -sf ../bin/$(PVER)mu-gdb.py \ + $(d_dbg)/usr/lib/debug/usr/lib/lib$(PVER)mu.so.1.0-gdb.py + ln -sf ../bin/$(PVER)mu-gdb.py \ + $(d_dbg)/usr/lib/lib$(PVER)dmu.so.1.0-gdb.py + dh_link -a + dh_compress -a -X.py + dh_fixperms -a + chmod 644 $(d_min)/$(scriptdir)/token.py + + : # make python scripts starting with '#!' executable + for i in `find debian -mindepth 3 -type f ! -name '*.dpatch' ! -perm 755`; do \ + if head -1 $$i | grep -q '^#!'; then \ + chmod 755 $$i; \ + echo "make executable: $$i"; \ + fi; \ + done + + dh_makeshlibs -p$(p_lib) -V '$(p_lib)' + dh_makeshlibs -p$(p_dbg) -V '$(p_dbg)' +# don't include the following symbols, found in extensions +# which either can be built as builtin or extension. + sed -ri \ + -e '/^ (PyInit_|_add_one_to_index|asdl_)/d' \ + -e '/^ (PyExpat_XML_|PyExpat_Xml)/d' \ + -e '/^ (ffi_type_|_ctypes_)/d' \ + $(d_lib)/DEBIAN/symbols $(d_dbg)/DEBIAN/symbols + dh_installdeb -a + dh_shlibdeps -a + dh_gencontrol -a + dh_md5sums -a + dh_builddeb -a + +# rules to patch the unpacked files in the source directory +# --------------------------------------------------------------------------- +# various rules to unpack addons and (un)apply patches. +# - patch / apply-patches +# - unpatch / reverse-patches + +patchdir = debian/patches + +glibc_version := $(shell dpkg -s locales | awk '/^Version:/ {print $$2}') +broken_utimes := $(shell dpkg --compare-versions $(glibc_version) lt 2.3.5 && echo yes || echo no) +old_sphinx := $(shell dpkg --compare-versions $$(dpkg -l python-sphinx | awk '/^ii *python-sphinx/ {print $$3}') lt 1 && echo yes || echo no) + +$(patchdir)/series: $(patchdir)/series.in + cpp -E \ + -D$(distribution) \ + $(if $(filter $(broken_utimes),yes),-DBROKEN_UTIMES) \ + $(if $(filter $(old_sphinx),yes),-DOLD_SPHINX) \ + -Darch_os_$(DEB_HOST_ARCH_OS) -Darch_$(DEB_HOST_ARCH) \ + -o - $(patchdir)/series.in \ + | egrep -v '^(#.*|$$)' > $(patchdir)/series + +patch-stamp: stamps/stamp-patch +patch: stamps/stamp-patch +stamps/stamp-patch: $(patchdir)/series + dh_testdir + QUILT_PATCHES=$(patchdir) quilt push -a || test $$? = 2 + rm -rf autom4te.cache configure + autoconf + mkdir -p stamps + echo ""; echo "Patches applied in this version:" > stamps/pxx + for i in $$(cat $(patchdir)/series); do \ + echo ""; echo "$$i:"; \ + sed -n 's/^# *DP: */ /p' $(patchdir)/$$i; \ + done >> stamps/pxx + mv stamps/pxx $@ + +reverse-patches: unpatch +unpatch: + QUILT_PATCHES=$(patchdir) quilt pop -a -R || test $$? = 2 + rm -f stamps/stamp-patch $(patchdir)/series + rm -rf configure autom4te.cache + +update-patches: $(patchdir)/series + export QUILT_PATCHES=$(patchdir); \ + export QUILT_REFRESH_ARGS="--no-timestamps --no-index -pab"; \ + export QUILT_DIFF_ARGS="--no-timestamps --no-index -pab"; \ + while quilt push; do quilt refresh; done + +binary: binary-indep binary-arch + +.PHONY: control-file configure build clean binary-indep binary-arch binary install + +# Local Variables: +# mode: makefile +# end: --- python3.2-3.2.3.orig/debian/source.lintian-overrides.in +++ python3.2-3.2.3/debian/source.lintian-overrides.in @@ -0,0 +1,2 @@ +# generated during the build +@PVER@ source: quilt-build-dep-but-no-series-file --- python3.2-3.2.3.orig/debian/script.py +++ python3.2-3.2.3/debian/script.py @@ -0,0 +1,51 @@ +#! /usr/bin/python + +# Copyright (C) 2012 Colin Watson . +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject +# to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +"""Trivial script(1) workalike, but without reading from standard input.""" + +import os +import pty +import select +import sys + +filename = sys.argv[1] +command = sys.argv[2] + +pid, master = pty.fork() +if pid == 0: # child + os.execlp("sh", "sh", "-c", command) + +# parent +with open(filename, "wb") as logfile: + try: + while True: + rfds, _, _ = select.select([master], [], []) + if master in rfds: + data = os.read(master, 65536) + os.write(1, data) + logfile.write(data) + logfile.flush() + except (IOError, OSError): + pass + +os.close(master) --- python3.2-3.2.3.orig/debian/PVER-doc.doc-base.PVER-api.in +++ python3.2-3.2.3/debian/PVER-doc.doc-base.PVER-api.in @@ -0,0 +1,13 @@ +Document: @PVER@-api +Title: Python/C API Reference Manual (v@VER@) +Author: Guido van Rossum +Abstract: This manual documents the API used by C (or C++) programmers who + want to write extension modules or embed Python. It is a + companion to *Extending and Embedding the Python Interpreter*, + which describes the general principles of extension writing but + does not document the API functions in detail. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/c-api/index.html +Files: /usr/share/doc/@PVER@/html/c-api/*.html --- python3.2-3.2.3.orig/debian/README.dbm +++ python3.2-3.2.3/debian/README.dbm @@ -0,0 +1,72 @@ + + Python and dbm modules on Debian + -------------------------------- + +This file documents the configuration of the dbm modules for Debian. It +gives hints at the preferred use of the dbm modules. + + +The preferred way to access dbm databases in Python is the anydbm module. +dbm databases behave like mappings (dictionaries). + +Since there exist several dbm database formats, we choose the following +layout for Python on Debian: + + * creating a new database with anydbm will create a Berkeley DB 2.X Hash + database file. This is the standard format used by libdb starting + with glibc 2.1. + + * opening an existing database with anydbm will try to guess the format + of the file (using whichdb) and then load it using one of the bsddb, + bsddb1, gdbm or dbm (only if the python-gdbm package is installed) + or dumbdbm modules. + + * The modules use the following database formats: + + - bsddb: Berkeley DB 2.X Hash (as in libc6 >=2.1 or libdb2) + - bsddb1: Berkeley DB 1.85 Hash (as in libc6 >=2.1 or libdb2) + - gdbm: GNU dbm 1.x or ndbm + - dbm: " (nearly the same as the gdbm module for us) + - dumbdbm: a hand-crafted format only used in this module + + That means that all usual formats should be readable with anydbm. + + * If you want to create a database in a format different from DB 2.X, + you can still directly use the specified module. + + * I.e. bsddb is the preferred module, and DB 2.X is the preferred format. + + * Note that the db1hash and bsddb1 modules are Debian specific. anydbm + and whichdb have been modified to support DB 2.X Hash files (see + below for details). + + + +For experts only: +---------------- + +Although bsddb employs the new DB 2.X format and uses the new Sleepycat +DB 2 library as included with glibc >= 2.1, it's still using the old +DB 1.85 API (which is still supported by DB 2). + +A more recent version 1.1 of the BSD DB module (available from +http://starship.skyport.net/robind/python/) directly uses the DB 2.X API. +It has a richer set of features. + + +On a glibc 2.1 system, bsddb is linked with -ldb, bsddb1 is linked with +-ldb1 and gdbm as well as dbm are linked with -lgdbm. + +On a glibc 2.0 system (e.g. potato for m68k or slink), bsddb will be +linked with -ldb2 while bsddb1 will be linked with -ldb (therefore +python-base here depends on libdb2). + + +db1hash and bsddb1 nearly completely identical to dbhash and bsddb. The +only difference is that bsddb is linked with the real DB 2 library, while +bsddb1 is linked with an library which provides compatibility with legacy +DB 1.85 databases. + + + July 16, 1999 + Gregor Hoffleit --- python3.2-3.2.3.orig/debian/PVER-dbg.README.Debian.in +++ python3.2-3.2.3/debian/PVER-dbg.README.Debian.in @@ -0,0 +1,51 @@ +Contents of the @PVER@-dbg package +------------------------------------- + +For debugging python and extension modules, you may want to add the contents +of /usr/share/doc/@PVER@/gdbinit to your ~/.gdbinit file. + +@PVER@-dbg contains two sets of packages: + + - debugging symbols for the standard @PVER@ build. When this package + is installed, gdb will automatically load up the debugging symbols + from it when debugging @PVER@ or one of the included extension + modules. + + - a separate @PVER@-dbg binary, configured --with-pydebug, enabling the + additional debugging code to help debug memory management problems. + +For the latter, all extension modules have to be recompiled to +correctly load with an pydebug enabled build. + + +Debian and Ubuntu specific changes to the debug interpreter +----------------------------------------------------------- +The python2.4 and python2.5 packages in Ubuntu feisty are modified to +first look for extension modules under a different name. + + normal build: foo.so + debug build: foo_d.so foo.so + +This naming schema allows installation of the extension modules into +the same path (The naming is directly taken from the Windows builds +which already uses this naming scheme). + +See https://wiki.ubuntu.com/PyDbgBuilds for more information. + + +Using the python-dbg builds +--------------------------- + + * Call the python-dbg or the pythonX.Y-dbg binaries instead of the + python or pythonX.Y binaries. + + * Properties of the debug build are described in + /usr/share/doc/@PVER@/SpecialBuilds.txt.gz. + The debug interpreter is built with Py_DEBUG defined. + + * From SpecialBuilds.txt: This is what is generally meant by "a debug + build" of Python. Py_DEBUG implies LLTRACE, Py_REF_DEBUG, + Py_TRACE_REFS, and PYMALLOC_DEBUG (if WITH_PYMALLOC is enabled). + In addition, C assert()s are enabled (via the C way: by not defining + NDEBUG), and some routines do additional sanity checks inside + "#ifdef Py_DEBUG" blocks. --- python3.2-3.2.3.orig/debian/PVER-doc.doc-base.PVER-ref.in +++ python3.2-3.2.3/debian/PVER-doc.doc-base.PVER-ref.in @@ -0,0 +1,18 @@ +Document: @PVER@-ref +Title: Python Reference Manual (v@VER@) +Author: Guido van Rossum +Abstract: This reference manual describes the syntax and "core semantics" of + the language. It is terse, but attempts to be exact and complete. + The semantics of non-essential built-in object types and of the + built-in functions and modules are described in the *Python + Library Reference*. For an informal introduction to the language, + see the *Python Tutorial*. For C or C++ programmers, two + additional manuals exist: *Extending and Embedding the Python + Interpreter* describes the high-level picture of how to write a + Python extension module, and the *Python/C API Reference Manual* + describes the interfaces available to C/C++ programmers in detail. +Section: Programming/Python + +Format: HTML +Index: /usr/share/doc/@PVER@/html/reference/index.html +Files: /usr/share/doc/@PVER@/html/reference/*.html --- python3.2-3.2.3.orig/debian/PVER.prerm.in +++ python3.2-3.2.3/debian/PVER.prerm.in @@ -0,0 +1,38 @@ +#! /bin/sh -e +# +# prerm script for the Debian @PVER@-base package. +# Written 1998 by Gregor Hoffleit . +# + +remove_bytecode() +{ + pkg=$1 + max=$(LANG=C LC_ALL=C xargs --show-limits < /dev/null 2>&1 | awk '/Maximum/ {print int($NF / 4)}') + dpkg -L $pkg \ + | awk -F/ 'BEGIN {OFS="/"} /\.py$/ {$NF=sprintf("__pycache__/%s.*.py[co]", substr($NF,1,length($NF)-3)); print}' \ + | xargs --max-chars="$max" echo \ + | while read files; do rm -f $files; done + find /usr/lib/python3 /usr/lib/@PVER@ -name dist-packages -prune -o -name __pycache__ -empty -print \ + | xargs -r rm -rf +} + +case "$1" in + remove|upgrade) + remove_bytecode @PVER@ + oldlocalsite=/usr/local/lib/@PVER@/site-packages + # issue #623057 + if [ -d $oldlocalsite -a ! -h $oldlocalsite ]; then + rmdir --ignore-fail-on-non-empty $oldlocalsite 2>/dev/null || true + fi + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python3.2-3.2.3.orig/debian/source.lintian-overrides +++ python3.2-3.2.3/debian/source.lintian-overrides @@ -0,0 +1,2 @@ +# generated during the build +python3.2 source: quilt-build-dep-but-no-series-file --- python3.2-3.2.3.orig/debian/idle-PVER.overrides.in +++ python3.2-3.2.3/debian/idle-PVER.overrides.in @@ -0,0 +1,2 @@ +# icon in dependent package +idle-@PVER@ binary: menu-icon-missing --- python3.2-3.2.3.orig/debian/idle-PVER.postrm.in +++ python3.2-3.2.3/debian/idle-PVER.postrm.in @@ -0,0 +1,9 @@ +#! /bin/sh -e + +if [ "$1" = "purge" ]; then + rm -rf /etc/idle-@PVER@ +fi + +#DEBHELPER# + +exit 0 --- python3.2-3.2.3.orig/debian/PVER-minimal.preinst.in +++ python3.2-3.2.3/debian/PVER-minimal.preinst.in @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e + +case "$1" in + install) + # remember newly installed runtime + mkdir -p /var/lib/python + touch /var/lib/python/@PVER@_installed + ;; + upgrade) + : + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 --- python3.2-3.2.3.orig/debian/PVER-minimal.postrm.in +++ python3.2-3.2.3/debian/PVER-minimal.postrm.in @@ -0,0 +1,29 @@ +#! /bin/sh -e + +if [ "$1" = "remove" ]; then + + (find /usr/lib/@PVER@ -name '*.py[co]' | xargs rm -f {}) 2>/dev/null || true + + for d in `find /usr/lib/@PVER@ -depth -type d -empty 2> /dev/null`; do \ + while rmdir $d 2> /dev/null; do d=`dirname $d`; done; \ + done + + if [ -f /var/lib/python/@PVER@_installed ]; then + rm -f /var/lib/python/@PVER@_installed + rmdir --ignore-fail-on-non-empty /var/lib/python 2>/dev/null + fi + + rmdir --parents /usr/local/lib/@PVER@ 2>/dev/null || true +fi + +if [ "$1" = "purge" ]; then + for d in `find /usr/lib/@PVER@ -depth -type d -empty 2> /dev/null`; do \ + while rmdir $d 2> /dev/null; do d=`dirname $d`; done; \ + done + rm -f /etc/@PVER@/site.py /etc/@PVER@/sitecustomize.py + rmdir --ignore-fail-on-non-empty /etc/@PVER@ 2>/dev/null +fi + +#DEBHELPER# + +exit 0 --- python3.2-3.2.3.orig/debian/control.in +++ python3.2-3.2.3/debian/control.in @@ -0,0 +1,110 @@ +Source: @PVER@ +Section: python +Priority: optional +Maintainer: Matthias Klose +Build-Depends: debhelper (>= 5.0.51~), quilt, autoconf, libreadline-dev, libncursesw5-dev (>= 5.3), zlib1g-dev, libdb5.1-dev, libgdbm-dev, tk8.5-dev, blt-dev (>= 2.4z), libssl-dev, sharutils, libbz2-dev, libexpat1-dev, libbluetooth-dev [linux-any], locales [!armel !avr32 !hppa !ia64 !mipsel], libsqlite3-dev, libffi-dev (>= 3.0.5), mime-support, libgpm2 [linux-any], netbase, lsb-release, bzip2, gdb, python, xvfb, xauth +Build-Depends-Indep: python-sphinx +Build-Conflicts: autoconf2.13 +Standards-Version: 3.9.3 +Vcs-Browser: https://code.launchpad.net/~doko/python/pkg@VER@-debian +Vcs-Bzr: http://bazaar.launchpad.net/~doko/python/pkg@VER@-debian + +Package: @PVER@ +Architecture: any +Priority: @PRIO@ +Depends: @PVER@-minimal (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends} +Suggests: @PVER@-doc, binutils +Provides: python@VER@-cjkcodecs, python@VER@-ctypes, python@VER@-elementtree, python@VER@-celementtree, python@VER@-wsgiref, @PVER@-gdbm, @PVER@-profiler +Conflicts: python3-profiler (<= 3.2-2) +Breaks: python-virtualenv (<< 1.7.1.2-2~) +Replaces: python3-profiler (<= 3.2-2) +Description: Interactive high-level object-oriented language (version @VER@) + Version @VER@ of the high-level, interactive object oriented language, + includes an extensive class library with lots of goodies for + network programming, system administration, sounds and graphics. + +Package: @PVER@-minimal +Architecture: any +Priority: @MINPRIO@ +Depends: ${shlibs:Depends}, ${misc:Depends} +Recommends: @PVER@ +Suggests: binfmt-support +Replaces: @PVER@ (<< 3.2~b2-1~) +Conflicts: binfmt-support (<< 1.1.2) +Description: Minimal subset of the Python language (version @VER@) + This package contains the interpreter and some essential modules. It can + be used in the boot process for some basic tasks. + See /usr/share/doc/@PVER@-minimal/README.Debian for a list of the modules + contained in this package. + +Package: lib@PVER@ +Architecture: any +Section: libs +Priority: @PRIO@ +Depends: @PVER@ (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Replaces: @PVER@ (<< 3.0~rc1) +Description: Shared Python runtime library (version @VER@) + Version @VER@ of the high-level, interactive object oriented language, + includes an extensive class library with lots of goodies for + network programming, system administration, sounds and graphics. + . + This package contains the shared runtime library, normally not needed + for programs using the statically linked interpreter. + +Package: @PVER@-examples +Architecture: all +Depends: @PVER@ (>= ${source:Version}), ${misc:Depends} +Description: Examples for the Python language (v@VER@) + Examples, Demos and Tools for Python (v@VER@). These are files included in + the upstream Python distribution (v@VER@). + +Package: @PVER@-dev +Architecture: any +Depends: @PVER@ (= ${binary:Version}), lib@PVER@ (= ${binary:Version}), libssl-dev, libexpat1-dev, ${shlibs:Depends}, ${misc:Depends} +Replaces: @PVER@ (<< 3.2.2-4) +Recommends: libc6-dev | libc-dev +Description: Header files and a static library for Python (v@VER@) + Header files, a static library and development tools for building + Python (v@VER@) modules, extending the Python interpreter or embedding + Python (v@VER@) in applications. + . + Maintainers of Python packages should read README.maintainers. + +Package: idle-@PVER@ +Architecture: all +Depends: @PVER@, python3-tk, @PVER@-tk, ${misc:Depends} +Enhances: @PVER@ +Description: IDE for Python (v@VER@) using Tkinter + IDLE is an Integrated Development Environment for Python (v@VER@). + IDLE is written using Tkinter and therefore quite platform-independent. + +Package: @PVER@-doc +Section: doc +Architecture: all +Depends: libjs-jquery, libjs-underscore, ${misc:Depends} +Suggests: @PVER@ +Description: Documentation for the high-level object-oriented language Python (v@VER@) + These is the official set of documentation for the interactive high-level + object-oriented language Python (v@VER@). All documents are provided + in HTML format. The package consists of ten documents: + . + * What's New in Python@VER@ + * Tutorial + * Python Library Reference + * Macintosh Module Reference + * Python Language Reference + * Extending and Embedding Python + * Python/C API Reference + * Installing Python Modules + * Documenting Python + * Distributing Python Modules + +Package: @PVER@-dbg +Section: debug +Architecture: any +Priority: extra +Depends: @PVER@ (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}, python +Suggests: python3-gdbm-dbg, python3-tk-dbg +Description: Debug Build of the Python Interpreter (version @VER@) + Python interpreter configured with --pydebug. Dynamically loaded modules are + searched in /usr/lib/@PVER@/lib-dynload/debug first. --- python3.2-3.2.3.orig/debian/PVER.menu.in +++ python3.2-3.2.3/debian/PVER.menu.in @@ -0,0 +1,4 @@ +?package(@PVER@):needs="text" section="Applications/Programming"\ + title="Python (v@VER@)"\ + icon="/usr/share/pixmaps/@PVER@.xpm"\ + command="/usr/bin/python@VER@" --- python3.2-3.2.3.orig/debian/sitecustomize.py.in +++ python3.2-3.2.3/debian/sitecustomize.py.in @@ -0,0 +1,7 @@ +# install the apport exception handler if available +try: + import apport_python_hook +except ImportError: + pass +else: + apport_python_hook.install() --- python3.2-3.2.3.orig/debian/source/format +++ python3.2-3.2.3/debian/source/format @@ -0,0 +1 @@ +1.0 --- python3.2-3.2.3.orig/debian/patches/langpack-gettext.diff +++ python3.2-3.2.3/debian/patches/langpack-gettext.diff @@ -0,0 +1,34 @@ +# DP: Description: support alternative gettext tree in +# DP: /usr/share/locale-langpack; if a file is present in both trees, +# DP: prefer the newer one +# DP: Upstream status: Ubuntu-Specific + +--- a/Lib/gettext.py ++++ b/Lib/gettext.py +@@ -394,11 +394,26 @@ + if lang == 'C': + break + mofile = os.path.join(localedir, lang, 'LC_MESSAGES', '%s.mo' % domain) ++ mofile_lp = os.path.join("/usr/share/locale-langpack", lang, ++ 'LC_MESSAGES', '%s.mo' % domain) ++ ++ # first look into the standard locale dir, then into the ++ # langpack locale dir ++ ++ # standard mo file + if os.path.exists(mofile): + if all: + result.append(mofile) + else: + return mofile ++ ++ # langpack mofile -> use it ++ if os.path.exists(mofile_lp): ++ if all: ++ result.append(mofile_lp) ++ else: ++ return mofile_lp ++ + return result + + --- python3.2-3.2.3.orig/debian/patches/linecache.diff +++ python3.2-3.2.3/debian/patches/linecache.diff @@ -0,0 +1,16 @@ +# DP: Proper handling of packages in linecache.py + +--- a/Lib/linecache.py ++++ b/Lib/linecache.py +@@ -109,6 +109,11 @@ + if os.path.isabs(filename): + return [] + ++ # Take care to handle packages. ++ if basename == '__init__.py': ++ # filename referes to a package ++ basename = filename ++ + for dirname in sys.path: + try: + fullname = os.path.join(dirname, basename) --- python3.2-3.2.3.orig/debian/patches/makesetup-bashism.diff +++ python3.2-3.2.3/debian/patches/makesetup-bashism.diff @@ -0,0 +1,13 @@ +# DP: Fix bashism in makesetup shell script + +--- a/Modules/makesetup ++++ b/Modules/makesetup +@@ -281,7 +281,7 @@ + -) ;; + *) sedf="@sed.in.$$" + trap 'rm -f $sedf' 0 1 2 3 +- echo "1i\\" >$sedf ++ printf "1i\\" >$sedf + str="# Generated automatically from $makepre by makesetup." + echo "$str" >>$sedf + echo "s%_MODOBJS_%$OBJS%" >>$sedf --- python3.2-3.2.3.orig/debian/patches/link-system-expat.diff +++ python3.2-3.2.3/debian/patches/link-system-expat.diff @@ -0,0 +1,22 @@ +# DP: Link with the system expat + +--- a/Modules/Setup.dist ++++ b/Modules/Setup.dist +@@ -168,7 +168,7 @@ + #_testcapi _testcapimodule.c # Python C API test module + #_random _randommodule.c # Random number generator + #atexit atexitmodule.c # Register functions to be run at interpreter-shutdown +-#_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H _elementtree.c # elementtree accelerator ++#_elementtree -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator + #_pickle _pickle.c # pickle accelerator + #_datetime _datetimemodule.c # datetime accelerator + #_bisect _bisectmodule.c # Bisection algorithms +@@ -364,7 +364,7 @@ + # + # More information on Expat can be found at www.libexpat.org. + # +-#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H ++#pyexpat pyexpat.c -lexpat + + # Hye-Shik Chang's CJKCodecs + --- python3.2-3.2.3.orig/debian/patches/revert-r83234.diff +++ python3.2-3.2.3/debian/patches/revert-r83234.diff @@ -0,0 +1,227 @@ +--- a/Doc/conf.py ++++ b/Doc/conf.py +@@ -13,7 +13,7 @@ + # --------------------- + + extensions = ['sphinx.ext.refcounting', 'sphinx.ext.coverage', +- 'sphinx.ext.doctest', 'pyspecific'] ++ 'sphinx.ext.doctest'] + templates_path = ['tools/sphinxext'] + + # General substitutions. +--- a/Doc/tools/sphinxext/pyspecific.py ++++ b/Doc/tools/sphinxext/pyspecific.py +@@ -84,32 +84,6 @@ + return [pnode] + + +-# Support for documenting decorators +- +-from sphinx import addnodes +-from sphinx.domains.python import PyModulelevel, PyClassmember +- +-class PyDecoratorMixin(object): +- def handle_signature(self, sig, signode): +- ret = super(PyDecoratorMixin, self).handle_signature(sig, signode) +- signode.insert(0, addnodes.desc_addname('@', '@')) +- return ret +- +- def needs_arglist(self): +- return False +- +-class PyDecoratorFunction(PyDecoratorMixin, PyModulelevel): +- def run(self): +- # a decorator function is a function after all +- self.name = 'py:function' +- return PyModulelevel.run(self) +- +-class PyDecoratorMethod(PyDecoratorMixin, PyClassmember): +- def run(self): +- self.name = 'py:method' +- return PyClassmember.run(self) +- +- + # Support for documenting version of removal in deprecations + + from sphinx.locale import versionlabels +@@ -227,6 +201,7 @@ + # Support for documenting Opcodes + + import re ++from sphinx import addnodes + + opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?') + +@@ -280,5 +255,3 @@ + app.add_description_unit('pdbcommand', 'pdbcmd', '%s (pdb command)', + parse_pdb_command) + app.add_description_unit('2to3fixer', '2to3fixer', '%s (2to3 fixer)') +- app.add_directive_to_domain('py', 'decorator', PyDecoratorFunction) +- app.add_directive_to_domain('py', 'decoratormethod', PyDecoratorMethod) +--- a/Doc/library/contextlib.rst ++++ b/Doc/library/contextlib.rst +@@ -15,7 +15,7 @@ + Functions provided: + + +-.. decorator:: contextmanager ++.. function:: contextmanager(func) + + This function is a :term:`decorator` that can be used to define a factory + function for :keyword:`with` statement context managers, without needing to +--- a/Doc/library/abc.rst ++++ b/Doc/library/abc.rst +@@ -126,7 +126,7 @@ + + It also provides the following decorators: + +-.. decorator:: abstractmethod(function) ++.. function:: abstractmethod(function) + + A decorator indicating abstract methods. + +--- a/Doc/library/unittest.rst ++++ b/Doc/library/unittest.rst +@@ -666,20 +666,20 @@ + + The following decorators implement test skipping and expected failures: + +-.. decorator:: skip(reason) ++.. function:: skip(reason) + + Unconditionally skip the decorated test. *reason* should describe why the + test is being skipped. + +-.. decorator:: skipIf(condition, reason) ++.. function:: skipIf(condition, reason) + + Skip the decorated test if *condition* is true. + +-.. decorator:: skipUnless(condition, reason) ++.. function:: skipUnless(condition, reason) + + Skip the decorated test unless *condition* is true. + +-.. decorator:: expectedFailure ++.. function:: expectedFailure + + Mark the test as an expected failure. If the test fails when run, the test + is not counted as a failure. +@@ -973,11 +973,11 @@ + :attr:`exception` attribute. This can be useful if the intention + is to perform additional checks on the exception raised:: + +- with self.assertRaises(SomeException) as cm: +- do_something() ++ with self.assertRaises(SomeException) as cm: ++ do_something() + +- the_exception = cm.exception +- self.assertEqual(the_exception.error_code, 3) ++ the_exception = cm.exception ++ self.assertEqual(the_exception.error_code, 3) + + .. versionchanged:: 3.1 + Added the ability to use :meth:`assertRaises` as a context manager. +--- a/Doc/library/importlib.rst ++++ b/Doc/library/importlib.rst +@@ -469,7 +469,7 @@ + This module contains the various objects that help in the construction of + an :term:`importer`. + +-.. decorator:: module_for_loader ++.. function:: module_for_loader(method) + + A :term:`decorator` for a :term:`loader` method, + to handle selecting the proper +@@ -494,7 +494,7 @@ + Use of this decorator handles all the details of which module object a + loader should initialize as specified by :pep:`302`. + +-.. decorator:: set_loader ++.. function:: set_loader(fxn) + + A :term:`decorator` for a :term:`loader` method, + to set the :attr:`__loader__` +@@ -502,7 +502,7 @@ + does nothing. It is assumed that the first positional argument to the + wrapped method is what :attr:`__loader__` should be set to. + +-.. decorator:: set_package ++.. function:: set_package(fxn) + + A :term:`decorator` for a :term:`loader` to set the :attr:`__package__` + attribute on the module returned by the loader. If :attr:`__package__` is +--- a/Doc/library/functools.rst ++++ b/Doc/library/functools.rst +@@ -111,7 +111,7 @@ + + .. versionadded:: 3.2 + +-.. decorator:: total_ordering ++.. function:: total_ordering(cls) + + Given a class defining one or more rich comparison ordering methods, this + class decorator supplies the rest. This simplifies the effort involved +@@ -217,7 +217,7 @@ + Missing attributes no longer trigger an :exc:`AttributeError`. + + +-.. decorator:: wraps(wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES) ++.. function:: wraps(wrapped, assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES) + + This is a convenience function for invoking ``partial(update_wrapper, + wrapped=wrapped, assigned=assigned, updated=updated)`` as a function decorator +--- a/Doc/documenting/markup.rst ++++ b/Doc/documenting/markup.rst +@@ -177,37 +177,6 @@ + are modified), side effects, and possible exceptions. A small example may be + provided. + +-.. describe:: decorator +- +- Describes a decorator function. The signature should *not* represent the +- signature of the actual function, but the usage as a decorator. For example, +- given the functions +- +- .. code-block:: python +- +- def removename(func): +- func.__name__ = '' +- return func +- +- def setnewname(name): +- def decorator(func): +- func.__name__ = name +- return func +- return decorator +- +- the descriptions should look like this:: +- +- .. decorator:: removename +- +- Remove name of the decorated function. +- +- .. decorator:: setnewname(name) +- +- Set name of the decorated function to *name*. +- +- There is no ``deco`` role to link to a decorator that is marked up with +- this directive; rather, use the ``:func:`` role. +- + .. describe:: class + + Describes a class. The signature can include parentheses with parameters +@@ -225,12 +194,6 @@ + parameter. The description should include similar information to that + described for ``function``. + +-.. describe:: decoratormethod +- +- Same as ``decorator``, but for decorators that are methods. +- +- Refer to a decorator method using the ``:meth:`` role. +- + .. describe:: opcode + + Describes a Python :term:`bytecode` instruction. --- python3.2-3.2.3.orig/debian/patches/plat-linux2_sparc.diff +++ python3.2-3.2.3/debian/patches/plat-linux2_sparc.diff @@ -0,0 +1,72 @@ +Index: Lib/plat-linux2/IN.py +=================================================================== +--- ./Lib/plat-linux2/IN.py (Revision 77754) ++++ ./Lib/plat-linux2/IN.py (Arbeitskopie) +@@ -442,37 +442,37 @@ + SIOCGPGRP = 0x8904 + SIOCATMARK = 0x8905 + SIOCGSTAMP = 0x8906 +-SOL_SOCKET = 1 +-SO_DEBUG = 1 +-SO_REUSEADDR = 2 +-SO_TYPE = 3 +-SO_ERROR = 4 +-SO_DONTROUTE = 5 +-SO_BROADCAST = 6 +-SO_SNDBUF = 7 +-SO_RCVBUF = 8 +-SO_KEEPALIVE = 9 +-SO_OOBINLINE = 10 +-SO_NO_CHECK = 11 +-SO_PRIORITY = 12 +-SO_LINGER = 13 +-SO_BSDCOMPAT = 14 +-SO_PASSCRED = 16 +-SO_PEERCRED = 17 +-SO_RCVLOWAT = 18 +-SO_SNDLOWAT = 19 +-SO_RCVTIMEO = 20 +-SO_SNDTIMEO = 21 +-SO_SECURITY_AUTHENTICATION = 22 +-SO_SECURITY_ENCRYPTION_TRANSPORT = 23 +-SO_SECURITY_ENCRYPTION_NETWORK = 24 +-SO_BINDTODEVICE = 25 +-SO_ATTACH_FILTER = 26 +-SO_DETACH_FILTER = 27 +-SO_PEERNAME = 28 +-SO_TIMESTAMP = 29 ++SOL_SOCKET = 0xffff ++SO_DEBUG = 0x0001 ++SO_REUSEADDR = 0x0004 ++SO_TYPE = 0x1008 ++SO_ERROR = 0x1007 ++SO_DONTROUTE = 0x0010 ++SO_BROADCAST = 0x0020 ++SO_SNDBUF = 0x1001 ++SO_RCVBUF = 0x1002 ++SO_KEEPALIVE = 0x0008 ++SO_OOBINLINE = 0x0100 ++SO_NO_CHECK = 0x000b ++SO_PRIORITY = 0x000c ++SO_LINGER = 0x0080 ++SO_BSDCOMPAT = 0x0400 ++SO_PASSCRED = 0x0002 ++SO_PEERCRED = 0x0040 ++SO_RCVLOWAT = 0x0800 ++SO_SNDLOWAT = 0x1000 ++SO_RCVTIMEO = 0x2000 ++SO_SNDTIMEO = 0x4000 ++SO_SECURITY_AUTHENTICATION = 0x5001 ++SO_SECURITY_ENCRYPTION_TRANSPORT = 0x5002 ++SO_SECURITY_ENCRYPTION_NETWORK = 0x5004 ++SO_BINDTODEVICE = 0x000d ++SO_ATTACH_FILTER = 0x001a ++SO_DETACH_FILTER = 0x001b ++SO_PEERNAME = 0x001c ++SO_TIMESTAMP = 0x001d + SCM_TIMESTAMP = SO_TIMESTAMP +-SO_ACCEPTCONN = 30 ++SO_ACCEPTCONN = 0x8000 + SOCK_STREAM = 1 + SOCK_DGRAM = 2 + SOCK_RAW = 3 --- python3.2-3.2.3.orig/debian/patches/apport-support.dpatch +++ python3.2-3.2.3/debian/patches/apport-support.dpatch @@ -0,0 +1,40 @@ +#! /bin/sh -e + +dir= +if [ $# -eq 3 -a "$2" = '-d' ]; then + pdir="-d $3" + dir="$3/" +elif [ $# -ne 1 ]; then + echo >&2 "usage: `basename $0`: -patch|-unpatch [-d ]" + exit 1 +fi +case "$1" in + -patch) + patch $pdir -f --no-backup-if-mismatch -p0 < $0 + ;; + -unpatch) + patch $pdir -f --no-backup-if-mismatch -R -p0 < $0 + ;; + *) + echo >&2 "usage: `basename $0`: -patch|-unpatch [-d ]" + exit 1 +esac +exit 0 + +--- Lib/site.py 2004-07-20 12:28:28.000000000 +1000 ++++ Lib/site.py 2006-11-09 09:28:32.000000000 +1100 +@@ -393,6 +393,14 @@ + # this module is run as a script, because this code is executed twice. + if hasattr(sys, "setdefaultencoding"): + del sys.setdefaultencoding ++ # install the apport exception handler if available ++ try: ++ import apport_python_hook ++ except ImportError: ++ pass ++ else: ++ apport_python_hook.install() ++ + + main() + --- python3.2-3.2.3.orig/debian/patches/ctypes-arm.diff +++ python3.2-3.2.3/debian/patches/ctypes-arm.diff @@ -0,0 +1,32 @@ +--- a/Lib/ctypes/util.py ++++ b/Lib/ctypes/util.py +@@ -206,16 +206,27 @@ + + def _findSoname_ldconfig(name): + import struct ++ # XXX this code assumes that we know all unames and that a single ++ # ABI is supported per uname; instead we should find what the ++ # ABI is (e.g. check ABI of current process) or simply ask libc ++ # to load the library for us ++ uname = os.uname()[4] ++ # ARM has a variety of unames, e.g. armv7l ++ if uname.startswith("arm"): ++ uname = "arm" + if struct.calcsize('l') == 4: +- machine = os.uname()[4] + '-32' ++ machine = uname + '-32' + else: +- machine = os.uname()[4] + '-64' ++ machine = uname + '-64' + mach_map = { + 'x86_64-64': 'libc6,x86-64', + 'ppc64-64': 'libc6,64bit', + 'sparc64-64': 'libc6,64bit', + 's390x-64': 'libc6,64bit', + 'ia64-64': 'libc6,IA-64', ++ # this actually breaks on biarch or multiarch as the first ++ # library wins; uname doesn't tell us which ABI we're using ++ 'arm-32': 'libc6(,hard-float)?', + } + abi_type = mach_map.get(machine, 'libc6') + --- python3.2-3.2.3.orig/debian/patches/test-sundry.diff +++ python3.2-3.2.3/debian/patches/test-sundry.diff @@ -0,0 +1,17 @@ +# DP: test_sundry: Don't fail on import of the profile and pstats module + +--- a/Lib/test/test_sundry.py ++++ b/Lib/test/test_sundry.py +@@ -50,7 +50,11 @@ + import mailcap + import nturl2path + import os2emxpath +- import pstats ++ try: ++ import pstats # separated out into the python-profiler package ++ except ImportError: ++ if test_support.verbose: ++ print("skipping profile and pstats") + import py_compile + import sndhdr + import tabnanny --- python3.2-3.2.3.orig/debian/patches/issue9012a.diff +++ python3.2-3.2.3/debian/patches/issue9012a.diff @@ -0,0 +1,11 @@ +--- a/Modules/Setup.dist ++++ b/Modules/Setup.dist +@@ -163,7 +163,7 @@ + #cmath cmathmodule.c _math.c # -lm # complex math library functions + #math mathmodule.c _math.c # -lm # math library functions, e.g. sin() + #_struct _struct.c # binary structure packing/unpacking +-#time timemodule.c # -lm # time operations and variables ++#time timemodule.c _time.c # -lm # time operations and variables + #_weakref _weakref.c # basic weak reference support + #_testcapi _testcapimodule.c # Python C API test module + #_random _randommodule.c # Random number generator --- python3.2-3.2.3.orig/debian/patches/sqlite-rpath.diff +++ python3.2-3.2.3/debian/patches/sqlite-rpath.diff @@ -0,0 +1,10 @@ +--- a/setup.py ++++ b/setup.py +@@ -1106,7 +1106,6 @@ + include_dirs=["Modules/_sqlite", + sqlite_incdir], + library_dirs=sqlite_libdir, +- runtime_library_dirs=sqlite_libdir, + extra_link_args=sqlite_extra_link_args, + libraries=["sqlite3",])) + else: --- python3.2-3.2.3.orig/debian/patches/link-opt.diff +++ python3.2-3.2.3/debian/patches/link-opt.diff @@ -0,0 +1,24 @@ +# DP: Call the linker with -O1 -Bsymbolic-functions + +--- a/configure.ac ++++ b/configure.ac +@@ -1733,8 +1733,8 @@ + fi + ;; + Linux*|GNU*|QNX*) +- LDSHARED='$(CC) -shared' +- LDCXXSHARED='$(CXX) -shared';; ++ LDSHARED='$(CC) -shared -Wl,-O1 -Wl,-Bsymbolic-functions' ++ LDCXXSHARED='$(CXX) -shared -Wl,-O1 -Wl,-Bsymbolic-functions';; + BSD/OS*/4*) + LDSHARED="gcc -shared" + LDCXXSHARED="g++ -shared";; +@@ -1832,7 +1832,7 @@ + LINKFORSHARED="-Wl,-E -Wl,+s";; + # LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";; + BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";; +- Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; ++ Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions";; + # -u libsys_s pulls in all symbols in libsys + Darwin/*) + LINKFORSHARED="$extra_undefs -framework CoreFoundation" --- python3.2-3.2.3.orig/debian/patches/plat-linux2_hppa.diff +++ python3.2-3.2.3/debian/patches/plat-linux2_hppa.diff @@ -0,0 +1,72 @@ +Index: Lib/plat-linux2/IN.py +=================================================================== +--- ./Lib/plat-linux2/IN.py (Revision 77754) ++++ ./Lib/plat-linux2/IN.py (Arbeitskopie) +@@ -442,37 +442,37 @@ + SIOCGPGRP = 0x8904 + SIOCATMARK = 0x8905 + SIOCGSTAMP = 0x8906 +-SOL_SOCKET = 1 +-SO_DEBUG = 1 +-SO_REUSEADDR = 2 +-SO_TYPE = 3 +-SO_ERROR = 4 +-SO_DONTROUTE = 5 +-SO_BROADCAST = 6 +-SO_SNDBUF = 7 +-SO_RCVBUF = 8 +-SO_KEEPALIVE = 9 +-SO_OOBINLINE = 10 +-SO_NO_CHECK = 11 +-SO_PRIORITY = 12 +-SO_LINGER = 13 +-SO_BSDCOMPAT = 14 +-SO_PASSCRED = 16 +-SO_PEERCRED = 17 +-SO_RCVLOWAT = 18 +-SO_SNDLOWAT = 19 +-SO_RCVTIMEO = 20 +-SO_SNDTIMEO = 21 +-SO_SECURITY_AUTHENTICATION = 22 +-SO_SECURITY_ENCRYPTION_TRANSPORT = 23 +-SO_SECURITY_ENCRYPTION_NETWORK = 24 +-SO_BINDTODEVICE = 25 +-SO_ATTACH_FILTER = 26 +-SO_DETACH_FILTER = 27 +-SO_PEERNAME = 28 +-SO_TIMESTAMP = 29 ++SOL_SOCKET = 0xffff ++SO_DEBUG = 0x0001 ++SO_REUSEADDR = 0x0004 ++SO_TYPE = 0x1008 ++SO_ERROR = 0x1007 ++SO_DONTROUTE = 0x0010 ++SO_BROADCAST = 0x0020 ++SO_SNDBUF = 0x1001 ++SO_RCVBUF = 0x1002 ++SO_KEEPALIVE = 0x0008 ++SO_OOBINLINE = 0x0100 ++SO_NO_CHECK = 0x400b ++SO_PRIORITY = 0x400c ++SO_LINGER = 0x0080 ++SO_BSDCOMPAT = 0x400e ++SO_PASSCRED = 0x4010 ++SO_PEERCRED = 0x4011 ++SO_RCVLOWAT = 0x1004 ++SO_SNDLOWAT = 0x1003 ++SO_RCVTIMEO = 0x1006 ++SO_SNDTIMEO = 0x1005 ++SO_SECURITY_AUTHENTICATION = 0x4016 ++SO_SECURITY_ENCRYPTION_TRANSPORT = 0x4017 ++SO_SECURITY_ENCRYPTION_NETWORK = 0x4018 ++SO_BINDTODEVICE = 0x4019 ++SO_ATTACH_FILTER = 0x401a ++SO_DETACH_FILTER = 0x401b ++SO_PEERNAME = 0x2000 ++SO_TIMESTAMP = 0x4012 + SCM_TIMESTAMP = SO_TIMESTAMP +-SO_ACCEPTCONN = 30 ++SO_ACCEPTCONN = 0x401c + SOCK_STREAM = 1 + SOCK_DGRAM = 2 + SOCK_RAW = 3 --- python3.2-3.2.3.orig/debian/patches/do-not-italicize-punctuation.patch +++ python3.2-3.2.3/debian/patches/do-not-italicize-punctuation.patch @@ -0,0 +1,50 @@ +diff -ru python2.5-2.5.2/Misc/python.man python2.5/Misc/python.man +--- python2.5-2.5.2/Misc/python.man 2010-04-26 09:17:43.000000000 -0700 ++++ python2.5/Misc/python.man 2010-04-26 09:16:39.000000000 -0700 +@@ -243,9 +243,9 @@ + from that file; + when called with + .B \-c +-.I command, ++.IR command , + it executes the Python statement(s) given as +-.I command. ++.IR command . + Here + .I command + may contain multiple statements separated by newlines. +@@ -255,7 +255,7 @@ + .PP + If available, the script name and additional arguments thereafter are + passed to the script in the Python variable +-.I sys.argv , ++.IR sys.argv , + which is a list of strings (you must first + .I import sys + to be able to access it). +@@ -269,14 +269,14 @@ + .I '-c'. + Note that options interpreted by the Python interpreter itself + are not placed in +-.I sys.argv. ++.IR sys.argv . + .PP + In interactive mode, the primary prompt is `>>>'; the second prompt + (which appears when a command is not complete) is `...'. + The prompts can be changed by assignment to + .I sys.ps1 + or +-.I sys.ps2. ++.IR sys.ps2 . + The interpreter quits when it reads an EOF at a prompt. + When an unhandled exception occurs, a stack trace is printed and + control returns to the primary prompt; in non-interactive mode, the +@@ -335,7 +335,7 @@ + inserted in the path in front of $PYTHONPATH. + The search path can be manipulated from within a Python program as the + variable +-.I sys.path . ++.IR sys.path . + .IP PYTHONSTARTUP + If this is the name of a readable file, the Python commands in that + file are executed before the first prompt is displayed in interactive --- python3.2-3.2.3.orig/debian/patches/bsddb-version.diff +++ python3.2-3.2.3/debian/patches/bsddb-version.diff @@ -0,0 +1,13 @@ +# DP: Disable the bsddb version check + +--- a/setup.py ++++ b/setup.py +@@ -770,7 +770,7 @@ + # a release. Most open source OSes come with one or more + # versions of BerkeleyDB already installed. + +- max_db_ver = (5, 1) ++ max_db_ver = (9, 9) + min_db_ver = (3, 3) + db_setup_debug = False # verbose debug prints from this script? + --- python3.2-3.2.3.orig/debian/patches/setup-modules.diff +++ python3.2-3.2.3/debian/patches/setup-modules.diff @@ -0,0 +1,64 @@ +# DP: Modules/Setup.dist: patches to build some extensions statically + +--- a/Modules/Setup.dist ++++ b/Modules/Setup.dist +@@ -168,7 +168,7 @@ + #_testcapi _testcapimodule.c # Python C API test module + #_random _randommodule.c # Random number generator + #atexit atexitmodule.c # Register functions to be run at interpreter-shutdown +-#_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator ++#_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H _elementtree.c # elementtree accelerator + #_pickle _pickle.c # pickle accelerator + #_datetime _datetimemodule.c # datetime accelerator + #_bisect _bisectmodule.c # Bisection algorithms +@@ -197,10 +197,7 @@ + + # Socket module helper for SSL support; you must comment out the other + # socket line above, and possibly edit the SSL variable: +-#SSL=/usr/local/ssl +-#_ssl _ssl.c \ +-# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ +-# -L$(SSL)/lib -lssl -lcrypto ++#_ssl _ssl.c -lssl -lcrypto + + # The crypt module is now disabled by default because it breaks builds + # on many systems (where -lcrypt is needed), e.g. Linux (I believe). +@@ -243,6 +240,7 @@ + #_sha256 sha256module.c + #_sha512 sha512module.c + ++#_hashlib _hashopenssl.c -lssl -lcrypto + + # The _tkinter module. + # +@@ -331,6 +329,7 @@ + # Fred Drake's interface to the Python parser + #parser parsermodule.c + ++#_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/stgdict.c _ctypes/cfield.c _ctypes/malloc_closure.c -lffi + + # Lee Busby's SIGFPE modules. + # The library to link fpectl with is platform specific. +@@ -365,7 +364,7 @@ + # + # More information on Expat can be found at www.libexpat.org. + # +-#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI ++#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H + + # Hye-Shik Chang's CJKCodecs + +--- a/Modules/_elementtree.c ++++ b/Modules/_elementtree.c +@@ -2040,7 +2040,10 @@ + static struct PyExpat_CAPI* expat_capi; + #define EXPAT(func) (expat_capi->func) + #else +-#define EXPAT(func) (XML_##func) ++#define EXPAT(func) (PyExpat_XML_##func) ++#define PyExpat_XML_GetErrorLineNumber PyExpat_XML_GetCurrentLineNumber ++#define PyExpat_XML_GetErrorColumnNumber PyExpat_XML_GetCurrentColumnNumber ++#define PyExpat_XML_GetErrorByteIndex PyExpat_XML_GetCurrentByteIndex + #endif + + typedef struct { --- python3.2-3.2.3.orig/debian/patches/cthreads.diff +++ python3.2-3.2.3/debian/patches/cthreads.diff @@ -0,0 +1,39 @@ +# DP: Remove cthreads detection + +--- a/configure.ac ++++ b/configure.ac +@@ -2046,7 +2046,6 @@ + + # Templates for things AC_DEFINEd more than once. + # For a single AC_DEFINE, no template is needed. +-AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package]) + AH_TEMPLATE(_REENTRANT, + [Define to force use of thread-safe errno, h_errno, and other functions]) + AH_TEMPLATE(WITH_THREAD, +@@ -2128,17 +2127,6 @@ + AC_MSG_RESULT($unistd_defines_pthreads) + + AC_DEFINE(_REENTRANT) +- AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD) +- AC_DEFINE(C_THREADS) +- AC_DEFINE(HURD_C_THREADS, 1, +- [Define if you are using Mach cthreads directly under /include]) +- LIBS="$LIBS -lthreads" +- THREADOBJ="Python/thread.o"],[ +- AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD) +- AC_DEFINE(C_THREADS) +- AC_DEFINE(MACH_C_THREADS, 1, +- [Define if you are using Mach cthreads under mach /]) +- THREADOBJ="Python/thread.o"],[ + # Just looking for pthread_create in libpthread is not enough: + # on HP/UX, pthread.h renames pthread_create to a different symbol name. + # So we really have to include pthread.h, and then link. +@@ -2174,7 +2162,7 @@ + LIBS="$LIBS -lcma" + THREADOBJ="Python/thread.o"],[ + USE_THREAD_MODULE="#"]) +- ])])])])])])]) ++ ])])])])]) + + AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) + LIBS="$LIBS -lmpc" --- python3.2-3.2.3.orig/debian/patches/platform-lsbrelease.diff +++ python3.2-3.2.3/debian/patches/platform-lsbrelease.diff @@ -0,0 +1,41 @@ +# DP: Use /etc/lsb-release to identify the platform. + +--- a/Lib/platform.py ++++ b/Lib/platform.py +@@ -284,6 +284,10 @@ + id = l[1] + return '', version, id + ++_distributor_id_file_re = re.compile("(?:DISTRIB_ID\s*=)\s*(.*)", re.I) ++_release_file_re = re.compile("(?:DISTRIB_RELEASE\s*=)\s*(.*)", re.I) ++_codename_file_re = re.compile("(?:DISTRIB_CODENAME\s*=)\s*(.*)", re.I) ++ + def linux_distribution(distname='', version='', id='', + + supported_dists=_supported_dists, +@@ -308,6 +312,25 @@ + args given as parameters. + + """ ++ # check for the Debian/Ubuntu /etc/lsb-release file first, needed so ++ # that the distribution doesn't get identified as Debian. ++ try: ++ etclsbrel = open("/etc/lsb-release", "rU") ++ for line in etclsbrel: ++ m = _distributor_id_file_re.search(line) ++ if m: ++ _u_distname = m.group(1).strip() ++ m = _release_file_re.search(line) ++ if m: ++ _u_version = m.group(1).strip() ++ m = _codename_file_re.search(line) ++ if m: ++ _u_id = m.group(1).strip() ++ if _u_distname and _u_version: ++ return (_u_distname, _u_version, _u_id) ++ except (EnvironmentError, UnboundLocalError): ++ pass ++ + try: + etc = os.listdir('/etc') + except os.error: --- python3.2-3.2.3.orig/debian/patches/statvfs-f_flag-constants.diff +++ python3.2-3.2.3/debian/patches/statvfs-f_flag-constants.diff @@ -0,0 +1,55 @@ +# DP: Modules/posixmodule.c: Add flags for statvfs.f_flag to constant list. + +From: Peter Jones +Date: Wed, 6 Jan 2010 15:22:38 -0500 +Subject: [PATCH] Add flags for statvfs.f_flag to constant list. + + Modules/posixmodule.c | 37 +++++++++++++++++++++++++++++++++++++ + 1 files changed, 37 insertions(+), 0 deletions(-) + +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -8364,6 +8364,43 @@ + if (ins(d, "ST_NOSUID", (long)ST_NOSUID)) return -1; + #endif /* ST_NOSUID */ + ++ /* These came from statvfs.h */ ++#ifdef ST_RDONLY ++ if (ins(d, "ST_RDONLY", (long)ST_RDONLY)) return -1; ++#endif /* ST_RDONLY */ ++#ifdef ST_NOSUID ++ if (ins(d, "ST_NOSUID", (long)ST_NOSUID)) return -1; ++#endif /* ST_NOSUID */ ++ ++ /* GNU extensions */ ++#ifdef ST_NODEV ++ if (ins(d, "ST_NODEV", (long)ST_NODEV)) return -1; ++#endif /* ST_NODEV */ ++#ifdef ST_NOEXEC ++ if (ins(d, "ST_NOEXEC", (long)ST_NOEXEC)) return -1; ++#endif /* ST_NOEXEC */ ++#ifdef ST_SYNCHRONOUS ++ if (ins(d, "ST_SYNCHRONOUS", (long)ST_SYNCHRONOUS)) return -1; ++#endif /* ST_SYNCHRONOUS */ ++#ifdef ST_MANDLOCK ++ if (ins(d, "ST_MANDLOCK", (long)ST_MANDLOCK)) return -1; ++#endif /* ST_MANDLOCK */ ++#ifdef ST_WRITE ++ if (ins(d, "ST_WRITE", (long)ST_WRITE)) return -1; ++#endif /* ST_WRITE */ ++#ifdef ST_APPEND ++ if (ins(d, "ST_APPEND", (long)ST_APPEND)) return -1; ++#endif /* ST_APPEND */ ++#ifdef ST_NOATIME ++ if (ins(d, "ST_NOATIME", (long)ST_NOATIME)) return -1; ++#endif /* ST_NOATIME */ ++#ifdef ST_NODIRATIME ++ if (ins(d, "ST_NODIRATIME", (long)ST_NODIRATIME)) return -1; ++#endif /* ST_NODIRATIME */ ++#ifdef ST_RELATIME ++ if (ins(d, "ST_RELATIME", (long)ST_RELATIME)) return -1; ++#endif /* ST_RELATIME */ ++ + #ifdef HAVE_SPAWNV + #if defined(PYOS_OS2) && defined(PYCC_GCC) + if (ins(d, "P_WAIT", (long)P_WAIT)) return -1; --- python3.2-3.2.3.orig/debian/patches/bsddb-libpath.diff +++ python3.2-3.2.3/debian/patches/bsddb-libpath.diff @@ -0,0 +1,19 @@ +# DP: Don't add the bsddb multilib path, if already in the standard lib path + +--- a/setup.py ++++ b/setup.py +@@ -943,7 +943,13 @@ + if db_setup_debug: + print("bsddb using BerkeleyDB lib:", db_ver, dblib) + print("bsddb lib dir:", dblib_dir, " inc dir:", db_incdir) +- db_incs = [db_incdir] ++ # only add db_incdir/dblib_dir if not in the standard paths ++ if db_incdir in inc_dirs: ++ db_incs = [] ++ else: ++ db_incs = [db_incdir] ++ if dblib_dir[0] in lib_dirs: ++ dblib_dir = [] + dblibs = [dblib] + else: + if db_setup_debug: print("db: no appropriate library found") --- python3.2-3.2.3.orig/debian/patches/enable-fpectl.diff +++ python3.2-3.2.3/debian/patches/enable-fpectl.diff @@ -0,0 +1,14 @@ +# DP: Enable the build of the fpectl module. + +--- a/setup.py ++++ b/setup.py +@@ -1190,6 +1190,9 @@ + else: + missing.append('_curses_panel') + ++ #fpectl fpectlmodule.c ... ++ exts.append( Extension('fpectl', ['fpectlmodule.c']) ) ++ + # Andrew Kuchling's zlib module. Note that some versions of zlib + # 1.1.3 have security problems. See CERT Advisory CA-2002-07: + # http://www.cert.org/advisories/CA-2002-07.html --- python3.2-3.2.3.orig/debian/patches/multiarch.diff +++ python3.2-3.2.3/debian/patches/multiarch.diff @@ -0,0 +1,55 @@ +# DP: Lookup extension modules with a multiarch suffix. + +Index: b/configure.ac +=================================================================== +--- a/configure.ac ++++ b/configure.ac +@@ -518,6 +518,8 @@ + ]) + fi + ++MULTIARCH=$($CC --print-multiarch 2>/dev/null) ++AC_SUBST(MULTIARCH) + + AC_MSG_CHECKING([for -Wl,--no-as-needed]) + save_LDFLAGS="$LDFLAGS" +Index: b/Makefile.pre.in +=================================================================== +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -91,6 +91,9 @@ + # Machine-dependent subdirectories + MACHDEP= @MACHDEP@ + ++# Multiarch directory (may be empty) ++MULTIARCH= @MULTIARCH@ ++ + # Install prefix for architecture-independent files + prefix= @prefix@ + +@@ -575,6 +578,7 @@ + + Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c Makefile + $(CC) -c $(PY_CORE_CFLAGS) \ ++ $(if $(MULTIARCH),-DMULTIARCH='"$(MULTIARCH)"') \ + -DSOABI='"$(SOABI)"' \ + -o $@ $(srcdir)/Python/dynload_shlib.c + +Index: b/Python/dynload_shlib.c +=================================================================== +--- a/Python/dynload_shlib.c ++++ b/Python/dynload_shlib.c +@@ -51,7 +51,13 @@ + {"module.exe", "rb", C_EXTENSION}, + {"MODULE.EXE", "rb", C_EXTENSION}, + #else /* !__VMS */ ++#ifdef MULTIARCH ++ {"." SOABI "-" MULTIARCH ".so", "rb", C_EXTENSION}, ++#endif + {"." SOABI ".so", "rb", C_EXTENSION}, ++#ifdef MULTIARCH ++ {"module." SOABI "-" MULTIARCH ".so", "rb", C_EXTENSION}, ++#endif + {"module." SOABI ".so", "rb", C_EXTENSION}, + {".abi" PYTHON_ABI_STRING ".so", "rb", C_EXTENSION}, + {"module.abi" PYTHON_ABI_STRING ".so", "rb", C_EXTENSION}, --- python3.2-3.2.3.orig/debian/patches/doc-nodownload.diff +++ python3.2-3.2.3/debian/patches/doc-nodownload.diff @@ -0,0 +1,13 @@ +# DP: Don't try to download documentation tools + +--- a/Doc/Makefile ++++ b/Doc/Makefile +@@ -58,7 +58,7 @@ + + update: clean checkout + +-build: checkout ++build: + mkdir -p build/$(BUILDER) build/doctrees + $(PYTHON) tools/sphinx-build.py $(ALLSPHINXOPTS) + @echo --- python3.2-3.2.3.orig/debian/patches/disable-sem-check.diff +++ python3.2-3.2.3/debian/patches/disable-sem-check.diff @@ -0,0 +1,36 @@ +# DP: Assume working semaphores, don't rely on running kernel for the check. + +--- a/configure.ac ++++ b/configure.ac +@@ -3488,8 +3488,13 @@ + AC_MSG_RESULT($ac_cv_posix_semaphores_enabled) + if test $ac_cv_posix_semaphores_enabled = no + then +- AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1, +- [Define if POSIX semaphores aren't enabled on your system]) ++ case $ac_sys_system in ++ Linux*) # assume yes, see https://launchpad.net/bugs/630511 ++ ;; ++ *) ++ AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1, ++ [Define if POSIX semaphores aren't enabled on your system]) ++ esac + fi + + # Multiprocessing check for broken sem_getvalue +@@ -3524,8 +3529,13 @@ + AC_MSG_RESULT($ac_cv_broken_sem_getvalue) + if test $ac_cv_broken_sem_getvalue = yes + then +- AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1, +- [define to 1 if your sem_getvalue is broken.]) ++ case $ac_sys_system in ++ Linux*) # assume yes, see https://launchpad.net/bugs/630511 ++ ;; ++ *) ++ AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1, ++ [define to 1 if your sem_getvalue is broken.]) ++ esac + fi + + # determine what size digit to use for Python's longs --- python3.2-3.2.3.orig/debian/patches/hurd-broken-poll.diff +++ python3.2-3.2.3/debian/patches/hurd-broken-poll.diff @@ -0,0 +1,23 @@ +# DP: Fix build failure on hurd, working around poll() on systems +# DP: on which it returns an error on invalid FDs. + +--- a/Modules/selectmodule.c ++++ b/Modules/selectmodule.c +@@ -1747,7 +1747,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 */ +@@ -1792,7 +1792,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) { --- python3.2-3.2.3.orig/debian/patches/utf16_error_handling.patch +++ python3.2-3.2.3/debian/patches/utf16_error_handling.patch @@ -0,0 +1,143 @@ +# DP: Proposed patch for CVE-2012-2135: Vulnerability in the utf-16 decoder +# DP: after error handling. + +diff -r b07488490001 Lib/test/test_codecs.py +--- a/Lib/test/test_codecs.py Fri Apr 20 14:36:47 2012 +0200 ++++ b/Lib/test/test_codecs.py Wed Apr 25 20:08:37 2012 +0300 +@@ -540,8 +540,19 @@ + ) + + def test_errors(self): +- self.assertRaises(UnicodeDecodeError, codecs.utf_16_le_decode, +- b"\xff", "strict", True) ++ tests = [ ++ (b'\xff', '\ufffd'), ++ (b'A\x00Z', 'A\ufffd'), ++ (b'A\x00B\x00C\x00D\x00Z', 'ABCD\ufffd'), ++ (b'\x00\xd8', '\ufffd'), ++ (b'\x00\xd8A', '\ufffd'), ++ (b'\x00\xd8A\x00', '\ufffdA'), ++ (b'\x00\xdcA\x00', '\ufffdA'), ++ ] ++ for raw, expected in tests: ++ self.assertRaises(UnicodeDecodeError, codecs.utf_16_le_decode, ++ raw, 'strict', True) ++ self.assertEqual(raw.decode('utf-16le', 'replace'), expected) + + def test_nonbmp(self): + self.assertEqual("\U00010203".encode(self.encoding), +@@ -568,8 +579,19 @@ + ) + + def test_errors(self): +- self.assertRaises(UnicodeDecodeError, codecs.utf_16_be_decode, +- b"\xff", "strict", True) ++ tests = [ ++ (b'\xff', '\ufffd'), ++ (b'\x00A\xff', 'A\ufffd'), ++ (b'\x00A\x00B\x00C\x00DZ', 'ABCD\ufffd'), ++ (b'\xd8\x00', '\ufffd'), ++ (b'\xd8\x00\xdc', '\ufffd'), ++ (b'\xd8\x00\x00A', '\ufffdA'), ++ (b'\xdc\x00\x00A', '\ufffdA'), ++ ] ++ for raw, expected in tests: ++ self.assertRaises(UnicodeDecodeError, codecs.utf_16_be_decode, ++ raw, 'strict', True) ++ self.assertEqual(raw.decode('utf-16be', 'replace'), expected) + + def test_nonbmp(self): + self.assertEqual("\U00010203".encode(self.encoding), +diff -r b07488490001 Objects/unicodeobject.c +--- a/Objects/unicodeobject.c Fri Apr 20 14:36:47 2012 +0200 ++++ b/Objects/unicodeobject.c Wed Apr 25 20:08:37 2012 +0300 +@@ -3425,7 +3425,7 @@ + /* Unpack UTF-16 encoded data */ + p = unicode->str; + q = (unsigned char *)s; +- e = q + size - 1; ++ e = q + size; + + if (byteorder) + bo = *byteorder; +@@ -3476,8 +3476,20 @@ + #endif + + aligned_end = (const unsigned char *) ((size_t) e & ~LONG_PTR_MASK); +- while (q < e) { ++ while (1) { + Py_UNICODE ch; ++ if (e - q < 2) { ++ /* remaining byte at the end? (size should be even) */ ++ if (q == e || consumed) ++ break; ++ errmsg = "truncated data"; ++ startinpos = ((const char *)q) - starts; ++ endinpos = ((const char *)e) - starts; ++ outpos = p - PyUnicode_AS_UNICODE(unicode); ++ goto utf16Error; ++ /* The remaining input chars are ignored if the callback ++ chooses to skip the input */ ++ } + /* First check for possible aligned read of a C 'long'. Unaligned + reads are more expensive, better to defer to another iteration. */ + if (!((size_t) q & LONG_PTR_MASK)) { +@@ -3546,8 +3558,8 @@ + } + p = _p; + q = _q; +- if (q >= e) +- break; ++ if (e - q < 2) ++ continue; + } + ch = (q[ihi] << 8) | q[ilo]; + +@@ -3559,10 +3571,10 @@ + } + + /* UTF-16 code pair: */ +- if (q > e) { ++ if (e - q < 2) { + errmsg = "unexpected end of data"; + startinpos = (((const char *)q) - 2) - starts; +- endinpos = ((const char *)e) + 1 - starts; ++ endinpos = ((const char *)e) - starts; + goto utf16Error; + } + if (0xD800 <= ch && ch <= 0xDBFF) { +@@ -3606,31 +3618,9 @@ + &outpos, + &p)) + goto onError; +- } +- /* remaining byte at the end? (size should be even) */ +- if (e == q) { +- if (!consumed) { +- errmsg = "truncated data"; +- startinpos = ((const char *)q) - starts; +- endinpos = ((const char *)e) + 1 - starts; +- outpos = p - PyUnicode_AS_UNICODE(unicode); +- if (unicode_decode_call_errorhandler( +- errors, +- &errorHandler, +- "utf16", errmsg, +- &starts, +- (const char **)&e, +- &startinpos, +- &endinpos, +- &exc, +- (const char **)&q, +- &unicode, +- &outpos, +- &p)) +- goto onError; +- /* The remaining input chars are ignored if the callback +- chooses to skip the input */ +- } ++ /* Update data because unicode_decode_call_errorhandler might have ++ changed the input object. */ ++ aligned_end = (const unsigned char *) ((size_t) e & ~LONG_PTR_MASK); + } + + if (byteorder) --- python3.2-3.2.3.orig/debian/patches/hurd-path_max.diff +++ python3.2-3.2.3/debian/patches/hurd-path_max.diff @@ -0,0 +1,89 @@ +# DP: Replace PATH_MAX with MAXPATHLEN. + +--- a/Python/pythonrun.c ++++ b/Python/pythonrun.c +@@ -680,7 +680,7 @@ + } + + static wchar_t *default_home = NULL; +-static wchar_t env_home[PATH_MAX+1]; ++static wchar_t env_home[MAXPATHLEN+1]; + + void + Py_SetPythonHome(wchar_t *home) +@@ -695,8 +695,8 @@ + if (home == NULL && !Py_IgnoreEnvironmentFlag) { + char* chome = Py_GETENV("PYTHONHOME"); + if (chome) { +- size_t r = mbstowcs(env_home, chome, PATH_MAX+1); +- if (r != (size_t)-1 && r <= PATH_MAX) ++ size_t r = mbstowcs(env_home, chome, MAXPATHLEN+1); ++ if (r != (size_t)-1 && r <= MAXPATHLEN) + home = env_home; + } + +--- a/Python/sysmodule.c ++++ b/Python/sysmodule.c +@@ -1804,7 +1804,7 @@ + #else /* All other filename syntaxes */ + if (_HAVE_SCRIPT_ARGUMENT(argc, argv)) { + #if defined(HAVE_REALPATH) +- if (_Py_wrealpath(argv0, fullpath, PATH_MAX)) { ++ if (_Py_wrealpath(argv0, fullpath, MAXPATHLEN)) { + argv0 = fullpath; + } + #endif +--- a/Python/fileutils.c ++++ b/Python/fileutils.c +@@ -1,4 +1,5 @@ + #include "Python.h" ++#include "osdefs.h" + #ifdef MS_WINDOWS + # include + #endif +@@ -325,7 +326,7 @@ + _Py_wreadlink(const wchar_t *path, wchar_t *buf, size_t bufsiz) + { + char *cpath; +- char cbuf[PATH_MAX]; ++ char cbuf[MAXPATHLEN]; + wchar_t *wbuf; + int res; + size_t r1; +@@ -335,11 +336,11 @@ + errno = EINVAL; + return -1; + } +- res = (int)readlink(cpath, cbuf, PATH_MAX); ++ res = (int)readlink(cpath, cbuf, MAXPATHLEN); + PyMem_Free(cpath); + if (res == -1) + return -1; +- if (res == PATH_MAX) { ++ if (res == MAXPATHLEN) { + errno = EINVAL; + return -1; + } +@@ -370,7 +371,7 @@ + wchar_t *resolved_path, size_t resolved_path_size) + { + char *cpath; +- char cresolved_path[PATH_MAX]; ++ char cresolved_path[MAXPATHLEN]; + wchar_t *wresolved_path; + char *res; + size_t r; +@@ -409,11 +410,11 @@ + #ifdef MS_WINDOWS + return _wgetcwd(buf, size); + #else +- char fname[PATH_MAX]; ++ char fname[MAXPATHLEN]; + wchar_t *wname; + size_t len; + +- if (getcwd(fname, PATH_MAX) == NULL) ++ if (getcwd(fname, MAXPATHLEN) == NULL) + return NULL; + wname = _Py_char2wchar(fname, &len); + if (wname == NULL) --- python3.2-3.2.3.orig/debian/patches/webbrowser.diff +++ python3.2-3.2.3/debian/patches/webbrowser.diff @@ -0,0 +1,27 @@ +# DP: Recognize other browsers: www-browser, x-www-browser, iceweasel, iceape. + +--- a/Lib/webbrowser.py ++++ b/Lib/webbrowser.py +@@ -444,9 +444,13 @@ + if "KDE_FULL_SESSION" in os.environ and _iscommand("kfmclient"): + register("kfmclient", Konqueror, Konqueror("kfmclient")) + ++ if _iscommand("x-www-browser"): ++ register("x-www-browser", None, BackgroundBrowser("x-www-browser")) ++ + # The Mozilla/Netscape browsers + for browser in ("mozilla-firefox", "firefox", + "mozilla-firebird", "firebird", ++ "iceweasel", "iceape", + "seamonkey", "mozilla", "netscape"): + if _iscommand(browser): + register(browser, None, Mozilla(browser)) +@@ -484,6 +488,8 @@ + + # Also try console browsers + if os.environ.get("TERM"): ++ if _iscommand("www-browser"): ++ register("www-browser", None, GenericBrowser("www-browser")) + # The Links/elinks browsers + if _iscommand("links"): + register("links", None, GenericBrowser("links")) --- python3.2-3.2.3.orig/debian/patches/revert-r83274.diff +++ python3.2-3.2.3/debian/patches/revert-r83274.diff @@ -0,0 +1,12 @@ +--- a/Doc/conf.py ++++ b/Doc/conf.py +@@ -65,9 +65,6 @@ + # Options for HTML output + # ----------------------- + +-html_theme = 'default' +-html_theme_options = {'collapsiblesidebar': True} +- + # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, + # using the given strftime format. + html_last_updated_fmt = '%b %d, %Y' --- python3.2-3.2.3.orig/debian/patches/bdist-wininst-notfound.diff +++ python3.2-3.2.3/debian/patches/bdist-wininst-notfound.diff @@ -0,0 +1,17 @@ +# DP: the wininst-* files cannot be built within Debian, needing a +# DP: zlib mingw build, which the zlib maintainer isn't going to provide. + +--- a/Lib/distutils/command/bdist_wininst.py ++++ b/Lib/distutils/command/bdist_wininst.py +@@ -340,7 +340,10 @@ + sfix = '' + + filename = os.path.join(directory, "wininst-%.1f%s.exe" % (bv, sfix)) +- f = open(filename, "rb") ++ try: ++ f = open(filename, "rb") ++ except IOError as e: ++ raise DistutilsFileError(str(e) + ', %s not included in the Debian packages.' % filename) + try: + return f.read() + finally: --- python3.2-3.2.3.orig/debian/patches/libffi-shared.diff +++ python3.2-3.2.3/debian/patches/libffi-shared.diff @@ -0,0 +1,11 @@ +--- a/setup.py ++++ b/setup.py +@@ -1770,7 +1770,7 @@ + break + ffi_lib = None + if ffi_inc is not None: +- for lib_name in ('ffi_convenience', 'ffi_pic', 'ffi'): ++ for lib_name in ('ffi', 'ffi_convenience', 'ffi_pic', 'ffi'): + if (self.compiler.find_library_file(lib_dirs, lib_name)): + ffi_lib = lib_name + break --- python3.2-3.2.3.orig/debian/patches/hg-updates.diff +++ python3.2-3.2.3/debian/patches/hg-updates.diff @@ -0,0 +1,26104 @@ +# DP: hg updates of the 3.2 release branch (until 2012-07-12). + +# hg diff -r v3.2.3 | filterdiff --exclude=.hgignore --exclude=.hgeol --exclude=.hgtags --remove-timestamps + +diff -r 3d0686d90f55 Doc/c-api/long.rst +--- a/Doc/c-api/long.rst ++++ b/Doc/c-api/long.rst +@@ -108,37 +108,55 @@ + + + .. XXX alias PyLong_AS_LONG (for now) +-.. c:function:: long PyLong_AsLong(PyObject *pylong) ++.. c:function:: long PyLong_AsLong(PyObject *obj) + + .. index:: + single: LONG_MAX + single: OverflowError (built-in exception) + +- Return a C :c:type:`long` representation of the contents of *pylong*. If +- *pylong* is greater than :const:`LONG_MAX`, raise an :exc:`OverflowError`, +- and return -1. Convert non-long objects automatically to long first, +- and return -1 if that raises exceptions. ++ Return a C :c:type:`long` representation of *obj*. If *obj* is not an ++ instance of :c:type:`PyLongObject`, first call its :meth:`__int__` method ++ (if present) to convert it to a :c:type:`PyLongObject`. + +-.. c:function:: long PyLong_AsLongAndOverflow(PyObject *pylong, int *overflow) ++ Raise :exc:`OverflowError` if the value of *obj* is out of range for a ++ :c:type:`long`. + +- Return a C :c:type:`long` representation of the contents of +- *pylong*. If *pylong* is greater than :const:`LONG_MAX` or less +- than :const:`LONG_MIN`, set *\*overflow* to ``1`` or ``-1``, +- respectively, and return ``-1``; otherwise, set *\*overflow* to +- ``0``. If any other exception occurs (for example a TypeError or +- MemoryError), then ``-1`` will be returned and *\*overflow* will +- be ``0``. + ++.. c:function:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow) + +-.. c:function:: PY_LONG_LONG PyLong_AsLongLongAndOverflow(PyObject *pylong, int *overflow) ++ Return a C :c:type:`long` representation of *obj*. If *obj* is not an ++ instance of :c:type:`PyLongObject`, first call its :meth:`__int__` method ++ (if present) to convert it to a :c:type:`PyLongObject`. + +- Return a C :c:type:`long long` representation of the contents of +- *pylong*. If *pylong* is greater than :const:`PY_LLONG_MAX` or less +- than :const:`PY_LLONG_MIN`, set *\*overflow* to ``1`` or ``-1``, +- respectively, and return ``-1``; otherwise, set *\*overflow* to +- ``0``. If any other exception occurs (for example a TypeError or +- MemoryError), then ``-1`` will be returned and *\*overflow* will +- be ``0``. ++ If the value of *obj* is greater than :const:`LONG_MAX` or less than ++ :const:`LONG_MIN`, set *\*overflow* to ``1`` or ``-1``, respectively, and ++ return ``-1``; otherwise, set *\*overflow* to ``0``. If any other exception ++ occurs set *\*overflow* to ``0`` and return ``-1`` as usual. ++ ++ ++.. c:function:: PY_LONG_LONG PyLong_AsLongLong(PyObject *obj) ++ ++ .. index:: ++ single: OverflowError (built-in exception) ++ ++ Return a C :c:type:`long long` representation of *obj*. If *obj* is not an ++ instance of :c:type:`PyLongObject`, first call its :meth:`__int__` method ++ (if present) to convert it to a :c:type:`PyLongObject`. ++ ++ Raise :exc:`OverflowError` if the value of *obj* is out of range for a ++ :c:type:`long`. ++ ++ ++.. c:function:: PY_LONG_LONG PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow) ++ ++ Return a C :c:type:`long long` representation of *obj*. If *obj* is not an ++ instance of :c:type:`PyLongObject`, first call its :meth:`__int__` method ++ (if present) to convert it to a :c:type:`PyLongObject`. ++ ++ If the value of *obj* is greater than :const:`PY_LLONG_MAX` or less than ++ :const:`PY_LLONG_MIN`, set *\*overflow* to ``1`` or ``-1``, respectively, ++ and return ``-1``; otherwise, set *\*overflow* to ``0``. If any other ++ exception occurs set *\*overflow* to ``0`` and return ``-1`` as usual. + + .. versionadded:: 3.2 + +@@ -149,9 +167,11 @@ + single: PY_SSIZE_T_MAX + single: OverflowError (built-in exception) + +- Return a C :c:type:`Py_ssize_t` representation of the contents of *pylong*. +- If *pylong* is greater than :const:`PY_SSIZE_T_MAX`, an :exc:`OverflowError` +- is raised and ``-1`` will be returned. ++ Return a C :c:type:`Py_ssize_t` representation of *pylong*. *pylong* must ++ be an instance of :c:type:`PyLongObject`. ++ ++ Raise :exc:`OverflowError` if the value of *pylong* is out of range for a ++ :c:type:`Py_ssize_t`. + + + .. c:function:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong) +@@ -160,26 +180,20 @@ + single: ULONG_MAX + single: OverflowError (built-in exception) + +- Return a C :c:type:`unsigned long` representation of the contents of *pylong*. +- If *pylong* is greater than :const:`ULONG_MAX`, an :exc:`OverflowError` is +- raised. ++ Return a C :c:type:`unsigned long` representation of *pylong*. *pylong* ++ must be an instance of :c:type:`PyLongObject`. ++ ++ Raise :exc:`OverflowError` if the value of *pylong* is out of range for a ++ :c:type:`unsigned long`. + + + .. c:function:: size_t PyLong_AsSize_t(PyObject *pylong) + +- Return a :c:type:`size_t` representation of the contents of *pylong*. If +- *pylong* is greater than the maximum value for a :c:type:`size_t`, an +- :exc:`OverflowError` is raised. ++ Return a C :c:type:`size_t` representation of of *pylong*. *pylong* must be ++ an instance of :c:type:`PyLongObject`. + +- +-.. c:function:: PY_LONG_LONG PyLong_AsLongLong(PyObject *pylong) +- +- .. index:: +- single: OverflowError (built-in exception) +- +- Return a C :c:type:`long long` from a Python integer. If *pylong* +- cannot be represented as a :c:type:`long long`, an +- :exc:`OverflowError` is raised and ``-1`` is returned. ++ Raise :exc:`OverflowError` if the value of *pylong* is out of range for a ++ :c:type:`size_t`. + + + .. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong) +@@ -187,32 +201,43 @@ + .. index:: + single: OverflowError (built-in exception) + +- Return a C :c:type:`unsigned long long` from a Python integer. If +- *pylong* cannot be represented as an :c:type:`unsigned long long`, +- an :exc:`OverflowError` is raised and ``(unsigned long long)-1`` is +- returned. ++ Return a C :c:type:`unsigned PY_LONG_LONG` representation of of *pylong*. ++ *pylong* must be an instance of :c:type:`PyLongObject`. ++ ++ Raise :exc:`OverflowError` if the value of *pylong* is out of range for an ++ :c:type:`unsigned PY_LONG_LONG`. + + .. versionchanged:: 3.1 + A negative *pylong* now raises :exc:`OverflowError`, not :exc:`TypeError`. + + +-.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *io) ++.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *obj) + +- Return a C :c:type:`unsigned long` from a Python integer, without checking for +- overflow. ++ Return a C :c:type:`unsigned long` representation of *obj*. If *obj* ++ is not an instance of :c:type:`PyLongObject`, first call its :meth:`__int__` ++ method (if present) to convert it to a :c:type:`PyLongObject`. + ++ If the value of *obj* is out of range for an :c:type:`unsigned long`, ++ return the reduction of that value modulo :const:`ULONG_MAX + 1`. + +-.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *io) + +- Return a C :c:type:`unsigned long long` from a Python integer, without +- checking for overflow. ++.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *obj) ++ ++ Return a C :c:type:`unsigned long long` representation of *obj*. If *obj* ++ is not an instance of :c:type:`PyLongObject`, first call its :meth:`__int__` ++ method (if present) to convert it to a :c:type:`PyLongObject`. ++ ++ If the value of *obj* is out of range for an :c:type:`unsigned long long`, ++ return the reduction of that value modulo :const:`PY_ULLONG_MAX + 1`. + + + .. c:function:: double PyLong_AsDouble(PyObject *pylong) + +- Return a C :c:type:`double` representation of the contents of *pylong*. If +- *pylong* cannot be approximately represented as a :c:type:`double`, an +- :exc:`OverflowError` exception is raised and ``-1.0`` will be returned. ++ Return a C :c:type:`double` representation of *pylong*. *pylong* must be ++ an instance of :c:type:`PyLongObject`. ++ ++ Raise :exc:`OverflowError` if the value of *pylong* is out of range for a ++ :c:type:`double`. + + + .. c:function:: void* PyLong_AsVoidPtr(PyObject *pylong) +diff -r 3d0686d90f55 Doc/conf.py +--- a/Doc/conf.py ++++ b/Doc/conf.py +@@ -65,9 +65,12 @@ + # Options for HTML output + # ----------------------- + +-html_theme = 'default' ++html_theme = 'pydoctheme' ++html_theme_path = ['tools/sphinxext'] + html_theme_options = {'collapsiblesidebar': True} + ++html_short_title = '%s Documentation' % release ++ + # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, + # using the given strftime format. + html_last_updated_fmt = '%b %d, %Y' +@@ -88,7 +91,7 @@ + } + + # Output an OpenSearch description file. +-html_use_opensearch = 'http://docs.python.org/dev/py3k' ++html_use_opensearch = 'http://docs.python.org/3.2' + + # Additional static files. + html_static_path = ['tools/sphinxext/static'] +diff -r 3d0686d90f55 Doc/extending/embedding.rst +--- a/Doc/extending/embedding.rst ++++ b/Doc/extending/embedding.rst +@@ -155,13 +155,13 @@ + interesting part with respect to embedding Python starts with :: + + Py_Initialize(); +- pName = PyString_FromString(argv[1]); ++ pName = PyUnicode_FromString(argv[1]); + /* Error checking of pName left out */ + pModule = PyImport_Import(pName); + + After initializing the interpreter, the script is loaded using + :c:func:`PyImport_Import`. This routine needs a Python string as its argument, +-which is constructed using the :c:func:`PyString_FromString` data conversion ++which is constructed using the :c:func:`PyUnicode_FromString` data conversion + routine. :: + + pFunc = PyObject_GetAttrString(pModule, argv[2]); +diff -r 3d0686d90f55 Doc/extending/newtypes.rst +--- a/Doc/extending/newtypes.rst ++++ b/Doc/extending/newtypes.rst +@@ -1459,9 +1459,8 @@ + } + + The only further addition is that the destructor needs to call the weak +-reference manager to clear any weak references. This should be done before any +-other parts of the destruction have occurred, but is only required if the weak +-reference list is non-*NULL*:: ++reference manager to clear any weak references. This is only required if the ++weak reference list is non-*NULL*:: + + static void + instance_dealloc(PyInstanceObject *inst) +diff -r 3d0686d90f55 Doc/faq/design.rst +--- a/Doc/faq/design.rst ++++ b/Doc/faq/design.rst +@@ -43,56 +43,45 @@ + See the next question. + + +-Why are floating point calculations so inaccurate? ++Why are floating-point calculations so inaccurate? + -------------------------------------------------- + +-People are often very surprised by results like this:: ++Users are often surprised by results like this:: + +- >>> 1.2 - 1.0 +- 0.199999999999999996 ++ >>> 1.2 - 1.0 ++ 0.199999999999999996 + +-and think it is a bug in Python. It's not. This has nothing to do with Python, +-but with how the underlying C platform handles floating point numbers, and +-ultimately with the inaccuracies introduced when writing down numbers as a +-string of a fixed number of digits. ++and think it is a bug in Python. It's not. This has little to do with Python, ++and much more to do with how the underlying platform handles floating-point ++numbers. + +-The internal representation of floating point numbers uses a fixed number of +-binary digits to represent a decimal number. Some decimal numbers can't be +-represented exactly in binary, resulting in small roundoff errors. ++The :class:`float` type in CPython uses a C ``double`` for storage. A ++:class:`float` object's value is stored in binary floating-point with a fixed ++precision (typically 53 bits) and Python uses C operations, which in turn rely ++on the hardware implementation in the processor, to perform floating-point ++operations. This means that as far as floating-point operations are concerned, ++Python behaves like many popular languages including C and Java. + +-In decimal math, there are many numbers that can't be represented with a fixed +-number of decimal digits, e.g. 1/3 = 0.3333333333....... ++Many numbers that can be written easily in decimal notation cannot be expressed ++exactly in binary floating-point. For example, after:: + +-In base 2, 1/2 = 0.1, 1/4 = 0.01, 1/8 = 0.001, etc. .2 equals 2/10 equals 1/5, +-resulting in the binary fractional number 0.001100110011001... ++ >>> x = 1.2 + +-Floating point numbers only have 32 or 64 bits of precision, so the digits are +-cut off at some point, and the resulting number is 0.199999999999999996 in +-decimal, not 0.2. ++the value stored for ``x`` is a (very good) approximation to the decimal value ++``1.2``, but is not exactly equal to it. On a typical machine, the actual ++stored value is:: + +-A floating point number's ``repr()`` function prints as many digits are +-necessary to make ``eval(repr(f)) == f`` true for any float f. The ``str()`` +-function prints fewer digits and this often results in the more sensible number +-that was probably intended:: ++ 1.0011001100110011001100110011001100110011001100110011 (binary) + +- >>> 1.1 - 0.9 +- 0.20000000000000007 +- >>> print(1.1 - 0.9) +- 0.2 ++which is exactly:: + +-One of the consequences of this is that it is error-prone to compare the result +-of some computation to a float with ``==``. Tiny inaccuracies may mean that +-``==`` fails. Instead, you have to check that the difference between the two +-numbers is less than a certain threshold:: ++ 1.1999999999999999555910790149937383830547332763671875 (decimal) + +- epsilon = 0.0000000000001 # Tiny allowed error +- expected_result = 0.4 ++The typical precision of 53 bits provides Python floats with 15-16 ++decimal digits of accuracy. + +- if expected_result-epsilon <= computation() <= expected_result+epsilon: +- ... +- +-Please see the chapter on :ref:`floating point arithmetic ` in +-the Python tutorial for more information. ++For a fuller explanation, please see the :ref:`floating point arithmetic ++` chapter in the Python tutorial. + + + Why are Python strings immutable? +@@ -284,8 +273,9 @@ + How fast are exceptions? + ------------------------ + +-A try/except block is extremely efficient. Actually catching an exception is +-expensive. In versions of Python prior to 2.0 it was common to use this idiom:: ++A try/except block is extremely efficient if no exceptions are raised. Actually ++catching an exception is expensive. In versions of Python prior to 2.0 it was ++common to use this idiom:: + + try: + value = mydict[key] +@@ -296,11 +286,10 @@ + This only made sense when you expected the dict to have the key almost all the + time. If that wasn't the case, you coded it like this:: + +- if mydict.has_key(key): ++ if key in mydict: + value = mydict[key] + else: +- mydict[key] = getvalue(key) +- value = mydict[key] ++ value = mydict[key] = getvalue(key) + + For this specific case, you could also use ``value = dict.setdefault(key, + getvalue(key))``, but only if the ``getvalue()`` call is cheap enough because it +diff -r 3d0686d90f55 Doc/faq/library.rst +--- a/Doc/faq/library.rst ++++ b/Doc/faq/library.rst +@@ -14,7 +14,7 @@ + + Check :ref:`the Library Reference ` to see if there's a relevant + standard library module. (Eventually you'll learn what's in the standard +-library and will able to skip this step.) ++library and will be able to skip this step.) + + For third-party packages, search the `Python Package Index + `_ or try `Google `_ or +@@ -28,7 +28,7 @@ + If you can't find a source file for a module it may be a built-in or + dynamically loaded module implemented in C, C++ or other compiled language. + In this case you may not have the source file or it may be something like +-mathmodule.c, somewhere in a C source directory (not on the Python Path). ++:file:`mathmodule.c`, somewhere in a C source directory (not on the Python Path). + + There are (at least) three kinds of modules in Python: + +@@ -60,18 +60,18 @@ + interpreter is installed on your platform. + + If you would like the script to be independent of where the Python interpreter +-lives, you can use the "env" program. Almost all Unix variants support the +-following, assuming the Python interpreter is in a directory on the user's +-$PATH:: ++lives, you can use the :program:`env` program. Almost all Unix variants support ++the following, assuming the Python interpreter is in a directory on the user's ++:envvar:`PATH`:: + + #!/usr/bin/env python + +-*Don't* do this for CGI scripts. The $PATH variable for CGI scripts is often +-very minimal, so you need to use the actual absolute pathname of the ++*Don't* do this for CGI scripts. The :envvar:`PATH` variable for CGI scripts is ++often very minimal, so you need to use the actual absolute pathname of the + interpreter. + +-Occasionally, a user's environment is so full that the /usr/bin/env program +-fails; or there's no env program at all. In that case, you can try the ++Occasionally, a user's environment is so full that the :program:`/usr/bin/env` ++program fails; or there's no env program at all. In that case, you can try the + following hack (due to Alex Rezinsky):: + + #! /bin/sh +@@ -92,11 +92,11 @@ + .. XXX curses *is* built by default, isn't it? + + For Unix variants: The standard Python source distribution comes with a curses +-module in the ``Modules/`` subdirectory, though it's not compiled by default +-(note that this is not available in the Windows distribution -- there is no +-curses module for Windows). ++module in the :source:`Modules` subdirectory, though it's not compiled by default. ++(Note that this is not available in the Windows distribution -- there is no ++curses module for Windows.) + +-The curses module supports basic curses features as well as many additional ++The :mod:`curses` module supports basic curses features as well as many additional + functions from ncurses and SYSV curses such as colour, alternative character set + support, pads, and mouse support. This means the module isn't compatible with + operating systems that only have BSD curses, but there don't seem to be any +@@ -110,7 +110,7 @@ + ------------------------------------------------- + + The :mod:`atexit` module provides a register function that is similar to C's +-onexit. ++:c:func:`onexit`. + + + Why don't my signal handlers work? +@@ -140,8 +140,8 @@ + The :mod:`unittest` module is a fancier testing framework modelled on Java and + Smalltalk testing frameworks. + +-For testing, it helps to write the program so that it may be easily tested by +-using good modular design. Your program should have almost all functionality ++To make testing easier, you should use good modular design in your program. ++Your program should have almost all functionality + encapsulated in either functions or class methods -- and this sometimes has the + surprising and delightful effect of making the program run faster (because local + variable accesses are faster than global accesses). Furthermore the program +@@ -157,7 +157,7 @@ + + Once your program is organized as a tractable collection of functions and class + behaviours you should write test functions that exercise the behaviours. A test +-suite can be associated with each module which automates a sequence of tests. ++suite that automates a sequence of tests can be associated with each module. + This sounds like a lot of work, but since Python is so terse and flexible it's + surprisingly easy. You can make coding much more pleasant and fun by writing + your test functions in parallel with the "production code", since this makes it +@@ -186,7 +186,7 @@ + How do I get a single keypress at a time? + ----------------------------------------- + +-For Unix variants: There are several solutions. It's straightforward to do this ++For Unix variants there are several solutions. It's straightforward to do this + using curses, but curses is a fairly large module to learn. + + .. XXX this doesn't work out of the box, some IO expert needs to check why +@@ -275,7 +275,7 @@ + + time.sleep(10) + +-Instead of trying to guess how long a :func:`time.sleep` delay will be enough, ++Instead of trying to guess a good delay value for :func:`time.sleep`, + it's better to use some kind of semaphore mechanism. One idea is to use the + :mod:`queue` module to create a queue object, let each thread append a token to + the queue when it finishes, and let the main thread read as many tokens from the +@@ -291,9 +291,9 @@ + Or, if you want fine control over the dispatching algorithm, you can write + your own logic manually. Use the :mod:`queue` module to create a queue + containing a list of jobs. The :class:`~queue.Queue` class maintains a +-list of objects with ``.put(obj)`` to add an item to the queue and ``.get()`` +-to return an item. The class will take care of the locking necessary to +-ensure that each job is handed out exactly once. ++list of objects and has a ``.put(obj)`` method that adds items to the queue and ++a ``.get()`` method to return them. The class will take care of the locking ++necessary to ensure that each job is handed out exactly once. + + Here's a trivial example:: + +@@ -302,7 +302,7 @@ + # The worker thread gets jobs off the queue. When the queue is empty, it + # assumes there will be no more work and exits. + # (Realistically workers will run until terminated.) +- def worker (): ++ def worker(): + print('Running worker') + time.sleep(0.1) + while True: +@@ -333,7 +333,9 @@ + print('Main thread sleeping') + time.sleep(5) + +-When run, this will produce the following output:: ++When run, this will produce the following output: ++ ++.. code-block:: none + + Running worker + Running worker +@@ -349,8 +351,8 @@ + Worker running with argument 5 + ... + +-Consult the module's documentation for more details; the ``Queue`` class +-provides a featureful interface. ++Consult the module's documentation for more details; the :class:`~queue.Queue`` ++class provides a featureful interface. + + + What kinds of global value mutation are thread-safe? +@@ -467,7 +469,7 @@ + To truncate a file, open it using ``f = open(filename, "rb+")``, and use + ``f.truncate(offset)``; offset defaults to the current seek position. There's + also ``os.ftruncate(fd, offset)`` for files opened with :func:`os.open`, where +-``fd`` is the file descriptor (a small integer). ++*fd* is the file descriptor (a small integer). + + The :mod:`shutil` module also contains a number of functions to work on files + including :func:`~shutil.copyfile`, :func:`~shutil.copytree`, and +@@ -501,15 +503,15 @@ + "short integer" (2 bytes), and 'l' reads one "long integer" (4 bytes) from the + string. + +-For data that is more regular (e.g. a homogeneous list of ints or thefloats), ++For data that is more regular (e.g. a homogeneous list of ints or floats), + you can also use the :mod:`array` module. + +- .. note:: +- To read and write binary data, it is mandatory to open the file in +- binary mode (here, passing ``"rb"`` to :func:`open`). If you use +- ``"r"`` instead (the default), the file will be open in text mode +- and ``f.read()`` will return :class:`str` objects rather than +- :class:`bytes` objects. ++.. note:: ++ To read and write binary data, it is mandatory to open the file in ++ binary mode (here, passing ``"rb"`` to :func:`open`). If you use ++ ``"r"`` instead (the default), the file will be open in text mode ++ and ``f.read()`` will return :class:`str` objects rather than ++ :class:`bytes` objects. + + + I can't seem to use os.read() on a pipe created with os.popen(); why? +@@ -518,7 +520,7 @@ + :func:`os.read` is a low-level function which takes a file descriptor, a small + integer representing the opened file. :func:`os.popen` creates a high-level + file object, the same type returned by the built-in :func:`open` function. +-Thus, to read n bytes from a pipe p created with :func:`os.popen`, you need to ++Thus, to read *n* bytes from a pipe *p* created with :func:`os.popen`, you need to + use ``p.read(n)``. + + +@@ -538,8 +540,8 @@ + Warning: in general it is unwise to do this because you can easily cause a + deadlock where your process is blocked waiting for output from the child + while the child is blocked waiting for input from you. This can be caused +- because the parent expects the child to output more text than it does, or it +- can be caused by data being stuck in stdio buffers due to lack of flushing. ++ by the parent expecting the child to output more text than it does or ++ by data being stuck in stdio buffers due to lack of flushing. + The Python parent can of course explicitly flush the data it sends to the + child before it reads any output, but if the child is a naive C program it + may have been written to never explicitly flush its output, even if it is +@@ -561,7 +563,7 @@ + get the result back. Unless the amount of data is very large, the easiest + way to do this is to write it to a temporary file and run the command with + that temporary file as input. The standard module :mod:`tempfile` exports a +- ``mktemp()`` function to generate unique temporary file names. :: ++ :func:`~tempfile.mktemp` function to generate unique temporary file names. :: + + import tempfile + import os +@@ -681,8 +683,8 @@ + msg, hdrs = req.read(), req.info() + + Note that in general for percent-encoded POST operations, query strings must be +-quoted using :func:`urllib.parse.urlencode`. For example to send name="Guy Steele, +-Jr.":: ++quoted using :func:`urllib.parse.urlencode`. For example, to send ++``name=Guy Steele, Jr.``:: + + >>> import urllib.parse + >>> urllib.parse.urlencode({'name': 'Guy Steele, Jr.'}) +@@ -696,19 +698,8 @@ + + .. XXX add modern template languages + +-There are many different modules available: +- +-* HTMLgen is a class library of objects corresponding to all the HTML 3.2 markup +- tags. It's used when you are writing in Python and wish to synthesize HTML +- pages for generating a web or for CGI forms, etc. +- +-* DocumentTemplate and Zope Page Templates are two different systems that are +- part of Zope. +- +-* Quixote's PTL uses Python syntax to assemble strings of text. +- +-Consult the `Web Programming wiki pages +-`_ for more links. ++You can find a collection of useful links on the `Web Programming wiki page ++`_. + + + How do I send mail from a Python script? +@@ -737,7 +728,7 @@ + server.quit() + + A Unix-only alternative uses sendmail. The location of the sendmail program +-varies between systems; sometimes it is ``/usr/lib/sendmail``, sometime ++varies between systems; sometimes it is ``/usr/lib/sendmail``, sometimes + ``/usr/sbin/sendmail``. The sendmail manual page will help you out. Here's + some sample code:: + +@@ -805,14 +796,6 @@ + :mod:`shelve` library module uses pickle and (g)dbm to create persistent + mappings containing arbitrary Python objects. + +-A more awkward way of doing things is to use pickle's little sister, marshal. +-The :mod:`marshal` module provides very fast ways to store noncircular basic +-Python types to files and strings, and back again. Although marshal does not do +-fancy things like store instances or handle shared references properly, it does +-run extremely fast. For example loading a half megabyte of data may take less +-than a third of a second. This often beats doing something more complex and +-general such as using gdbm with pickle/shelve. +- + + Mathematics and Numerics + ======================== +diff -r 3d0686d90f55 Doc/faq/programming.rst +--- a/Doc/faq/programming.rst ++++ b/Doc/faq/programming.rst +@@ -794,9 +794,9 @@ + That's a tough one, in general. First, here are a list of things to + remember before diving further: + +-* Performance characteristics vary accross Python implementations. This FAQ ++* Performance characteristics vary across Python implementations. This FAQ + focusses on :term:`CPython`. +-* Behaviour can vary accross operating systems, especially when talking about ++* Behaviour can vary across operating systems, especially when talking about + I/O or multi-threading. + * You should always find the hot spots in your program *before* attempting to + optimize any code (see the :mod:`profile` module). +diff -r 3d0686d90f55 Doc/glossary.rst +--- a/Doc/glossary.rst ++++ b/Doc/glossary.rst +@@ -146,9 +146,9 @@ + For more information about descriptors' methods, see :ref:`descriptors`. + + dictionary +- An associative array, where arbitrary keys are mapped to values. The keys +- can be any object with :meth:`__hash__` function and :meth:`__eq__` +- methods. Called a hash in Perl. ++ An associative array, where arbitrary keys are mapped to values. The ++ keys can be any object with :meth:`__hash__` and :meth:`__eq__` methods. ++ Called a hash in Perl. + + docstring + A string literal which appears as the first expression in a class, +@@ -194,7 +194,7 @@ + An object exposing a file-oriented API (with methods such as + :meth:`read()` or :meth:`write()`) to an underlying resource. Depending + on the way it was created, a file object can mediate access to a real +- on-disk file or to another other type of storage or communication device ++ on-disk file or to another type of storage or communication device + (for example standard input/output, in-memory buffers, sockets, pipes, + etc.). File objects are also called :dfn:`file-like objects` or + :dfn:`streams`. +@@ -385,7 +385,7 @@ + :meth:`str.lower` method can serve as a key function for case insensitive + sorts. Alternatively, an ad-hoc key function can be built from a + :keyword:`lambda` expression such as ``lambda r: (r[0], r[2])``. Also, +- the :mod:`operator` module provides three key function constuctors: ++ the :mod:`operator` module provides three key function constructors: + :func:`~operator.attrgetter`, :func:`~operator.itemgetter`, and + :func:`~operator.methodcaller`. See the :ref:`Sorting HOW TO + ` for examples of how to create and use key functions. +diff -r 3d0686d90f55 Doc/howto/advocacy.rst +--- a/Doc/howto/advocacy.rst ++++ b/Doc/howto/advocacy.rst +@@ -264,8 +264,7 @@ + + **What are the restrictions on Python's use?** + +-They're practically nonexistent. Consult the :file:`Misc/COPYRIGHT` file in the +-source distribution, or the section :ref:`history-and-license` for the full ++They're practically nonexistent. Consult :ref:`history-and-license` for the full + language, but it boils down to three conditions: + + * You have to leave the copyright notice on the software; if you don't include +diff -r 3d0686d90f55 Doc/howto/argparse.rst +--- /dev/null ++++ b/Doc/howto/argparse.rst +@@ -0,0 +1,764 @@ ++***************** ++Argparse Tutorial ++***************** ++ ++:author: Tshepang Lekhonkhobe ++ ++.. _argparse-tutorial: ++ ++This tutorial is intended to be a gentle introduction to :mod:`argparse`, the ++recommended command-line parsing module in the Python standard library. ++ ++.. note:: ++ ++ There's two other modules that fulfill the same task, namely ++ :mod:`getopt` (an equivalent for :c:func:`getopt` from the C ++ language) and the deprecated :mod:`optparse`. ++ Note also that :mod:`argparse` is based on :mod:`optparse`, ++ and therefore very similar in terms of usage. ++ ++ ++Concepts ++======== ++ ++Let's show the sort of functionality that we are going to explore in this ++introductory tutorial by making use of the :command:`ls` command: ++ ++.. code-block:: sh ++ ++ $ ls ++ cpython devguide prog.py pypy rm-unused-function.patch ++ $ ls pypy ++ ctypes_configure demo dotviewer include lib_pypy lib-python ... ++ $ ls -l ++ total 20 ++ drwxr-xr-x 19 wena wena 4096 Feb 18 18:51 cpython ++ drwxr-xr-x 4 wena wena 4096 Feb 8 12:04 devguide ++ -rwxr-xr-x 1 wena wena 535 Feb 19 00:05 prog.py ++ drwxr-xr-x 14 wena wena 4096 Feb 7 00:59 pypy ++ -rw-r--r-- 1 wena wena 741 Feb 18 01:01 rm-unused-function.patch ++ $ ls --help ++ Usage: ls [OPTION]... [FILE]... ++ List information about the FILEs (the current directory by default). ++ Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. ++ ... ++ ++A few concepts we can learn from the four commands: ++ ++* The :command:`ls` command is useful when run without any options at all. It defaults ++ to displaying the contents of the current directory. ++ ++* If we want beyond what it provides by default, we tell it a bit more. In ++ this case, we want it to display a different directory, ``pypy``. ++ What we did is specify what is known as a positional argument. It's named so ++ because the program should know what to do with the value, solely based on ++ where it appears on the command line. This concept is more relevant ++ to a command like :command:`cp`, whose most basic usage is ``cp SRC DEST``. ++ The first position is *what you want copied,* and the second ++ position is *where you want it copied to*. ++ ++* Now, say we want to change behaviour of the program. In our example, ++ we display more info for each file instead of just showing the file names. ++ The ``-l`` in that case is known as an optional argument. ++ ++* That's a snippet of the help text. It's very useful in that you can ++ come across a program you have never used before, and can figure out ++ how it works simply by reading it's help text. ++ ++ ++The basics ++========== ++ ++Let us start with a very simple example which does (almost) nothing:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.parse_args() ++ ++Following is a result of running the code: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py ++ $ python3 prog.py --help ++ usage: prog.py [-h] ++ ++ optional arguments: ++ -h, --help show this help message and exit ++ $ python3 prog.py --verbose ++ usage: prog.py [-h] ++ prog.py: error: unrecognized arguments: --verbose ++ $ python3 prog.py foo ++ usage: prog.py [-h] ++ prog.py: error: unrecognized arguments: foo ++ ++Here is what is happening: ++ ++* Running the script without any options results in nothing displayed to ++ stdout. Not so useful. ++ ++* The second one starts to display the usefulness of the :mod:`argparse` ++ module. We have done almost nothing, but already we get a nice help message. ++ ++* The ``--help`` option, which can also be shortened to ``-h``, is the only ++ option we get for free (i.e. no need to specify it). Specifying anything ++ else results in an error. But even then, we do get a useful usage message, ++ also for free. ++ ++ ++Introducing Positional arguments ++================================ ++ ++An example:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("echo") ++ args = parser.parse_args() ++ print(args.echo) ++ ++And running the code: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py ++ usage: prog.py [-h] echo ++ prog.py: error: the following arguments are required: echo ++ $ python3 prog.py --help ++ usage: prog.py [-h] echo ++ ++ positional arguments: ++ echo ++ ++ optional arguments: ++ -h, --help show this help message and exit ++ $ python3 prog.py foo ++ foo ++ ++Here is what's happening: ++ ++* We've added the :meth:`add_argument` method, which is what we use to specify ++ which command-line options the program is willing to accept. In this case, ++ I've named it ``echo`` so that it's in line with its function. ++ ++* Calling our program now requires us to specify an option. ++ ++* The :meth:`parse_args` method actually returns some data from the ++ options specified, in this case, ``echo``. ++ ++* The variable is some form of 'magic' that :mod:`argparse` performs for free ++ (i.e. no need to specify which variable that value is stored in). ++ You will also notice that its name matches the string argument given ++ to the method, ``echo``. ++ ++Note however that, although the help display looks nice and all, it currently ++is not as helpful as it can be. For example we see that we got ``echo`` as a ++positional argument, but we don't know what it does, other than by guessing or ++by reading the source code. So, let's make it a bit more useful:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("echo", help="echo the string you use here") ++ args = parser.parse_args() ++ print(args.echo) ++ ++And we get: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py -h ++ usage: prog.py [-h] echo ++ ++ positional arguments: ++ echo echo the string you use here ++ ++ optional arguments: ++ -h, --help show this help message and exit ++ ++Now, how about doing something even more useful:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("square", help="display a square of a given number") ++ args = parser.parse_args() ++ print(args.square**2) ++ ++Following is a result of running the code: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py 4 ++ Traceback (most recent call last): ++ File "prog.py", line 5, in ++ print(args.square**2) ++ TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int' ++ ++That didn't go so well. That's because :mod:`argparse` treats the options we ++give it as strings, unless we tell it otherwise. So, let's tell ++:mod:`argparse` to treat that input as an integer:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("square", help="display a square of a given number", ++ type=int) ++ args = parser.parse_args() ++ print(args.square**2) ++ ++Following is a result of running the code: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py 4 ++ 16 ++ $ python3 prog.py four ++ usage: prog.py [-h] square ++ prog.py: error: argument square: invalid int value: 'four' ++ ++That went well. The program now even helpfully quits on bad illegal input ++before proceeding. ++ ++ ++Introducing Optional arguments ++============================== ++ ++So far we, have been playing with positional arguments. Let us ++have a look on how to add optional ones:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("--verbosity", help="increase output verbosity") ++ args = parser.parse_args() ++ if args.verbosity: ++ print("verbosity turned on") ++ ++And the output: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py --verbosity 1 ++ verbosity turned on ++ $ python3 prog.py ++ $ python3 prog.py --help ++ usage: prog.py [-h] [--verbosity VERBOSITY] ++ ++ optional arguments: ++ -h, --help show this help message and exit ++ --verbosity VERBOSITY ++ increase output verbosity ++ $ python3 prog.py --verbosity ++ usage: prog.py [-h] [--verbosity VERBOSITY] ++ prog.py: error: argument --verbosity: expected one argument ++ ++Here is what is happening: ++ ++* The program is written so as to display something when ``--verbosity`` is ++ specified and display nothing when not. ++ ++* To show that the option is actually optional, there is no error when running ++ the program without it. Note that by default, if an optional argument isn't ++ used, the relevant variable, in this case :attr:`args.verbosity`, is ++ given ``None`` as a value, which is the reason it fails the truth ++ test of the :keyword:`if` statement. ++ ++* The help message is a bit different. ++ ++* When using the ``--verbosity`` option, one must also specify some value, ++ any value. ++ ++The above example accepts arbitrary integer values for ``--verbosity``, but for ++our simple program, only two values are actually useful, ``True`` or ``False``. ++Let's modify the code accordingly:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("--verbose", help="increase output verbosity", ++ action="store_true") ++ args = parser.parse_args() ++ if args.verbose: ++ print("verbosity turned on") ++ ++And the output: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py --verbose ++ verbosity turned on ++ $ python3 prog.py --verbose 1 ++ usage: prog.py [-h] [--verbose] ++ prog.py: error: unrecognized arguments: 1 ++ $ python3 prog.py --help ++ usage: prog.py [-h] [--verbose] ++ ++ optional arguments: ++ -h, --help show this help message and exit ++ --verbose increase output verbosity ++ ++Here is what is happening: ++ ++* The option is now more of a flag than something that requires a value. ++ We even changed the name of the option to match that idea. ++ Note that we now specify a new keyword, ``action``, and give it the value ++ ``"store_true"``. This means that, if the option is specified, ++ assign the value ``True`` to :data:`args.verbose`. ++ Not specifying it implies ``False``. ++ ++* It complains when you specify a value, in true spirit of what flags ++ actually are. ++ ++* Notice the different help text. ++ ++ ++Short options ++------------- ++ ++If you are familiar with command line usage, ++you will notice that I haven't yet touched on the topic of short ++versions of the options. It's quite simple:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("-v", "--verbose", help="increase output verbosity", ++ action="store_true") ++ args = parser.parse_args() ++ if args.verbose: ++ print("verbosity turned on") ++ ++And here goes: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py -v ++ verbosity turned on ++ $ python3 prog.py --help ++ usage: prog.py [-h] [-v] ++ ++ optional arguments: ++ -h, --help show this help message and exit ++ -v, --verbose increase output verbosity ++ ++Note that the new ability is also reflected in the help text. ++ ++ ++Combining Positional and Optional arguments ++=========================================== ++ ++Our program keeps growing in complexity:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("square", type=int, ++ help="display a square of a given number") ++ parser.add_argument("-v", "--verbose", action="store_true", ++ help="increase output verbosity") ++ args = parser.parse_args() ++ answer = args.square**2 ++ if args.verbose: ++ print("the square of {} equals {}".format(args.square, answer)) ++ else: ++ print(answer) ++ ++And now the output: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py ++ usage: prog.py [-h] [-v] square ++ prog.py: error: the following arguments are required: square ++ $ python3 prog.py 4 ++ 16 ++ $ python3 prog.py 4 --verbose ++ the square of 4 equals 16 ++ $ python3 prog.py --verbose 4 ++ the square of 4 equals 16 ++ ++* We've brought back a positional argument, hence the complaint. ++ ++* Note that the order does not matter. ++ ++How about we give this program of ours back the ability to have ++multiple verbosity values, and actually get to use them:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("square", type=int, ++ help="display a square of a given number") ++ parser.add_argument("-v", "--verbosity", type=int, ++ help="increase output verbosity") ++ args = parser.parse_args() ++ answer = args.square**2 ++ if args.verbosity == 2: ++ print("the square of {} equals {}".format(args.square, answer)) ++ elif args.verbosity == 1: ++ print("{}^2 == {}".format(args.square, answer)) ++ else: ++ print(answer) ++ ++And the output: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py 4 ++ 16 ++ $ python3 prog.py 4 -v ++ usage: prog.py [-h] [-v VERBOSITY] square ++ prog.py: error: argument -v/--verbosity: expected one argument ++ $ python3 prog.py 4 -v 1 ++ 4^2 == 16 ++ $ python3 prog.py 4 -v 2 ++ the square of 4 equals 16 ++ $ python3 prog.py 4 -v 3 ++ 16 ++ ++These all look good except the last one, which exposes a bug in our program. ++Let's fix it by restricting the values the ``--verbosity`` option can accept:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("square", type=int, ++ help="display a square of a given number") ++ parser.add_argument("-v", "--verbosity", type=int, choices=[0, 1, 2], ++ help="increase output verbosity") ++ args = parser.parse_args() ++ answer = args.square**2 ++ if args.verbosity == 2: ++ print("the square of {} equals {}".format(args.square, answer)) ++ elif args.verbosity == 1: ++ print("{}^2 == {}".format(args.square, answer)) ++ else: ++ print(answer) ++ ++And the output: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py 4 -v 3 ++ usage: prog.py [-h] [-v {0,1,2}] square ++ prog.py: error: argument -v/--verbosity: invalid choice: 3 (choose from 0, 1, 2) ++ $ python3 prog.py 4 -h ++ usage: prog.py [-h] [-v {0,1,2}] square ++ ++ positional arguments: ++ square display a square of a given number ++ ++ optional arguments: ++ -h, --help show this help message and exit ++ -v {0,1,2}, --verbosity {0,1,2} ++ increase output verbosity ++ ++Note that the change also reflects both in the error message as well as the ++help string. ++ ++Now, let's use a different approach of playing with verbosity, which is pretty ++common. It also matches the way the CPython executable handles its own ++verbosity argument (check the output of ``python --help``):: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("square", type=int, ++ help="display the square of a given number") ++ parser.add_argument("-v", "--verbosity", action="count", ++ help="increase output verbosity") ++ args = parser.parse_args() ++ answer = args.square**2 ++ if args.verbosity == 2: ++ print("the square of {} equals {}".format(args.square, answer)) ++ elif args.verbosity == 1: ++ print("{}^2 == {}".format(args.square, answer)) ++ else: ++ print(answer) ++ ++We have introduced another action, "count", ++to count the number of occurences of a specific optional arguments: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py 4 ++ 16 ++ $ python3 prog.py 4 -v ++ 4^2 == 16 ++ $ python3 prog.py 4 -vv ++ the square of 4 equals 16 ++ $ python3 prog.py 4 --verbosity --verbosity ++ the square of 4 equals 16 ++ $ python3 prog.py 4 -v 1 ++ usage: prog.py [-h] [-v] square ++ prog.py: error: unrecognized arguments: 1 ++ $ python3 prog.py 4 -h ++ usage: prog.py [-h] [-v] square ++ ++ positional arguments: ++ square display a square of a given number ++ ++ optional arguments: ++ -h, --help show this help message and exit ++ -v, --verbosity increase output verbosity ++ $ python3 prog.py 4 -vvv ++ 16 ++ ++* Yes, it's now more of a flag (similar to ``action="store_true"``) in the ++ previous version of our script. That should explain the complaint. ++ ++* It also behaves similar to "store_true" action. ++ ++* Now here's a demonstration of what the "count" action gives. You've probably ++ seen this sort of usage before. ++ ++* And, just like the "store_true" action, if you don't specify the ``-v`` flag, ++ that flag is considered to have ``None`` value. ++ ++* As should be expected, specifying the long form of the flag, we should get ++ the same output. ++ ++* Sadly, our help output isn't very informative on the new ability our script ++ has acquired, but that can always be fixed by improving the documentation for ++ out script (e.g. via the ``help`` keyword argument). ++ ++* That last output exposes a bug in our program. ++ ++ ++Let's fix:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("square", type=int, ++ help="display a square of a given number") ++ parser.add_argument("-v", "--verbosity", action="count", ++ help="increase output verbosity") ++ args = parser.parse_args() ++ answer = args.square**2 ++ ++ # bugfix: replace == with >= ++ if args.verbosity >= 2: ++ print("the square of {} equals {}".format(args.square, answer)) ++ elif args.verbosity >= 1: ++ print("{}^2 == {}".format(args.square, answer)) ++ else: ++ print(answer) ++ ++And this is what it gives: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py 4 -vvv ++ the square of 4 equals 16 ++ $ python3 prog.py 4 -vvvv ++ the square of 4 equals 16 ++ $ python3 prog.py 4 ++ Traceback (most recent call last): ++ File "prog.py", line 11, in ++ if args.verbosity >= 2: ++ TypeError: unorderable types: NoneType() >= int() ++ ++* First output went well, and fixes the bug we had before. ++ That is, we want any value >= 2 to be as verbose as possible. ++ ++* Third output not so good. ++ ++Let's fix that bug:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("square", type=int, ++ help="display a square of a given number") ++ parser.add_argument("-v", "--verbosity", action="count", default=0, ++ help="increase output verbosity") ++ args = parser.parse_args() ++ answer = args.square**2 ++ if args.verbosity >= 2: ++ print("the square of {} equals {}".format(args.square, answer)) ++ elif args.verbosity >= 1: ++ print("{}^2 == {}".format(args.square, answer)) ++ else: ++ print(answer) ++ ++We've just introduced yet another keyword, ``default``. ++We've set it to ``0`` in order to make it comparable to the other int values. ++Remember that by default, ++if an optional argument isn't specified, ++it gets the ``None`` value, and that cannot be compared to an int value ++(hence the :exc:`TypeError` exception). ++ ++And: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py 4 ++ 16 ++ ++You can go quite far just with what we've learned so far, ++and we have only scratched the surface. ++The :mod:`argparse` module is very powerful, ++and we'll explore a bit more of it before we end this tutorial. ++ ++ ++Getting a little more advanced ++============================== ++ ++What if we wanted to expand our tiny program to perform other powers, ++not just squares:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("x", type=int, help="the base") ++ parser.add_argument("y", type=int, help="the exponent") ++ parser.add_argument("-v", "--verbosity", action="count", default=0) ++ args = parser.parse_args() ++ answer = args.x**args.y ++ if args.verbosity >= 2: ++ print("{} to the power {} equals {}".format(args.x, args.y, answer)) ++ elif args.verbosity >= 1: ++ print("{}^{} == {}".format(args.x, args.y, answer)) ++ else: ++ print(answer) ++ ++Output: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py ++ usage: prog.py [-h] [-v] x y ++ prog.py: error: the following arguments are required: x, y ++ $ python3 prog.py -h ++ usage: prog.py [-h] [-v] x y ++ ++ positional arguments: ++ x the base ++ y the exponent ++ ++ optional arguments: ++ -h, --help show this help message and exit ++ -v, --verbosity ++ $ python3 prog.py 4 2 -v ++ 4^2 == 16 ++ ++ ++Notice that so far we've been using verbosity level to *change* the text ++that gets displayed. The following example instead uses verbosity level ++to display *more* text instead:: ++ ++ import argparse ++ parser = argparse.ArgumentParser() ++ parser.add_argument("x", type=int, help="the base") ++ parser.add_argument("y", type=int, help="the exponent") ++ parser.add_argument("-v", "--verbosity", action="count", default=0) ++ args = parser.parse_args() ++ answer = args.x**args.y ++ if args.verbosity >= 2: ++ print("Running '{}'".format(__file__)) ++ if args.verbosity >= 1: ++ print("{}^{} == ".format(args.x, args.y), end="") ++ print(answer) ++ ++Output: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py 4 2 ++ 16 ++ $ python3 prog.py 4 2 -v ++ 4^2 == 16 ++ $ python3 prog.py 4 2 -vv ++ Running 'prog.py' ++ 4^2 == 16 ++ ++ ++Conflicting options ++------------------- ++ ++So far, we have been working with two methods of an ++:class:`argparse.ArgumentParser` instance. Let's introduce a third one, ++:meth:`add_mutually_exclusive_group`. It allows for us to specify options that ++conflict with each other. Let's also change the rest of the program make the ++new functionality makes more sense: ++we'll introduce the ``--quiet`` option, ++which will be the opposite of the ``--verbose`` one:: ++ ++ import argparse ++ ++ parser = argparse.ArgumentParser() ++ group = parser.add_mutually_exclusive_group() ++ group.add_argument("-v", "--verbose", action="store_true") ++ group.add_argument("-q", "--quiet", action="store_true") ++ parser.add_argument("x", type=int, help="the base") ++ parser.add_argument("y", type=int, help="the exponent") ++ args = parser.parse_args() ++ answer = args.x**args.y ++ ++ if args.quiet: ++ print(answer) ++ elif args.verbose: ++ print("{} to the power {} equals {}".format(args.x, args.y, answer)) ++ else: ++ print("{}^{} == {}".format(args.x, args.y, answer)) ++ ++Our program is now simpler, and we've lost some functionality for the sake of ++demonstration. Anyways, here's the output: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py 4 2 ++ 4^2 == 16 ++ $ python3 prog.py 4 2 -q ++ 16 ++ $ python3 prog.py 4 2 -v ++ 4 to the power 2 equals 16 ++ $ python3 prog.py 4 2 -vq ++ usage: prog.py [-h] [-v | -q] x y ++ prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose ++ $ python3 prog.py 4 2 -v --quiet ++ usage: prog.py [-h] [-v | -q] x y ++ prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose ++ ++That should be easy to follow. I've added that last output so you can see the ++sort of flexibility you get, i.e. mixing long form options with short form ++ones. ++ ++Before we conclude, you probably want to tell your users the main purpose of ++your program, just in case they don't know:: ++ ++ import argparse ++ ++ parser = argparse.ArgumentParser(description="calculate X to the power of Y") ++ group = parser.add_mutually_exclusive_group() ++ group.add_argument("-v", "--verbose", action="store_true") ++ group.add_argument("-q", "--quiet", action="store_true") ++ parser.add_argument("x", type=int, help="the base") ++ parser.add_argument("y", type=int, help="the exponent") ++ args = parser.parse_args() ++ answer = args.x**args.y ++ ++ if args.quiet: ++ print(answer) ++ elif args.verbose: ++ print("{} to the power {} equals {}".format(args.x, args.y, answer)) ++ else: ++ print("{}^{} == {}".format(args.x, args.y, answer)) ++ ++Note that slight difference in the usage text. Note the ``[-v | -q]``, ++which tells us that we can either use ``-v`` or ``-q``, ++but not both at the same time: ++ ++.. code-block:: sh ++ ++ $ python3 prog.py --help ++ usage: prog.py [-h] [-v | -q] x y ++ ++ calculate X to the power of Y ++ ++ positional arguments: ++ x the base ++ y the exponent ++ ++ optional arguments: ++ -h, --help show this help message and exit ++ -v, --verbose ++ -q, --quiet ++ ++ ++Conclusion ++========== ++ ++The :mod:`argparse` module offers a lot more than shown here. ++Its docs are quite detailed and thorough, and full of examples. ++Having gone through this tutorial, you should easily digest them ++without feeling overwhelmed. +diff -r 3d0686d90f55 Doc/howto/cporting.rst +--- a/Doc/howto/cporting.rst ++++ b/Doc/howto/cporting.rst +@@ -2,27 +2,28 @@ + + .. _cporting-howto: + +-******************************** +-Porting Extension Modules to 3.0 +-******************************** ++************************************* ++Porting Extension Modules to Python 3 ++************************************* + + :author: Benjamin Peterson + + + .. topic:: Abstract + +- Although changing the C-API was not one of Python 3.0's objectives, the many +- Python level changes made leaving 2.x's API intact impossible. In fact, some +- changes such as :func:`int` and :func:`long` unification are more obvious on +- the C level. This document endeavors to document incompatibilities and how +- they can be worked around. ++ Although changing the C-API was not one of Python 3's objectives, ++ the many Python-level changes made leaving Python 2's API intact ++ impossible. In fact, some changes such as :func:`int` and ++ :func:`long` unification are more obvious on the C level. This ++ document endeavors to document incompatibilities and how they can ++ be worked around. + + + Conditional compilation + ======================= + +-The easiest way to compile only some code for 3.0 is to check if +-:c:macro:`PY_MAJOR_VERSION` is greater than or equal to 3. :: ++The easiest way to compile only some code for Python 3 is to check ++if :c:macro:`PY_MAJOR_VERSION` is greater than or equal to 3. :: + + #if PY_MAJOR_VERSION >= 3 + #define IS_PY3K +@@ -35,7 +36,7 @@ + Changes to Object APIs + ====================== + +-Python 3.0 merged together some types with similar functions while cleanly ++Python 3 merged together some types with similar functions while cleanly + separating others. + + +@@ -43,14 +44,14 @@ + ----------------------- + + +-Python 3.0's :func:`str` (``PyString_*`` functions in C) type is equivalent to +-2.x's :func:`unicode` (``PyUnicode_*``). The old 8-bit string type has become +-:func:`bytes`. Python 2.6 and later provide a compatibility header, ++Python 3's :func:`str` (``PyString_*`` functions in C) type is equivalent to ++Python 2's :func:`unicode` (``PyUnicode_*``). The old 8-bit string type has ++become :func:`bytes`. Python 2.6 and later provide a compatibility header, + :file:`bytesobject.h`, mapping ``PyBytes`` names to ``PyString`` ones. For best +-compatibility with 3.0, :c:type:`PyUnicode` should be used for textual data and ++compatibility with Python 3, :c:type:`PyUnicode` should be used for textual data and + :c:type:`PyBytes` for binary data. It's also important to remember that +-:c:type:`PyBytes` and :c:type:`PyUnicode` in 3.0 are not interchangeable like +-:c:type:`PyString` and :c:type:`PyUnicode` are in 2.x. The following example ++:c:type:`PyBytes` and :c:type:`PyUnicode` in Python 3 are not interchangeable like ++:c:type:`PyString` and :c:type:`PyUnicode` are in Python 2. The following example + shows best practices with regards to :c:type:`PyUnicode`, :c:type:`PyString`, + and :c:type:`PyBytes`. :: + +@@ -94,10 +95,12 @@ + long/int Unification + -------------------- + +-In Python 3.0, there is only one integer type. It is called :func:`int` on the +-Python level, but actually corresponds to 2.x's :func:`long` type. In the +-C-API, ``PyInt_*`` functions are replaced by their ``PyLong_*`` neighbors. The +-best course of action here is using the ``PyInt_*`` functions aliased to ++Python 3 has only one integer type, :func:`int`. But it actually ++corresponds to Python 2's :func:`long` type--the :func:`int` type ++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. :: + +@@ -120,10 +123,11 @@ + Module initialization and state + =============================== + +-Python 3.0 has a revamped extension module initialization system. (See +-:pep:`3121`.) Instead of storing module state in globals, they should be stored +-in an interpreter specific structure. Creating modules that act correctly in +-both 2.x and 3.0 is tricky. The following simple example demonstrates how. :: ++Python 3 has a revamped extension module initialization system. (See ++:pep:`3121`.) Instead of storing module state in globals, they should ++be stored in an interpreter specific structure. Creating modules that ++act correctly in both Python 2 and Python 3 is tricky. The following ++simple example demonstrates how. :: + + #include "Python.h" + +@@ -209,10 +213,65 @@ + } + + ++CObject replaced with Capsule ++============================= ++ ++The :c:type:`Capsule` object was introduced in Python 3.1 and 2.7 to replace ++:c:type:`CObject`. CObjects were useful, ++but the :c:type:`CObject` API was problematic: it didn't permit distinguishing ++between valid CObjects, which allowed mismatched CObjects to crash the ++interpreter, and some of its APIs relied on undefined behavior in C. ++(For further reading on the rationale behind Capsules, please see :issue:`5630`.) ++ ++If you're currently using CObjects, and you want to migrate to 3.1 or newer, ++you'll need to switch to Capsules. ++:c:type:`CObject` was deprecated in 3.1 and 2.7 and completely removed in ++Python 3.2. If you only support 2.7, or 3.1 and above, you ++can simply switch to :c:type:`Capsule`. If you need to support Python 3.0, ++or versions of Python earlier than 2.7, ++you'll have to support both CObjects and Capsules. ++(Note that Python 3.0 is no longer supported, and it is not recommended ++for production use.) ++ ++The following example header file :file:`capsulethunk.h` may ++solve the problem for you. Simply write your code against the ++:c:type:`Capsule` API and include this header file after ++:file:`Python.h`. Your code will automatically use Capsules ++in versions of Python with Capsules, and switch to CObjects ++when Capsules are unavailable. ++ ++:file:`capsulethunk.h` simulates Capsules using CObjects. However, ++:c:type:`CObject` provides no place to store the capsule's "name". As a ++result the simulated :c:type:`Capsule` objects created by :file:`capsulethunk.h` ++behave slightly differently from real Capsules. Specifically: ++ ++ * The name parameter passed in to :c:func:`PyCapsule_New` is ignored. ++ ++ * The name parameter passed in to :c:func:`PyCapsule_IsValid` and ++ :c:func:`PyCapsule_GetPointer` is ignored, and no error checking ++ of the name is performed. ++ ++ * :c:func:`PyCapsule_GetName` always returns NULL. ++ ++ * :c:func:`PyCapsule_SetName` always throws an exception and ++ returns failure. (Since there's no way to store a name ++ in a CObject, noisy failure of :c:func:`PyCapsule_SetName` ++ was deemed preferable to silent failure here. If this is ++ inconvenient, feel free to modify your local ++ copy as you see fit.) ++ ++You can find :file:`capsulethunk.h` in the Python source distribution ++as :source:`Doc/includes/capsulethunk.h`. We also include it here for ++your convenience: ++ ++.. literalinclude:: ../includes/capsulethunk.h ++ ++ ++ + Other options + ============= + + If you are writing a new extension module, you might consider `Cython + `_. It translates a Python-like language to C. The +-extension modules it creates are compatible with Python 3.x and 2.x. ++extension modules it creates are compatible with Python 3 and Python 2. + +diff -r 3d0686d90f55 Doc/howto/curses.rst +--- a/Doc/howto/curses.rst ++++ b/Doc/howto/curses.rst +@@ -118,7 +118,7 @@ + A common problem when debugging a curses application is to get your terminal + messed up when the application dies without restoring the terminal to its + previous state. In Python this commonly happens when your code is buggy and +-raises an uncaught exception. Keys are no longer be echoed to the screen when ++raises an uncaught exception. Keys are no longer echoed to the screen when + you type them, for example, which makes using the shell difficult. + + In Python you can avoid these complications and make debugging much easier by +@@ -271,7 +271,7 @@ + highlight certain words. curses supports this by allowing you to specify an + attribute for each cell on the screen. + +-An attribute is a integer, each bit representing a different attribute. You can ++An attribute is an integer, each bit representing a different attribute. You can + try to display text with multiple attribute bits set, but curses doesn't + guarantee that all the possible combinations are available, or that they're all + visually distinct. That depends on the ability of the terminal being used, so +@@ -300,7 +300,7 @@ + curses.A_REVERSE) + stdscr.refresh() + +-The curses library also supports color on those terminals that provide it, The ++The curses library also supports color on those terminals that provide it. The + most common such terminal is probably the Linux console, followed by color + xterms. + +diff -r 3d0686d90f55 Doc/howto/index.rst +--- a/Doc/howto/index.rst ++++ b/Doc/howto/index.rst +@@ -27,4 +27,5 @@ + unicode.rst + urllib2.rst + webservers.rst ++ argparse.rst + +diff -r 3d0686d90f55 Doc/howto/logging-cookbook.rst +--- a/Doc/howto/logging-cookbook.rst ++++ b/Doc/howto/logging-cookbook.rst +@@ -268,12 +268,12 @@ + .. currentmodule:: logging.handlers + + Sometimes you have to get your logging handlers to do their work without +-blocking the thread you’re logging from. This is common in Web applications, ++blocking the thread you're logging from. This is common in Web applications, + though of course it also occurs in other scenarios. + + A common culprit which demonstrates sluggish behaviour is the + :class:`SMTPHandler`: sending emails can take a long time, for a +-number of reasons outside the developer’s control (for example, a poorly ++number of reasons outside the developer's control (for example, a poorly + performing mail or network infrastructure). But almost any network-based + handler can block: Even a :class:`SocketHandler` operation may do a + DNS query under the hood which is too slow (and this query can be deep in the +@@ -292,7 +292,7 @@ + + The second part of the solution is :class:`QueueListener`, which has been + designed as the counterpart to :class:`QueueHandler`. A +-:class:`QueueListener` is very simple: it’s passed a queue and some handlers, ++:class:`QueueListener` is very simple: it's passed a queue and some handlers, + and it fires up an internal thread which listens to its queue for LogRecords + sent from ``QueueHandlers`` (or any other source of ``LogRecords``, for that + matter). The ``LogRecords`` are removed from the queue and passed to the +@@ -745,7 +745,7 @@ + raise + except: + import sys, traceback +- print >> sys.stderr, 'Whoops! Problem:' ++ print('Whoops! Problem:', file=sys.stderr) + traceback.print_exc(file=sys.stderr) + + # Arrays used for random selections in this demo +@@ -964,6 +964,219 @@ + Obviously this example sets the log length much too small as an extreme + example. You would want to set *maxBytes* to an appropriate value. + ++.. _format-styles: ++ ++Use of alternative formatting styles ++------------------------------------ ++ ++When logging was added to the Python standard library, the only way of ++formatting messages with variable content was to use the %-formatting ++method. Since then, Python has gained two new formatting approaches: ++:class:`string.Template` (added in Python 2.4) and :meth:`str.format` ++(added in Python 2.6). ++ ++Logging (as of 3.2) provides improved support for these two additional ++formatting styles. The :class:`Formatter` class been enhanced to take an ++additional, optional keyword parameter named ``style``. This defaults to ++``'%'``, but other possible values are ``'{'`` and ``'$'``, which correspond ++to the other two formatting styles. Backwards compatibility is maintained by ++default (as you would expect), but by explicitly specifying a style parameter, ++you get the ability to specify format strings which work with ++:meth:`str.format` or :class:`string.Template`. Here's an example console ++session to show the possibilities: ++ ++.. code-block:: pycon ++ ++ >>> import logging ++ >>> root = logging.getLogger() ++ >>> root.setLevel(logging.DEBUG) ++ >>> handler = logging.StreamHandler() ++ >>> bf = logging.Formatter('{asctime} {name} {levelname:8s} {message}', ++ ... style='{') ++ >>> handler.setFormatter(bf) ++ >>> root.addHandler(handler) ++ >>> logger = logging.getLogger('foo.bar') ++ >>> logger.debug('This is a DEBUG message') ++ 2010-10-28 15:11:55,341 foo.bar DEBUG This is a DEBUG message ++ >>> logger.critical('This is a CRITICAL message') ++ 2010-10-28 15:12:11,526 foo.bar CRITICAL This is a CRITICAL message ++ >>> df = logging.Formatter('$asctime $name ${levelname} $message', ++ ... style='$') ++ >>> handler.setFormatter(df) ++ >>> logger.debug('This is a DEBUG message') ++ 2010-10-28 15:13:06,924 foo.bar DEBUG This is a DEBUG message ++ >>> logger.critical('This is a CRITICAL message') ++ 2010-10-28 15:13:11,494 foo.bar CRITICAL This is a CRITICAL message ++ >>> ++ ++Note that the formatting of logging messages for final output to logs is ++completely independent of how an individual logging message is constructed. ++That can still use %-formatting, as shown here:: ++ ++ >>> logger.error('This is an%s %s %s', 'other,', 'ERROR,', 'message') ++ 2010-10-28 15:19:29,833 foo.bar ERROR This is another, ERROR, message ++ >>> ++ ++Logging calls (``logger.debug()``, ``logger.info()`` etc.) only take ++positional parameters for the actual logging message itself, with keyword ++parameters used only for determining options for how to handle the actual ++logging call (e.g. the ``exc_info`` keyword parameter to indicate that ++traceback information should be logged, or the ``extra`` keyword parameter ++to indicate additional contextual information to be added to the log). So ++you cannot directly make logging calls using :meth:`str.format` or ++:class:`string.Template` syntax, because internally the logging package ++uses %-formatting to merge the format string and the variable arguments. ++There would no changing this while preserving backward compatibility, since ++all logging calls which are out there in existing code will be using %-format ++strings. ++ ++There is, however, a way that you can use {}- and $- formatting to construct ++your individual log messages. Recall that for a message you can use an ++arbitrary object as a message format string, and that the logging package will ++call ``str()`` on that object to get the actual format string. Consider the ++following two classes:: ++ ++ class BraceMessage(object): ++ def __init__(self, fmt, *args, **kwargs): ++ self.fmt = fmt ++ self.args = args ++ self.kwargs = kwargs ++ ++ def __str__(self): ++ return self.fmt.format(*self.args, **self.kwargs) ++ ++ class DollarMessage(object): ++ def __init__(self, fmt, **kwargs): ++ self.fmt = fmt ++ self.kwargs = kwargs ++ ++ def __str__(self): ++ from string import Template ++ return Template(self.fmt).substitute(**self.kwargs) ++ ++Either of these can be used in place of a format string, to allow {}- or ++$-formatting to be used to build the actual "message" part which appears in the ++formatted log output in place of "%(message)s" or "{message}" or "$message". ++It's a little unwieldy to use the class names whenever you want to log ++something, but it's quite palatable if you use an alias such as __ (double ++underscore – not to be confused with _, the single underscore used as a ++synonym/alias for :func:`gettext.gettext` or its brethren). ++ ++The above classes are not included in Python, though they're easy enough to ++copy and paste into your own code. They can be used as follows (assuming that ++they're declared in a module called ``wherever``): ++ ++.. code-block:: pycon ++ ++ >>> from wherever import BraceMessage as __ ++ >>> print(__('Message with {0} {name}', 2, name='placeholders')) ++ Message with 2 placeholders ++ >>> class Point: pass ++ ... ++ >>> p = Point() ++ >>> p.x = 0.5 ++ >>> p.y = 0.5 ++ >>> print(__('Message with coordinates: ({point.x:.2f}, {point.y:.2f})', ++ ... point=p)) ++ Message with coordinates: (0.50, 0.50) ++ >>> from wherever import DollarMessage as __ ++ >>> print(__('Message with $num $what', num=2, what='placeholders')) ++ Message with 2 placeholders ++ >>> ++ ++While the above examples use ``print()`` to show how the formatting works, you ++would of course use ``logger.debug()`` or similar to actually log using this ++approach. ++ ++One thing to note is that you pay no significant performance penalty with this ++approach: the actual formatting happens not when you make the logging call, but ++when (and if) the logged message is actually about to be output to a log by a ++handler. So the only slightly unusual thing which might trip you up is that the ++parentheses go around the format string and the arguments, not just the format ++string. That's because the __ notation is just syntax sugar for a constructor ++call to one of the XXXMessage classes. ++ ++ ++.. currentmodule:: logging ++ ++.. _custom-logrecord: ++ ++Customising ``LogRecord`` ++------------------------- ++ ++Every logging event is represented by a :class:`LogRecord` instance. ++When an event is logged and not filtered out by a logger's level, a ++:class:`LogRecord` is created, populated with information about the event and ++then passed to the handlers for that logger (and its ancestors, up to and ++including the logger where further propagation up the hierarchy is disabled). ++Before Python 3.2, there were only two places where this creation was done: ++ ++* :meth:`Logger.makeRecord`, which is called in the normal process of ++ logging an event. This invoked :class:`LogRecord` directly to create an ++ instance. ++* :func:`makeLogRecord`, which is called with a dictionary containing ++ attributes to be added to the LogRecord. This is typically invoked when a ++ suitable dictionary has been received over the network (e.g. in pickle form ++ via a :class:`~handlers.SocketHandler`, or in JSON form via an ++ :class:`~handlers.HTTPHandler`). ++ ++This has usually meant that if you need to do anything special with a ++:class:`LogRecord`, you've had to do one of the following. ++ ++* Create your own :class:`Logger` subclass, which overrides ++ :meth:`Logger.makeRecord`, and set it using :func:`~logging.setLoggerClass` ++ before any loggers that you care about are instantiated. ++* Add a :class:`Filter` to a logger or handler, which does the ++ necessary special manipulation you need when its ++ :meth:`~Filter.filter` method is called. ++ ++The first approach would be a little unwieldy in the scenario where (say) ++several different libraries wanted to do different things. Each would attempt ++to set its own :class:`Logger` subclass, and the one which did this last would ++win. ++ ++The second approach works reasonably well for many cases, but does not allow ++you to e.g. use a specialized subclass of :class:`LogRecord`. Library ++developers can set a suitable filter on their loggers, but they would have to ++remember to do this every time they introduced a new logger (which they would ++do simply by adding new packages or modules and doing :: ++ ++ logger = logging.getLogger(__name__) ++ ++at module level). It's probably one too many things to think about. Developers ++could also add the filter to a :class:`~logging.NullHandler` attached to their ++top-level logger, but this would not be invoked if an application developer ++attached a handler to a lower-level library logger – so output from that ++handler would not reflect the intentions of the library developer. ++ ++In Python 3.2 and later, :class:`~logging.LogRecord` creation is done through a ++factory, which you can specify. The factory is just a callable you can set with ++:func:`~logging.setLogRecordFactory`, and interrogate with ++:func:`~logging.getLogRecordFactory`. The factory is invoked with the same ++signature as the :class:`~logging.LogRecord` constructor, as :class:`LogRecord` ++is the default setting for the factory. ++ ++This approach allows a custom factory to control all aspects of LogRecord ++creation. For example, you could return a subclass, or just add some additional ++attributes to the record once created, using a pattern similar to this:: ++ ++ old_factory = logging.getLogRecordFactory() ++ ++ def record_factory(*args, **kwargs): ++ record = old_factory(*args, **kwargs) ++ record.custom_attribute = 0xdecafbad ++ return record ++ ++ logging.setLogRecordFactory(record_factory) ++ ++This pattern allows different libraries to chain factories together, and as ++long as they don't overwrite each other's attributes or unintentionally ++overwrite the attributes provided as standard, there should be no surprises. ++However, it should be borne in mind that each link in the chain adds run-time ++overhead to all logging operations, and the technique should only be used when ++the use of a :class:`Filter` does not provide the desired result. ++ ++ + .. _zeromq-handlers: + + Subclassing QueueHandler - a ZeroMQ example +@@ -1102,3 +1315,276 @@ + For more information about this configuration, you can see the `relevant + section `_ + of the Django documentation. ++ ++A more elaborate multiprocessing example ++---------------------------------------- ++ ++The following working example shows how logging can be used with multiprocessing ++using configuration files. The configurations are fairly simple, but serve to ++illustrate how more complex ones could be implemented in a real multiprocessing ++scenario. ++ ++In the example, the main process spawns a listener process and some worker ++processes. Each of the main process, the listener and the workers have three ++separate configurations (the workers all share the same configuration). We can ++see logging in the main process, how the workers log to a QueueHandler and how ++the listener implements a QueueListener and a more complex logging ++configuration, and arranges to dispatch events received via the queue to the ++handlers specified in the configuration. Note that these configurations are ++purely illustrative, but you should be able to adapt this example to your own ++scenario. ++ ++Here's the script - the docstrings and the comments hopefully explain how it ++works:: ++ ++ import logging ++ import logging.config ++ import logging.handlers ++ from multiprocessing import Process, Queue, Event, current_process ++ import os ++ import random ++ import time ++ ++ class MyHandler(object): ++ """ ++ A simple handler for logging events. It runs in the listener process and ++ dispatches events to loggers based on the name in the received record, ++ which then get dispatched, by the logging system, to the handlers ++ configured for those loggers. ++ """ ++ def handle(self, record): ++ logger = logging.getLogger(record.name) ++ # The process name is transformed just to show that it's the listener ++ # doing the logging to files and console ++ record.processName = '%s (for %s)' % (current_process().name, record.processName) ++ logger.handle(record) ++ ++ def listener_process(q, stop_event, config): ++ """ ++ This could be done in the main process, but is just done in a separate ++ process for illustrative purposes. ++ ++ This initialises logging according to the specified configuration, ++ starts the listener and waits for the main process to signal completion ++ via the event. The listener is then stopped, and the process exits. ++ """ ++ logging.config.dictConfig(config) ++ listener = logging.handlers.QueueListener(q, MyHandler()) ++ listener.start() ++ if os.name == 'posix': ++ # On POSIX, the setup logger will have been configured in the ++ # parent process, but should have been disabled following the ++ # dictConfig call. ++ # On Windows, since fork isn't used, the setup logger won't ++ # exist in the child, so it would be created and the message ++ # would appear - hence the "if posix" clause. ++ logger = logging.getLogger('setup') ++ logger.critical('Should not appear, because of disabled logger ...') ++ stop_event.wait() ++ listener.stop() ++ ++ def worker_process(config): ++ """ ++ A number of these are spawned for the purpose of illustration. In ++ practice, they could be a heterogenous bunch of processes rather than ++ ones which are identical to each other. ++ ++ This initialises logging according to the specified configuration, ++ and logs a hundred messages with random levels to randomly selected ++ loggers. ++ ++ A small sleep is added to allow other processes a chance to run. This ++ is not strictly needed, but it mixes the output from the different ++ processes a bit more than if it's left out. ++ """ ++ logging.config.dictConfig(config) ++ levels = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, ++ logging.CRITICAL] ++ loggers = ['foo', 'foo.bar', 'foo.bar.baz', ++ 'spam', 'spam.ham', 'spam.ham.eggs'] ++ if os.name == 'posix': ++ # On POSIX, the setup logger will have been configured in the ++ # parent process, but should have been disabled following the ++ # dictConfig call. ++ # On Windows, since fork isn't used, the setup logger won't ++ # exist in the child, so it would be created and the message ++ # would appear - hence the "if posix" clause. ++ logger = logging.getLogger('setup') ++ logger.critical('Should not appear, because of disabled logger ...') ++ for i in range(100): ++ lvl = random.choice(levels) ++ logger = logging.getLogger(random.choice(loggers)) ++ logger.log(lvl, 'Message no. %d', i) ++ time.sleep(0.01) ++ ++ def main(): ++ q = Queue() ++ # The main process gets a simple configuration which prints to the console. ++ config_initial = { ++ 'version': 1, ++ 'formatters': { ++ 'detailed': { ++ 'class': 'logging.Formatter', ++ 'format': '%(asctime)s %(name)-15s %(levelname)-8s %(processName)-10s %(message)s' ++ } ++ }, ++ 'handlers': { ++ 'console': { ++ 'class': 'logging.StreamHandler', ++ 'level': 'INFO', ++ }, ++ }, ++ 'root': { ++ 'level': 'DEBUG', ++ 'handlers': ['console'] ++ }, ++ } ++ # The worker process configuration is just a QueueHandler attached to the ++ # root logger, which allows all messages to be sent to the queue. ++ # We disable existing loggers to disable the "setup" logger used in the ++ # parent process. This is needed on POSIX because the logger will ++ # be there in the child following a fork(). ++ config_worker = { ++ 'version': 1, ++ 'disable_existing_loggers': True, ++ 'handlers': { ++ 'queue': { ++ 'class': 'logging.handlers.QueueHandler', ++ 'queue': q, ++ }, ++ }, ++ 'root': { ++ 'level': 'DEBUG', ++ 'handlers': ['queue'] ++ }, ++ } ++ # The listener process configuration shows that the full flexibility of ++ # logging configuration is available to dispatch events to handlers however ++ # you want. ++ # We disable existing loggers to disable the "setup" logger used in the ++ # parent process. This is needed on POSIX because the logger will ++ # be there in the child following a fork(). ++ config_listener = { ++ 'version': 1, ++ 'disable_existing_loggers': True, ++ 'formatters': { ++ 'detailed': { ++ 'class': 'logging.Formatter', ++ 'format': '%(asctime)s %(name)-15s %(levelname)-8s %(processName)-10s %(message)s' ++ }, ++ 'simple': { ++ 'class': 'logging.Formatter', ++ 'format': '%(name)-15s %(levelname)-8s %(processName)-10s %(message)s' ++ } ++ }, ++ 'handlers': { ++ 'console': { ++ 'class': 'logging.StreamHandler', ++ 'level': 'INFO', ++ 'formatter': 'simple', ++ }, ++ 'file': { ++ 'class': 'logging.FileHandler', ++ 'filename': 'mplog.log', ++ 'mode': 'w', ++ 'formatter': 'detailed', ++ }, ++ 'foofile': { ++ 'class': 'logging.FileHandler', ++ 'filename': 'mplog-foo.log', ++ 'mode': 'w', ++ 'formatter': 'detailed', ++ }, ++ 'errors': { ++ 'class': 'logging.FileHandler', ++ 'filename': 'mplog-errors.log', ++ 'mode': 'w', ++ 'level': 'ERROR', ++ 'formatter': 'detailed', ++ }, ++ }, ++ 'loggers': { ++ 'foo': { ++ 'handlers' : ['foofile'] ++ } ++ }, ++ 'root': { ++ 'level': 'DEBUG', ++ 'handlers': ['console', 'file', 'errors'] ++ }, ++ } ++ # Log some initial events, just to show that logging in the parent works ++ # normally. ++ logging.config.dictConfig(config_initial) ++ logger = logging.getLogger('setup') ++ logger.info('About to create workers ...') ++ workers = [] ++ for i in range(5): ++ wp = Process(target=worker_process, name='worker %d' % (i + 1), ++ args=(config_worker,)) ++ workers.append(wp) ++ wp.start() ++ logger.info('Started worker: %s', wp.name) ++ logger.info('About to create listener ...') ++ stop_event = Event() ++ lp = Process(target=listener_process, name='listener', ++ args=(q, stop_event, config_listener)) ++ lp.start() ++ logger.info('Started listener') ++ # We now hang around for the workers to finish their work. ++ for wp in workers: ++ wp.join() ++ # Workers all done, listening can now stop. ++ # Logging in the parent still works normally. ++ logger.info('Telling listener to stop ...') ++ stop_event.set() ++ lp.join() ++ logger.info('All done.') ++ ++ if __name__ == '__main__': ++ main() ++ ++ ++Inserting a BOM into messages sent to a SysLogHandler ++----------------------------------------------------- ++ ++`RFC 5424 `_ requires that a ++Unicode message be sent to a syslog daemon as a set of bytes which have the ++following structure: an optional pure-ASCII component, followed by a UTF-8 Byte ++Order Mark (BOM), followed by Unicode encoded using UTF-8. (See the `relevant ++section of the specification `_.) ++ ++In Python 3.1, code was added to ++:class:`~logging.handlers.SysLogHandler` to insert a BOM into the message, but ++unfortunately, it was implemented incorrectly, with the BOM appearing at the ++beginning of the message and hence not allowing any pure-ASCII component to ++appear before it. ++ ++As this behaviour is broken, the incorrect BOM insertion code is being removed ++from Python 3.2.4 and later. However, it is not being replaced, and if you ++want to produce RFC 5424-compliant messages which includes a BOM, an optional ++pure-ASCII sequence before it and arbitrary Unicode after it, encoded using ++UTF-8, then you need to do the following: ++ ++#. Attach a :class:`~logging.Formatter` instance to your ++ :class:`~logging.handlers.SysLogHandler` instance, with a format string ++ such as:: ++ ++ 'ASCII section\ufeffUnicode section' ++ ++ The Unicode code point ``'\feff```, when encoded using UTF-8, will be ++ encoded as a UTF-8 BOM -- the byte-string ``b'\xef\xbb\xbf'``. ++ ++#. Replace the ASCII section with whatever placeholders you like, but make sure ++ that the data that appears in there after substitution is always ASCII (that ++ way, it will remain unchanged after UTF-8 encoding). ++ ++#. Replace the Unicode section with whatever placeholders you like; if the data ++ which appears there after substitution is Unicode, that's fine -- it will be ++ encoded using UTF-8. ++ ++The formatted message *will* be encoded using UTF-8 encoding by ++``SysLogHandler``. If you follow the above rules, you should be able to produce ++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. ++ +diff -r 3d0686d90f55 Doc/howto/logging.rst +--- a/Doc/howto/logging.rst ++++ b/Doc/howto/logging.rst +@@ -651,6 +651,22 @@ + code approach, mainly separation of configuration and code and the ability of + noncoders to easily modify the logging properties. + ++.. warning:: The :func:`fileConfig` function takes a default parameter, ++ ``disable_existing_loggers``, which defaults to ``True`` for reasons of ++ backward compatibility. This may or may not be what you want, since it ++ will cause any loggers existing before the :func:`fileConfig` call to ++ be disabled unless they (or an ancestor) are explicitly named in the ++ configuration. Please refer to the reference documentation for more ++ information, and specify ``False`` for this parameter if you wish. ++ ++ The dictionary passed to :func:`dictConfig` can also specify a Boolean ++ value with key ``disable_existing_loggers``, which if not specified ++ explicitly in the dictionary also defaults to being interpreted as ++ ``True``. This leads to the logger-disabling behaviour described above, ++ which may not be what you want - in which case, provide the key ++ explicitly with a value of ``False``. ++ ++ + .. currentmodule:: logging + + Note that the class names referenced in config files need to be either relative +diff -r 3d0686d90f55 Doc/howto/pyporting.rst +--- a/Doc/howto/pyporting.rst ++++ b/Doc/howto/pyporting.rst +@@ -39,7 +39,7 @@ + Finally, you do have the option of :ref:`using 2to3 ` to translate + Python 2 code into Python 3 code (with some manual help). This can take the + form of branching your code and using 2to3 to start a Python 3 branch. You can +-also have users perform the translation as installation time automatically so ++also have users perform the translation at installation time automatically so + that you only have to maintain a Python 2 codebase. + + Regardless of which approach you choose, porting is not as hard or +@@ -234,7 +234,7 @@ + ``b'py'[1:2]`` is ``'y'`` in Python 2 and ``b'y'`` in Python 3 (i.e., close + enough). + +-You cannot concatenate bytes and strings in Python 3. But since in Python ++You cannot concatenate bytes and strings in Python 3. But since Python + 2 has bytes aliased to ``str``, it will succeed: ``b'a' + u'b'`` works in + Python 2, but ``b'a' + 'b'`` in Python 3 is a :exc:`TypeError`. A similar issue + also comes about when doing comparisons between bytes and strings. +@@ -328,7 +328,7 @@ + textual data, people have over the years been rather loose in their delineation + of what ``str`` instances held text compared to bytes. In Python 3 you cannot + be so care-free anymore and need to properly handle the difference. The key +-handling this issue to make sure that **every** string literal in your ++handling this issue is to make sure that **every** string literal in your + Python 2 code is either syntactically of functionally marked as either bytes or + text data. After this is done you then need to make sure your APIs are designed + to either handle a specific type or made to be properly polymorphic. +@@ -343,7 +343,7 @@ + and then designating textual data with a ``u`` prefix or using the + ``unicode_literals`` future statement. + +-If your project supports versions of Python pre-dating 2.6, then you should use ++If your project supports versions of Python predating 2.6, then you should use + the six_ project and its ``b()`` function to denote bytes literals. For text + literals you can either use six's ``u()`` function or use a ``u`` prefix. + +@@ -439,7 +439,7 @@ + There are two ways to solve this issue. One is to use a custom 2to3 fixer. The + blog post at http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/ + specifies how to do this. That will allow 2to3 to change all instances of ``def +-__unicode(self): ...`` to ``def __str__(self): ...``. This does require you ++__unicode(self): ...`` to ``def __str__(self): ...``. This does require that you + define your ``__str__()`` method in Python 2 before your ``__unicode__()`` + method. + +diff -r 3d0686d90f55 Doc/howto/regex.rst +--- a/Doc/howto/regex.rst ++++ b/Doc/howto/regex.rst +@@ -360,7 +360,7 @@ + + 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 +-:file:`Tools/demo/redemo.py`, a demonstration program included with the ++:source:`Tools/demo/redemo.py`, a demonstration program included with the + Python distribution. It allows you to enter REs and strings, and displays + whether the RE matches or fails. :file:`redemo.py` can be quite useful when + trying to debug a complicated RE. Phil Schwartz's `Kodos +@@ -495,7 +495,7 @@ + the same ones in several locations, then it might be worthwhile to collect all + the definitions in one place, in a section of code that compiles all the REs + ahead of time. To take an example from the standard library, here's an extract +-from the now deprecated :file:`xmllib.py`:: ++from the now-defunct Python 2 standard :mod:`xmllib` module:: + + ref = re.compile( ... ) + entityref = re.compile( ... ) +diff -r 3d0686d90f55 Doc/howto/sockets.rst +--- a/Doc/howto/sockets.rst ++++ b/Doc/howto/sockets.rst +@@ -153,7 +153,7 @@ + there, you may wait forever for the reply, because the request may still be in + your output buffer. + +-Now we come the major stumbling block of sockets - ``send`` and ``recv`` operate ++Now we come to the major stumbling block of sockets - ``send`` and ``recv`` operate + on the network buffers. They do not necessarily handle all the bytes you hand + them (or expect from them), because their major focus is handling the network + buffers. In general, they return when the associated network buffers have been +@@ -164,7 +164,7 @@ + When a ``recv`` returns 0 bytes, it means the other side has closed (or is in + the process of closing) the connection. You will not receive any more data on + this connection. Ever. You may be able to send data successfully; I'll talk +-about that some on the next page. ++more about this later. + + A protocol like HTTP uses a socket for only one transfer. The client sends a + request, then reads a reply. That's it. The socket is discarded. This means that +diff -r 3d0686d90f55 Doc/howto/sorting.rst +--- a/Doc/howto/sorting.rst ++++ b/Doc/howto/sorting.rst +@@ -42,7 +42,7 @@ + Key Functions + ============= + +-Both :meth:`list.sort` and :func:`sorted` have *key* parameter to specify a ++Both :meth:`list.sort` and :func:`sorted` have a *key* parameter to specify a + function to be called on each list element prior to making comparisons. + + For example, here's a case-insensitive string comparison: +@@ -89,7 +89,7 @@ + The key-function patterns shown above are very common, so Python provides + convenience functions to make accessor functions easier and faster. The + :mod:`operator` module has :func:`~operator.itemgetter`, +-:func:`~operator.attrgetter`, and an :func:`~operator.methodcaller` function. ++:func:`~operator.attrgetter`, and a :func:`~operator.methodcaller` function. + + Using those functions, the above examples become simpler and faster: + +@@ -114,7 +114,7 @@ + ======================== + + Both :meth:`list.sort` and :func:`sorted` accept a *reverse* parameter with a +-boolean value. This is using to flag descending sorts. For example, to get the ++boolean value. This is used to flag descending sorts. For example, to get the + student data in reverse *age* order: + + >>> sorted(student_tuples, key=itemgetter(2), reverse=True) +diff -r 3d0686d90f55 Doc/howto/urllib2.rst +--- a/Doc/howto/urllib2.rst ++++ b/Doc/howto/urllib2.rst +@@ -108,6 +108,7 @@ + 'language' : 'Python' } + + data = urllib.parse.urlencode(values) ++ data = data.encode('utf-8') # data should be bytes + req = urllib.request.Request(url, data) + response = urllib.request.urlopen(req) + the_page = response.read() +@@ -172,7 +173,8 @@ + 'language' : 'Python' } + headers = { 'User-Agent' : user_agent } + +- data = urllib.parse.urlencode(values) ++ data = urllib.parse.urlencode(values) ++ data = data.encode('utf-8') + req = urllib.request.Request(url, data, headers) + response = urllib.request.urlopen(req) + the_page = response.read() +@@ -446,12 +448,12 @@ + + When authentication is required, the server sends a header (as well as the 401 + error code) requesting authentication. This specifies the authentication scheme +-and a 'realm'. The header looks like : ``Www-authenticate: SCHEME ++and a 'realm'. The header looks like : ``WWW-Authenticate: SCHEME + realm="REALM"``. + + e.g. :: + +- Www-authenticate: Basic realm="cPanel Users" ++ WWW-Authenticate: Basic realm="cPanel Users" + + + The client should then retry the request with the appropriate name and password +diff -r 3d0686d90f55 Doc/includes/capsulethunk.h +--- /dev/null ++++ b/Doc/includes/capsulethunk.h +@@ -0,0 +1,134 @@ ++#ifndef __CAPSULETHUNK_H ++#define __CAPSULETHUNK_H ++ ++#if ( (PY_VERSION_HEX < 0x02070000) \ ++ || ((PY_VERSION_HEX >= 0x03000000) \ ++ && (PY_VERSION_HEX < 0x03010000)) ) ++ ++#define __PyCapsule_GetField(capsule, field, default_value) \ ++ ( PyCapsule_CheckExact(capsule) \ ++ ? (((PyCObject *)capsule)->field) \ ++ : (default_value) \ ++ ) \ ++ ++#define __PyCapsule_SetField(capsule, field, value) \ ++ ( PyCapsule_CheckExact(capsule) \ ++ ? (((PyCObject *)capsule)->field = value), 1 \ ++ : 0 \ ++ ) \ ++ ++ ++#define PyCapsule_Type PyCObject_Type ++ ++#define PyCapsule_CheckExact(capsule) (PyCObject_Check(capsule)) ++#define PyCapsule_IsValid(capsule, name) (PyCObject_Check(capsule)) ++ ++ ++#define PyCapsule_New(pointer, name, destructor) \ ++ (PyCObject_FromVoidPtr(pointer, destructor)) ++ ++ ++#define PyCapsule_GetPointer(capsule, name) \ ++ (PyCObject_AsVoidPtr(capsule)) ++ ++/* Don't call PyCObject_SetPointer here, it fails if there's a destructor */ ++#define PyCapsule_SetPointer(capsule, pointer) \ ++ __PyCapsule_SetField(capsule, cobject, pointer) ++ ++ ++#define PyCapsule_GetDestructor(capsule) \ ++ __PyCapsule_GetField(capsule, destructor) ++ ++#define PyCapsule_SetDestructor(capsule, dtor) \ ++ __PyCapsule_SetField(capsule, destructor, dtor) ++ ++ ++/* ++ * Sorry, there's simply no place ++ * to store a Capsule "name" in a CObject. ++ */ ++#define PyCapsule_GetName(capsule) NULL ++ ++static int ++PyCapsule_SetName(PyObject *capsule, const char *unused) ++{ ++ unused = unused; ++ PyErr_SetString(PyExc_NotImplementedError, ++ "can't use PyCapsule_SetName with CObjects"); ++ return 1; ++} ++ ++ ++ ++#define PyCapsule_GetContext(capsule) \ ++ __PyCapsule_GetField(capsule, descr) ++ ++#define PyCapsule_SetContext(capsule, context) \ ++ __PyCapsule_SetField(capsule, descr, context) ++ ++ ++static void * ++PyCapsule_Import(const char *name, int no_block) ++{ ++ PyObject *object = NULL; ++ void *return_value = NULL; ++ char *trace; ++ size_t name_length = (strlen(name) + 1) * sizeof(char); ++ char *name_dup = (char *)PyMem_MALLOC(name_length); ++ ++ if (!name_dup) { ++ return NULL; ++ } ++ ++ memcpy(name_dup, name, name_length); ++ ++ trace = name_dup; ++ while (trace) { ++ char *dot = strchr(trace, '.'); ++ if (dot) { ++ *dot++ = '\0'; ++ } ++ ++ if (object == NULL) { ++ if (no_block) { ++ object = PyImport_ImportModuleNoBlock(trace); ++ } else { ++ object = PyImport_ImportModule(trace); ++ if (!object) { ++ PyErr_Format(PyExc_ImportError, ++ "PyCapsule_Import could not " ++ "import module \"%s\"", trace); ++ } ++ } ++ } else { ++ PyObject *object2 = PyObject_GetAttrString(object, trace); ++ Py_DECREF(object); ++ object = object2; ++ } ++ if (!object) { ++ goto EXIT; ++ } ++ ++ trace = dot; ++ } ++ ++ if (PyCObject_Check(object)) { ++ PyCObject *cobject = (PyCObject *)object; ++ return_value = cobject->cobject; ++ } else { ++ PyErr_Format(PyExc_AttributeError, ++ "PyCapsule_Import \"%s\" is not valid", ++ name); ++ } ++ ++EXIT: ++ Py_XDECREF(object); ++ if (name_dup) { ++ PyMem_FREE(name_dup); ++ } ++ return return_value; ++} ++ ++#endif /* #if PY_VERSION_HEX < 0x02070000 */ ++ ++#endif /* __CAPSULETHUNK_H */ +diff -r 3d0686d90f55 Doc/library/__future__.rst +--- a/Doc/library/__future__.rst ++++ b/Doc/library/__future__.rst +@@ -75,7 +75,7 @@ + | division | 2.2.0a2 | 3.0 | :pep:`238`: | + | | | | *Changing the Division Operator* | + +------------------+-------------+--------------+---------------------------------------------+ +-| absolute_import | 2.5.0a1 | 2.7 | :pep:`328`: | ++| absolute_import | 2.5.0a1 | 3.0 | :pep:`328`: | + | | | | *Imports: Multi-Line and Absolute/Relative* | + +------------------+-------------+--------------+---------------------------------------------+ + | with_statement | 2.5.0a1 | 2.6 | :pep:`343`: | +diff -r 3d0686d90f55 Doc/library/argparse.rst +--- a/Doc/library/argparse.rst ++++ b/Doc/library/argparse.rst +@@ -12,6 +12,12 @@ + + -------------- + ++.. sidebar:: Tutorial ++ ++ This page contains the API reference information. For a more gentle ++ introduction to Python command-line parsing, have a look at the ++ :ref:`argparse tutorial `. ++ + The :mod:`argparse` module makes it easy to write user-friendly command-line + interfaces. The program defines what arguments it requires, and :mod:`argparse` + will figure out how to parse those out of :data:`sys.argv`. The :mod:`argparse` +@@ -1076,6 +1082,9 @@ + optional arguments: + -h, --help show this help message and exit + ++As the help string supports %-formatting, if you want a literal ``%`` to appear ++in the help string, you must escape it as ``%%``. ++ + :mod:`argparse` supports silencing the help entry for certain options, by + setting the ``help`` value to ``argparse.SUPPRESS``:: + +@@ -1642,8 +1651,8 @@ + + --bar BAR bar help + +- Note that any arguments not your user defined groups will end up back in the +- usual "positional arguments" and "optional arguments" sections. ++ Note that any arguments not in your user-defined groups will end up back ++ in the usual "positional arguments" and "optional arguments" sections. + + + Mutual exclusion +@@ -1833,9 +1842,10 @@ + * Replace all :meth:`optparse.OptionParser.add_option` calls with + :meth:`ArgumentParser.add_argument` calls. + +-* Replace ``options, args = parser.parse_args()`` with ``args = ++* Replace ``(options, args) = parser.parse_args()`` with ``args = + parser.parse_args()`` and add additional :meth:`ArgumentParser.add_argument` +- calls for the positional arguments. ++ calls for the positional arguments. Keep in mind that what was previously ++ called ``options``, now in :mod:`argparse` context is called ``args``. + + * Replace callback actions and the ``callback_*`` keyword arguments with + ``type`` or ``action`` arguments. +diff -r 3d0686d90f55 Doc/library/cgi.rst +--- a/Doc/library/cgi.rst ++++ b/Doc/library/cgi.rst +@@ -86,11 +86,14 @@ + tracking down bugs. You can always remove the ``cgitb`` line later when you + have tested your script and are confident that it works correctly. + +-To get at submitted form data, use the :class:`FieldStorage` class. Instantiate +-it exactly once, without arguments. This reads the form contents from standard +-input or the environment (depending on the value of various environment +-variables set according to the CGI standard). Since it may consume standard +-input, it should be instantiated only once. ++To get at submitted form data, use the :class:`FieldStorage` class. If the form ++contains non-ASCII characters, use the *encoding* keyword parameter set to the ++value of the encoding defined for the document. It is usually contained in the ++META tag in the HEAD section of the HTML document or by the ++:mailheader:`Content-Type` header). This reads the form contents from the ++standard input or the environment (depending on the value of various ++environment variables set according to the CGI standard). Since it may consume ++standard input, it should be instantiated only once. + + The :class:`FieldStorage` instance can be indexed like a Python dictionary. + It allows membership testing with the :keyword:`in` operator, and also supports +@@ -136,10 +139,10 @@ + + If a field represents an uploaded file, accessing the value via the + :attr:`value` attribute or the :func:`getvalue` method reads the entire file in +-memory as a string. This may not be what you want. You can test for an uploaded ++memory as bytes. This may not be what you want. You can test for an uploaded + file by testing either the :attr:`filename` attribute or the :attr:`!file` + attribute. You can then read the data at leisure from the :attr:`!file` +-attribute:: ++attribute (the :func:`read` and :func:`readline` methods will return bytes):: + + fileitem = form["userfile"] + if fileitem.file: +diff -r 3d0686d90f55 Doc/library/datetime.rst +--- a/Doc/library/datetime.rst ++++ b/Doc/library/datetime.rst +@@ -12,28 +12,34 @@ + The :mod:`datetime` module supplies classes for manipulating dates and times in + both simple and complex ways. While date and time arithmetic is supported, the + focus of the implementation is on efficient attribute extraction for output +-formatting and manipulation. For related +-functionality, see also the :mod:`time` and :mod:`calendar` modules. ++formatting and manipulation. For related functionality, see also the ++:mod:`time` and :mod:`calendar` modules. + +-There are two kinds of date and time objects: "naive" and "aware". This +-distinction refers to whether the object has any notion of time zone, daylight +-saving time, or other kind of algorithmic or political time adjustment. Whether +-a naive :class:`.datetime` object represents Coordinated Universal Time (UTC), +-local time, or time in some other timezone is purely up to the program, just +-like it's up to the program whether a particular number represents metres, +-miles, or mass. Naive :class:`.datetime` objects are easy to understand and to +-work with, at the cost of ignoring some aspects of reality. ++There are two kinds of date and time objects: "naive" and "aware". + +-For applications requiring more, :class:`.datetime` and :class:`.time` objects +-have an optional time zone information attribute, :attr:`tzinfo`, that can be +-set to an instance of a subclass of the abstract :class:`tzinfo` class. These +-:class:`tzinfo` objects capture information about the offset from UTC time, the +-time zone name, and whether Daylight Saving Time is in effect. Note that only +-one concrete :class:`tzinfo` class, the :class:`timezone` class, is supplied by the +-:mod:`datetime` module. The :class:`timezone` class can represent simple +-timezones with fixed offset from UTC such as UTC itself or North American EST and +-EDT timezones. Supporting timezones at whatever level of detail is +-required is up to the application. The rules for time adjustment across the ++An aware object has sufficient knowledge of applicable algorithmic and ++political time adjustments, such as time zone and daylight saving time ++information, to locate itself relative to other aware objects. An aware object ++is used to represent a specific moment in time that is not open to ++interpretation [#]_. ++ ++A naive object does not contain enough information to unambiguously locate ++itself relative to other date/time objects. Whether a naive object represents ++Coordinated Universal Time (UTC), local time, or time in some other timezone is ++purely up to the program, just like it is up to the program whether a ++particular number represents metres, miles, or mass. Naive objects are easy to ++understand and to work with, at the cost of ignoring some aspects of reality. ++ ++For applications requiring aware objects, :class:`.datetime` and :class:`.time` ++objects have an optional time zone information attribute, :attr:`tzinfo`, that ++can be set to an instance of a subclass of the abstract :class:`tzinfo` class. ++These :class:`tzinfo` objects capture information about the offset from UTC ++time, the time zone name, and whether Daylight Saving Time is in effect. Note ++that only one concrete :class:`tzinfo` class, the :class:`timezone` class, is ++supplied by the :mod:`datetime` module. The :class:`timezone` class can ++represent simple timezones with fixed offset from UTC, such as UTC itself or ++North American EST and EDT timezones. Supporting timezones at deeper levels of ++detail is up to the application. The rules for time adjustment across the + world are more political than rational, change frequently, and there is no + standard suitable for every application aside from UTC. + +@@ -114,10 +120,13 @@ + + Objects of the :class:`date` type are always naive. + +-An object *d* of type :class:`.time` or :class:`.datetime` may be naive or aware. +-*d* is aware if ``d.tzinfo`` is not ``None`` and ``d.tzinfo.utcoffset(d)`` does +-not return ``None``. If ``d.tzinfo`` is ``None``, or if ``d.tzinfo`` is not +-``None`` but ``d.tzinfo.utcoffset(d)`` returns ``None``, *d* is naive. ++An object of type :class:`.time` or :class:`.datetime` may be naive or aware. ++A :class:`.datetime` object *d* is aware if ``d.tzinfo`` is not ``None`` and ++``d.tzinfo.utcoffset(d)`` does not return ``None``. If ``d.tzinfo`` is ++``None``, or if ``d.tzinfo`` is not ``None`` but ``d.tzinfo.utcoffset(d)`` ++returns ``None``, *d* is naive. A :class:`.time` object *t* is aware ++if ``t.tzinfo`` is not ``None`` and ``t.tzinfo.utcoffset(None)`` does not return ++``None``. Otherwise, *t* is naive. + + The distinction between naive and aware doesn't apply to :class:`timedelta` + objects. +@@ -1118,14 +1127,14 @@ + + >>> from datetime import timedelta, datetime, tzinfo + >>> class GMT1(tzinfo): +- ... def __init__(self): # DST starts last Sunday in March ++ ... def utcoffset(self, dt): ++ ... return timedelta(hours=1) + self.dst(dt) ++ ... def dst(self, dt): ++ ... # DST starts last Sunday in March + ... d = datetime(dt.year, 4, 1) # ends last Sunday in October + ... self.dston = d - timedelta(days=d.weekday() + 1) + ... d = datetime(dt.year, 11, 1) + ... self.dstoff = d - timedelta(days=d.weekday() + 1) +- ... def utcoffset(self, dt): +- ... return timedelta(hours=1) + self.dst(dt) +- ... def dst(self, dt): + ... if self.dston <= dt.replace(tzinfo=None) < self.dstoff: + ... return timedelta(hours=1) + ... else: +@@ -1134,16 +1143,15 @@ + ... return "GMT +1" + ... + >>> class GMT2(tzinfo): +- ... def __init__(self): ++ ... def utcoffset(self, dt): ++ ... return timedelta(hours=2) + self.dst(dt) ++ ... def dst(self, dt): + ... d = datetime(dt.year, 4, 1) + ... self.dston = d - timedelta(days=d.weekday() + 1) + ... d = datetime(dt.year, 11, 1) + ... self.dstoff = d - timedelta(days=d.weekday() + 1) +- ... def utcoffset(self, dt): +- ... return timedelta(hours=1) + self.dst(dt) +- ... def dst(self, dt): + ... if self.dston <= dt.replace(tzinfo=None) < self.dstoff: +- ... return timedelta(hours=2) ++ ... return timedelta(hours=1) + ... else: + ... return timedelta(0) + ... def tzname(self,dt): +@@ -1518,7 +1526,6 @@ + + .. literalinclude:: ../includes/tzinfo-examples.py + +- + Note that there are unavoidable subtleties twice per year in a :class:`tzinfo` + subclass accounting for both standard and daylight time, at the DST transition + points. For concreteness, consider US Eastern (UTC -0500), where EDT begins the +@@ -1537,7 +1544,7 @@ + 3:00. A wall time of the form 2:MM doesn't really make sense on that day, so + ``astimezone(Eastern)`` won't deliver a result with ``hour == 2`` on the day DST + begins. In order for :meth:`astimezone` to make this guarantee, the +-:meth:`rzinfo.dst` method must consider times in the "missing hour" (2:MM for ++:meth:`tzinfo.dst` method must consider times in the "missing hour" (2:MM for + Eastern) to be in daylight time. + + When DST ends (the "end" line), there's a potentially worse problem: there's an +@@ -1558,6 +1565,22 @@ + or any other fixed-offset :class:`tzinfo` subclass (such as a class representing + only EST (fixed offset -5 hours), or only EDT (fixed offset -4 hours)). + ++.. seealso:: ++ ++ `pytz `_ ++ The standard library has no :class:`tzinfo` instances except for UTC, but ++ there exists a third-party library which brings the *IANA timezone ++ database* (also known as the Olson database) to Python: *pytz*. ++ ++ *pytz* contains up-to-date information and its usage is recommended. ++ ++ `IANA timezone database `_ ++ The Time Zone Database (often called tz or zoneinfo) contains code and ++ data that represent the history of local time for many representative ++ locations around the globe. It is updated periodically to reflect changes ++ made by political bodies to time zone boundaries, UTC offsets, and ++ daylight-saving rules. ++ + + .. _datetime-timezone: + +@@ -1791,3 +1814,7 @@ + When the ``%z`` directive is provided to the :meth:`strptime` method, an + aware :class:`.datetime` object will be produced. The ``tzinfo`` of the + result will be set to a :class:`timezone` instance. ++ ++.. rubric:: Footnotes ++ ++.. [#] If, that is, we ignore the effects of Relativity +diff -r 3d0686d90f55 Doc/library/email.charset.rst +--- a/Doc/library/email.charset.rst ++++ b/Doc/library/email.charset.rst +@@ -1,5 +1,5 @@ +-:mod:`email`: Representing character sets +------------------------------------------ ++:mod:`email.charset`: Representing character sets ++------------------------------------------------- + + .. module:: email.charset + :synopsis: Character Sets +diff -r 3d0686d90f55 Doc/library/email.encoders.rst +--- a/Doc/library/email.encoders.rst ++++ b/Doc/library/email.encoders.rst +@@ -1,5 +1,5 @@ +-:mod:`email`: Encoders +----------------------- ++:mod:`email.encoders`: Encoders ++------------------------------- + + .. module:: email.encoders + :synopsis: Encoders for email message payloads. +@@ -18,6 +18,10 @@ + payload, encode it, and reset the payload to this newly encoded value. They + should also set the :mailheader:`Content-Transfer-Encoding` header as appropriate. + ++Note that these functions are not meaningful for a multipart message. They ++must be applied to individual subparts instead, and will raise a ++:exc:`TypeError` if passed a message whose type is multipart. ++ + Here are the encoding functions provided: + + +diff -r 3d0686d90f55 Doc/library/email.errors.rst +--- a/Doc/library/email.errors.rst ++++ b/Doc/library/email.errors.rst +@@ -1,5 +1,5 @@ +-:mod:`email`: Exception and Defect classes +------------------------------------------- ++:mod:`email.errors`: Exception and Defect classes ++------------------------------------------------- + + .. module:: email.errors + :synopsis: The exception classes used by the email package. +diff -r 3d0686d90f55 Doc/library/email.generator.rst +--- a/Doc/library/email.generator.rst ++++ b/Doc/library/email.generator.rst +@@ -1,5 +1,5 @@ +-:mod:`email`: Generating MIME documents +---------------------------------------- ++:mod:`email.generator`: Generating MIME documents ++------------------------------------------------- + + .. module:: email.generator + :synopsis: Generate flat text email messages from a message structure. +@@ -17,10 +17,10 @@ + standards-compliant way, should handle MIME and non-MIME email messages just + fine, and is designed so that the transformation from flat text, to a message + structure via the :class:`~email.parser.Parser` class, and back to flat text, +-is idempotent (the input is identical to the output). On the other hand, using +-the Generator on a :class:`~email.message.Message` constructed by program may +-result in changes to the :class:`~email.message.Message` object as defaults are +-filled in. ++is idempotent (the input is identical to the output) [#]_. On the other hand, ++using the Generator on a :class:`~email.message.Message` constructed by program ++may result in changes to the :class:`~email.message.Message` object as defaults ++are filled in. + + :class:`bytes` output can be generated using the :class:`BytesGenerator` class. + If the message object structure contains non-ASCII bytes, this generator's +@@ -178,7 +178,7 @@ + representing the part. + + +-.. class:: DecodedGenerator(outfp[, mangle_from_=True, maxheaderlen=78, fmt=None) ++.. class:: DecodedGenerator(outfp, mangle_from_=True, maxheaderlen=78, fmt=None) + + This class, derived from :class:`Generator` walks through all the subparts of a + message. If the subpart is of main type :mimetype:`text`, then it prints the +@@ -204,3 +204,12 @@ + The default value for *fmt* is ``None``, meaning :: + + [Non-text (%(type)s) part of message omitted, filename %(filename)s] ++ ++ ++.. rubric:: Footnotes ++ ++.. [#] This statement assumes that you use the appropriate setting for the ++ ``unixfrom`` argument, and that you set maxheaderlen=0 (which will ++ preserve whatever the input line lengths were). It is also not strictly ++ true, since in many cases runs of whitespace in headers are collapsed ++ into single blanks. The latter is a bug that will eventually be fixed. +diff -r 3d0686d90f55 Doc/library/email.header.rst +--- a/Doc/library/email.header.rst ++++ b/Doc/library/email.header.rst +@@ -1,5 +1,5 @@ +-:mod:`email`: Internationalized headers +---------------------------------------- ++:mod:`email.header`: Internationalized headers ++---------------------------------------------- + + .. module:: email.header + :synopsis: Representing non-ASCII headers +diff -r 3d0686d90f55 Doc/library/email.iterators.rst +--- a/Doc/library/email.iterators.rst ++++ b/Doc/library/email.iterators.rst +@@ -1,5 +1,5 @@ +-:mod:`email`: Iterators +------------------------ ++:mod:`email.iterators`: Iterators ++--------------------------------- + + .. module:: email.iterators + :synopsis: Iterate over a message object tree. +diff -r 3d0686d90f55 Doc/library/email.message.rst +--- a/Doc/library/email.message.rst ++++ b/Doc/library/email.message.rst +@@ -1,5 +1,5 @@ +-:mod:`email`: Representing an email message +-------------------------------------------- ++:mod:`email.message`: Representing an email message ++--------------------------------------------------- + + .. module:: email.message + :synopsis: The base class representing email messages. +diff -r 3d0686d90f55 Doc/library/email.mime.rst +--- a/Doc/library/email.mime.rst ++++ b/Doc/library/email.mime.rst +@@ -1,5 +1,5 @@ +-:mod:`email`: Creating email and MIME objects from scratch +----------------------------------------------------------- ++:mod:`email.mime`: Creating email and MIME objects from scratch ++--------------------------------------------------------------- + + .. module:: email.mime + :synopsis: Build MIME messages. +diff -r 3d0686d90f55 Doc/library/email.parser.rst +--- a/Doc/library/email.parser.rst ++++ b/Doc/library/email.parser.rst +@@ -1,5 +1,5 @@ +-:mod:`email`: Parsing email messages +------------------------------------- ++:mod:`email.parser`: Parsing email messages ++------------------------------------------- + + .. module:: email.parser + :synopsis: Parse flat text email messages to produce a message object structure. +diff -r 3d0686d90f55 Doc/library/email.util.rst +--- a/Doc/library/email.util.rst ++++ b/Doc/library/email.util.rst +@@ -1,5 +1,5 @@ +-:mod:`email`: Miscellaneous utilities +-------------------------------------- ++:mod:`email.utils`: Miscellaneous utilities ++------------------------------------------- + + .. module:: email.utils + :synopsis: Miscellaneous email package utilities. +diff -r 3d0686d90f55 Doc/library/functions.rst +--- a/Doc/library/functions.rst ++++ b/Doc/library/functions.rst +@@ -247,6 +247,13 @@ + the function serves as a numeric conversion function like :func:`int` + and :func:`float`. If both arguments are omitted, returns ``0j``. + ++ .. note:: ++ ++ When converting from a string, the string must not contain whitespace ++ around the central ``+`` or ``-`` operator. For example, ++ ``complex('1+2j')`` is fine, but ``complex('1 + 2j')`` raises ++ :exc:`ValueError`. ++ + The complex type is described in :ref:`typesnumeric`. + + +@@ -410,7 +417,10 @@ + current scope. If only *globals* is provided, it must be a dictionary, which + will be used for both the global and the local variables. If *globals* and + *locals* are given, they are used for the global and local variables, +- respectively. If provided, *locals* can be any mapping object. ++ respectively. If provided, *locals* can be any mapping object. Remember ++ that at module level, globals and locals are the same dictionary. If exec ++ gets two separate objects as *globals* and *locals*, the code will be ++ executed as if it were embedded in a class definition. + + If the *globals* dictionary does not contain a value for the key + ``__builtins__``, a reference to the dictionary of the built-in module +diff -r 3d0686d90f55 Doc/library/html.rst +--- a/Doc/library/html.rst ++++ b/Doc/library/html.rst +@@ -4,8 +4,6 @@ + .. module:: html + :synopsis: Helpers for manipulating HTML. + +-.. versionadded:: 3.2 +- + **Source code:** :source:`Lib/html/__init__.py` + + -------------- +@@ -19,3 +17,5 @@ + characters in HTML. If the optional flag *quote* is true, the characters + (``"``) and (``'``) are also translated; this helps for inclusion in an HTML + attribute value delimited by quotes, as in ````. ++ ++ .. versionadded:: 3.2 +diff -r 3d0686d90f55 Doc/library/http.cookiejar.rst +--- a/Doc/library/http.cookiejar.rst ++++ b/Doc/library/http.cookiejar.rst +@@ -700,7 +700,7 @@ + The :class:`Cookie` class also defines the following method: + + +-.. method:: Cookie.is_expired([now=None]) ++.. method:: Cookie.is_expired(now=None) + + True if cookie has passed the time at which the server requested it should + expire. If *now* is given (in seconds since the epoch), return whether the +diff -r 3d0686d90f55 Doc/library/http.cookies.rst +--- a/Doc/library/http.cookies.rst ++++ b/Doc/library/http.cookies.rst +@@ -17,8 +17,14 @@ + + The module formerly strictly applied the parsing rules described in the + :rfc:`2109` and :rfc:`2068` specifications. It has since been discovered that +-MSIE 3.0x doesn't follow the character rules outlined in those specs. As a +-result, the parsing rules used are a bit less strict. ++MSIE 3.0x doesn't follow the character rules outlined in those specs and also ++many current day browsers and servers have relaxed parsing rules when comes to ++Cookie handling. As a result, the parsing rules used are a bit less strict. ++ ++The character set, :data:`string.ascii_letters`, :data:`string.digits` and ++``!#$%&'*+-.^_`|~`` denote the set of valid characters allowed by this module ++in Cookie name (as :attr:`~Morsel.key`). ++ + + .. note:: + +diff -r 3d0686d90f55 Doc/library/http.server.rst +--- a/Doc/library/http.server.rst ++++ b/Doc/library/http.server.rst +@@ -229,7 +229,7 @@ + to create custom error logging mechanisms. The *format* argument is a + standard printf-style format string, where the additional arguments to + :meth:`log_message` are applied as inputs to the formatting. The client +- address and current date and time are prefixed to every message logged. ++ ip address and current date and time are prefixed to every message logged. + + .. method:: version_string() + +@@ -333,7 +333,7 @@ + httpd.serve_forever() + + :mod:`http.server` can also be invoked directly using the :option:`-m` +-switch of the interpreter a with ``port number`` argument. Similar to ++switch of the interpreter with a ``port number`` argument. Similar to + the previous example, this serves files relative to the current directory. :: + + python -m http.server 8000 +diff -r 3d0686d90f55 Doc/library/imp.rst +--- a/Doc/library/imp.rst ++++ b/Doc/library/imp.rst +@@ -64,7 +64,7 @@ + path and the last item in the *description* tuple is :const:`PKG_DIRECTORY`. + + This function does not handle hierarchical module names (names containing +- dots). In order to find *P*.*M*, that is, submodule *M* of package *P*, use ++ dots). In order to find *P.M*, that is, submodule *M* of package *P*, use + :func:`find_module` and :func:`load_module` to find and load package *P*, and + then use :func:`find_module` with the *path* argument set to ``P.__path__``. + When *P* itself has a dotted name, apply this recipe recursively. +@@ -256,7 +256,7 @@ + + .. data:: PY_FROZEN + +- The module was found as a frozen module (see :func:`init_frozen`). ++ The module was found as a frozen module. + + + .. class:: NullImporter(path_string) +diff -r 3d0686d90f55 Doc/library/json.rst +--- a/Doc/library/json.rst ++++ b/Doc/library/json.rst +@@ -90,7 +90,7 @@ + ['[2.0', ', 1.0', ']'] + + +-.. highlight:: none ++.. highlight:: bash + + Using json.tool from the shell to validate and pretty-print:: + +@@ -98,10 +98,10 @@ + { + "json": "obj" + } +- $ echo '{ 1.2:3.4}' | python -mjson.tool +- Expecting property name: line 1 column 2 (char 2) ++ $ echo '{1.2:3.4}' | python -mjson.tool ++ Expecting property name enclosed in double quotes: line 1 column 1 (char 1) + +-.. highlight:: python ++.. highlight:: python3 + + .. note:: + +@@ -168,6 +168,14 @@ + so trying to serialize multiple objects with repeated calls to + :func:`dump` using the same *fp* will result in an invalid JSON file. + ++ .. note:: ++ ++ Keys in key/value pairs of JSON are always of the type :class:`str`. When ++ a dictionary is converted into JSON, all the keys of the dictionary are ++ coerced to strings. As a result of this, if a dictionary is convered ++ into JSON and then back into a dictionary, the dictionary may not equal ++ the original one. That is, ``loads(dumps(x)) != x`` if x has non-string ++ keys. + + .. function:: load(fp, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw) + +@@ -201,10 +209,13 @@ + (e.g. :class:`float`). + + *parse_constant*, if specified, will be called with one of the following +- strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``, ``'null'``, ``'true'``, +- ``'false'``. This can be used to raise an exception if invalid JSON numbers ++ strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. ++ This can be used to raise an exception if invalid JSON numbers + are encountered. + ++ .. versionchanged:: 3.1 ++ *parse_constant* doesn't get called on 'null', 'true', 'false' anymore. ++ + To use a custom :class:`JSONDecoder` subclass, specify it with the ``cls`` + kwarg; otherwise :class:`JSONDecoder` is used. Additional keyword arguments + will be passed to the constructor of the class. +diff -r 3d0686d90f55 Doc/library/locale.rst +--- a/Doc/library/locale.rst ++++ b/Doc/library/locale.rst +@@ -160,22 +160,22 @@ + + .. data:: D_T_FMT + +- Get a string that can be used as a format string for :func:`strftime` to ++ Get a string that can be used as a format string for :func:`time.strftime` to + represent date and time in a locale-specific way. + + .. data:: D_FMT + +- Get a string that can be used as a format string for :func:`strftime` to ++ Get a string that can be used as a format string for :func:`time.strftime` to + represent a date in a locale-specific way. + + .. data:: T_FMT + +- Get a string that can be used as a format string for :func:`strftime` to ++ Get a string that can be used as a format string for :func:`time.strftime` to + represent a time in a locale-specific way. + + .. data:: T_FMT_AMPM + +- Get a format string for :func:`strftime` to represent time in the am/pm ++ Get a format string for :func:`time.strftime` to represent time in the am/pm + format. + + .. data:: DAY_1 ... DAY_7 +@@ -239,24 +239,24 @@ + then-emperor's reign. + + Normally it should not be necessary to use this value directly. Specifying +- the ``E`` modifier in their format strings causes the :func:`strftime` ++ the ``E`` modifier in their format strings causes the :func:`time.strftime` + function to use this information. The format of the returned string is not + specified, and therefore you should not assume knowledge of it on different + systems. + + .. data:: ERA_D_T_FMT + +- Get a format string for :func:`strftime` to represent date and time in a ++ Get a format string for :func:`time.strftime` to represent date and time in a + locale-specific era-based way. + + .. data:: ERA_D_FMT + +- Get a format string for :func:`strftime` to represent a date in a ++ Get a format string for :func:`time.strftime` to represent a date in a + locale-specific era-based way. + + .. data:: ERA_T_FMT + +- Get a format string for :func:`strftime` to represent a time in a ++ Get a format string for :func:`time.strftime` to represent a time in a + locale-specific era-based way. + + .. data:: ALT_DIGITS +diff -r 3d0686d90f55 Doc/library/logging.handlers.rst +--- a/Doc/library/logging.handlers.rst ++++ b/Doc/library/logging.handlers.rst +@@ -654,7 +654,7 @@ + :class:`BufferingHandler`, which is an abstract class. This buffers logging + records in memory. Whenever each record is added to the buffer, a check is made + by calling :meth:`shouldFlush` to see if the buffer should be flushed. If it +-should, then :meth:`flush` is expected to do the needful. ++should, then :meth:`flush` is expected to do the flushing. + + + .. class:: BufferingHandler(capacity) +diff -r 3d0686d90f55 Doc/library/logging.rst +--- a/Doc/library/logging.rst ++++ b/Doc/library/logging.rst +@@ -49,9 +49,22 @@ + Logger Objects + -------------- + +-Loggers have the following attributes and methods. Note that Loggers are never ++Loggers have the following attributes and methods. Note that Loggers are never + instantiated directly, but always through the module-level function +-``logging.getLogger(name)``. ++``logging.getLogger(name)``. Multiple calls to :func:`getLogger` with the same ++name will always return a reference to the same Logger object. ++ ++The ``name`` is potentially a period-separated hierarchical value, like ++``foo.bar.baz`` (though it could also be just plain ``foo``, for example). ++Loggers that are further down in the hierarchical list are children of loggers ++higher up in the list. For example, given a logger with a name of ``foo``, ++loggers with names of ``foo.bar``, ``foo.bar.baz``, and ``foo.bam`` are all ++descendants of ``foo``. The logger name hierarchy is analogous to the Python ++package hierarchy, and identical to it if you organise your loggers on a ++per-module basis using the recommended construction ++``logging.getLogger(__name__)``. That's because in a module, ``__name__`` ++is the module's name in the Python package namespace. ++ + + .. class:: Logger + +@@ -159,7 +172,7 @@ + + FORMAT = '%(asctime)-15s %(clientip)s %(user)-8s %(message)s' + logging.basicConfig(format=FORMAT) +- d = { 'clientip' : '192.168.0.1', 'user' : 'fbloggs' } ++ d = {'clientip': '192.168.0.1', 'user': 'fbloggs'} + logger = logging.getLogger('tcpserver') + logger.warning('Protocol problem: %s', 'connection reset', extra=d) + +@@ -929,7 +942,8 @@ + effect is to disable all logging calls of severity *lvl* and below, so that + if you call it with a value of INFO, then all INFO and DEBUG events would be + discarded, whereas those of severity WARNING and above would be processed +- according to the logger's effective level. ++ according to the logger's effective level. To undo the effect of a call to ++ ``logging.disable(lvl)``, call ``logging.disable(logging.NOTSET)``. + + + .. function:: addLevelName(lvl, levelName) +@@ -1077,7 +1091,7 @@ + If *capture* is ``True``, warnings issued by the :mod:`warnings` module will + be redirected to the logging system. Specifically, a warning will be + formatted using :func:`warnings.formatwarning` and the resulting string +- logged to a logger named ``'py.warnings'`` with a severity of ``'WARNING'``. ++ logged to a logger named ``'py.warnings'`` with a severity of :const:`WARNING`. + + If *capture* is ``False``, the redirection of warnings to the logging system + will stop, and warnings will be redirected to their original destinations +diff -r 3d0686d90f55 Doc/library/mailbox.rst +--- a/Doc/library/mailbox.rst ++++ b/Doc/library/mailbox.rst +@@ -89,7 +89,8 @@ + format-specific information is used. Otherwise, reasonable defaults for + format-specific information are used. + +- .. versionchanged:: 3.2 support for binary input ++ .. versionchanged:: 3.2 ++ Support for binary input was added. + + + .. method:: remove(key) +diff -r 3d0686d90f55 Doc/library/markup.rst +--- a/Doc/library/markup.rst ++++ b/Doc/library/markup.rst +@@ -23,7 +23,7 @@ + html.rst + html.parser.rst + html.entities.rst +- pyexpat.rst ++ xml.etree.elementtree.rst + xml.dom.rst + xml.dom.minidom.rst + xml.dom.pulldom.rst +@@ -31,4 +31,4 @@ + xml.sax.handler.rst + xml.sax.utils.rst + xml.sax.reader.rst +- xml.etree.elementtree.rst ++ pyexpat.rst +diff -r 3d0686d90f55 Doc/library/multiprocessing.rst +--- a/Doc/library/multiprocessing.rst ++++ b/Doc/library/multiprocessing.rst +@@ -79,7 +79,8 @@ + def info(title): + print(title) + print('module name:', __name__) +- print('parent process:', os.getppid()) ++ if hasattr(os, 'getppid'): # only available on Unix ++ print('parent process:', os.getppid()) + print('process id:', os.getpid()) + + def f(name): +@@ -1114,7 +1115,7 @@ + HELLO WORLD + [(3.515625, 39.0625), (33.0625, 4.0), (5.640625, 90.25)] + +-.. highlight:: python ++.. highlight:: python3 + + + .. _multiprocessing-managers: +@@ -2256,16 +2257,19 @@ + Demonstration of how to create and use customized managers and proxies: + + .. literalinclude:: ../includes/mp_newtype.py ++ :language: python3 + + + Using :class:`Pool`: + + .. literalinclude:: ../includes/mp_pool.py ++ :language: python3 + + + Synchronization types like locks, conditions and queues: + + .. literalinclude:: ../includes/mp_synchronize.py ++ :language: python3 + + + An example showing how to use queues to feed tasks to a collection of worker +diff -r 3d0686d90f55 Doc/library/nis.rst +--- a/Doc/library/nis.rst ++++ b/Doc/library/nis.rst +@@ -17,7 +17,7 @@ + The :mod:`nis` module defines the following functions: + + +-.. function:: match(key, mapname[, domain=default_domain]) ++.. function:: match(key, mapname, domain=default_domain) + + Return the match for *key* in map *mapname*, or raise an error + (:exc:`nis.error`) if there is none. Both should be strings, *key* is 8-bit +@@ -30,7 +30,7 @@ + unspecified, lookup is in the default NIS domain. + + +-.. function:: cat(mapname[, domain=default_domain]) ++.. function:: cat(mapname, domain=default_domain) + + Return a dictionary mapping *key* to *value* such that ``match(key, + mapname)==value``. Note that both keys and values of the dictionary are +@@ -42,7 +42,7 @@ + unspecified, lookup is in the default NIS domain. + + +-.. function:: maps([domain=default_domain]) ++.. function:: maps(domain=default_domain) + + Return a list of all valid maps. + +diff -r 3d0686d90f55 Doc/library/operator.rst +--- a/Doc/library/operator.rst ++++ b/Doc/library/operator.rst +@@ -340,7 +340,7 @@ + +-----------------------+-------------------------+---------------------------------------+ + | Containment Test | ``obj in seq`` | ``contains(seq, obj)`` | + +-----------------------+-------------------------+---------------------------------------+ +-| Division | ``a / b`` | ``div(a, b)`` | ++| Division | ``a / b`` | ``truediv(a, b)`` | + +-----------------------+-------------------------+---------------------------------------+ + | Division | ``a // b`` | ``floordiv(a, b)`` | + +-----------------------+-------------------------+---------------------------------------+ +@@ -404,7 +404,7 @@ + +-----------------------+-------------------------+---------------------------------------+ + + Inplace Operators +-================= ++----------------- + + Many operations have an "in-place" version. Listed below are functions + providing a more primitive access to in-place operators than the usual syntax +diff -r 3d0686d90f55 Doc/library/os.rst +--- a/Doc/library/os.rst ++++ b/Doc/library/os.rst +@@ -227,6 +227,20 @@ + + Availability: Unix. + ++ .. note:: On Mac OS X, :func:`getgroups` behavior differs somewhat from ++ other Unix platforms. If the Python interpreter was built with a ++ deployment target of :const:`10.5` or earlier, :func:`getgroups` returns ++ the list of effective group ids associated with the current user process; ++ this list is limited to a system-defined number of entries, typically 16, ++ and may be modified by calls to :func:`setgroups` if suitably privileged. ++ If built with a deployment target greater than :const:`10.5`, ++ :func:`getgroups` returns the current group access list for the user ++ associated with the effective user id of the process; the group access ++ list may change over the lifetime of the process, it is not affected by ++ calls to :func:`setgroups`, and its length is not limited to 16. The ++ deployment target value, :const:`MACOSX_DEPLOYMENT_TARGET`, can be ++ obtained with :func:`sysconfig.get_config_var`. ++ + + .. function:: initgroups(username, gid) + +@@ -389,6 +403,10 @@ + + Availability: Unix. + ++ .. note:: On Mac OS X, the length of *groups* may not exceed the ++ system-defined maximum number of effective group ids, typically 16. ++ See the documentation for :func:`getgroups` for cases where it may not ++ return the same group list set by calling setgroups(). + + .. function:: setpgrp() + +@@ -527,22 +545,12 @@ + These functions create new :term:`file objects `. (See also :func:`open`.) + + +-.. function:: fdopen(fd[, mode[, bufsize]]) +- +- .. index:: single: I/O control; buffering +- +- Return an open file object connected to the file descriptor *fd*. The *mode* +- and *bufsize* arguments have the same meaning as the corresponding arguments to +- the built-in :func:`open` function. +- +- When specified, the *mode* argument must start with one of the letters +- ``'r'``, ``'w'``, or ``'a'``, otherwise a :exc:`ValueError` is raised. +- +- On Unix, when the *mode* argument starts with ``'a'``, the *O_APPEND* flag is +- set on the file descriptor (which the :c:func:`fdopen` implementation already +- does on most platforms). +- +- Availability: Unix, Windows. ++.. function:: fdopen(fd, *args, **kwargs) ++ ++ Return an open file object connected to the file descriptor *fd*. ++ This is an alias of :func:`open` and accepts the same arguments. ++ The only difference is that the first argument of :func:`fdopen` ++ must always be an integer. + + + .. _os-fd-ops: +@@ -1127,7 +1135,7 @@ + Availability: Unix. + + +-.. function:: mknod(filename[, mode=0o600[, device]]) ++.. function:: mknod(filename[, mode=0o600[, device=0]]) + + Create a filesystem node (file, device special file or named pipe) named + *filename*. *mode* specifies both the permissions to use and the type of node +diff -r 3d0686d90f55 Doc/library/ossaudiodev.rst +--- a/Doc/library/ossaudiodev.rst ++++ b/Doc/library/ossaudiodev.rst +@@ -277,7 +277,7 @@ + simple calculations. + + +-.. method:: oss_audio_device.setparameters(format, nchannels, samplerate [, strict=False]) ++.. method:: oss_audio_device.setparameters(format, nchannels, samplerate[, strict=False]) + + Set the key audio sampling parameters---sample format, number of channels, and + sampling rate---in one method call. *format*, *nchannels*, and *samplerate* +diff -r 3d0686d90f55 Doc/library/pickle.rst +--- a/Doc/library/pickle.rst ++++ b/Doc/library/pickle.rst +@@ -85,45 +85,48 @@ + ------------------ + + .. index:: +- single: XDR + single: External Data Representation + + The data format used by :mod:`pickle` is Python-specific. This has the + advantage that there are no restrictions imposed by external standards such as +-XDR (which can't represent pointer sharing); however it means that non-Python +-programs may not be able to reconstruct pickled Python objects. ++JSON or XDR (which can't represent pointer sharing); however it means that ++non-Python programs may not be able to reconstruct pickled Python objects. + +-By default, the :mod:`pickle` data format uses a compact binary representation. ++By default, the :mod:`pickle` data format uses a relatively compact binary ++representation. If you need optimal size characteristics, you can efficiently ++:doc:`compress ` pickled data. ++ + The module :mod:`pickletools` contains tools for analyzing data streams +-generated by :mod:`pickle`. ++generated by :mod:`pickle`. :mod:`pickletools` source code has extensive ++comments about opcodes used by pickle protocols. + + There are currently 4 different protocols which can be used for pickling. + +-* Protocol version 0 is the original human-readable protocol and is ++* Protocol version 0 is the original "human-readable" protocol and is + backwards compatible with earlier versions of Python. + +-* Protocol version 1 is the old binary format which is also compatible with ++* Protocol version 1 is an old binary format which is also compatible with + earlier versions of Python. + + * Protocol version 2 was introduced in Python 2.3. It provides much more +- efficient pickling of :term:`new-style class`\es. ++ efficient pickling of :term:`new-style class`\es. Refer to :pep:`307` for ++ information about improvements brought by protocol 2. + +-* Protocol version 3 was added in Python 3.0. It has explicit support for +- bytes and cannot be unpickled by Python 2.x pickle modules. This is +- the current recommended protocol, use it whenever it is possible. +- +-Refer to :pep:`307` for information about improvements brought by +-protocol 2. See :mod:`pickletools`'s source code for extensive +-comments about opcodes used by pickle protocols. ++* Protocol version 3 was added in Python 3. It has explicit support for ++ :class:`bytes` objects and cannot be unpickled by Python 2.x. This is ++ the default as well as the current recommended protocol; use it whenever ++ possible. + + + Module Interface + ---------------- + +-To serialize an object hierarchy, you first create a pickler, then you call the +-pickler's :meth:`dump` method. To de-serialize a data stream, you first create +-an unpickler, then you call the unpickler's :meth:`load` method. The +-:mod:`pickle` module provides the following constant: ++To serialize an object hierarchy, you simply call the :func:`dumps` function. ++Similarly, to de-serialize a data stream, you call the :func:`loads` function. ++However, if you want more control over serialization and de-serialization, ++you can create a :class:`Pickler` or an :class:`Unpickler` object, respectively. ++ ++The :mod:`pickle` module provides the following constants: + + + .. data:: HIGHEST_PROTOCOL +@@ -134,8 +137,7 @@ + .. data:: DEFAULT_PROTOCOL + + The default protocol used for pickling. May be less than HIGHEST_PROTOCOL. +- Currently the default protocol is 3; a backward-incompatible protocol +- designed for Python 3.0. ++ Currently the default protocol is 3, a new protocol designed for Python 3.0. + + + The :mod:`pickle` module provides the following functions to make the pickling +diff -r 3d0686d90f55 Doc/library/queue.rst +--- a/Doc/library/queue.rst ++++ b/Doc/library/queue.rst +@@ -15,8 +15,8 @@ + availability of thread support in Python; see the :mod:`threading` + module. + +-Implements three types of queue whose only difference is the order that +-the entries are retrieved. In a FIFO queue, the first tasks added are ++The module implements three types of queue, which differ only in the order in ++which the entries are retrieved. In a FIFO queue, the first tasks added are + the first retrieved. In a LIFO queue, the most recently added entry is + the first retrieved (operating like a stack). With a priority queue, + the entries are kept sorted (using the :mod:`heapq` module) and the +diff -r 3d0686d90f55 Doc/library/random.rst +--- a/Doc/library/random.rst ++++ b/Doc/library/random.rst +@@ -309,7 +309,7 @@ + >>> random.sample([1, 2, 3, 4, 5], 3) # Three samples without replacement + [4, 1, 5] + +-A common task is to make a :func:`random.choice` with weighted probababilites. ++A common task is to make a :func:`random.choice` with weighted probabilities. + + If the weights are small integer ratios, a simple technique is to build a sample + population with repeats:: +diff -r 3d0686d90f55 Doc/library/re.rst +--- a/Doc/library/re.rst ++++ b/Doc/library/re.rst +@@ -278,7 +278,7 @@ + lookbehind will back up 3 characters and check if the contained pattern matches. + The contained pattern must only match strings of some fixed length, meaning that + ``abc`` or ``a|b`` are allowed, but ``a*`` and ``a{3,4}`` are not. Note that +- patterns which start with positive lookbehind assertions will never match at the ++ patterns which start with positive lookbehind assertions will not match at the + beginning of the string being searched; you will most likely want to use the + :func:`search` function rather than the :func:`match` function: + +@@ -330,16 +330,22 @@ + Matches the empty string, but only at the beginning or end of a word. + A word is defined as a sequence of Unicode alphanumeric or underscore + characters, so the end of a word is indicated by whitespace or a +- non-alphanumeric, non-underscore Unicode character. Note that +- formally, ``\b`` is defined as the boundary between a ``\w`` and a +- ``\W`` character (or vice versa). By default Unicode alphanumerics +- are the ones used, but this can be changed by using the :const:`ASCII` +- flag. Inside a character range, ``\b`` represents the backspace +- character, for compatibility with Python's string literals. ++ non-alphanumeric, non-underscore Unicode character. Note that formally, ++ ``\b`` is defined as the boundary between a ``\w`` and a ``\W`` character ++ (or vice versa), or between ``\w`` and the beginning/end of the string. ++ This means that ``r'\bfoo\b'`` matches ``'foo'``, ``'foo.'``, ``'(foo)'``, ++ ``'bar foo baz'`` but not ``'foobar'`` or ``'foo3'``. ++ ++ By default Unicode alphanumerics are the ones used, but this can be changed ++ by using the :const:`ASCII` flag. Inside a character range, ``\b`` ++ represents the backspace character, for compatibility with Python's string ++ literals. + + ``\B`` +- Matches the empty string, but only when it is *not* at the beginning or end of a +- word. This is just the opposite of ``\b``, so word characters are ++ Matches the empty string, but only when it is *not* at the beginning or end ++ of a word. This means that ``r'py\B'`` matches ``'python'``, ``'py3'``, ++ ``'py2'``, but not ``'py'``, ``'py.'``, or ``'py!'``. ++ ``\B`` is just the opposite of ``\b``, so word characters are + Unicode alphanumerics or the underscore, although this can be changed + by using the :const:`ASCII` flag. + +@@ -411,37 +417,15 @@ + \r \t \v \x + \\ + ++(Note that ``\b`` is used to represent word boundaries, and means "backspace" ++only inside character classes.) ++ + Octal escapes are included in a limited form. If the first digit is a 0, or if + there are three octal digits, it is considered an octal escape. Otherwise, it is + a group reference. As for string literals, octal escapes are always at most + three digits in length. + + +-.. _matching-searching: +- +-Matching vs. Searching +----------------------- +- +-.. sectionauthor:: Fred L. Drake, Jr. +- +- +-Python offers two different primitive operations based on regular expressions: +-**match** checks for a match only at the beginning of the string, while +-**search** checks for a match anywhere in the string (this is what Perl does +-by default). +- +-Note that match may differ from search even when using a regular expression +-beginning with ``'^'``: ``'^'`` matches only at the start of the string, or in +-:const:`MULTILINE` mode also immediately following a newline. The "match" +-operation succeeds only if the pattern matches at the start of the string +-regardless of mode, or at the starting position given by the optional *pos* +-argument regardless of whether a newline precedes it. +- +- >>> re.match("c", "abcdef") # No match +- >>> re.search("c", "abcdef") # Match +- <_sre.SRE_Match object at ...> +- +- + .. _contents-of-module-re: + + Module Contents +@@ -575,10 +559,11 @@ + `. Return ``None`` if the string does not match the pattern; + note that this is different from a zero-length match. + +- .. note:: ++ Note that even in :const:`MULTILINE` mode, :func:`re.match` will only match ++ at the beginning of the string and not at the beginning of each line. + +- If you want to locate a match anywhere in *string*, use :func:`search` +- instead. ++ If you want to locate a match anywhere in *string*, use :func:`search` ++ instead (see also :ref:`search-vs-match`). + + + .. function:: split(pattern, string, maxsplit=0, flags=0) +@@ -762,16 +747,14 @@ + The optional *pos* and *endpos* parameters have the same meaning as for the + :meth:`~regex.search` method. + +- .. note:: +- +- If you want to locate a match anywhere in *string*, use +- :meth:`~regex.search` instead. +- + >>> pattern = re.compile("o") + >>> pattern.match("dog") # No match as "o" is not at the start of "dog". + >>> pattern.match("dog", 1) # Match as "o" is the 2nd character of "dog". + <_sre.SRE_Match object at ...> + ++ If you want to locate a match anywhere in *string*, use ++ :meth:`~regex.search` instead (see also :ref:`search-vs-match`). ++ + + .. method:: regex.split(string, maxsplit=0) + +@@ -804,8 +787,9 @@ + + .. attribute:: regex.flags + +- The flags argument used when the RE object was compiled, or ``0`` if no flags +- were provided. ++ The regex matching flags. This is a combination of the flags given to ++ :func:`.compile`, any ``(?...)`` inline flags in the pattern, and implicit ++ flags such as :data:`UNICODE` if the pattern is a Unicode string. + + + .. attribute:: regex.groups +@@ -964,16 +948,15 @@ + .. attribute:: match.pos + + The value of *pos* which was passed to the :meth:`~regex.search` or +- :meth:`~regex.match` method of a :ref:`match object `. This +- is the index into the string at which the RE engine started looking for a +- match. ++ :meth:`~regex.match` method of a :ref:`regex object `. This is ++ the index into the string at which the RE engine started looking for a match. + + + .. attribute:: match.endpos + + The value of *endpos* which was passed to the :meth:`~regex.search` or +- :meth:`~regex.match` method of a :ref:`match object `. This +- is the index into the string beyond which the RE engine will not go. ++ :meth:`~regex.match` method of a :ref:`regex object `. This is ++ the index into the string beyond which the RE engine will not go. + + + .. attribute:: match.lastindex +@@ -1089,13 +1072,13 @@ + +--------------------------------+---------------------------------------------+ + | ``%i`` | ``[-+]?(0[xX][\dA-Fa-f]+|0[0-7]*|\d+)`` | + +--------------------------------+---------------------------------------------+ +-| ``%o`` | ``0[0-7]*`` | ++| ``%o`` | ``[-+]?[0-7]+`` | + +--------------------------------+---------------------------------------------+ + | ``%s`` | ``\S+`` | + +--------------------------------+---------------------------------------------+ + | ``%u`` | ``\d+`` | + +--------------------------------+---------------------------------------------+ +-| ``%x``, ``%X`` | ``0[xX][\dA-Fa-f]+`` | ++| ``%x``, ``%X`` | ``[-+]?(0[xX])?[\dA-Fa-f]+`` | + +--------------------------------+---------------------------------------------+ + + To extract the filename and numbers from a string like :: +@@ -1111,59 +1094,39 @@ + (\S+) - (\d+) errors, (\d+) warnings + + +-Avoiding recursion +-^^^^^^^^^^^^^^^^^^ +- +-If you create regular expressions that require the engine to perform a lot of +-recursion, you may encounter a :exc:`RuntimeError` exception with the message +-``maximum recursion limit exceeded``. For example, :: +- +- >>> s = 'Begin ' + 1000*'a very long string ' + 'end' +- >>> re.match('Begin (\w| )*? end', s).end() +- Traceback (most recent call last): +- File "", line 1, in ? +- File "/usr/local/lib/python3.2/re.py", line 132, in match +- return _compile(pattern, flags).match(string) +- RuntimeError: maximum recursion limit exceeded +- +-You can often restructure your regular expression to avoid recursion. +- +-Simple uses of the ``*?`` pattern are special-cased to avoid recursion. Thus, +-the above regular expression can avoid recursion by being recast as ``Begin +-[a-zA-Z0-9_ ]*?end``. As a further benefit, such regular expressions will run +-faster than their recursive equivalents. +- ++.. _search-vs-match: + + search() vs. match() + ^^^^^^^^^^^^^^^^^^^^ + +-In a nutshell, :func:`match` only attempts to match a pattern at the beginning +-of a string where :func:`search` will match a pattern anywhere in a string. +-For example: ++.. sectionauthor:: Fred L. Drake, Jr. + +- >>> re.match("o", "dog") # No match as "o" is not the first letter of "dog". +- >>> re.search("o", "dog") # Match as search() looks everywhere in the string. ++Python offers two different primitive operations based on regular expressions: ++:func:`re.match` checks for a match only at the beginning of the string, while ++:func:`re.search` checks for a match anywhere in the string (this is what Perl ++does by default). ++ ++For example:: ++ ++ >>> re.match("c", "abcdef") # No match ++ >>> re.search("c", "abcdef") # Match + <_sre.SRE_Match object at ...> + +-.. note:: ++Regular expressions beginning with ``'^'`` can be used with :func:`search` to ++restrict the match at the beginning of the string:: + +- The following applies only to regular expression objects like those created +- with ``re.compile("pattern")``, not the primitives ``re.match(pattern, +- string)`` or ``re.search(pattern, string)``. ++ >>> re.match("c", "abcdef") # No match ++ >>> re.search("^c", "abcdef") # No match ++ >>> re.search("^a", "abcdef") # Match ++ <_sre.SRE_Match object at ...> + +-:func:`match` has an optional second parameter that gives an index in the string +-where the search is to start:: ++Note however that in :const:`MULTILINE` mode :func:`match` only matches at the ++beginning of the string, whereas using :func:`search` with a regular expression ++beginning with ``'^'`` will match at the beginning of each line. + +- >>> pattern = re.compile("o") +- >>> pattern.match("dog") # No match as "o" is not at the start of "dog." +- +- # Equivalent to the above expression as 0 is the default starting index: +- >>> pattern.match("dog", 0) +- +- # Match as "o" is the 2nd character of "dog" (index 0 is the first): +- >>> pattern.match("dog", 1) ++ >>> re.match('X', 'A\nB\nX', re.MULTILINE) # No match ++ >>> re.search('^X', 'A\nB\nX', re.MULTILINE) # Match + <_sre.SRE_Match object at ...> +- >>> pattern.match("dog", 2) # No match as "o" is not the 3rd character of "dog." + + + Making a Phonebook +@@ -1177,7 +1140,7 @@ + First, here is the input. Normally it may come from a file, here we are using + triple-quoted string syntax: + +- >>> input = """Ross McFluff: 834.345.1254 155 Elm Street ++ >>> text = """Ross McFluff: 834.345.1254 155 Elm Street + ... + ... Ronald Heathmore: 892.345.3428 436 Finley Avenue + ... Frank Burger: 925.541.7625 662 South Dogwood Way +@@ -1191,7 +1154,7 @@ + .. doctest:: + :options: +NORMALIZE_WHITESPACE + +- >>> entries = re.split("\n+", input) ++ >>> entries = re.split("\n+", text) + >>> entries + ['Ross McFluff: 834.345.1254 155 Elm Street', + 'Ronald Heathmore: 892.345.3428 436 Finley Avenue', +diff -r 3d0686d90f55 Doc/library/select.rst +--- a/Doc/library/select.rst ++++ b/Doc/library/select.rst +@@ -181,7 +181,7 @@ + Remove a registered file descriptor from the epoll object. + + +-.. method:: epoll.poll([timeout=-1[, maxevents=-1]]) ++.. method:: epoll.poll(timeout=-1, maxevents=-1) + + Wait for events. timeout in seconds (float) + +diff -r 3d0686d90f55 Doc/library/signal.rst +--- a/Doc/library/signal.rst ++++ b/Doc/library/signal.rst +@@ -5,46 +5,58 @@ + :synopsis: Set handlers for asynchronous events. + + +-This module provides mechanisms to use signal handlers in Python. Some general +-rules for working with signals and their handlers: ++This module provides mechanisms to use signal handlers in Python. + +-* A handler for a particular signal, once set, remains installed until it is +- explicitly reset (Python emulates the BSD style interface regardless of the +- underlying implementation), with the exception of the handler for +- :const:`SIGCHLD`, which follows the underlying implementation. + +-* There is no way to "block" signals temporarily from critical sections (since +- this is not supported by all Unix flavors). ++General rules ++------------- + +-* Although Python signal handlers are called asynchronously as far as the Python +- user is concerned, they can only occur between the "atomic" instructions of the +- Python interpreter. This means that signals arriving during long calculations +- implemented purely in C (such as regular expression matches on large bodies of +- text) may be delayed for an arbitrary amount of time. ++The :func:`signal.signal` function allows to define custom handlers to be ++executed when a signal is received. A small number of default handlers are ++installed: :const:`SIGPIPE` is ignored (so write errors on pipes and sockets ++can be reported as ordinary Python exceptions) and :const:`SIGINT` is ++translated into a :exc:`KeyboardInterrupt` exception. + +-* When a signal arrives during an I/O operation, it is possible that the I/O +- operation raises an exception after the signal handler returns. This is +- dependent on the underlying Unix system's semantics regarding interrupted system +- calls. ++A handler for a particular signal, once set, remains installed until it is ++explicitly reset (Python emulates the BSD style interface regardless of the ++underlying implementation), with the exception of the handler for ++:const:`SIGCHLD`, which follows the underlying implementation. + +-* Because the C signal handler always returns, it makes little sense to catch +- synchronous errors like :const:`SIGFPE` or :const:`SIGSEGV`. ++There is no way to "block" signals temporarily from critical sections (since ++this is not supported by all Unix flavors). + +-* Python installs a small number of signal handlers by default: :const:`SIGPIPE` +- is ignored (so write errors on pipes and sockets can be reported as ordinary +- Python exceptions) and :const:`SIGINT` is translated into a +- :exc:`KeyboardInterrupt` exception. All of these can be overridden. + +-* Some care must be taken if both signals and threads are used in the same +- program. The fundamental thing to remember in using signals and threads +- simultaneously is: always perform :func:`signal` operations in the main thread +- of execution. Any thread can perform an :func:`alarm`, :func:`getsignal`, +- :func:`pause`, :func:`setitimer` or :func:`getitimer`; only the main thread +- can set a new signal handler, and the main thread will be the only one to +- receive signals (this is enforced by the Python :mod:`signal` module, even +- if the underlying thread implementation supports sending signals to +- individual threads). This means that signals can't be used as a means of +- inter-thread communication. Use locks instead. ++Execution of Python signal handlers ++^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ++ ++A Python signal handler does not get executed inside the low-level (C) signal ++handler. Instead, the low-level signal handler sets a flag which tells the ++:term:`virtual machine` to execute the corresponding Python signal handler ++at a later point(for example at the next :term:`bytecode` instruction). ++This has consequences: ++ ++* It makes little sense to catch synchronous errors like :const:`SIGFPE` or ++ :const:`SIGSEGV`. ++ ++* A long-running calculation implemented purely in C (such as regular ++ expression matching on a large body of text) may run uninterrupted for an ++ arbitrary amount of time, regardless of any signals received. The Python ++ signal handlers will be called when the calculation finishes. ++ ++ ++Signals and threads ++^^^^^^^^^^^^^^^^^^^ ++ ++Python signal handlers are always executed in the main Python thread, ++even if the signal was received in another thread. This means that signals ++can't be used as a means of inter-thread communication. You can use ++the synchronization primitives from the :mod:`threading` module instead. ++ ++Besides, only the main thread is allowed to set a new signal handler. ++ ++ ++Module contents ++--------------- + + The variables defined in the :mod:`signal` module are: + +diff -r 3d0686d90f55 Doc/library/socket.rst +--- a/Doc/library/socket.rst ++++ b/Doc/library/socket.rst +@@ -47,7 +47,7 @@ + - A pair ``(host, port)`` is used for the :const:`AF_INET` address family, + where *host* is a string representing either a hostname in Internet domain + notation like ``'daring.cwi.nl'`` or an IPv4 address like ``'100.50.200.5'``, +- and *port* is an integral port number. ++ and *port* is an integer. + + - For :const:`AF_INET6` address family, a four-tuple ``(host, port, flowinfo, + scopeid)`` is used, where *flowinfo* and *scopeid* represent the ``sin6_flowinfo`` +diff -r 3d0686d90f55 Doc/library/sqlite3.rst +--- a/Doc/library/sqlite3.rst ++++ b/Doc/library/sqlite3.rst +@@ -3,7 +3,7 @@ + + .. module:: sqlite3 + :synopsis: A DB-API 2.0 implementation using SQLite 3.x. +-.. sectionauthor:: Gerhard Häring ++.. sectionauthor:: Gerhard Häring + + + SQLite is a C library that provides a lightweight disk-based database that +@@ -20,6 +20,7 @@ + represents the database. Here the data will be stored in the + :file:`/tmp/example` file:: + ++ import sqlite3 + conn = sqlite3.connect('/tmp/example') + + You can also supply the special name ``:memory:`` to create a database in RAM. +@@ -56,7 +57,7 @@ + + # Never do this -- insecure! + symbol = 'IBM' +- c.execute("... where symbol = '%s'" % symbol) ++ c.execute("select * from stocks where symbol = '%s'" % symbol) + + # Do this instead + t = (symbol,) +@@ -64,7 +65,7 @@ + + # Larger example + for t in [('2006-03-28', 'BUY', 'IBM', 1000, 45.00), +- ('2006-04-05', 'BUY', 'MSOFT', 1000, 72.00), ++ ('2006-04-05', 'BUY', 'MSFT', 1000, 72.00), + ('2006-04-06', 'SELL', 'IBM', 500, 53.00), + ]: + c.execute('insert into stocks values (?,?,?,?,?)', t) +@@ -271,7 +272,6 @@ + calling the cursor method, then calls the cursor's :meth:`executemany + ` method with the parameters given. + +- + .. method:: Connection.executescript(sql_script) + + This is a nonstandard shortcut that creates an intermediate cursor object by +@@ -376,22 +376,22 @@ + aggregates or whole new virtual table implementations. One well-known + extension is the fulltext-search extension distributed with SQLite. + ++ Loadable extensions are disabled by default. See [#f1]_. ++ + .. versionadded:: 3.2 + + .. literalinclude:: ../includes/sqlite3/load_extension.py + +- Loadable extensions are disabled by default. See [#f1]_. +- + .. method:: Connection.load_extension(path) + + This routine loads a SQLite extension from a shared library. You have to + enable extension loading with :meth:`enable_load_extension` before you can + use this routine. + ++ Loadable extensions are disabled by default. See [#f1]_. ++ + .. versionadded:: 3.2 + +- Loadable extensions are disabled by default. See [#f1]_. +- + .. attribute:: Connection.row_factory + + You can change this attribute to a callable that accepts the cursor and the +@@ -514,7 +514,7 @@ + or :const:`None` when no more data is available. + + +-.. method:: Cursor.fetchmany([size=cursor.arraysize]) ++.. method:: Cursor.fetchmany(size=cursor.arraysize) + + Fetches the next set of rows of a query result, returning a list. An empty + list is returned when no more rows are available. +diff -r 3d0686d90f55 Doc/library/stdtypes.rst +--- a/Doc/library/stdtypes.rst ++++ b/Doc/library/stdtypes.rst +@@ -819,7 +819,8 @@ + also string-specific methods described in the :ref:`string-methods` section. + + Bytes and bytearray objects contain single bytes -- the former is immutable +-while the latter is a mutable sequence. Bytes objects can be constructed the ++while the latter is a mutable sequence. ++Bytes objects can be constructed by using the + constructor, :func:`bytes`, and from literals; use a ``b`` prefix with normal + string syntax: ``b'xyzzy'``. To construct byte arrays, use the + :func:`bytearray` function. +@@ -1304,8 +1305,8 @@ + Return a list of the words in the string, using *sep* as the delimiter + string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, + the list will have at most ``maxsplit+1`` elements). If *maxsplit* is not +- specified, then there is no limit on the number of splits (all possible +- splits are made). ++ specified or ``-1``, then there is no limit on the number of splits ++ (all possible splits are made). + + If *sep* is given, consecutive delimiters are not grouped together and are + deemed to delimit empty strings (for example, ``'1,,2'.split(',')`` returns +@@ -1328,7 +1329,13 @@ + + Return a list of the lines in the string, breaking at line boundaries. Line + breaks are not included in the resulting list unless *keepends* is given and +- true. ++ true. This method uses the universal newlines approach to splitting lines. ++ Unlike :meth:`~str.split`, if the string ends with line boundary characters ++ the returned list does ``not`` have an empty last element. ++ ++ For example, ``'ab c\n\nde fg\rkl\r\n'.splitlines()`` returns ++ ``['ab c', '', 'de fg', 'kl']``, while the same call with ``splitlines(True)`` ++ returns ``['ab c\n', '\n, 'de fg\r', 'kl\r\n']``. + + + .. method:: str.startswith(prefix[, start[, end]]) +@@ -1437,8 +1444,13 @@ + + .. note:: + +- The formatting operations described here are obsolete and may go away in future +- versions of Python. Use the new :ref:`string-formatting` in new code. ++ The formatting operations described here are modelled on C's printf() ++ syntax. They only support formatting of certain builtin types. The ++ use of a binary operator means that care may be needed in order to ++ format tuples and dictionaries correctly. As the new ++ :ref:`string-formatting` syntax is more flexible and handles tuples and ++ dictionaries naturally, it is recommended for new code. However, there ++ are no current plans to deprecate printf-style formatting. + + String objects have one unique built-in operation: the ``%`` operator (modulo). + This is also known as the string *formatting* or *interpolation* operator. +diff -r 3d0686d90f55 Doc/library/string.rst +--- a/Doc/library/string.rst ++++ b/Doc/library/string.rst +@@ -292,7 +292,7 @@ + + .. productionlist:: sf + format_spec: [[`fill`]`align`][`sign`][#][0][`width`][,][.`precision`][`type`] +- fill: ++ fill: + align: "<" | ">" | "=" | "^" + sign: "+" | "-" | " " + width: `integer` +diff -r 3d0686d90f55 Doc/library/subprocess.rst +--- a/Doc/library/subprocess.rst ++++ b/Doc/library/subprocess.rst +@@ -735,7 +735,7 @@ + to receive a SIGPIPE if p2 exits before p1. + + Alternatively, for trusted input, the shell's own pipeline support may still +-be used directly: ++be used directly:: + + output=`dmesg | grep hda` + # becomes +diff -r 3d0686d90f55 Doc/library/syslog.rst +--- a/Doc/library/syslog.rst ++++ b/Doc/library/syslog.rst +@@ -78,7 +78,8 @@ + Facilities: + :const:`LOG_KERN`, :const:`LOG_USER`, :const:`LOG_MAIL`, :const:`LOG_DAEMON`, + :const:`LOG_AUTH`, :const:`LOG_LPR`, :const:`LOG_NEWS`, :const:`LOG_UUCP`, +- :const:`LOG_CRON` and :const:`LOG_LOCAL0` to :const:`LOG_LOCAL7`. ++ :const:`LOG_CRON`, :const:`LOG_SYSLOG` and :const:`LOG_LOCAL0` to ++ :const:`LOG_LOCAL7`. + + Log options: + :const:`LOG_PID`, :const:`LOG_CONS`, :const:`LOG_NDELAY`, :const:`LOG_NOWAIT` +diff -r 3d0686d90f55 Doc/library/test.rst +--- a/Doc/library/test.rst ++++ b/Doc/library/test.rst +@@ -171,9 +171,9 @@ + + Running :mod:`test` directly allows what resources are available for + tests to use to be set. You do this by using the ``-u`` command-line +-option. Run :program:`python -m test -uall` to turn on all +-resources; specifying ``all`` as an option for ``-u`` enables all +-possible resources. If all but one resource is desired (a more common case), a ++option. Specifying ``all`` as the value for the ``-u`` option enables all ++possible resources: :program:`python -m test -uall`. ++If all but one resource is desired (a more common case), a + comma-separated list of resources that are not desired may be listed after + ``all``. The command :program:`python -m test -uall,-audio,-largefile` + will run :mod:`test` with all resources except the ``audio`` and +@@ -362,7 +362,7 @@ + + with captured_stdout() as s: + print("hello") +- assert s.getvalue() == "hello" ++ assert s.getvalue() == "hello\n" + + + .. function:: import_module(name, deprecated=False) +diff -r 3d0686d90f55 Doc/library/threading.rst +--- a/Doc/library/threading.rst ++++ b/Doc/library/threading.rst +@@ -218,30 +218,31 @@ + + This class represents an activity that is run in a separate thread of control. + There are two ways to specify the activity: by passing a callable object to the +-constructor, or by overriding the :meth:`run` method in a subclass. No other +-methods (except for the constructor) should be overridden in a subclass. In +-other words, *only* override the :meth:`__init__` and :meth:`run` methods of +-this class. ++constructor, or by overriding the :meth:`~Thread.run` method in a subclass. ++No other methods (except for the constructor) should be overridden in a ++subclass. In other words, *only* override the :meth:`~Thread.__init__` ++and :meth:`~Thread.run` methods of this class. + + Once a thread object is created, its activity must be started by calling the +-thread's :meth:`start` method. This invokes the :meth:`run` method in a +-separate thread of control. ++thread's :meth:`~Thread.start` method. This invokes the :meth:`~Thread.run` ++method in a separate thread of control. + + Once the thread's activity is started, the thread is considered 'alive'. It +-stops being alive when its :meth:`run` method terminates -- either normally, or +-by raising an unhandled exception. The :meth:`is_alive` method tests whether the +-thread is alive. ++stops being alive when its :meth:`~Thread.run` method terminates -- either ++normally, or by raising an unhandled exception. The :meth:`~Thread.is_alive` ++method tests whether the thread is alive. + +-Other threads can call a thread's :meth:`join` method. This blocks the calling +-thread until the thread whose :meth:`join` method is called is terminated. ++Other threads can call a thread's :meth:`~Thread.join` method. This blocks ++the calling thread until the thread whose :meth:`~Thread.join` method is ++called is terminated. + + A thread has a name. The name can be passed to the constructor, and read or +-changed through the :attr:`name` attribute. ++changed through the :attr:`~Thread.name` attribute. + +-A thread can be flagged as a "daemon thread". The significance of this flag is +-that the entire Python program exits when only daemon threads are left. The +-initial value is inherited from the creating thread. The flag can be set +-through the :attr:`daemon` property. ++A thread can be flagged as a "daemon thread". The significance of this flag ++is that the entire Python program exits when only daemon threads are left. ++The initial value is inherited from the creating thread. The flag can be ++set through the :attr:`~Thread.daemon` property. + + There is a "main thread" object; this corresponds to the initial thread of + control in the Python program. It is not a daemon thread. +@@ -250,8 +251,8 @@ + thread objects corresponding to "alien threads", which are threads of control + started outside the threading module, such as directly from C code. Dummy + thread objects have limited functionality; they are always considered alive and +-daemonic, and cannot be :meth:`join`\ ed. They are never deleted, since it is +-impossible to detect the termination of alien threads. ++daemonic, and cannot be :meth:`~Thread.join`\ ed. They are never deleted, ++since it is impossible to detect the termination of alien threads. + + + .. class:: Thread(group=None, target=None, name=None, args=(), kwargs={}) +@@ -282,7 +283,8 @@ + Start the thread's activity. + + It must be called at most once per thread object. It arranges for the +- object's :meth:`run` method to be invoked in a separate thread of control. ++ object's :meth:`~Thread.run` method to be invoked in a separate thread ++ of control. + + This method will raise a :exc:`RuntimeError` if called more than once + on the same thread object. +@@ -298,25 +300,27 @@ + + .. method:: join(timeout=None) + +- Wait until the thread terminates. This blocks the calling thread until the +- thread whose :meth:`join` method is called terminates -- either normally +- or through an unhandled exception -- or until the optional timeout occurs. ++ Wait until the thread terminates. This blocks the calling thread until ++ the thread whose :meth:`~Thread.join` method is called terminates -- either ++ normally or through an unhandled exception --, or until the optional ++ timeout occurs. + + When the *timeout* argument is present and not ``None``, it should be a + floating point number specifying a timeout for the operation in seconds +- (or fractions thereof). As :meth:`join` always returns ``None``, you must +- call :meth:`is_alive` after :meth:`join` to decide whether a timeout +- happened -- if the thread is still alive, the :meth:`join` call timed out. ++ (or fractions thereof). As :meth:`~Thread.join` always returns ``None``, ++ you must call :meth:`~Thread.is_alive` after :meth:`~Thread.join` to ++ decide whether a timeout happened -- if the thread is still alive, the ++ :meth:`~Thread.join` call timed out. + + When the *timeout* argument is not present or ``None``, the operation will + block until the thread terminates. + +- A thread can be :meth:`join`\ ed many times. ++ A thread can be :meth:`~Thread.join`\ ed many times. + +- :meth:`join` raises a :exc:`RuntimeError` if an attempt is made to join +- the current thread as that would cause a deadlock. It is also an error to +- :meth:`join` a thread before it has been started and attempts to do so +- raises the same exception. ++ :meth:`~Thread.join` raises a :exc:`RuntimeError` if an attempt is made ++ to join the current thread as that would cause a deadlock. It is also ++ an error to :meth:`~Thread.join` a thread before it has been started ++ and attempts to do so raise the same exception. + + .. attribute:: name + +@@ -334,7 +338,7 @@ + + The 'thread identifier' of this thread or ``None`` if the thread has not + been started. This is a nonzero integer. See the +- :func:`thread.get_ident()` function. Thread identifiers may be recycled ++ :func:`_thread.get_ident()` function. Thread identifiers may be recycled + when a thread exits and another thread is created. The identifier is + available even after the thread has exited. + +@@ -342,18 +346,18 @@ + + Return whether the thread is alive. + +- This method returns ``True`` just before the :meth:`run` method starts +- until just after the :meth:`run` method terminates. The module function +- :func:`.enumerate` returns a list of all alive threads. ++ This method returns ``True`` just before the :meth:`~Thread.run` method ++ starts until just after the :meth:`~Thread.run` method terminates. The ++ module function :func:`.enumerate` returns a list of all alive threads. + + .. attribute:: daemon + + A boolean value indicating whether this thread is a daemon thread (True) +- or not (False). This must be set before :meth:`start` is called, ++ or not (False). This must be set before :meth:`~Thread.start` is called, + otherwise :exc:`RuntimeError` is raised. Its initial value is inherited + from the creating thread; the main thread is not a daemon thread and +- therefore all threads created in the main thread default to :attr:`daemon` +- = ``False``. ++ therefore all threads created in the main thread default to ++ :attr:`~Thread.daemon` = ``False``. + + The entire Python program exits when no alive non-daemon threads are left. + +@@ -375,19 +379,22 @@ + extension module. + + A primitive lock is in one of two states, "locked" or "unlocked". It is created +-in the unlocked state. It has two basic methods, :meth:`acquire` and +-:meth:`release`. When the state is unlocked, :meth:`acquire` changes the state +-to locked and returns immediately. When the state is locked, :meth:`acquire` +-blocks until a call to :meth:`release` in another thread changes it to unlocked, +-then the :meth:`acquire` call resets it to locked and returns. The +-:meth:`release` method should only be called in the locked state; it changes the +-state to unlocked and returns immediately. If an attempt is made to release an +-unlocked lock, a :exc:`RuntimeError` will be raised. ++in the unlocked state. It has two basic methods, :meth:`~Lock.acquire` and ++:meth:`~Lock.release`. When the state is unlocked, :meth:`~Lock.acquire` ++changes the state to locked and returns immediately. When the state is locked, ++:meth:`~Lock.acquire` blocks until a call to :meth:`~Lock.release` in another ++thread changes it to unlocked, then the :meth:`~Lock.acquire` call resets it ++to locked and returns. The :meth:`~Lock.release` method should only be ++called in the locked state; it changes the state to unlocked and returns ++immediately. If an attempt is made to release an unlocked lock, a ++:exc:`RuntimeError` will be raised. + +-When more than one thread is blocked in :meth:`acquire` waiting for the state to +-turn to unlocked, only one thread proceeds when a :meth:`release` call resets +-the state to unlocked; which one of the waiting threads proceeds is not defined, +-and may vary across implementations. ++Locks also support the :ref:`context manager protocol `. ++ ++When more than one thread is blocked in :meth:`~Lock.acquire` waiting for the ++state to turn to unlocked, only one thread proceeds when a :meth:`~Lock.release` ++call resets the state to unlocked; which one of the waiting threads proceeds ++is not defined, and may vary across implementations. + + All methods are executed atomically. + +@@ -396,15 +403,12 @@ + + Acquire a lock, blocking or non-blocking. + +- When invoked without arguments, block until the lock is unlocked, then set it to +- locked, and return true. ++ When invoked with the *blocking* argument set to ``True`` (the default), ++ block until the lock is unlocked, then set it to locked and return ``True``. + +- When invoked with the *blocking* argument set to true, do the same thing as when +- called without arguments, and return true. +- +- When invoked with the *blocking* argument set to false, do not block. If a call +- without an argument would block, return false immediately; otherwise, do the +- same thing as when called without arguments, and return true. ++ When invoked with the *blocking* argument set to ``False``, do not block. ++ If a call with *blocking* set to ``True`` would block, return ``False`` ++ immediately; otherwise, set the lock to locked and return ``True``. + + When invoked with the floating-point *timeout* argument set to a positive + value, block for at most the number of seconds specified by *timeout* +@@ -424,13 +428,14 @@ + + .. method:: Lock.release() + +- Release a lock. ++ Release a lock. This can be called from any thread, not only the thread ++ which has acquired the lock. + + When the lock is locked, reset it to unlocked, and return. If any other threads + are blocked waiting for the lock to become unlocked, allow exactly one of them + to proceed. + +- Do not call this method when the lock is unlocked. ++ When invoked on an unlocked lock, a :exc:`ThreadError` is raised. + + There is no return value. + +@@ -446,12 +451,14 @@ + locks. In the locked state, some thread owns the lock; in the unlocked state, + no thread owns it. + +-To lock the lock, a thread calls its :meth:`acquire` method; this returns once +-the thread owns the lock. To unlock the lock, a thread calls its +-:meth:`release` method. :meth:`acquire`/:meth:`release` call pairs may be +-nested; only the final :meth:`release` (the :meth:`release` of the outermost +-pair) resets the lock to unlocked and allows another thread blocked in +-:meth:`acquire` to proceed. ++To lock the lock, a thread calls its :meth:`~RLock.acquire` method; this ++returns once the thread owns the lock. To unlock the lock, a thread calls ++its :meth:`~Lock.release` method. :meth:`~Lock.acquire`/:meth:`~Lock.release` ++call pairs may be nested; only the final :meth:`~Lock.release` (the ++:meth:`~Lock.release` of the outermost pair) resets the lock to unlocked and ++allows another thread blocked in :meth:`~Lock.acquire` to proceed. ++ ++Reentrant locks also support the :ref:`context manager protocol `. + + + .. method:: RLock.acquire(blocking=True, timeout=-1) +@@ -503,62 +510,76 @@ + ----------------- + + A condition variable is always associated with some kind of lock; this can be +-passed in or one will be created by default. (Passing one in is useful when +-several condition variables must share the same lock.) ++passed in or one will be created by default. Passing one in is useful when ++several condition variables must share the same lock. The lock is part of ++the condition object: you don't have to track it separately. + +-A condition variable has :meth:`acquire` and :meth:`release` methods that call +-the corresponding methods of the associated lock. It also has a :meth:`wait` +-method, and :meth:`notify` and :meth:`notify_all` methods. These three must only +-be called when the calling thread has acquired the lock, otherwise a +-:exc:`RuntimeError` is raised. ++A condition variable obeys the :ref:`context manager protocol `: ++using the ``with`` statement acquires the associated lock for the duration of ++the enclosed block. The :meth:`~Condition.acquire` and ++:meth:`~Condition.release` methods also call the corresponding methods of ++the associated lock. + +-The :meth:`wait` method releases the lock, and then blocks until it is awakened +-by a :meth:`notify` or :meth:`notify_all` call for the same condition variable in +-another thread. Once awakened, it re-acquires the lock and returns. It is also +-possible to specify a timeout. ++Other methods must be called with the associated lock held. The ++:meth:`~Condition.wait` method releases the lock, and then blocks until ++another thread awakens it by calling :meth:`~Condition.notify` or ++:meth:`~Condition.notify_all`. Once awakened, :meth:`~Condition.wait` ++re-acquires the lock and returns. It is also possible to specify a timeout. + +-The :meth:`notify` method wakes up one of the threads waiting for the condition +-variable, if any are waiting. The :meth:`notify_all` method wakes up all threads +-waiting for the condition variable. ++The :meth:`~Condition.notify` method wakes up one of the threads waiting for ++the condition variable, if any are waiting. The :meth:`~Condition.notify_all` ++method wakes up all threads waiting for the condition variable. + +-Note: the :meth:`notify` and :meth:`notify_all` methods don't release the lock; +-this means that the thread or threads awakened will not return from their +-:meth:`wait` call immediately, but only when the thread that called +-:meth:`notify` or :meth:`notify_all` finally relinquishes ownership of the lock. ++Note: the :meth:`~Condition.notify` and :meth:`~Condition.notify_all` methods ++don't release the lock; this means that the thread or threads awakened will ++not return from their :meth:`~Condition.wait` call immediately, but only when ++the thread that called :meth:`~Condition.notify` or :meth:`~Condition.notify_all` ++finally relinquishes ownership of the lock. + +-Tip: the typical programming style using condition variables uses the lock to ++ ++Usage ++^^^^^ ++ ++The typical programming style using condition variables uses the lock to + synchronize access to some shared state; threads that are interested in a +-particular change of state call :meth:`wait` repeatedly until they see the +-desired state, while threads that modify the state call :meth:`notify` or +-:meth:`notify_all` when they change the state in such a way that it could +-possibly be a desired state for one of the waiters. For example, the following +-code is a generic producer-consumer situation with unlimited buffer capacity:: ++particular change of state call :meth:`~Condition.wait` repeatedly until they ++see the desired state, while threads that modify the state call ++:meth:`~Condition.notify` or :meth:`~Condition.notify_all` when they change ++the state in such a way that it could possibly be a desired state for one ++of the waiters. For example, the following code is a generic ++producer-consumer situation with unlimited buffer capacity:: + + # Consume one item +- cv.acquire() +- while not an_item_is_available(): +- cv.wait() +- get_an_available_item() +- cv.release() ++ with cv: ++ while not an_item_is_available(): ++ cv.wait() ++ get_an_available_item() + + # Produce one item +- cv.acquire() +- make_an_item_available() +- cv.notify() +- cv.release() ++ with cv: ++ make_an_item_available() ++ cv.notify() + +-To choose between :meth:`notify` and :meth:`notify_all`, consider whether one +-state change can be interesting for only one or several waiting threads. E.g. +-in a typical producer-consumer situation, adding one item to the buffer only +-needs to wake up one consumer thread. ++The ``while`` loop checking for the application's condition is necessary ++because :meth:`~Condition.wait` can return after an arbitrary long time, ++and the condition which prompted the :meth:`~Condition.notify` call may ++no longer hold true. This is inherent to multi-threaded programming. The ++:meth:`~Condition.wait_for` method can be used to automate the condition ++checking, and eases the computation of timeouts:: + +-Note: Condition variables can be, depending on the implementation, subject +-to both spurious wakeups (when :meth:`wait` returns without a :meth:`notify` +-call) and stolen wakeups (when another thread acquires the lock before the +-awoken thread.) For this reason, it is always necessary to verify the state +-the thread is waiting for when :meth:`wait` returns and optionally repeat +-the call as often as necessary. ++ # Consume an item ++ with cv: ++ cv.wait_for(an_item_is_available) ++ get_an_available_item() + ++To choose between :meth:`~Condition.notify` and :meth:`~Condition.notify_all`, ++consider whether one state change can be interesting for only one or several ++waiting threads. E.g. in a typical producer-consumer situation, adding one ++item to the buffer only needs to wake up one consumer thread. ++ ++ ++Interface ++^^^^^^^^^ + + .. class:: Condition(lock=None) + +@@ -626,12 +647,6 @@ + held when called and is re-aquired on return. The predicate is evaluated + with the lock held. + +- Using this method, the consumer example above can be written thus:: +- +- with cv: +- cv.wait_for(an_item_is_available) +- get_an_available_item() +- + .. versionadded:: 3.2 + + .. method:: notify(n=1) +@@ -667,12 +682,16 @@ + + This is one of the oldest synchronization primitives in the history of computer + science, invented by the early Dutch computer scientist Edsger W. Dijkstra (he +-used :meth:`P` and :meth:`V` instead of :meth:`acquire` and :meth:`release`). ++used the names ``P()`` and ``V()`` instead of :meth:`~Semaphore.acquire` and ++:meth:`~Semaphore.release`). + + A semaphore manages an internal counter which is decremented by each +-:meth:`acquire` call and incremented by each :meth:`release` call. The counter +-can never go below zero; when :meth:`acquire` finds that it is zero, it blocks, +-waiting until some other thread calls :meth:`release`. ++:meth:`~Semaphore.acquire` call and incremented by each :meth:`~Semaphore.release` ++call. The counter can never go below zero; when :meth:`~Semaphore.acquire` ++finds that it is zero, it blocks, waiting until some other thread calls ++:meth:`~Semaphore.release`. ++ ++Semaphores also support the :ref:`context manager protocol `. + + + .. class:: Semaphore(value=1) +@@ -688,11 +707,12 @@ + When invoked without arguments: if the internal counter is larger than + zero on entry, decrement it by one and return immediately. If it is zero + on entry, block, waiting until some other thread has called +- :meth:`release` to make it larger than zero. This is done with proper +- interlocking so that if multiple :meth:`acquire` calls are blocked, +- :meth:`release` will wake exactly one of them up. The implementation may +- pick one at random, so the order in which blocked threads are awakened +- should not be relied on. Returns true (or blocks indefinitely). ++ :meth:`~Semaphore.release` to make it larger than zero. This is done ++ with proper interlocking so that if multiple :meth:`acquire` calls are ++ blocked, :meth:`~Semaphore.release` will wake exactly one of them up. ++ The implementation may pick one at random, so the order in which ++ blocked threads are awakened should not be relied on. Returns ++ true (or blocks indefinitely). + + When invoked with *blocking* set to false, do not block. If a call + without an argument would block, return false immediately; otherwise, +@@ -729,11 +749,12 @@ + Once spawned, worker threads call the semaphore's acquire and release methods + when they need to connect to the server:: + +- pool_sema.acquire() +- conn = connectdb() +- ... use connection ... +- conn.close() +- pool_sema.release() ++ with pool_sema: ++ conn = connectdb() ++ try: ++ ... use connection ... ++ finally: ++ conn.close() + + The use of a bounded semaphore reduces the chance that a programming error which + causes the semaphore to be released more than it's acquired will go undetected. +@@ -748,8 +769,8 @@ + thread signals an event and other threads wait for it. + + An event object manages an internal flag that can be set to true with the +-:meth:`~Event.set` method and reset to false with the :meth:`clear` method. The +-:meth:`wait` method blocks until the flag is true. ++:meth:`~Event.set` method and reset to false with the :meth:`~Event.clear` ++method. The :meth:`~Event.wait` method blocks until the flag is true. + + + .. class:: Event() +@@ -776,7 +797,7 @@ + + Block until the internal flag is true. If the internal flag is true on + entry, return immediately. Otherwise, block until another thread calls +- :meth:`set` to set the flag to true, or until the optional timeout occurs. ++ :meth:`.set` to set the flag to true, or until the optional timeout occurs. + + When the timeout argument is present and not ``None``, it should be a + floating point number specifying a timeout for the operation in seconds +@@ -832,8 +853,8 @@ + + This class provides a simple synchronization primitive for use by a fixed number + of threads that need to wait for each other. Each of the threads tries to pass +-the barrier by calling the :meth:`wait` method and will block until all of the +-threads have made the call. At this points, the threads are released ++the barrier by calling the :meth:`~Barrier.wait` method and will block until ++all of the threads have made the call. At this points, the threads are released + simultanously. + + The barrier can be reused any number of times for the same number of threads. +@@ -934,19 +955,24 @@ + + All of the objects provided by this module that have :meth:`acquire` and + :meth:`release` methods can be used as context managers for a :keyword:`with` +-statement. The :meth:`acquire` method will be called when the block is entered, +-and :meth:`release` will be called when the block is exited. ++statement. The :meth:`acquire` method will be called when the block is ++entered, and :meth:`release` will be called when the block is exited. Hence, ++the following snippet:: ++ ++ with some_lock: ++ # do something... ++ ++is equivalent to:: ++ ++ some_lock.acquire() ++ try: ++ # do something... ++ finally: ++ some_lock.release() + + Currently, :class:`Lock`, :class:`RLock`, :class:`Condition`, + :class:`Semaphore`, and :class:`BoundedSemaphore` objects may be used as +-:keyword:`with` statement context managers. For example:: +- +- import threading +- +- some_rlock = threading.RLock() +- +- with some_rlock: +- print("some_rlock is locked while this executes") ++:keyword:`with` statement context managers. + + + .. _threaded-imports: +diff -r 3d0686d90f55 Doc/library/time.rst +--- a/Doc/library/time.rst ++++ b/Doc/library/time.rst +@@ -81,9 +81,9 @@ + the units in which their value or argument is expressed. E.g. on most Unix + systems, the clock "ticks" only 50 or 100 times a second. + +-* On the other hand, the precision of :func:`time` and :func:`sleep` is better ++* On the other hand, the precision of :func:`.time` and :func:`sleep` is better + than their Unix equivalents: times are expressed as floating point numbers, +- :func:`time` returns the most accurate time available (using Unix ++ :func:`.time` returns the most accurate time available (using Unix + :c:func:`gettimeofday` where available), and :func:`sleep` will accept a time + with a nonzero fraction (Unix :c:func:`select` is used to implement this, where + available). +@@ -177,7 +177,7 @@ + + Convert a time expressed in seconds since the epoch to a string representing + local time. If *secs* is not provided or :const:`None`, the current time as +- returned by :func:`time` is used. ``ctime(secs)`` is equivalent to ++ returned by :func:`.time` is used. ``ctime(secs)`` is equivalent to + ``asctime(localtime(secs))``. Locale information is not used by :func:`ctime`. + + +@@ -190,7 +190,7 @@ + + Convert a time expressed in seconds since the epoch to a :class:`struct_time` in + UTC in which the dst flag is always zero. If *secs* is not provided or +- :const:`None`, the current time as returned by :func:`time` is used. Fractions ++ :const:`None`, the current time as returned by :func:`.time` is used. Fractions + of a second are ignored. See above for a description of the + :class:`struct_time` object. See :func:`calendar.timegm` for the inverse of this + function. +@@ -199,7 +199,7 @@ + .. function:: localtime([secs]) + + Like :func:`gmtime` but converts to local time. If *secs* is not provided or +- :const:`None`, the current time as returned by :func:`time` is used. The dst ++ :const:`None`, the current time as returned by :func:`.time` is used. The dst + flag is set to ``1`` when DST applies to the given time. + + +@@ -208,7 +208,7 @@ + This is the inverse function of :func:`localtime`. Its argument is the + :class:`struct_time` or full 9-tuple (since the dst flag is needed; use ``-1`` + as the dst flag if it is unknown) which expresses the time in *local* time, not +- UTC. It returns a floating point number, for compatibility with :func:`time`. ++ UTC. It returns a floating point number, for compatibility with :func:`.time`. + If the input value cannot be represented as a valid time, either + :exc:`OverflowError` or :exc:`ValueError` will be raised (which depends on + whether the invalid value is caught by Python or the underlying C libraries). +@@ -430,8 +430,8 @@ + + .. function:: time() + +- Return the time as a floating point number expressed in seconds since the epoch, +- in UTC. Note that even though the time is always returned as a floating point ++ Return the time in seconds since the epoch as a floating point number. ++ Note that even though the time is always returned as a floating point + number, not all systems provide time with a better precision than 1 second. + While this function normally returns non-decreasing values, it can return a + lower value than a previous call if the system clock has been set back between +diff -r 3d0686d90f55 Doc/library/timeit.rst +--- a/Doc/library/timeit.rst ++++ b/Doc/library/timeit.rst +@@ -99,7 +99,19 @@ + timeit.Timer('for i in range(10): oct(i)', 'gc.enable()').timeit() + + +-The module also defines two convenience functions: ++The module also defines three convenience functions: ++ ++ ++.. function:: default_timer() ++ ++ Define a default timer, in a platform specific manner. On Windows, ++ :func:`time.clock` has microsecond granularity but :func:`time.time`'s ++ granularity is 1/60th of a second; on Unix, :func:`time.clock` has 1/100th of ++ a second granularity and :func:`time.time` is much more precise. On either ++ platform, :func:`default_timer` measures wall clock time, not the CPU ++ time. This means that other processes running on the same computer may ++ interfere with the timing. ++ + + .. function:: repeat(stmt='pass', setup='pass', timer=, repeat=3, number=1000000) + +@@ -161,13 +173,9 @@ + If :option:`-n` is not given, a suitable number of loops is calculated by trying + successive powers of 10 until the total time is at least 0.2 seconds. + +-The default timer function is platform dependent. On Windows, +-:func:`time.clock` has microsecond granularity but :func:`time.time`'s +-granularity is 1/60th of a second; on Unix, :func:`time.clock` has 1/100th of a +-second granularity and :func:`time.time` is much more precise. On either +-platform, the default timer functions measure wall clock time, not the CPU time. +-This means that other processes running on the same computer may interfere with +-the timing. The best thing to do when accurate timing is necessary is to repeat ++:func:`default_timer` measurations can be affected by other programs running on ++the same machine, so ++the best thing to do when accurate timing is necessary is to repeat + the timing a few times and use the best time. The :option:`-r` option is good + for this; the default of 3 repetitions is probably enough in most cases. On + Unix, you can use :func:`time.clock` to measure CPU time. +diff -r 3d0686d90f55 Doc/library/unittest.rst +--- a/Doc/library/unittest.rst ++++ b/Doc/library/unittest.rst +@@ -640,7 +640,7 @@ + + Classes can be skipped just like methods: :: + +- @skip("showing class skipping") ++ @unittest.skip("showing class skipping") + class MySkippedTestCase(unittest.TestCase): + def test_not_run(self): + pass +@@ -1553,8 +1553,8 @@ + The :class:`TestLoader` class is used to create test suites from classes and + modules. Normally, there is no need to create an instance of this class; the + :mod:`unittest` module provides an instance that can be shared as +- ``unittest.defaultTestLoader``. Using a subclass or instance, however, allows +- customization of some configurable properties. ++ :data:`unittest.defaultTestLoader`. Using a subclass or instance, however, ++ allows customization of some configurable properties. + + :class:`TestLoader` objects have the following methods: + +@@ -1926,9 +1926,10 @@ + testLoader=unittest.defaultTestLoader, exit=True, verbosity=1, \ + failfast=None, catchbreak=None, buffer=None, warnings=None) + +- A command-line program that runs a set of tests; this is primarily for making +- test modules conveniently executable. The simplest use for this function is to +- include the following line at the end of a test script:: ++ A command-line program that loads a set of tests from *module* and runs them; ++ this is primarily for making test modules conveniently executable. ++ The simplest use for this function is to include the following line at the ++ end of a test script:: + + if __name__ == '__main__': + unittest.main() +@@ -1939,10 +1940,17 @@ + if __name__ == '__main__': + unittest.main(verbosity=2) + ++ The *argv* argument can be a list of options passed to the program, with the ++ first element being the program name. If not specified or ``None``, ++ the values of :data:`sys.argv` are used. ++ + The *testRunner* argument can either be a test runner class or an already + created instance of it. By default ``main`` calls :func:`sys.exit` with + an exit code indicating success or failure of the tests run. + ++ The *testLoader* argument has to be a :class:`TestLoader` instance, ++ and defaults to :data:`defaultTestLoader`. ++ + ``main`` supports being used from the interactive interpreter by passing in the + argument ``exit=False``. This displays the result on standard output without + calling :func:`sys.exit`:: +@@ -1950,7 +1958,7 @@ + >>> from unittest import main + >>> main(module='test_module', exit=False) + +- The ``failfast``, ``catchbreak`` and ``buffer`` parameters have the same ++ The *failfast*, *catchbreak* and *buffer* parameters have the same + effect as the same-name `command-line options`_. + + The *warning* argument specifies the :ref:`warning filter ` +@@ -1962,11 +1970,11 @@ + This stores the result of the tests run as the ``result`` attribute. + + .. versionchanged:: 3.1 +- The ``exit`` parameter was added. ++ The *exit* parameter was added. + + .. versionchanged:: 3.2 +- The ``verbosity``, ``failfast``, ``catchbreak``, ``buffer`` +- and ``warnings`` parameters were added. ++ The *verbosity*, *failfast*, *catchbreak*, *buffer* ++ and *warnings* parameters were added. + + + load_tests Protocol +diff -r 3d0686d90f55 Doc/library/urllib.parse.rst +--- a/Doc/library/urllib.parse.rst ++++ b/Doc/library/urllib.parse.rst +@@ -22,11 +22,11 @@ + to an absolute URL given a "base URL." + + The module has been designed to match the Internet RFC on Relative Uniform +-Resource Locators (and discovered a bug in an earlier draft!). It supports the +-following URL schemes: ``file``, ``ftp``, ``gopher``, ``hdl``, ``http``, +-``https``, ``imap``, ``mailto``, ``mms``, ``news``, ``nntp``, ``prospero``, +-``rsync``, ``rtsp``, ``rtspu``, ``sftp``, ``shttp``, ``sip``, ``sips``, +-``snews``, ``svn``, ``svn+ssh``, ``telnet``, ``wais``. ++Resource Locators. It supports the following URL schemes: ``file``, ``ftp``, ++``gopher``, ``hdl``, ``http``, ``https``, ``imap``, ``mailto``, ``mms``, ++``news``, ``nntp``, ``prospero``, ``rsync``, ``rtsp``, ``rtspu``, ``sftp``, ++``shttp``, ``sip``, ``sips``, ``snews``, ``svn``, ``svn+ssh``, ``telnet``, ++``wais``. + + The :mod:`urllib.parse` module defines functions that fall into two broad + categories: URL parsing and URL quoting. These are covered in detail in +@@ -512,9 +512,10 @@ + + Convert a mapping object or a sequence of two-element tuples, which may + either be a :class:`str` or a :class:`bytes`, to a "percent-encoded" +- string. The resultant string must be converted to bytes using the +- user-specified encoding before it is sent to :func:`urlopen` as the optional +- *data* argument. ++ string. If the resultant string is to be used as a *data* for POST ++ operation with :func:`urlopen` function, then it should be properly encoded ++ to bytes, otherwise it would result in a :exc:`TypeError`. ++ + The resulting string is a series of ``key=value`` pairs separated by ``'&'`` + characters, where both *key* and *value* are quoted using :func:`quote_plus` + above. When a sequence of two-element tuples is used as the *query* +diff -r 3d0686d90f55 Doc/library/urllib.request.rst +--- a/Doc/library/urllib.request.rst ++++ b/Doc/library/urllib.request.rst +@@ -2,9 +2,10 @@ + ============================================================= + + .. module:: urllib.request +- :synopsis: Next generation URL opening library. ++ :synopsis: Extensible library for opening URLs. + .. moduleauthor:: Jeremy Hylton + .. sectionauthor:: Moshe Zadka ++.. sectionauthor:: Senthil Kumaran + + + The :mod:`urllib.request` module defines functions and classes which help in +@@ -20,16 +21,26 @@ + Open the URL *url*, which can be either a string or a + :class:`Request` object. + +- *data* may be a bytes object specifying additional data to send to the ++ *data* must be a bytes object specifying additional data to be sent to the + server, or ``None`` if no such data is needed. *data* may also be an + iterable object and in that case Content-Length value must be specified in + the headers. Currently HTTP requests are the only ones that use *data*; the + HTTP request will be a POST instead of a GET when the *data* parameter is +- provided. *data* should be a buffer in the standard ++ provided. ++ ++ *data* should be a buffer in the standard + :mimetype:`application/x-www-form-urlencoded` format. The + :func:`urllib.parse.urlencode` function takes a mapping or sequence of +- 2-tuples and returns a string in this format. urllib.request module uses +- HTTP/1.1 and includes ``Connection:close`` header in its HTTP requests. ++ 2-tuples and returns a string in this format. It should be encoded to bytes ++ before being used as the *data* parameter. The charset parameter in ++ ``Content-Type`` header may be used to specify the encoding. If charset ++ parameter is not sent with the Content-Type header, the server following the ++ HTTP 1.1 recommendation may assume that the data is encoded in ISO-8859-1 ++ encoding. It is advisable to use charset parameter with encoding used in ++ ``Content-Type`` header with the :class:`Request`. ++ ++ urllib.request module uses HTTP/1.1 and includes ``Connection:close`` header ++ in its HTTP requests. + + The optional *timeout* parameter specifies a timeout in seconds for + blocking operations like the connection attempt (if not specified, +@@ -46,8 +57,8 @@ + If neither *cafile* nor *capath* is specified, an HTTPS request + will not do any verification of the server's certificate. + +- This function returns a file-like object with two additional methods from +- the :mod:`urllib.response` module ++ This function returns a file-like object that works as a :term:`context manager`, ++ with two additional methods from the :mod:`urllib.response` module + + * :meth:`geturl` --- return the URL of the resource retrieved, + commonly used to determine if a redirect was followed +@@ -66,9 +77,10 @@ + are handled through the proxy when they are set. + + The legacy ``urllib.urlopen`` function from Python 2.6 and earlier has been +- discontinued; :func:`urlopen` corresponds to the old ``urllib2.urlopen``. +- Proxy handling, which was done by passing a dictionary parameter to +- ``urllib.urlopen``, can be obtained by using :class:`ProxyHandler` objects. ++ discontinued; :func:`urllib.request.urlopen` corresponds to the old ++ ``urllib2.urlopen``. Proxy handling, which was done by passing a dictionary ++ parameter to ``urllib.urlopen``, can be obtained by using ++ :class:`ProxyHandler` objects. + + .. versionchanged:: 3.2 + *cafile* and *capath* were added. +@@ -83,10 +95,11 @@ + .. function:: install_opener(opener) + + Install an :class:`OpenerDirector` instance as the default global opener. +- Installing an opener is only necessary if you want urlopen to use that opener; +- otherwise, simply call :meth:`OpenerDirector.open` instead of :func:`urlopen`. +- The code does not check for a real :class:`OpenerDirector`, and any class with +- the appropriate interface will work. ++ Installing an opener is only necessary if you want urlopen to use that ++ opener; otherwise, simply call :meth:`OpenerDirector.open` instead of ++ :func:`~urllib.request.urlopen`. The code does not check for a real ++ :class:`OpenerDirector`, and any class with the appropriate interface will ++ work. + + + .. function:: build_opener([handler, ...]) +@@ -138,14 +151,21 @@ + + *url* should be a string containing a valid URL. + +- *data* may be a string specifying additional data to send to the +- server, or ``None`` if no such data is needed. Currently HTTP +- requests are the only ones that use *data*; the HTTP request will +- be a POST instead of a GET when the *data* parameter is provided. +- *data* should be a buffer in the standard +- :mimetype:`application/x-www-form-urlencoded` format. The +- :func:`urllib.parse.urlencode` function takes a mapping or sequence +- of 2-tuples and returns a string in this format. ++ *data* must be a bytes object specifying additional data to send to the ++ server, or ``None`` if no such data is needed. Currently HTTP requests are ++ the only ones that use *data*; the HTTP request will be a POST instead of a ++ GET when the *data* parameter is provided. *data* should be a buffer in the ++ standard :mimetype:`application/x-www-form-urlencoded` format. ++ ++ The :func:`urllib.parse.urlencode` function takes a mapping or sequence of ++ 2-tuples and returns a string in this format. It should be encoded to bytes ++ before being used as the *data* parameter. The charset parameter in ++ ``Content-Type`` header may be used to specify the encoding. If charset ++ parameter is not sent with the Content-Type header, the server following the ++ HTTP 1.1 recommendation may assume that the data is encoded in ISO-8859-1 ++ encoding. It is advisable to use charset parameter with encoding used in ++ ``Content-Type`` header with the :class:`Request`. ++ + + *headers* should be a dictionary, and will be treated as if + :meth:`add_header` was called with each key and value as arguments. +@@ -157,6 +177,9 @@ + :mod:`urllib`'s default user agent string is + ``"Python-urllib/2.6"`` (on Python 2.6). + ++ An example of using ``Content-Type`` header with *data* argument would be ++ sending a dictionary like ``{"Content-Type":" application/x-www-form-urlencoded;charset=utf-8"}`` ++ + The final two arguments are only of interest for correct handling + of third-party HTTP cookies: + +@@ -424,6 +447,17 @@ + Return the selector --- the part of the URL that is sent to the server. + + ++.. method:: Request.get_header(header_name, default=None) ++ ++ Return the value of the given header. If the header is not present, return ++ the default value. ++ ++ ++.. method:: Request.header_items() ++ ++ Return a list of tuples (header_name, header_value) of the Request headers. ++ ++ + .. method:: Request.set_proxy(host, type) + + Prepare the request by connecting to a proxy server. The *host* and *type* will +@@ -868,10 +902,9 @@ + Open the file locally, if there is no host name, or the host name is + ``'localhost'``. + +- This method is applicable only for local hostnames. When a remote hostname +- is given, an :exc:`URLError` is raised. +- +-.. versionchanged:: 3.2 ++ .. versionchanged:: 3.2 ++ This method is applicable only for local hostnames. When a remote ++ hostname is given, an :exc:`URLError` is raised. + + + .. _ftp-handler-objects: +@@ -967,8 +1000,17 @@ + the various ways in which a (X)HTML or a XML document could have specified its + encoding information. + +-As python.org website uses *utf-8* encoding as specified in it's meta tag, we +-will use same for decoding the bytes object. :: ++As the python.org website uses *utf-8* encoding as specified in it's meta tag, we ++will use the same for decoding the bytes object. :: ++ ++ >>> with urllib.request.urlopen('http://www.python.org/') as f: ++ ... print(f.read(100).decode('utf-8')) ++ ... ++ >> import urllib.request + >>> f = urllib.request.urlopen('http://www.python.org/') +@@ -976,7 +1018,6 @@ + >> import urllib.request + >>> import urllib.parse +- >>> params = urllib.parse.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0}) +- >>> params = params.encode('utf-8') +- >>> f = urllib.request.urlopen("http://www.musi-cal.com/cgi-bin/query", params) ++ >>> data = urllib.parse.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0}) ++ >>> data = data.encode('utf-8') ++ >>> request = urllib.request.Request("http://requestb.in/xrbl82xr") ++ >>> # adding charset parameter to the Content-Type header. ++ >>> request.add_header("Content-Type","application/x-www-form-urlencoded;charset=utf-8") ++ >>> f = urllib.request.urlopen(request, data) + >>> print(f.read().decode('utf-8')) + + The following example uses an explicitly specified HTTP proxy, overriding +@@ -1114,10 +1159,10 @@ + size in response to a retrieval request. + + If the *url* uses the :file:`http:` scheme identifier, the optional *data* +- argument may be given to specify a ``POST`` request (normally the request type +- is ``GET``). The *data* argument must in standard +- :mimetype:`application/x-www-form-urlencoded` format; see the :func:`urlencode` +- function below. ++ argument may be given to specify a ``POST`` request (normally the request ++ type is ``GET``). The *data* argument must be a bytes object in standard ++ :mimetype:`application/x-www-form-urlencoded` format; see the ++ :func:`urlencode` function below. + + :func:`urlretrieve` will raise :exc:`ContentTooShortError` when it detects that + the amount of data available was less than the expected amount (which is the +diff -r 3d0686d90f55 Doc/library/webbrowser.rst +--- a/Doc/library/webbrowser.rst ++++ b/Doc/library/webbrowser.rst +@@ -133,9 +133,9 @@ + +-----------------------+-----------------------------------------+-------+ + | ``'windows-default'`` | :class:`WindowsDefault` | \(2) | + +-----------------------+-----------------------------------------+-------+ +-| ``'internet-config'`` | :class:`InternetConfig` | \(3) | ++| ``'macosx'`` | :class:`MacOSX('default')` | \(3) | + +-----------------------+-----------------------------------------+-------+ +-| ``'macosx'`` | :class:`MacOSX('default')` | \(4) | ++| ``'safari'`` | :class:`MacOSX('safari')` | \(3) | + +-----------------------+-----------------------------------------+-------+ + + Notes: +@@ -151,9 +151,6 @@ + Only on Windows platforms. + + (3) +- Only on Mac OS platforms; requires the standard MacPython :mod:`ic` module. +- +-(4) + Only on Mac OS X platform. + + Here are some simple examples:: +diff -r 3d0686d90f55 Doc/library/winreg.rst +--- a/Doc/library/winreg.rst ++++ b/Doc/library/winreg.rst +@@ -243,7 +243,7 @@ + specified in *file_name* is relative to the remote computer. + + +-.. function:: OpenKey(key, sub_key, reserved=0, access=KEY_ALL_ACCESS) ++.. function:: OpenKey(key, sub_key, reserved=0, access=KEY_READ) + + Opens the specified key, returning a :ref:`handle object `. + +@@ -252,9 +252,9 @@ + + *sub_key* is a string that identifies the sub_key to open. + +- *res* is a reserved integer, and must be zero. The default is zero. ++ *reserved* is a reserved integer, and must be zero. The default is zero. + +- *sam* is an integer that specifies an access mask that describes the desired ++ *access* is an integer that specifies an access mask that describes the desired + security access for the key. Default is :const:`KEY_READ`. See :ref:`Access + Rights ` for other allowed values. + +diff -r 3d0686d90f55 Doc/library/xml.dom.minidom.rst +--- a/Doc/library/xml.dom.minidom.rst ++++ b/Doc/library/xml.dom.minidom.rst +@@ -15,6 +15,14 @@ + 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. ++ + DOM applications typically start by parsing some XML into a DOM. With + :mod:`xml.dom.minidom`, this is done through the parse functions:: + +diff -r 3d0686d90f55 Doc/library/xml.dom.pulldom.rst +--- a/Doc/library/xml.dom.pulldom.rst ++++ b/Doc/library/xml.dom.pulldom.rst +@@ -9,34 +9,72 @@ + + -------------- + +-:mod:`xml.dom.pulldom` allows building only selected portions of a Document +-Object Model representation of a document from SAX events. ++The :mod:`xml.dom.pulldom` module provides a "pull parser" which can also be ++asked to produce DOM-accessible fragments of the document where necessary. The ++basic concept involves pulling "events" from a stream of incoming XML and ++processing them. In contrast to SAX which also employs an event-driven ++processing model together with callbacks, the user of a pull parser is ++responsible for explicitly pulling events from the stream, looping over those ++events until either processing is finished or an error condition occurs. + ++Example:: + +-.. class:: PullDOM(documentFactory=None) ++ from xml.dom import pulldom + +- :class:`xml.sax.handler.ContentHandler` implementation that ... ++ doc = pulldom.parse('sales_items.xml') ++ for event, node in doc: ++ if event == pulldom.START_ELEMENT and node.tagName == 'item': ++ if int(node.getAttribute('price')) > 50: ++ doc.expandNode(node) ++ print(node.toxml()) + ++``event`` is a constant and can be one of: + +-.. class:: DOMEventStream(stream, parser, bufsize) ++* :data:`START_ELEMENT` ++* :data:`END_ELEMENT` ++* :data:`COMMENT` ++* :data:`START_DOCUMENT` ++* :data:`END_DOCUMENT` ++* :data:`CHARACTERS` ++* :data:`PROCESSING_INSTRUCTION` ++* :data:`IGNORABLE_WHITESPACE` + +- ... ++``node`` is a object of type :class:`xml.dom.minidom.Document`, ++:class:`xml.dom.minidom.Element` or :class:`xml.dom.minidom.Text`. ++ ++Since the document is treated as a "flat" stream of events, the document "tree" ++is implicitly traversed and the desired elements are found regardless of their ++depth in the tree. In other words, one does not need to consider hierarchical ++issues such as recursive searching of the document nodes, although if the ++context of elements were important, one would either need to maintain some ++context-related state (i.e. remembering where one is in the document at any ++given point) or to make use of the :func:`DOMEventStream.expandNode` method ++and switch to DOM-related processing. ++ ++ ++.. class:: PullDom(documentFactory=None) ++ ++ Subclass of :class:`xml.sax.handler.ContentHandler`. + + + .. class:: SAX2DOM(documentFactory=None) + +- :class:`xml.sax.handler.ContentHandler` implementation that ... ++ Subclass of :class:`xml.sax.handler.ContentHandler`. + + + .. function:: parse(stream_or_string, parser=None, bufsize=None) + +- ... ++ Return a :class:`DOMEventStream` from the given input. *stream_or_string* may be ++ either a file name, or a file-like object. *parser*, if given, must be a ++ :class:`XmlReader` object. This function will change the document handler of the ++ parser and activate namespace support; other parser configuration (like ++ setting an entity resolver) must have been done in advance. + ++If you have XML in a string, you can use the :func:`parseString` function instead: + + .. function:: parseString(string, parser=None) + +- ... +- ++ Return a :class:`DOMEventStream` that represents the (Unicode) *string*. + + .. data:: default_bufsize + +@@ -45,24 +83,37 @@ + The value of this variable can be changed before calling :func:`parse` and + the new value will take effect. + +- + .. _domeventstream-objects: + + DOMEventStream Objects + ---------------------- + ++.. class:: DOMEventStream(stream, parser, bufsize) + +-.. method:: DOMEventStream.getEvent() + +- ... ++ .. method:: getEvent() + ++ Return a tuple containing *event* and the current *node* as ++ :class:`xml.dom.minidom.Document` if event equals :data:`START_DOCUMENT`, ++ :class:`xml.dom.minidom.Element` if event equals :data:`START_ELEMENT` or ++ :data:`END_ELEMENT` or :class:`xml.dom.minidom.Text` if event equals ++ :data:`CHARACTERS`. ++ The current node does not contain informations about its children, unless ++ :func:`expandNode` is called. + +-.. method:: DOMEventStream.expandNode(node) ++ .. method:: expandNode(node) + +- ... ++ Expands all children of *node* into *node*. Example:: + ++ xml = 'Foo

Some text

' ++ doc = pulldom.parseString(xml) ++ for event, node in doc: ++ if event == pulldom.START_ELEMENT and node.tagName == 'p': ++ # Following statement only prints '

' ++ print(node.toxml()) ++ doc.exandNode(node) ++ # Following statement prints node with all its children '

Some text

and more

' ++ print(node.toxml()) + +-.. method:: DOMEventStream.reset() ++ .. method:: DOMEventStream.reset() + +- ... +- +diff -r 3d0686d90f55 Doc/library/xml.etree.elementtree.rst +--- a/Doc/library/xml.etree.elementtree.rst ++++ b/Doc/library/xml.etree.elementtree.rst +@@ -95,11 +95,14 @@ + .. function:: iterparse(source, events=None, parser=None) + + Parses an XML section into an element tree incrementally, and reports what's +- going on to the user. *source* is a filename or :term:`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. ++ going on to the user. *source* is a filename or :term:`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 ++ :class:`XMLParser` parser is used. Returns an :term:`iterator` providing ++ ``(event, elem)`` pairs. + + .. note:: + +diff -r 3d0686d90f55 Doc/reference/compound_stmts.rst +--- a/Doc/reference/compound_stmts.rst ++++ b/Doc/reference/compound_stmts.rst +@@ -535,6 +535,11 @@ + access the local variables of the function containing the def. See section + :ref:`naming` for details. + ++.. seealso:: ++ ++ :pep:`3107` - Function Annotations ++ The original specification for function annotations. ++ + + .. _class: + +diff -r 3d0686d90f55 Doc/reference/simple_stmts.rst +--- a/Doc/reference/simple_stmts.rst ++++ b/Doc/reference/simple_stmts.rst +@@ -393,7 +393,6 @@ + the sliced object). + + .. versionchanged:: 3.2 +- + Previously it was illegal to delete a name from the local namespace if it + occurs as a free variable in a nested block. + +diff -r 3d0686d90f55 Doc/tools/sphinxext/download.html +--- a/Doc/tools/sphinxext/download.html ++++ b/Doc/tools/sphinxext/download.html +@@ -39,8 +39,12 @@ + + + ++

These archives contain all the content in the documentation.

+ +-

These archives contain all the content in the documentation.

++

HTML Help (.chm) files are made available in the "Windows" section ++on the Python ++download page.

++ + +

Unpacking

+ +diff -r 3d0686d90f55 Doc/tools/sphinxext/indexsidebar.html +--- a/Doc/tools/sphinxext/indexsidebar.html ++++ b/Doc/tools/sphinxext/indexsidebar.html +@@ -3,20 +3,15 @@ +

Docs for other versions

+ + +

Other resources

+ +diff -r 3d0686d90f55 Doc/tools/sphinxext/layout.html +--- a/Doc/tools/sphinxext/layout.html ++++ b/Doc/tools/sphinxext/layout.html +@@ -2,6 +2,7 @@ + {% block rootrellink %} +
  • ++
  • Python{{ reldelim1 }}
  • +
  • {{ shorttitle }}{{ reldelim1 }}
  • + {% endblock %} + {% block extrahead %} +diff -r 3d0686d90f55 Doc/tools/sphinxext/pydoctheme/static/pydoctheme.css +--- /dev/null ++++ b/Doc/tools/sphinxext/pydoctheme/static/pydoctheme.css +@@ -0,0 +1,170 @@ ++@import url("default.css"); ++ ++body { ++ background-color: white; ++ margin-left: 1em; ++ margin-right: 1em; ++} ++ ++div.related { ++ margin-bottom: 1.2em; ++ padding: 0.5em 0; ++ border-top: 1px solid #ccc; ++ margin-top: 0.5em; ++} ++ ++div.related a:hover { ++ color: #0095C4; ++} ++ ++div.related:first-child { ++ border-top: 0; ++ border-bottom: 1px solid #ccc; ++} ++ ++div.sphinxsidebar { ++ background-color: #eeeeee; ++ border-radius: 5px; ++ line-height: 130%; ++ font-size: smaller; ++} ++ ++div.sphinxsidebar h3, div.sphinxsidebar h4 { ++ margin-top: 1.5em; ++} ++ ++div.sphinxsidebarwrapper > h3:first-child { ++ margin-top: 0.2em; ++} ++ ++div.sphinxsidebarwrapper > ul > li > ul > li { ++ margin-bottom: 0.4em; ++} ++ ++div.sphinxsidebar a:hover { ++ color: #0095C4; ++} ++ ++div.sphinxsidebar input { ++ font-family: 'Lucida Grande',Arial,sans-serif; ++ border: 1px solid #999999; ++ font-size: smaller; ++ border-radius: 3px; ++} ++ ++div.sphinxsidebar input[type=text] { ++ max-width: 150px; ++} ++ ++div.body { ++ padding: 0 0 0 1.2em; ++} ++ ++div.body p { ++ line-height: 140%; ++} ++ ++div.body h1, div.body h2, div.body h3, div.body h4, div.body h5, div.body h6 { ++ margin: 0; ++ border: 0; ++ padding: 0.3em 0; ++} ++ ++div.body hr { ++ border: 0; ++ background-color: #ccc; ++ height: 1px; ++} ++ ++div.body pre { ++ border-radius: 3px; ++ border: 1px solid #ac9; ++} ++ ++div.body div.admonition, div.body div.impl-detail { ++ border-radius: 3px; ++} ++ ++div.body div.impl-detail > p { ++ margin: 0; ++} ++ ++div.body div.seealso { ++ border: 1px solid #dddd66; ++} ++ ++div.body a { ++ color: #00608f; ++} ++ ++div.body a:visited { ++ color: #30306f; ++} ++ ++div.body a:hover { ++ color: #00B0E4; ++} ++ ++tt, pre { ++ font-family: monospace, sans-serif; ++ font-size: 96.5%; ++} ++ ++div.body tt { ++ border-radius: 3px; ++} ++ ++div.body tt.descname { ++ font-size: 120%; ++} ++ ++div.body tt.xref, div.body a tt { ++ font-weight: normal; ++} ++ ++p.deprecated { ++ border-radius: 3px; ++} ++ ++table.docutils { ++ border: 1px solid #ddd; ++ min-width: 20%; ++ border-radius: 3px; ++ margin-top: 10px; ++ margin-bottom: 10px; ++} ++ ++table.docutils td, table.docutils th { ++ border: 1px solid #ddd !important; ++ border-radius: 3px; ++} ++ ++table p, table li { ++ text-align: left !important; ++} ++ ++table.docutils th { ++ background-color: #eee; ++ padding: 0.3em 0.5em; ++} ++ ++table.docutils td { ++ background-color: white; ++ padding: 0.3em 0.5em; ++} ++ ++table.footnote, table.footnote td { ++ border: 0 !important; ++} ++ ++div.footer { ++ line-height: 150%; ++ margin-top: -2em; ++ text-align: right; ++ width: auto; ++ margin-right: 10px; ++} ++ ++div.footer a:hover { ++ color: #0095C4; ++} +diff -r 3d0686d90f55 Doc/tools/sphinxext/pydoctheme/theme.conf +--- /dev/null ++++ b/Doc/tools/sphinxext/pydoctheme/theme.conf +@@ -0,0 +1,23 @@ ++[theme] ++inherit = default ++stylesheet = pydoctheme.css ++pygments_style = sphinx ++ ++[options] ++bodyfont = 'Lucida Grande', Arial, sans-serif ++headfont = 'Lucida Grande', Arial, sans-serif ++footerbgcolor = white ++footertextcolor = #555555 ++relbarbgcolor = white ++relbartextcolor = #666666 ++relbarlinkcolor = #444444 ++sidebarbgcolor = white ++sidebartextcolor = #444444 ++sidebarlinkcolor = #444444 ++bgcolor = white ++textcolor = #222222 ++linkcolor = #0090c0 ++visitedlinkcolor = #00608f ++headtextcolor = #1a1a1a ++headbgcolor = white ++headlinkcolor = #aaaaaa +diff -r 3d0686d90f55 Doc/tools/sphinxext/pyspecific.py +--- a/Doc/tools/sphinxext/pyspecific.py ++++ b/Doc/tools/sphinxext/pyspecific.py +@@ -27,10 +27,10 @@ + self.body.append(self.starttag(node, 'p', CLASS=node['type'])) + text = versionlabels[node['type']] % node['version'] + if len(node): +- text += ': ' ++ text += ':' + else: + text += '.' +- self.body.append('%s' % text) ++ self.body.append('%s ' % text) + + from sphinx.writers.html import HTMLTranslator + from sphinx.locale import versionlabels +diff -r 3d0686d90f55 Doc/tools/sphinxext/static/copybutton.js +--- a/Doc/tools/sphinxext/static/copybutton.js ++++ b/Doc/tools/sphinxext/static/copybutton.js +@@ -17,7 +17,8 @@ + 'cursor':'pointer', 'position': 'absolute', 'top': '0', 'right': '0', + 'border-color': border_color, 'border-style': border_style, + 'border-width': border_width, 'color': border_color, 'text-size': '75%', +- 'font-family': 'monospace', 'padding-left': '0.2em', 'padding-right': '0.2em' ++ 'font-family': 'monospace', 'padding-left': '0.2em', 'padding-right': '0.2em', ++ 'border-radius': '0 3px 0 0' + } + + // create and add the button to all the code blocks that contain >>> +diff -r 3d0686d90f55 Doc/tools/sphinxext/static/sidebar.js +--- /dev/null ++++ b/Doc/tools/sphinxext/static/sidebar.js +@@ -0,0 +1,155 @@ ++/* ++ * sidebar.js ++ * ~~~~~~~~~~ ++ * ++ * This script makes the Sphinx sidebar collapsible. ++ * ++ * .sphinxsidebar contains .sphinxsidebarwrapper. This script adds in ++ * .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton used to ++ * collapse and expand the sidebar. ++ * ++ * When the sidebar is collapsed the .sphinxsidebarwrapper is hidden and the ++ * width of the sidebar and the margin-left of the document are decreased. ++ * When the sidebar is expanded the opposite happens. This script saves a ++ * per-browser/per-session cookie used to remember the position of the sidebar ++ * among the pages. Once the browser is closed the cookie is deleted and the ++ * position reset to the default (expanded). ++ * ++ * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS. ++ * :license: BSD, see LICENSE for details. ++ * ++ */ ++ ++$(function() { ++ // global elements used by the functions. ++ // the 'sidebarbutton' element is defined as global after its ++ // creation, in the add_sidebar_button function ++ var bodywrapper = $('.bodywrapper'); ++ var sidebar = $('.sphinxsidebar'); ++ var sidebarwrapper = $('.sphinxsidebarwrapper'); ++ ++ // original margin-left of the bodywrapper and width of the sidebar ++ // with the sidebar expanded ++ var bw_margin_expanded = bodywrapper.css('margin-left'); ++ var ssb_width_expanded = sidebar.width(); ++ ++ // margin-left of the bodywrapper and width of the sidebar ++ // with the sidebar collapsed ++ var bw_margin_collapsed = '.8em'; ++ var ssb_width_collapsed = '.8em'; ++ ++ // colors used by the current theme ++ var dark_color = '#AAAAAA'; ++ var light_color = '#CCCCCC'; ++ ++ function sidebar_is_collapsed() { ++ return sidebarwrapper.is(':not(:visible)'); ++ } ++ ++ function toggle_sidebar() { ++ if (sidebar_is_collapsed()) ++ expand_sidebar(); ++ else ++ collapse_sidebar(); ++ } ++ ++ function collapse_sidebar() { ++ sidebarwrapper.hide(); ++ sidebar.css('width', ssb_width_collapsed); ++ bodywrapper.css('margin-left', bw_margin_collapsed); ++ sidebarbutton.css({ ++ 'margin-left': '0', ++ 'height': bodywrapper.height(), ++ 'border-radius': '5px' ++ }); ++ sidebarbutton.find('span').text('»'); ++ sidebarbutton.attr('title', _('Expand sidebar')); ++ document.cookie = 'sidebar=collapsed'; ++ } ++ ++ function expand_sidebar() { ++ bodywrapper.css('margin-left', bw_margin_expanded); ++ sidebar.css('width', ssb_width_expanded); ++ sidebarwrapper.show(); ++ sidebarbutton.css({ ++ 'margin-left': ssb_width_expanded-12, ++ 'height': bodywrapper.height(), ++ 'border-radius': '0 5px 5px 0' ++ }); ++ sidebarbutton.find('span').text('«'); ++ sidebarbutton.attr('title', _('Collapse sidebar')); ++ //sidebarwrapper.css({'padding-top': ++ // Math.max(window.pageYOffset - sidebarwrapper.offset().top, 10)}); ++ document.cookie = 'sidebar=expanded'; ++ } ++ ++ function add_sidebar_button() { ++ sidebarwrapper.css({ ++ 'float': 'left', ++ 'margin-right': '0', ++ 'width': ssb_width_expanded - 28 ++ }); ++ // create the button ++ sidebar.append( ++ '
    «
    ' ++ ); ++ var sidebarbutton = $('#sidebarbutton'); ++ // find the height of the viewport to center the '<<' in the page ++ var viewport_height; ++ if (window.innerHeight) ++ viewport_height = window.innerHeight; ++ else ++ viewport_height = $(window).height(); ++ var sidebar_offset = sidebar.offset().top; ++ var sidebar_height = Math.max(bodywrapper.height(), sidebar.height()); ++ sidebarbutton.find('span').css({ ++ 'display': 'block', ++ 'position': 'fixed', ++ 'top': Math.min(viewport_height/2, sidebar_height/2 + sidebar_offset) - 10 ++ }); ++ ++ sidebarbutton.click(toggle_sidebar); ++ sidebarbutton.attr('title', _('Collapse sidebar')); ++ sidebarbutton.css({ ++ 'border-radius': '0 5px 5px 0', ++ 'color': '#444444', ++ 'background-color': '#CCCCCC', ++ 'font-size': '1.2em', ++ 'cursor': 'pointer', ++ 'height': sidebar_height, ++ 'padding-top': '1px', ++ 'padding-left': '1px', ++ 'margin-left': ssb_width_expanded - 12 ++ }); ++ ++ sidebarbutton.hover( ++ function () { ++ $(this).css('background-color', dark_color); ++ }, ++ function () { ++ $(this).css('background-color', light_color); ++ } ++ ); ++ } ++ ++ function set_position_from_cookie() { ++ if (!document.cookie) ++ return; ++ var items = document.cookie.split(';'); ++ for(var k=0; k>> u + ((12345, 54321, 'hello!'), (1, 2, 3, 4, 5)) ++ >>> # Tuples are immutable: ++ ... t[0] = 88888 ++ Traceback (most recent call last): ++ File "", line 1, in ++ TypeError: 'tuple' object does not support item assignment ++ >>> # but they can contain mutable objects: ++ ... v = ([1, 2, 3], [3, 2, 1]) ++ >>> v ++ ([1, 2, 3], [3, 2, 1]) ++ + + As you see, on output tuples are always enclosed in parentheses, so that nested + tuples are interpreted correctly; they may be input with or without surrounding + parentheses, although often parentheses are necessary anyway (if the tuple is +-part of a larger expression). ++part of a larger expression). It is not possible to assign to the individual ++items of a tuple, however it is possible to create tuples which contain mutable ++objects, such as lists. + +-Tuples have many uses. For example: (x, y) coordinate pairs, employee records +-from a database, etc. Tuples, like strings, are immutable: it is not possible +-to assign to the individual items of a tuple (you can simulate much of the same +-effect with slicing and concatenation, though). It is also possible to create +-tuples which contain mutable objects, such as lists. ++Though tuples may seem similar to lists, they are often used in different ++situations and for different purposes. ++Tuples are :term:`immutable`, and usually contain an heterogeneous sequence of ++elements that are accessed via unpacking (see later in this section) or indexing ++(or even by attribute in the case of :func:`namedtuples `). ++Lists are :term:`mutable`, and their elements are usually homogeneous and are ++accessed by iterating over the list. + + A special problem is the construction of tuples containing 0 or 1 items: the + syntax has some extra quirks to accommodate these. Empty tuples are constructed +@@ -388,8 +402,6 @@ + sequence. Note that multiple assignment is really just a combination of tuple + packing and sequence unpacking. + +-.. XXX Add a bit on the difference between tuples and lists. +- + + .. _tut-sets: + +diff -r 3d0686d90f55 Include/Python.h +--- a/Include/Python.h ++++ b/Include/Python.h +@@ -100,7 +100,6 @@ + #include "warnings.h" + #include "weakrefobject.h" + #include "structseq.h" +-#include "accu.h" + + #include "codecs.h" + #include "pyerrors.h" +diff -r 3d0686d90f55 Include/patchlevel.h +--- a/Include/patchlevel.h ++++ b/Include/patchlevel.h +@@ -2,7 +2,7 @@ + /* Python version identification scheme. + + When the major or minor version changes, the VERSION variable in +- configure.in must also be changed. ++ configure.ac must also be changed. + + There is also (independent) API version information in modsupport.h. + */ +diff -r 3d0686d90f55 Include/pyport.h +--- a/Include/pyport.h ++++ b/Include/pyport.h +@@ -557,6 +557,30 @@ + _Py_set_387controlword(old_387controlword) + #endif + ++/* get and set x87 control word for VisualStudio/x86 */ ++#if defined(_MSC_VER) && !defined(_WIN64) /* x87 not supported in 64-bit */ ++#define HAVE_PY_SET_53BIT_PRECISION 1 ++#define _Py_SET_53BIT_PRECISION_HEADER \ ++ unsigned int old_387controlword, new_387controlword, out_387controlword ++/* We use the __control87_2 function to set only the x87 control word. ++ The SSE control word is unaffected. */ ++#define _Py_SET_53BIT_PRECISION_START \ ++ do { \ ++ __control87_2(0, 0, &old_387controlword, NULL); \ ++ new_387controlword = \ ++ (old_387controlword & ~(_MCW_PC | _MCW_RC)) | (_PC_53 | _RC_NEAR); \ ++ if (new_387controlword != old_387controlword) \ ++ __control87_2(new_387controlword, _MCW_PC | _MCW_RC, \ ++ &out_387controlword, NULL); \ ++ } while (0) ++#define _Py_SET_53BIT_PRECISION_END \ ++ do { \ ++ if (new_387controlword != old_387controlword) \ ++ __control87_2(old_387controlword, _MCW_PC | _MCW_RC, \ ++ &out_387controlword, NULL); \ ++ } while (0) ++#endif ++ + /* default definitions are empty */ + #ifndef HAVE_PY_SET_53BIT_PRECISION + #define _Py_SET_53BIT_PRECISION_HEADER +diff -r 3d0686d90f55 Lib/__future__.py +--- a/Lib/__future__.py ++++ b/Lib/__future__.py +@@ -114,7 +114,7 @@ + CO_FUTURE_DIVISION) + + absolute_import = _Feature((2, 5, 0, "alpha", 1), +- (2, 7, 0, "alpha", 0), ++ (3, 0, 0, "alpha", 0), + CO_FUTURE_ABSOLUTE_IMPORT) + + with_statement = _Feature((2, 5, 0, "alpha", 1), +diff -r 3d0686d90f55 Lib/_strptime.py +--- a/Lib/_strptime.py ++++ b/Lib/_strptime.py +@@ -339,7 +339,7 @@ + raise ValueError("unconverted data remains: %s" % + data_string[found.end():]) + +- year = 1900 ++ year = None + month = day = 1 + hour = minute = second = fraction = 0 + tz = -1 +@@ -444,6 +444,12 @@ + else: + tz = value + break ++ leap_year_fix = False ++ if year is None and month == 2 and day == 29: ++ year = 1904 # 1904 is first leap year of 20th century ++ leap_year_fix = True ++ elif year is None: ++ year = 1900 + # If we know the week of the year and what day of that week, we can figure + # out the Julian day of the year. + if julian == -1 and week_of_year != -1 and weekday != -1: +@@ -472,6 +478,12 @@ + else: + gmtoff = None + ++ if leap_year_fix: ++ # the caller didn't supply a year but asked for Feb 29th. We couldn't ++ # use the default of 1900 for computations. We set it back to ensure ++ # that February 29th is smaller than March 1st. ++ year = 1900 ++ + return (year, month, day, + hour, minute, second, + weekday, julian, tz, gmtoff, tzname), fraction +diff -r 3d0686d90f55 Lib/_weakrefset.py +--- a/Lib/_weakrefset.py ++++ b/Lib/_weakrefset.py +@@ -63,7 +63,7 @@ + yield item + + def __len__(self): +- return sum(x() is not None for x in self.data) ++ return len(self.data) - len(self._pending_removals) + + def __contains__(self, item): + try: +@@ -114,36 +114,21 @@ + def update(self, other): + if self._pending_removals: + self._commit_removals() +- if isinstance(other, self.__class__): +- self.data.update(other.data) +- else: +- for element in other: +- self.add(element) ++ for element in other: ++ self.add(element) + + def __ior__(self, other): + self.update(other) + return self + +- # Helper functions for simple delegating methods. +- def _apply(self, other, method): +- if not isinstance(other, self.__class__): +- other = self.__class__(other) +- newdata = method(other.data) +- newset = self.__class__() +- newset.data = newdata ++ def difference(self, other): ++ newset = self.copy() ++ newset.difference_update(other) + return newset +- +- def difference(self, other): +- return self._apply(other, self.data.difference) + __sub__ = difference + + def difference_update(self, other): +- if self._pending_removals: +- self._commit_removals() +- if self is other: +- self.data.clear() +- else: +- self.data.difference_update(ref(item) for item in other) ++ self.__isub__(other) + def __isub__(self, other): + if self._pending_removals: + self._commit_removals() +@@ -154,13 +139,11 @@ + return self + + def intersection(self, other): +- return self._apply(other, self.data.intersection) ++ return self.__class__(item for item in other if item in self) + __and__ = intersection + + def intersection_update(self, other): +- if self._pending_removals: +- self._commit_removals() +- self.data.intersection_update(ref(item) for item in other) ++ self.__iand__(other) + def __iand__(self, other): + if self._pending_removals: + self._commit_removals() +@@ -169,17 +152,17 @@ + + def issubset(self, other): + return self.data.issubset(ref(item) for item in other) +- __lt__ = issubset ++ __le__ = issubset + +- def __le__(self, other): +- return self.data <= set(ref(item) for item in other) ++ def __lt__(self, other): ++ return self.data < set(ref(item) for item in other) + + def issuperset(self, other): + return self.data.issuperset(ref(item) for item in other) +- __gt__ = issuperset ++ __ge__ = issuperset + +- def __ge__(self, other): +- return self.data >= set(ref(item) for item in other) ++ def __gt__(self, other): ++ return self.data > set(ref(item) for item in other) + + def __eq__(self, other): + if not isinstance(other, self.__class__): +@@ -187,27 +170,24 @@ + return self.data == set(ref(item) for item in other) + + def symmetric_difference(self, other): +- return self._apply(other, self.data.symmetric_difference) ++ newset = self.copy() ++ newset.symmetric_difference_update(other) ++ return newset + __xor__ = symmetric_difference + + def symmetric_difference_update(self, other): +- if self._pending_removals: +- self._commit_removals() +- if self is other: +- self.data.clear() +- else: +- self.data.symmetric_difference_update(ref(item) for item in other) ++ self.__ixor__(other) + def __ixor__(self, other): + if self._pending_removals: + self._commit_removals() + if self is other: + self.data.clear() + else: +- self.data.symmetric_difference_update(ref(item) for item in other) ++ self.data.symmetric_difference_update(ref(item, self._remove) for item in other) + return self + + def union(self, other): +- return self._apply(other, self.data.union) ++ return self.__class__(e for s in (self, other) for e in s) + __or__ = union + + def isdisjoint(self, other): +diff -r 3d0686d90f55 Lib/asyncore.py +--- a/Lib/asyncore.py ++++ b/Lib/asyncore.py +@@ -225,6 +225,7 @@ + debug = False + connected = False + accepting = False ++ connecting = False + closing = False + addr = None + ignore_log_types = frozenset(['warning']) +@@ -248,7 +249,7 @@ + try: + self.addr = sock.getpeername() + except socket.error as err: +- if err.args[0] == ENOTCONN: ++ if err.args[0] in (ENOTCONN, EINVAL): + # To handle the case where we got an unconnected + # socket. + self.connected = False +@@ -342,9 +343,11 @@ + + def connect(self, address): + self.connected = False ++ self.connecting = True + err = self.socket.connect_ex(address) + if err in (EINPROGRESS, EALREADY, EWOULDBLOCK) \ + or err == EINVAL and os.name in ('nt', 'ce'): ++ self.addr = address + return + if err in (0, EISCONN): + self.addr = address +@@ -400,6 +403,7 @@ + def close(self): + self.connected = False + self.accepting = False ++ self.connecting = False + self.del_channel() + try: + self.socket.close() +@@ -438,7 +442,8 @@ + # sockets that are connected + self.handle_accept() + elif not self.connected: +- self.handle_connect_event() ++ if self.connecting: ++ self.handle_connect_event() + self.handle_read() + else: + self.handle_read() +@@ -449,6 +454,7 @@ + raise socket.error(err, _strerror(err)) + self.handle_connect() + self.connected = True ++ self.connecting = False + + def handle_write_event(self): + if self.accepting: +@@ -457,12 +463,8 @@ + return + + if not self.connected: +- #check for errors +- err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR) +- if err != 0: +- raise socket.error(err, _strerror(err)) +- +- self.handle_connect_event() ++ if self.connecting: ++ self.handle_connect_event() + self.handle_write() + + def handle_expt_event(self): +diff -r 3d0686d90f55 Lib/bdb.py +--- a/Lib/bdb.py ++++ b/Lib/bdb.py +@@ -22,6 +22,7 @@ + self.skip = set(skip) if skip else None + self.breaks = {} + self.fncache = {} ++ self.frame_returning = None + + def canonic(self, filename): + if filename == "<" + filename[1:-1] + ">": +@@ -80,7 +81,11 @@ + + def dispatch_return(self, frame, arg): + if self.stop_here(frame) or frame == self.returnframe: +- self.user_return(frame, arg) ++ try: ++ self.frame_returning = frame ++ self.user_return(frame, arg) ++ finally: ++ self.frame_returning = None + if self.quitting: raise BdbQuit + return self.trace_dispatch + +@@ -186,6 +191,14 @@ + + def set_step(self): + """Stop after one line of code.""" ++ # Issue #13183: pdb skips frames after hitting a breakpoint and running ++ # step commands. ++ # Restore the trace function in the caller (that may not have been set ++ # for performance reasons) when returning from the current frame. ++ if self.frame_returning: ++ caller_frame = self.frame_returning.f_back ++ if caller_frame and not caller_frame.f_trace: ++ caller_frame.f_trace = self.trace_dispatch + self._set_stopinfo(None, None) + + def set_next(self, frame): +diff -r 3d0686d90f55 Lib/concurrent/futures/_base.py +--- a/Lib/concurrent/futures/_base.py ++++ b/Lib/concurrent/futures/_base.py +@@ -112,12 +112,14 @@ + def __init__(self, num_pending_calls, stop_on_exception): + self.num_pending_calls = num_pending_calls + self.stop_on_exception = stop_on_exception ++ self.lock = threading.Lock() + super().__init__() + + def _decrement_pending_calls(self): +- self.num_pending_calls -= 1 +- if not self.num_pending_calls: +- self.event.set() ++ with self.lock: ++ self.num_pending_calls -= 1 ++ if not self.num_pending_calls: ++ self.event.set() + + def add_result(self, future): + super().add_result(future) +diff -r 3d0686d90f55 Lib/ctypes/test/test_numbers.py +--- a/Lib/ctypes/test/test_numbers.py ++++ b/Lib/ctypes/test/test_numbers.py +@@ -217,6 +217,16 @@ + # probably be changed: + self.assertRaises(TypeError, c_int, c_long(42)) + ++ def test_float_overflow(self): ++ import sys ++ big_int = int(sys.float_info.max) * 2 ++ for t in float_types + [c_longdouble]: ++ self.assertRaises(OverflowError, t, big_int) ++ if (hasattr(t, "__ctype_be__")): ++ self.assertRaises(OverflowError, t.__ctype_be__, big_int) ++ if (hasattr(t, "__ctype_le__")): ++ self.assertRaises(OverflowError, t.__ctype_le__, big_int) ++ + ## def test_perf(self): + ## check_perf() + +diff -r 3d0686d90f55 Lib/distutils/command/bdist_rpm.py +--- a/Lib/distutils/command/bdist_rpm.py ++++ b/Lib/distutils/command/bdist_rpm.py +@@ -3,7 +3,7 @@ + Implements the Distutils 'bdist_rpm' command (create RPM source and binary + distributions).""" + +-import sys, os ++import subprocess, sys, os + from distutils.core import Command + from distutils.debug import DEBUG + from distutils.util import get_platform +@@ -190,7 +190,7 @@ + if self.fix_python: + self.python = sys.executable + else: +- self.python = "python" ++ self.python = "python3" + elif self.fix_python: + raise DistutilsOptionError( + "--python and --fix-python are mutually exclusive options") +@@ -320,6 +320,7 @@ + rpm_cmd.append('-bb') + else: + rpm_cmd.append('-ba') ++ rpm_cmd.extend(['--define', '__python %s' % self.python]) + if self.rpm3_mode: + rpm_cmd.extend(['--define', + '_topdir %s' % os.path.abspath(self.rpm_base)]) +@@ -405,6 +406,21 @@ + 'Summary: ' + self.distribution.get_description(), + ] + ++ # Workaround for #14443 which affects some RPM based systems such as ++ # RHEL6 (and probably derivatives) ++ vendor_hook = subprocess.getoutput('rpm --eval %{__os_install_post}') ++ # Generate a potential replacement value for __os_install_post (whilst ++ # normalizing the whitespace to simplify the test for whether the ++ # invocation of brp-python-bytecompile passes in __python): ++ vendor_hook = '\n'.join([' %s \\' % line.strip() ++ for line in vendor_hook.splitlines()]) ++ problem = "brp-python-bytecompile \\\n" ++ fixed = "brp-python-bytecompile %{__python} \\\n" ++ fixed_hook = vendor_hook.replace(problem, fixed) ++ if fixed_hook != vendor_hook: ++ spec_file.append('# Workaround for http://bugs.python.org/issue14443') ++ spec_file.append('%define __os_install_post ' + fixed_hook + '\n') ++ + # put locale summaries into spec file + # XXX not supported for now (hard to put a dictionary + # in a config file -- arg!) +diff -r 3d0686d90f55 Lib/distutils/command/upload.py +--- a/Lib/distutils/command/upload.py ++++ b/Lib/distutils/command/upload.py +@@ -125,7 +125,7 @@ + + if self.sign: + data['gpg_signature'] = (os.path.basename(filename) + ".asc", +- open(filename+".asc").read()) ++ open(filename+".asc", "rb").read()) + + # set up the authentication + user_pass = (self.username + ":" + self.password).encode('ascii') +diff -r 3d0686d90f55 Lib/distutils/tests/test_bdist_msi.py +--- a/Lib/distutils/tests/test_bdist_msi.py ++++ b/Lib/distutils/tests/test_bdist_msi.py +@@ -1,12 +1,11 @@ + """Tests for distutils.command.bdist_msi.""" ++import sys + import unittest +-import sys +- + from test.support import run_unittest +- + from distutils.tests import support + +-@unittest.skipUnless(sys.platform=="win32", "These tests are only for win32") ++ ++@unittest.skipUnless(sys.platform == 'win32', 'these tests require Windows') + class BDistMSITestCase(support.TempdirManager, + support.LoggingSilencer, + unittest.TestCase): +@@ -14,10 +13,11 @@ + def test_minimal(self): + # minimal test XXX need more tests + from distutils.command.bdist_msi import bdist_msi +- pkg_pth, dist = self.create_dist() ++ project_dir, dist = self.create_dist() + cmd = bdist_msi(dist) + cmd.ensure_finalized() + ++ + def test_suite(): + return unittest.makeSuite(BDistMSITestCase) + +diff -r 3d0686d90f55 Lib/distutils/tests/test_sdist.py +--- a/Lib/distutils/tests/test_sdist.py ++++ b/Lib/distutils/tests/test_sdist.py +@@ -6,6 +6,7 @@ + import zipfile + from os.path import join + from textwrap import dedent ++from test.support import captured_stdout, check_warnings, run_unittest + + try: + import zlib +@@ -13,7 +14,6 @@ + except ImportError: + ZLIB_SUPPORT = False + +-from test.support import captured_stdout, check_warnings, run_unittest + + from distutils.command.sdist import sdist, show_formats + from distutils.core import Distribution +@@ -326,6 +326,7 @@ + # filling data_files by pointing files in package_data + dist.package_data = {'somecode': ['*.txt']} + self.write_file((self.tmp_dir, 'somecode', 'doc.txt'), '#') ++ cmd.formats = ['gztar'] + cmd.ensure_finalized() + cmd.run() + +diff -r 3d0686d90f55 Lib/doctest.py +--- a/Lib/doctest.py ++++ b/Lib/doctest.py +@@ -2266,7 +2266,8 @@ + return "Doctest: " + self._dt_test.name + + class SkipDocTestCase(DocTestCase): +- def __init__(self): ++ def __init__(self, module): ++ self.module = module + DocTestCase.__init__(self, None) + + def setUp(self): +@@ -2276,7 +2277,10 @@ + pass + + def shortDescription(self): +- return "Skipping tests from %s" % module.__name__ ++ return "Skipping tests from %s" % self.module.__name__ ++ ++ __str__ = shortDescription ++ + + def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, + **options): +@@ -2324,7 +2328,7 @@ + if not tests and sys.flags.optimize >=2: + # Skip doctests when running with -O2 + suite = unittest.TestSuite() +- suite.addTest(SkipDocTestCase()) ++ suite.addTest(SkipDocTestCase(module)) + return suite + elif not tests: + # Why do we want to do this? Because it reveals a bug that might +diff -r 3d0686d90f55 Lib/email/__init__.py +--- a/Lib/email/__init__.py ++++ b/Lib/email/__init__.py +@@ -11,6 +11,7 @@ + 'charset', + 'encoders', + 'errors', ++ 'feedparser', + 'generator', + 'header', + 'iterators', +diff -r 3d0686d90f55 Lib/email/_parseaddr.py +--- a/Lib/email/_parseaddr.py ++++ b/Lib/email/_parseaddr.py +@@ -13,7 +13,7 @@ + 'quote', + ] + +-import time ++import time, calendar + + SPACE = ' ' + EMPTYSTRING = '' +@@ -152,13 +152,13 @@ + + + def mktime_tz(data): +- """Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp.""" ++ """Turn a 10-tuple as returned by parsedate_tz() into a POSIX timestamp.""" + if data[9] is None: + # No zone info, so localtime is better assumption than GMT + return time.mktime(data[:8] + (-1,)) + else: +- t = time.mktime(data[:8] + (0,)) +- return t - data[9] - time.timezone ++ t = calendar.timegm(data) ++ return t - data[9] + + + def quote(str): +diff -r 3d0686d90f55 Lib/email/feedparser.py +--- a/Lib/email/feedparser.py ++++ b/Lib/email/feedparser.py +@@ -19,7 +19,7 @@ + object's .defects attribute. + """ + +-__all__ = ['FeedParser'] ++__all__ = ['FeedParser', 'BytesFeedParser'] + + import re + +diff -r 3d0686d90f55 Lib/email/generator.py +--- a/Lib/email/generator.py ++++ b/Lib/email/generator.py +@@ -4,7 +4,7 @@ + + """Classes to generate plain text from a message object tree.""" + +-__all__ = ['Generator', 'DecodedGenerator'] ++__all__ = ['Generator', 'DecodedGenerator', 'BytesGenerator'] + + import re + import sys +@@ -360,7 +360,7 @@ + for h, v in msg._headers: + self.write('%s: ' % h) + if isinstance(v, Header): +- self.write(v.encode(maxlinelen=self._maxheaderlen)+NL) ++ self.write(v.encode(maxlinelen=self._maxheaderlen)+self._NL) + elif _has_surrogates(v): + # If we have raw 8bit data in a byte string, we have no idea + # what the encoding is. There is no safe way to split this +diff -r 3d0686d90f55 Lib/email/header.py +--- a/Lib/email/header.py ++++ b/Lib/email/header.py +@@ -283,7 +283,12 @@ + # character set, otherwise an early error is thrown. + output_charset = charset.output_codec or 'us-ascii' + if output_charset != _charset.UNKNOWN8BIT: +- s.encode(output_charset, errors) ++ try: ++ s.encode(output_charset, errors) ++ except UnicodeEncodeError: ++ if output_charset!='us-ascii': ++ raise ++ charset = UTF8 + self._chunks.append((s, charset)) + + def encode(self, splitchars=';, \t', maxlinelen=None, linesep='\n'): +diff -r 3d0686d90f55 Lib/email/message.py +--- a/Lib/email/message.py ++++ b/Lib/email/message.py +@@ -613,17 +613,15 @@ + the form (CHARSET, LANGUAGE, VALUE). Note that both CHARSET and + LANGUAGE can be None, in which case you should consider VALUE to be + encoded in the us-ascii charset. You can usually ignore LANGUAGE. ++ The parameter value (either the returned string, or the VALUE item in ++ the 3-tuple) is always unquoted, unless unquote is set to False. + +- Your application should be prepared to deal with 3-tuple return +- values, and can convert the parameter to a Unicode string like so: ++ If your application doesn't care whether the parameter was RFC 2231 ++ encoded, it can turn the return value into a string as follows: + + param = msg.get_param('foo') +- if isinstance(param, tuple): +- param = unicode(param[2], param[0] or 'us-ascii') ++ param = email.utils.collapse_rfc2231_value(rawparam) + +- In any case, the parameter value (either the returned string, or the +- VALUE item in the 3-tuple) is always unquoted, unless unquote is set +- to False. + """ + if header not in self: + return failobj +diff -r 3d0686d90f55 Lib/email/parser.py +--- a/Lib/email/parser.py ++++ b/Lib/email/parser.py +@@ -4,7 +4,7 @@ + + """A parser of RFC 2822 and MIME email messages.""" + +-__all__ = ['Parser', 'HeaderParser'] ++__all__ = ['Parser', 'HeaderParser', 'BytesParser'] + + import warnings + from io import StringIO, TextIOWrapper +diff -r 3d0686d90f55 Lib/email/test/test_email.py +--- a/Lib/email/test/test_email.py ++++ b/Lib/email/test/test_email.py +@@ -619,6 +619,19 @@ + msg['Dummy'] = 'dummy\nX-Injected-Header: test' + self.assertRaises(errors.HeaderParseError, msg.as_string) + ++ def test_unicode_header_defaults_to_utf8_encoding(self): ++ # Issue 14291 ++ m = MIMEText('abc\n') ++ m['Subject'] = 'É test' ++ self.assertEqual(str(m),textwrap.dedent("""\ ++ Content-Type: text/plain; charset="us-ascii" ++ MIME-Version: 1.0 ++ Content-Transfer-Encoding: 7bit ++ Subject: =?utf-8?q?=C3=89_test?= ++ ++ abc ++ """)) ++ + # Test the email.encoders module + class TestEncoders(unittest.TestCase): + +@@ -1060,9 +1073,13 @@ + 'f\xfcr Offshore-Windkraftprojekte ' + '') + msg['Reply-To'] = header_string +- self.assertRaises(UnicodeEncodeError, msg.as_string) ++ eq(msg.as_string(maxheaderlen=78), """\ ++Reply-To: =?utf-8?q?Britische_Regierung_gibt_gr=C3=BCnes_Licht_f=C3=BCr_Offs?= ++ =?utf-8?q?hore-Windkraftprojekte_=3Ca-very-long-address=40example=2Ecom=3E?= ++ ++""") + msg = Message() +- msg['Reply-To'] = Header(header_string, 'utf-8', ++ msg['Reply-To'] = Header(header_string, + header_name='Reply-To') + eq(msg.as_string(maxheaderlen=78), """\ + Reply-To: =?utf-8?q?Britische_Regierung_gibt_gr=C3=BCnes_Licht_f=C3=BCr_Offs?= +@@ -1226,7 +1243,6 @@ + =?utf-8?q?_folding_white_space_works?=""")+'\n') + + +- + # Test mangling of "From " lines in the body of a message + class TestFromMangling(unittest.TestCase): + def setUp(self): +@@ -2502,14 +2518,11 @@ + + def test__all__(self): + module = __import__('email') +- # Can't use sorted() here due to Python 2.3 compatibility +- all = module.__all__[:] +- all.sort() +- self.assertEqual(all, [ +- 'base64mime', 'charset', 'encoders', 'errors', 'generator', +- 'header', 'iterators', 'message', 'message_from_binary_file', +- 'message_from_bytes', 'message_from_file', +- 'message_from_string', 'mime', 'parser', ++ self.assertEqual(sorted(module.__all__), [ ++ 'base64mime', 'charset', 'encoders', 'errors', 'feedparser', ++ 'generator', 'header', 'iterators', 'message', ++ 'message_from_binary_file', 'message_from_bytes', ++ 'message_from_file', 'message_from_string', 'mime', 'parser', + 'quoprimime', 'utils', + ]) + +@@ -2572,6 +2585,12 @@ + eq(time.localtime(t)[:6], timetup[:6]) + eq(int(time.strftime('%Y', timetup[:9])), 2003) + ++ def test_mktime_tz(self): ++ self.assertEqual(utils.mktime_tz((1970, 1, 1, 0, 0, 0, ++ -1, -1, -1, 0)), 0) ++ self.assertEqual(utils.mktime_tz((1970, 1, 1, 0, 0, 0, ++ -1, -1, -1, 1234)), -1234) ++ + def test_parsedate_y2k(self): + """Test for parsing a date with a two-digit year. + +@@ -3424,6 +3443,30 @@ + g.flatten(msg) + self.assertEqual(s.getvalue(), source) + ++ def test_bytes_generator_b_encoding_linesep(self): ++ # Issue 14062: b encoding was tacking on an extra \n. ++ m = Message() ++ # This has enough non-ascii that it should always end up b encoded. ++ m['Subject'] = Header('žluÅ¥ouÄký kůň') ++ s = BytesIO() ++ g = email.generator.BytesGenerator(s) ++ g.flatten(m, linesep='\r\n') ++ self.assertEqual( ++ s.getvalue(), ++ b'Subject: =?utf-8?b?xb5sdcWlb3XEjWvDvSBrxa/FiA==?=\r\n\r\n') ++ ++ def test_generator_b_encoding_linesep(self): ++ # Since this broke in ByteGenerator, test Generator for completeness. ++ m = Message() ++ # This has enough non-ascii that it should always end up b encoded. ++ m['Subject'] = Header('žluÅ¥ouÄký kůň') ++ s = StringIO() ++ g = email.generator.Generator(s) ++ g.flatten(m, linesep='\r\n') ++ self.assertEqual( ++ s.getvalue(), ++ 'Subject: =?utf-8?b?xb5sdcWlb3XEjWvDvSBrxa/FiA==?=\r\n\r\n') ++ + maxDiff = None + + +diff -r 3d0686d90f55 Lib/gzip.py +--- a/Lib/gzip.py ++++ b/Lib/gzip.py +@@ -159,9 +159,8 @@ + if fileobj is None: + fileobj = self.myfileobj = builtins.open(filename, mode or 'rb') + if filename is None: +- if hasattr(fileobj, 'name') and isinstance(fileobj.name, str): +- filename = fileobj.name +- else: ++ filename = getattr(fileobj, 'name', '') ++ if not isinstance(filename, (str, bytes)): + filename = '' + if mode is None: + if hasattr(fileobj, 'mode'): mode = fileobj.mode +@@ -236,7 +235,8 @@ + # RFC 1952 requires the FNAME field to be Latin-1. Do not + # include filenames that cannot be represented that way. + fname = os.path.basename(self.name) +- fname = fname.encode('latin-1') ++ if not isinstance(fname, bytes): ++ fname = fname.encode('latin-1') + if fname.endswith(b'.gz'): + fname = fname[:-3] + except UnicodeEncodeError: +diff -r 3d0686d90f55 Lib/html/parser.py +--- a/Lib/html/parser.py ++++ b/Lib/html/parser.py +@@ -22,7 +22,7 @@ + starttagopen = re.compile('<[a-zA-Z]') + piclose = re.compile('>') + commentclose = re.compile(r'--\s*>') +-tagfind = re.compile('[a-zA-Z][-.a-zA-Z0-9:_]*') ++tagfind = re.compile('([a-zA-Z][-.a-zA-Z0-9:_]*)(?:\s|/(?!>))*') + # see http://www.w3.org/TR/html5/tokenization.html#tag-open-state + # and http://www.w3.org/TR/html5/tokenization.html#tag-name-state + tagfind_tolerant = re.compile('[a-zA-Z][^\t\n\r\f />\x00]*') +@@ -36,7 +36,7 @@ + r'\s*([a-zA-Z_][-.:a-zA-Z_0-9]*)(\s*=\s*' + r'(\'[^\']*\'|"[^"]*"|[^\s"\'=<>`]*))?') + attrfind_tolerant = re.compile( +- r'[\s/]*((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*' ++ r'((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*' + r'(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?(?:\s|/(?!>))*') + locatestarttagend = re.compile(r""" + <[a-zA-Z][-.a-zA-Z0-9:_]* # tag name +@@ -327,7 +327,7 @@ + match = tagfind.match(rawdata, i+1) + assert match, 'unexpected call to parse_starttag()' + k = match.end() +- self.lasttag = tag = rawdata[i+1:k].lower() ++ self.lasttag = tag = match.group(1).lower() + while k < endpos: + if self.strict: + m = attrfind.match(rawdata, k) +diff -r 3d0686d90f55 Lib/http/client.py +--- a/Lib/http/client.py ++++ b/Lib/http/client.py +@@ -563,7 +563,7 @@ + # a vanishingly small number of sites EOF without + # sending the trailer + break +- if line == b"\r\n": ++ if line in (b'\r\n', b'\n', b''): + break + + # we read everything; close the "file" +@@ -715,7 +715,10 @@ + line = response.fp.readline(_MAXLINE + 1) + if len(line) > _MAXLINE: + raise LineTooLong("header line") +- if line == b'\r\n': ++ if not line: ++ # for sites which EOF without sending a trailer ++ break ++ if line in (b'\r\n', b'\n', b''): + break + + def connect(self): +@@ -994,7 +997,7 @@ + + self.putrequest(method, url, **skips) + +- if body and ('content-length' not in header_names): ++ if body is not None and ('content-length' not in header_names): + self._set_content_length(body) + for hdr, value in headers.items(): + self.putheader(hdr, value) +diff -r 3d0686d90f55 Lib/http/cookies.py +--- a/Lib/http/cookies.py ++++ b/Lib/http/cookies.py +@@ -301,7 +301,7 @@ + from time import gmtime, time + now = time() + year, month, day, hh, mm, ss, wd, y, z = gmtime(now + future) +- return "%s, %02d-%3s-%4d %02d:%02d:%02d GMT" % \ ++ return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % \ + (weekdayname[wd], day, monthname[month], year, hh, mm, ss) + + +@@ -439,7 +439,7 @@ + (?P # Start of group 'val' + "(?:[^\\"]|\\.)*" # Any doublequoted string + | # or +- \w{3},\s[\w\d-]{9,11}\s[\d:]{8}\sGMT # Special case for "expires" attr ++ \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT # Special case for "expires" attr + | # or + """ + _LegalCharsPatt + r"""* # Any word or empty string + ) # End of group 'val' +diff -r 3d0686d90f55 Lib/http/server.py +--- a/Lib/http/server.py ++++ b/Lib/http/server.py +@@ -508,13 +508,13 @@ + specified as subsequent arguments (it's just like + printf!). + +- The client host and current date/time are prefixed to ++ The client ip and current date/time are prefixed to + every message. + + """ + + sys.stderr.write("%s - - [%s] %s\n" % +- (self.address_string(), ++ (self.client_address[0], + self.log_date_time_string(), + format%args)) + +@@ -825,44 +825,47 @@ + + # Utilities for CGIHTTPRequestHandler + +-# TODO(gregory.p.smith): Move this into an appropriate library. +-def _url_collapse_path_split(path): ++def _url_collapse_path(path): + """ + Given a URL path, remove extra '/'s and '.' path elements and collapse +- any '..' references. ++ any '..' references and returns a colllapsed path. + + Implements something akin to RFC-2396 5.2 step 6 to parse relative paths. ++ The utility of this function is limited to is_cgi method and helps ++ preventing some security attacks. + + Returns: A tuple of (head, tail) where tail is everything after the final / + and head is everything before it. Head will always start with a '/' and, + if it contains anything else, never have a trailing '/'. + + Raises: IndexError if too many '..' occur within the path. ++ + """ + # Similar to os.path.split(os.path.normpath(path)) but specific to URL + # path semantics rather than local operating system semantics. +- path_parts = [] +- for part in path.split('/'): +- if part == '.': +- path_parts.append('') +- else: +- path_parts.append(part) +- # Filter out blank non trailing parts before consuming the '..'. +- path_parts = [part for part in path_parts[:-1] if part] + path_parts[-1:] ++ path_parts = path.split('/') ++ head_parts = [] ++ for part in path_parts[:-1]: ++ if part == '..': ++ head_parts.pop() # IndexError if more '..' than prior parts ++ elif part and part != '.': ++ head_parts.append( part ) + if path_parts: + tail_part = path_parts.pop() ++ if tail_part: ++ if tail_part == '..': ++ head_parts.pop() ++ tail_part = '' ++ elif tail_part == '.': ++ tail_part = '' + else: + tail_part = '' +- head_parts = [] +- for part in path_parts: +- if part == '..': +- head_parts.pop() +- else: +- head_parts.append(part) +- if tail_part and tail_part == '..': +- head_parts.pop() +- tail_part = '' +- return ('/' + '/'.join(head_parts), tail_part) ++ ++ splitpath = ('/' + '/'.join(head_parts), tail_part) ++ collapsed_path = "/".join(splitpath) ++ ++ return collapsed_path ++ + + + nobody = None +@@ -943,13 +946,15 @@ + (and the next character is a '/' or the end of the string). + + """ +- +- splitpath = _url_collapse_path_split(self.path) +- if splitpath[0] in self.cgi_directories: +- self.cgi_info = splitpath ++ collapsed_path = _url_collapse_path(self.path) ++ dir_sep = collapsed_path.find('/', 1) ++ head, tail = collapsed_path[:dir_sep], collapsed_path[dir_sep+1:] ++ if head in self.cgi_directories: ++ self.cgi_info = head, tail + return True + return False + ++ + cgi_directories = ['/cgi-bin', '/htbin'] + + def is_executable(self, path): +diff -r 3d0686d90f55 Lib/idlelib/AutoComplete.py +--- a/Lib/idlelib/AutoComplete.py ++++ b/Lib/idlelib/AutoComplete.py +@@ -124,19 +124,26 @@ + curline = self.text.get("insert linestart", "insert") + i = j = len(curline) + if hp.is_in_string() and (not mode or mode==COMPLETE_FILES): ++ # Find the beginning of the string ++ # fetch_completions will look at the file system to determine whether the ++ # string value constitutes an actual file name ++ # XXX could consider raw strings here and unescape the string value if it's ++ # not raw. + self._remove_autocomplete_window() + mode = COMPLETE_FILES +- while i and curline[i-1] in FILENAME_CHARS: ++ # Find last separator or string start ++ while i and curline[i-1] not in "'\"" + SEPS: + i -= 1 + comp_start = curline[i:j] + j = i +- while i and curline[i-1] in FILENAME_CHARS + SEPS: ++ # Find string start ++ while i and curline[i-1] not in "'\"": + i -= 1 + comp_what = curline[i:j] + elif hp.is_in_code() and (not mode or mode==COMPLETE_ATTRIBUTES): + self._remove_autocomplete_window() + mode = COMPLETE_ATTRIBUTES +- while i and curline[i-1] in ID_CHARS: ++ while i and (curline[i-1] in ID_CHARS or ord(curline[i-1]) > 127): + i -= 1 + comp_start = curline[i:j] + if i and curline[i-1] == '.': +diff -r 3d0686d90f55 Lib/idlelib/AutoCompleteWindow.py +--- a/Lib/idlelib/AutoCompleteWindow.py ++++ b/Lib/idlelib/AutoCompleteWindow.py +@@ -354,6 +354,15 @@ + # A modifier key, so ignore + return + ++ elif event.char and event.char >= ' ': ++ # Regular character with a non-length-1 keycode ++ self._change_start(self.start + event.char) ++ self.lasttypedstart = self.start ++ self.listbox.select_clear(0, int(self.listbox.curselection()[0])) ++ self.listbox.select_set(self._binary_search(self.start)) ++ self._selection_changed() ++ return "break" ++ + else: + # Unknown event, close the window and let it through. + self.hide_window() +diff -r 3d0686d90f55 Lib/idlelib/CallTipWindow.py +--- a/Lib/idlelib/CallTipWindow.py ++++ b/Lib/idlelib/CallTipWindow.py +@@ -22,6 +22,7 @@ + self.parenline = self.parencol = None + self.lastline = None + self.hideid = self.checkhideid = None ++ self.checkhide_after_id = None + + def position_window(self): + """Check if needs to reposition the window, and if so - do it.""" +@@ -102,7 +103,10 @@ + self.hidetip() + else: + self.position_window() +- self.widget.after(CHECKHIDE_TIME, self.checkhide_event) ++ if self.checkhide_after_id is not None: ++ self.widget.after_cancel(self.checkhide_after_id) ++ self.checkhide_after_id = \ ++ self.widget.after(CHECKHIDE_TIME, self.checkhide_event) + + def hide_event(self, event): + if not self.tipwindow: +diff -r 3d0686d90f55 Lib/idlelib/CallTips.py +--- a/Lib/idlelib/CallTips.py ++++ b/Lib/idlelib/CallTips.py +@@ -67,18 +67,18 @@ + if not sur_paren: + return + hp.set_index(sur_paren[0]) +- name = hp.get_expression() +- if not name: ++ expression = hp.get_expression() ++ if not expression: + return +- if not evalfuncs and (name.find('(') != -1): ++ if not evalfuncs and (expression.find('(') != -1): + return +- argspec = self.fetch_tip(name) ++ argspec = self.fetch_tip(expression) + if not argspec: + return + self.active_calltip = self._calltip_window() + self.active_calltip.showtip(argspec, sur_paren[0], sur_paren[1]) + +- def fetch_tip(self, name): ++ def fetch_tip(self, expression): + """Return the argument list and docstring of a function or class. + + If there is a Python subprocess, get the calltip there. Otherwise, +@@ -94,53 +94,59 @@ + """ + try: + rpcclt = self.editwin.flist.pyshell.interp.rpcclt +- except: ++ except AttributeError: + rpcclt = None + if rpcclt: + return rpcclt.remotecall("exec", "get_the_calltip", +- (name,), {}) ++ (expression,), {}) + else: +- entity = self.get_entity(name) +- return get_argspec(entity) ++ return get_argspec(get_entity(expression)) + +- def get_entity(self, name): +- "Lookup name in a namespace spanning sys.modules and __main.dict__." +- if name: +- namespace = sys.modules.copy() +- namespace.update(__main__.__dict__) +- try: +- return eval(name, namespace) +- except (NameError, AttributeError): +- return None ++def get_entity(expression): ++ """Return the object corresponding to expression evaluated ++ in a namespace spanning sys.modules and __main.dict__. ++ """ ++ if expression: ++ namespace = sys.modules.copy() ++ namespace.update(__main__.__dict__) ++ try: ++ return eval(expression, namespace) ++ except BaseException: ++ # An uncaught exception closes idle, and eval can raise any ++ # exception, especially if user classes are involved. ++ return None + +-def _find_constructor(class_ob): +- "Find the nearest __init__() in the class tree." +- try: +- return class_ob.__init__.__func__ +- except AttributeError: +- for base in class_ob.__bases__: +- init = _find_constructor(base) +- if init: +- return init +- return None ++# The following are used in both get_argspec and tests ++_first_param = re.compile('(?<=\()\w*\,?\s*') ++_default_callable_argspec = "No docstring, see docs." + + def get_argspec(ob): +- """Get a string describing the arguments for the given object.""" ++ '''Return a string describing the arguments and return of a callable object. ++ ++ For Python-coded functions and methods, the first line is introspected. ++ Delete 'self' parameter for classes (.__init__) and bound methods. ++ The last line is the first line of the doc string. For builtins, this typically ++ includes the arguments in addition to the return value. ++ ++ ''' + argspec = "" +- if ob is not None: ++ if hasattr(ob, '__call__'): + if isinstance(ob, type): +- fob = _find_constructor(ob) +- if fob is None: +- fob = lambda: None +- elif isinstance(ob, types.MethodType): +- fob = ob.__func__ ++ fob = getattr(ob, '__init__', None) ++ elif isinstance(ob.__call__, types.MethodType): ++ fob = ob.__call__ + else: + fob = ob +- if isinstance(fob, (types.FunctionType, types.LambdaType)): ++ if isinstance(fob, (types.FunctionType, types.MethodType)): + argspec = inspect.formatargspec(*inspect.getfullargspec(fob)) +- pat = re.compile('self\,?\s*') +- argspec = pat.sub("", argspec) +- doc = getattr(ob, "__doc__", "") ++ if (isinstance(ob, (type, types.MethodType)) or ++ isinstance(ob.__call__, types.MethodType)): ++ argspec = _first_param.sub("", argspec) ++ ++ if isinstance(ob.__call__, types.MethodType): ++ doc = ob.__call__.__doc__ ++ else: ++ doc = getattr(ob, "__doc__", "") + if doc: + doc = doc.lstrip() + pos = doc.find("\n") +@@ -149,55 +155,113 @@ + if argspec: + argspec += "\n" + argspec += doc[:pos] ++ if not argspec: ++ argspec = _default_callable_argspec + return argspec + + ################################################# + # +-# Test code +-# ++# Test code tests CallTips.fetch_tip, get_entity, and get_argspec ++ + def main(): ++ # Putting expected in docstrings results in doubled tips for test + def t1(): "()" + def t2(a, b=None): "(a, b=None)" + def t3(a, *args): "(a, *args)" + def t4(*args): "(*args)" +- def t5(a, *args): "(a, *args)" +- def t6(a, b=None, *args, **kw): "(a, b=None, *args, **kw)" ++ def t5(a, b=None, *args, **kw): "(a, b=None, *args, **kw)" + + class TC(object): + "(ai=None, *b)" +- def __init__(self, ai=None, *b): "(ai=None, *b)" +- def t1(self): "()" +- def t2(self, ai, b=None): "(ai, b=None)" +- def t3(self, ai, *args): "(ai, *args)" +- def t4(self, *args): "(*args)" +- def t5(self, ai, *args): "(ai, *args)" +- def t6(self, ai, b=None, *args, **kw): "(ai, b=None, *args, **kw)" +- +- __main__.__dict__.update(locals()) +- +- def test(tests): +- ct = CallTips() +- failed=[] +- for t in tests: +- expected = t.__doc__ + "\n" + t.__doc__ +- name = t.__name__ +- # exercise fetch_tip(), not just get_argspec() +- try: +- qualified_name = "%s.%s" % (t.__self__.__class__.__name__, name) +- except AttributeError: +- qualified_name = name +- argspec = ct.fetch_tip(qualified_name) +- if argspec != expected: +- failed.append(t) +- fmt = "%s - expected %s, but got %s" +- print(fmt % (t.__name__, expected, get_argspec(t))) +- print("%d of %d tests failed" % (len(failed), len(tests))) ++ def __init__(self, ai=None, *b): "(self, ai=None, *b)" ++ def t1(self): "(self)" ++ def t2(self, ai, b=None): "(self, ai, b=None)" ++ def t3(self, ai, *args): "(self, ai, *args)" ++ def t4(self, *args): "(self, *args)" ++ def t5(self, ai, b=None, *args, **kw): "(self, ai, b=None, *args, **kw)" ++ def t6(no, self): "(no, self)" ++ @classmethod ++ def cm(cls, a): "(cls, a)" ++ @staticmethod ++ def sm(b): "(b)" ++ def __call__(self, ci): "(self, ci)" + + tc = TC() +- tests = (t1, t2, t3, t4, t5, t6, +- TC, tc.t1, tc.t2, tc.t3, tc.t4, tc.t5, tc.t6) + +- test(tests) ++ # Python classes that inherit builtin methods ++ class Int(int): "Int(x[, base]) -> integer" ++ class List(list): "List() -> new empty list" ++ # Simulate builtin with no docstring for default argspec test ++ class SB: __call__ = None ++ ++ __main__.__dict__.update(locals()) # required for get_entity eval() ++ ++ num_tests = num_fail = 0 ++ tip = CallTips().fetch_tip ++ ++ def test(expression, expected): ++ nonlocal num_tests, num_fail ++ num_tests += 1 ++ argspec = tip(expression) ++ if argspec != expected: ++ num_fail += 1 ++ fmt = "%s - expected\n%r\n - but got\n%r" ++ print(fmt % (expression, expected, argspec)) ++ ++ def test_builtins(): ++ # if first line of a possibly multiline compiled docstring changes, ++ # must change corresponding test string ++ test('int', "int(x[, base]) -> integer") ++ test('Int', Int.__doc__) ++ test('types.MethodType', "method(function, instance)") ++ test('list', "list() -> new empty list") ++ test('List', List.__doc__) ++ test('list.__new__', ++ 'T.__new__(S, ...) -> a new object with type S, a subtype of T') ++ test('list.__init__', ++ 'x.__init__(...) initializes x; see help(type(x)) for signature') ++ append_doc = "L.append(object) -> None -- append object to end" ++ test('list.append', append_doc) ++ test('[].append', append_doc) ++ test('List.append', append_doc) ++ test('SB()', _default_callable_argspec) ++ ++ def test_funcs(): ++ for func in (t1, t2, t3, t4, t5, TC,): ++ fdoc = func.__doc__ ++ test(func.__name__, fdoc + "\n" + fdoc) ++ for func in (TC.t1, TC.t2, TC.t3, TC.t4, TC.t5, TC.t6, TC.sm, ++ TC.__call__): ++ fdoc = func.__doc__ ++ test('TC.'+func.__name__, fdoc + "\n" + fdoc) ++ fdoc = TC.cm.__func__.__doc__ ++ test('TC.cm.__func__', fdoc + "\n" + fdoc) ++ ++ def test_methods(): ++ # test that first parameter is correctly removed from argspec ++ # using _first_param re to calculate expected masks re errors ++ for meth, mdoc in ((tc.t1, "()"), (tc.t4, "(*args)"), (tc.t6, "(self)"), ++ (TC.cm, "(a)"),): ++ test('tc.'+meth.__name__, mdoc + "\n" + meth.__doc__) ++ test('tc', "(ci)" + "\n" + tc.__call__.__doc__) ++ # directly test that re works to delete unicode parameter name ++ uni = "(A\u0391\u0410\u05d0\u0627\u0905\u1e00\u3042, a)" # various As ++ assert _first_param.sub('', uni) == '(a)' ++ ++ def test_non_callables(): ++ # expression evaluates, but not to a callable ++ for expr in ('0', '0.0' 'num_tests', b'num_tests', '[]', '{}'): ++ test(expr, '') ++ # expression does not evaluate, but raises an exception ++ for expr in ('1a', 'xyx', 'num_tests.xyz', '[int][1]', '{0:int}[1]'): ++ test(expr, '') ++ ++ test_builtins() ++ test_funcs() ++ test_non_callables() ++ test_methods() ++ ++ print("%d of %d tests failed" % (num_fail, num_tests)) + + if __name__ == '__main__': + main() +diff -r 3d0686d90f55 Lib/idlelib/EditorWindow.py +--- a/Lib/idlelib/EditorWindow.py ++++ b/Lib/idlelib/EditorWindow.py +@@ -860,7 +860,7 @@ + # for each edit window instance, construct the recent files menu + for instance in self.top.instance_dict: + menu = instance.recent_files_menu +- menu.delete(1, END) # clear, and rebuild: ++ menu.delete(0, END) # clear, and rebuild: + for i, file_name in enumerate(rf_list): + file_name = file_name.rstrip() # zap \n + # make unicode string to display non-ASCII chars correctly +diff -r 3d0686d90f55 Lib/idlelib/GrepDialog.py +--- a/Lib/idlelib/GrepDialog.py ++++ b/Lib/idlelib/GrepDialog.py +@@ -81,7 +81,7 @@ + hits = 0 + for fn in list: + try: +- f = open(fn) ++ f = open(fn, errors='replace') + except IOError as msg: + print(msg) + continue +diff -r 3d0686d90f55 Lib/idlelib/IOBinding.py +--- a/Lib/idlelib/IOBinding.py ++++ b/Lib/idlelib/IOBinding.py +@@ -156,29 +156,33 @@ + self.filename_change_hook() + + def open(self, event=None, editFile=None): +- if self.editwin.flist: ++ flist = self.editwin.flist ++ # Save in case parent window is closed (ie, during askopenfile()). ++ if flist: + if not editFile: + filename = self.askopenfile() + else: + filename=editFile + if filename: +- # If the current window has no filename and hasn't been +- # modified, we replace its contents (no loss). Otherwise +- # we open a new window. But we won't replace the +- # shell window (which has an interp(reter) attribute), which +- # gets set to "not modified" at every new prompt. +- try: +- interp = self.editwin.interp +- except AttributeError: +- interp = None +- if not self.filename and self.get_saved() and not interp: +- self.editwin.flist.open(filename, self.loadfile) ++ # If editFile is valid and already open, flist.open will ++ # shift focus to its existing window. ++ # If the current window exists and is a fresh unnamed, ++ # unmodified editor window (not an interpreter shell), ++ # pass self.loadfile to flist.open so it will load the file ++ # in the current window (if the file is not already open) ++ # instead of a new window. ++ if (self.editwin and ++ not getattr(self.editwin, 'interp', None) and ++ not self.filename and ++ self.get_saved()): ++ flist.open(filename, self.loadfile) + else: +- self.editwin.flist.open(filename) ++ flist.open(filename) + else: +- self.text.focus_set() ++ if self.text: ++ self.text.focus_set() + return "break" +- # ++ + # Code for use outside IDLE: + if self.get_saved(): + reply = self.maybesave() +diff -r 3d0686d90f55 Lib/idlelib/NEWS.txt +--- a/Lib/idlelib/NEWS.txt ++++ b/Lib/idlelib/NEWS.txt +@@ -1,3 +1,31 @@ ++What's New in IDLE 3.2.4? ++========================= ++ ++- Issue #13532, #15319: Check that arguments to sys.stdout.write are strings. ++ ++- Issue # 12510: Attempt to get certain tool tips no longer crashes IDLE. ++ Erroneous tool tips have been corrected. Default added for callables. ++ ++- Issue10365: File open dialog now works instead of crashing even when ++ parent window is closed while dialog is open. ++ ++- Issue 14876: use user-selected font for highlight configuration. ++ ++- Issue #14937: Perform auto-completion of filenames in strings even for ++ non-ASCII filenames. Likewise for identifiers. ++ ++What's New in IDLE 3.2.3? ++========================= ++ ++- Issue #14409: IDLE now properly executes commands in the Shell window ++ when it cannot read the normal config files on startup and ++ has to use the built-in default key bindings. ++ There was previously a bug in one of the defaults. ++ ++- Issue #3573: IDLE hangs when passing invalid command line args ++ (directory(ies) instead of file(s)). ++ ++ + What's New in IDLE 3.2.1? + ========================= + +diff -r 3d0686d90f55 Lib/idlelib/PyShell.py +--- a/Lib/idlelib/PyShell.py ++++ b/Lib/idlelib/PyShell.py +@@ -309,6 +309,11 @@ + "console": idleConf.GetHighlight(theme, "console"), + }) + ++ def removecolors(self): ++ # Don't remove shell color tags before "iomark" ++ for tag in self.tagdefs: ++ self.tag_remove(tag, "iomark", "end") ++ + class ModifiedUndoDelegator(UndoDelegator): + "Extend base class: forbid insert/delete before the I/O mark" + +@@ -1237,6 +1242,8 @@ + self.encoding = encoding + + def write(self, s): ++ if not isinstance(s, str): ++ raise TypeError('must be str, not ' + type(s).__name__) + self.shell.write(s, self.tags) + + def writelines(self, lines): +@@ -1389,8 +1396,10 @@ + + if enable_edit: + if not (cmd or script): +- for filename in args: +- flist.open(filename) ++ for filename in args[:]: ++ if flist.open(filename) is None: ++ # filename is a directory actually, disconsider it ++ args.remove(filename) + if not args: + flist.new() + if enable_shell: +@@ -1433,7 +1442,8 @@ + if tkversionwarning: + shell.interp.runcommand(''.join(("print('", tkversionwarning, "')"))) + +- root.mainloop() ++ while flist.inversedict: # keep IDLE running while files are open. ++ root.mainloop() + root.destroy() + + if __name__ == "__main__": +diff -r 3d0686d90f55 Lib/idlelib/configDialog.py +--- a/Lib/idlelib/configDialog.py ++++ b/Lib/idlelib/configDialog.py +@@ -187,7 +187,7 @@ + text=' Highlighting Theme ') + #frameCustom + self.textHighlightSample=Text(frameCustom,relief=SOLID,borderwidth=1, +- font=('courier',12,''),cursor='hand2',width=21,height=10, ++ font=('courier',12,''),cursor='hand2',width=21,height=11, + takefocus=FALSE,highlightthickness=0,wrap=NONE) + text=self.textHighlightSample + text.bind('',lambda e: 'break') +@@ -821,8 +821,10 @@ + fontWeight=tkFont.BOLD + else: + fontWeight=tkFont.NORMAL +- self.editFont.config(size=self.fontSize.get(), ++ size=self.fontSize.get() ++ self.editFont.config(size=size, + weight=fontWeight,family=fontName) ++ self.textHighlightSample.configure(font=(fontName, size, fontWeight)) + + def SetHighlightTarget(self): + if self.highlightTarget.get()=='Cursor': #bg not possible +diff -r 3d0686d90f55 Lib/idlelib/configHandler.py +--- a/Lib/idlelib/configHandler.py ++++ b/Lib/idlelib/configHandler.py +@@ -595,7 +595,7 @@ + '<>': [''], + '<>': [''], + '<>': [''], +- '<>': [' '], ++ '<>': ['', ''], + '<>': [''], + '<>': [''], + '<>': [''], +diff -r 3d0686d90f55 Lib/idlelib/run.py +--- a/Lib/idlelib/run.py ++++ b/Lib/idlelib/run.py +@@ -1,4 +1,5 @@ + import sys ++import io + import linecache + import time + import socket +@@ -244,6 +245,29 @@ + 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'): ++ 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) ++ ++ def write(self, s): ++ if not isinstance(s, str): ++ raise TypeError('must be str, not ' + type(s).__name__) ++ return self.rpc.write(s) + + class MyHandler(rpc.RPCHandler): + +@@ -252,8 +276,8 @@ + executive = Executive(self) + self.register("exec", executive) + sys.stdin = self.console = self.get_remote_proxy("stdin") +- sys.stdout = self.get_remote_proxy("stdout") +- sys.stderr = self.get_remote_proxy("stderr") ++ sys.stdout = _RPCFile(self.get_remote_proxy("stdout")) ++ sys.stderr = _RPCFile(self.get_remote_proxy("stderr")) + # page help() text to shell. + import pydoc # import must be done here to capture i/o binding + pydoc.pager = pydoc.plainpager +diff -r 3d0686d90f55 Lib/idlelib/tabbedpages.py +--- a/Lib/idlelib/tabbedpages.py ++++ b/Lib/idlelib/tabbedpages.py +@@ -78,7 +78,7 @@ + def remove_tab(self, tab_name): + """Remove the tab named """ + if not tab_name in self._tab_names: +- raise KeyError("No such Tab: '%s" % page_name) ++ raise KeyError("No such Tab: '%s" % tab_name) + + self._tab_names.remove(tab_name) + self._arrange_tabs() +@@ -88,7 +88,7 @@ + if tab_name == self._selected_tab: + return + if tab_name is not None and tab_name not in self._tabs: +- raise KeyError("No such Tab: '%s" % page_name) ++ raise KeyError("No such Tab: '%s" % tab_name) + + # deselect the current selected tab + if self._selected_tab is not None: +diff -r 3d0686d90f55 Lib/imaplib.py +--- a/Lib/imaplib.py ++++ b/Lib/imaplib.py +@@ -22,7 +22,7 @@ + + __version__ = "2.58" + +-import binascii, errno, random, re, socket, subprocess, sys, time ++import binascii, errno, random, re, socket, subprocess, sys, time, calendar + + try: + import ssl +@@ -1340,19 +1340,9 @@ + zone = -zone + + tt = (year, mon, day, hour, min, sec, -1, -1, -1) ++ utc = calendar.timegm(tt) - zone + +- utc = time.mktime(tt) +- +- # Following is necessary because the time module has no 'mkgmtime'. +- # 'mktime' assumes arg in local timezone, so adds timezone/altzone. +- +- lt = time.localtime(utc) +- if time.daylight and lt[-1]: +- zone = zone + time.altzone +- else: +- zone = zone + time.timezone +- +- return time.localtime(utc - zone) ++ return time.localtime(utc) + + + +diff -r 3d0686d90f55 Lib/io.py +--- a/Lib/io.py ++++ b/Lib/io.py +@@ -34,15 +34,6 @@ + """ + # New I/O library conforming to PEP 3116. + +-# XXX edge cases when switching between reading/writing +-# XXX need to support 1 meaning line-buffered +-# XXX whenever an argument is None, use the default value +-# XXX read/write ops should check readable/writable +-# XXX buffered readinto should work with arbitrary buffer objects +-# XXX use incremental encoder for text output, at least for UTF-16 and UTF-8-SIG +-# XXX check writable, readable and seekable in appropriate places +- +- + __author__ = ("Guido van Rossum , " + "Mike Verdone , " + "Mark Russell , " +diff -r 3d0686d90f55 Lib/json/__init__.py +--- a/Lib/json/__init__.py ++++ b/Lib/json/__init__.py +@@ -97,7 +97,7 @@ + "json": "obj" + } + $ echo '{ 1.2:3.4}' | python -m json.tool +- Expecting property name: line 1 column 2 (char 2) ++ Expecting property name enclosed in double quotes: line 1 column 2 (char 2) + """ + __version__ = '2.0.9' + __all__ = [ +diff -r 3d0686d90f55 Lib/json/decoder.py +--- a/Lib/json/decoder.py ++++ b/Lib/json/decoder.py +@@ -173,7 +173,8 @@ + pairs = object_hook(pairs) + return pairs, end + 1 + elif nextchar != '"': +- raise ValueError(errmsg("Expecting property name", s, end)) ++ raise ValueError(errmsg( ++ "Expecting property name enclosed in double quotes", s, end)) + end += 1 + while True: + key, end = scanstring(s, end, strict) +@@ -183,7 +184,7 @@ + if s[end:end + 1] != ':': + end = _w(s, end).end() + if s[end:end + 1] != ':': +- raise ValueError(errmsg("Expecting : delimiter", s, end)) ++ raise ValueError(errmsg("Expecting ':' delimiter", s, end)) + end += 1 + + try: +@@ -211,12 +212,13 @@ + if nextchar == '}': + break + elif nextchar != ',': +- raise ValueError(errmsg("Expecting , delimiter", s, end - 1)) ++ raise ValueError(errmsg("Expecting ',' delimiter", s, end - 1)) + end = _w(s, end).end() + nextchar = s[end:end + 1] + end += 1 + if nextchar != '"': +- raise ValueError(errmsg("Expecting property name", s, end - 1)) ++ raise ValueError(errmsg( ++ "Expecting property name enclosed in double quotes", s, end - 1)) + if object_pairs_hook is not None: + result = object_pairs_hook(pairs) + return result, end +@@ -250,7 +252,7 @@ + if nextchar == ']': + break + elif nextchar != ',': +- raise ValueError(errmsg("Expecting , delimiter", s, end)) ++ raise ValueError(errmsg("Expecting ',' delimiter", s, end)) + try: + if s[end] in _ws: + end += 1 +diff -r 3d0686d90f55 Lib/json/encoder.py +--- a/Lib/json/encoder.py ++++ b/Lib/json/encoder.py +@@ -27,8 +27,7 @@ + ESCAPE_DCT.setdefault(chr(i), '\\u{0:04x}'.format(i)) + #ESCAPE_DCT.setdefault(chr(i), '\\u%04x' % (i,)) + +-# Assume this produces an infinity on all machines (probably not guaranteed) +-INFINITY = float('1e66666') ++INFINITY = float('inf') + FLOAT_REPR = repr + + def encode_basestring(s): +diff -r 3d0686d90f55 Lib/json/tool.py +--- a/Lib/json/tool.py ++++ b/Lib/json/tool.py +@@ -7,7 +7,7 @@ + "json": "obj" + } + $ echo '{ 1.2:3.4}' | python -m json.tool +- Expecting property name: line 1 column 2 (char 2) ++ Expecting property name enclosed in double quotes: line 1 column 2 (char 2) + + """ + import sys +diff -r 3d0686d90f55 Lib/lib2to3/tests/test_parser.py +--- a/Lib/lib2to3/tests/test_parser.py ++++ b/Lib/lib2to3/tests/test_parser.py +@@ -11,10 +11,14 @@ + # Testing imports + from . import support + from .support import driver, test_dir ++from test.support import verbose + + # Python imports + import os ++import sys + import unittest ++import warnings ++import subprocess + + # Local imports + from lib2to3.pgen2 import tokenize +@@ -171,10 +175,12 @@ + try: + tree = driver.parse_string(source) + except ParseError as err: +- print('ParseError on file', filepath, err) ++ if verbose > 0: ++ warnings.warn('ParseError on file %s (%s)' % (filepath, err)) + continue + new = str(tree) +- if diff(filepath, new): ++ x = diff(filepath, new) ++ if x: + self.fail("Idempotency failed: %s" % filepath) + + def test_extended_unpacking(self): +@@ -183,6 +189,7 @@ + driver.parse_string("(z, *y, w) = m\n") + driver.parse_string("for *z, m in d: pass\n") + ++ + class TestLiterals(GrammarTest): + + def validate(self, s): +@@ -221,7 +228,7 @@ + with open('@', 'w') as f: + f.write(str(result)) + fn = fn.replace('"', '\\"') +- return os.system('diff -u "%s" @' % fn) ++ return subprocess.call(['diff', '-u', fn, '@'], stdout=(subprocess.DEVNULL if verbose < 1 else None)) + finally: + try: + os.remove("@") +diff -r 3d0686d90f55 Lib/logging/__init__.py +--- a/Lib/logging/__init__.py ++++ b/Lib/logging/__init__.py +@@ -1,4 +1,4 @@ +-# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved. ++# Copyright 2001-2012 by Vinay Sajip. All Rights Reserved. + # + # Permission to use, copy, modify, and distribute this software and its + # documentation for any purpose and without fee is hereby granted, +@@ -16,9 +16,9 @@ + + """ + Logging package for Python. Based on PEP 282 and comments thereto in +-comp.lang.python, and influenced by Apache's log4j system. ++comp.lang.python. + +-Copyright (C) 2001-2011 Vinay Sajip. All Rights Reserved. ++Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved. + + To use, simply 'import logging' and log away! + """ +@@ -917,8 +917,12 @@ + """ + Flushes the stream. + """ +- if self.stream and hasattr(self.stream, "flush"): +- self.stream.flush() ++ self.acquire() ++ try: ++ if self.stream and hasattr(self.stream, "flush"): ++ self.stream.flush() ++ finally: ++ self.release() + + def emit(self, record): + """ +@@ -969,12 +973,16 @@ + """ + Closes the stream. + """ +- if self.stream: +- self.flush() +- if hasattr(self.stream, "close"): +- self.stream.close() +- StreamHandler.close(self) +- self.stream = None ++ self.acquire() ++ try: ++ if self.stream: ++ self.flush() ++ if hasattr(self.stream, "close"): ++ self.stream.close() ++ StreamHandler.close(self) ++ self.stream = None ++ finally: ++ self.release() + + def _open(self): + """ +diff -r 3d0686d90f55 Lib/logging/handlers.py +--- a/Lib/logging/handlers.py ++++ b/Lib/logging/handlers.py +@@ -1,4 +1,4 @@ +-# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved. ++# Copyright 2001-2012 by Vinay Sajip. All Rights Reserved. + # + # Permission to use, copy, modify, and distribute this software and its + # documentation for any purpose and without fee is hereby granted, +@@ -16,15 +16,14 @@ + + """ + Additional handlers for the logging package for Python. The core package is +-based on PEP 282 and comments thereto in comp.lang.python, and influenced by +-Apache's log4j system. ++based on PEP 282 and comments thereto in comp.lang.python. + +-Copyright (C) 2001-2010 Vinay Sajip. All Rights Reserved. ++Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved. + + To use, simply 'import logging.handlers' and log away! + """ + +-import logging, socket, os, pickle, struct, time, re ++import errno, logging, socket, os, pickle, struct, time, re + from stat import ST_DEV, ST_INO, ST_MTIME + import queue + try: +@@ -271,9 +270,10 @@ + dstAtRollover = time.localtime(newRolloverAt)[-1] + if dstNow != dstAtRollover: + if not dstNow: # DST kicks in before next rollover, so we need to deduct an hour +- newRolloverAt = newRolloverAt - 3600 ++ addend = -3600 + else: # DST bows out before next rollover, so we need to add an hour +- newRolloverAt = newRolloverAt + 3600 ++ addend = 3600 ++ newRolloverAt += addend + result = newRolloverAt + return result + +@@ -324,11 +324,20 @@ + self.stream.close() + self.stream = None + # get the time that this sequence started at and make it a TimeTuple ++ currentTime = int(time.time()) ++ dstNow = time.localtime(currentTime)[-1] + t = self.rolloverAt - self.interval + if self.utc: + timeTuple = time.gmtime(t) + else: + timeTuple = time.localtime(t) ++ dstThen = timeTuple[-1] ++ if dstNow != dstThen: ++ if dstNow: ++ addend = 3600 ++ else: ++ addend = -3600 ++ timeTuple = time.localtime(t + addend) + dfn = self.baseFilename + "." + time.strftime(self.suffix, timeTuple) + if os.path.exists(dfn): + os.remove(dfn) +@@ -338,19 +347,18 @@ + os.remove(s) + self.mode = 'w' + self.stream = self._open() +- currentTime = int(time.time()) + newRolloverAt = self.computeRollover(currentTime) + while newRolloverAt <= currentTime: + newRolloverAt = newRolloverAt + self.interval + #If DST changes and midnight or weekly rollover, adjust for this. + if (self.when == 'MIDNIGHT' or self.when.startswith('W')) and not self.utc: +- dstNow = time.localtime(currentTime)[-1] + dstAtRollover = time.localtime(newRolloverAt)[-1] + if dstNow != dstAtRollover: + if not dstNow: # DST kicks in before next rollover, so we need to deduct an hour +- newRolloverAt = newRolloverAt - 3600 ++ addend = -3600 + else: # DST bows out before next rollover, so we need to add an hour +- newRolloverAt = newRolloverAt + 3600 ++ addend = 3600 ++ newRolloverAt += addend + self.rolloverAt = newRolloverAt + + class WatchedFileHandler(logging.FileHandler): +@@ -375,11 +383,13 @@ + """ + def __init__(self, filename, mode='a', encoding=None, delay=0): + logging.FileHandler.__init__(self, filename, mode, encoding, delay) +- if not os.path.exists(self.baseFilename): +- self.dev, self.ino = -1, -1 +- else: +- stat = os.stat(self.baseFilename) +- self.dev, self.ino = stat[ST_DEV], stat[ST_INO] ++ self.dev, self.ino = -1, -1 ++ self._statstream() ++ ++ def _statstream(self): ++ if self.stream: ++ sres = os.fstat(self.stream.fileno()) ++ self.dev, self.ino = sres[ST_DEV], sres[ST_INO] + + def emit(self, record): + """ +@@ -389,21 +399,30 @@ + has, close the old stream and reopen the file to get the + current stream. + """ +- if not os.path.exists(self.baseFilename): +- stat = None +- changed = 1 +- else: +- stat = os.stat(self.baseFilename) +- changed = (stat[ST_DEV] != self.dev) or (stat[ST_INO] != self.ino) +- if changed and self.stream is not None: +- self.stream.flush() +- self.stream.close() +- self.stream = self._open() +- if stat is None: +- stat = os.stat(self.baseFilename) +- self.dev, self.ino = stat[ST_DEV], stat[ST_INO] ++ # Reduce the chance of race conditions by stat'ing by path only ++ # once and then fstat'ing our new fd if we opened a new log stream. ++ # See issue #14632: Thanks to John Mulligan for the problem report ++ # and patch. ++ try: ++ # stat the file by path, checking for existence ++ sres = os.stat(self.baseFilename) ++ except OSError as err: ++ if err.errno == errno.ENOENT: ++ sres = None ++ else: ++ raise ++ # compare file system stat with that of our stream file handle ++ if not sres or sres[ST_DEV] != self.dev or sres[ST_INO] != self.ino: ++ if self.stream is not None: ++ # we have an open file handle, clean it up ++ self.stream.flush() ++ self.stream.close() ++ # open a new file handle and get new stat info from that fd ++ self.stream = self._open() ++ self._statstream() + logging.FileHandler.emit(self, record) + ++ + class SocketHandler(logging.Handler): + """ + A handler class which writes logging records, in pickle format, to +@@ -511,11 +530,16 @@ + """ + ei = record.exc_info + if ei: +- dummy = self.format(record) # just to get traceback text into record.exc_text +- record.exc_info = None # to avoid Unpickleable error +- s = pickle.dumps(record.__dict__, 1) +- if ei: +- record.exc_info = ei # for next handler ++ # just to get traceback text into record.exc_text ... ++ dummy = self.format(record) ++ # See issue #14436: If msg or args are objects, they may not be ++ # available on the receiving end. So we convert the msg % args ++ # to a string, save it as msg and zap the args. ++ d = dict(record.__dict__) ++ d['msg'] = record.getMessage() ++ d['args'] = None ++ d['exc_info'] = None ++ s = pickle.dumps(d, 1) + slen = struct.pack(">L", len(s)) + return slen + s + +@@ -554,10 +578,14 @@ + """ + Closes the socket. + """ +- if self.sock: +- self.sock.close() +- self.sock = None +- logging.Handler.close(self) ++ self.acquire() ++ try: ++ if self.sock: ++ self.sock.close() ++ self.sock = None ++ logging.Handler.close(self) ++ finally: ++ self.release() + + class DatagramHandler(SocketHandler): + """ +@@ -733,7 +761,11 @@ + except socket.error: + self.socket.close() + self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) +- self.socket.connect(address) ++ try: ++ self.socket.connect(address) ++ except socket.error: ++ self.socket.close() ++ raise + + def encodePriority(self, facility, priority): + """ +@@ -752,9 +784,13 @@ + """ + Closes the socket. + """ +- if self.unixsocket: +- self.socket.close() +- logging.Handler.close(self) ++ self.acquire() ++ try: ++ if self.unixsocket: ++ self.socket.close() ++ logging.Handler.close(self) ++ finally: ++ self.release() + + def mapPriority(self, levelName): + """ +@@ -787,8 +823,6 @@ + prio = prio.encode('utf-8') + # Message is a string. Convert to bytes as required by RFC 5424 + msg = msg.encode('utf-8') +- if codecs: +- msg = codecs.BOM_UTF8 + msg + msg = prio + msg + try: + if self.unixsocket: +@@ -841,6 +875,7 @@ + self.toaddrs = toaddrs + self.subject = subject + self.secure = secure ++ self._timeout = 5.0 + + def getSubject(self, record): + """ +@@ -863,7 +898,7 @@ + port = self.mailport + if not port: + port = smtplib.SMTP_PORT +- smtp = smtplib.SMTP(self.mailhost, port) ++ smtp = smtplib.SMTP(self.mailhost, port, timeout=self._timeout) + msg = self.format(record) + msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\nDate: %s\r\n\r\n%s" % ( + self.fromaddr, +@@ -1095,7 +1130,11 @@ + + This version just zaps the buffer to empty. + """ +- self.buffer = [] ++ self.acquire() ++ try: ++ self.buffer = [] ++ finally: ++ self.release() + + def close(self): + """ +@@ -1145,18 +1184,26 @@ + + The record buffer is also cleared by this operation. + """ +- if self.target: +- for record in self.buffer: +- self.target.handle(record) +- self.buffer = [] ++ self.acquire() ++ try: ++ if self.target: ++ for record in self.buffer: ++ self.target.handle(record) ++ self.buffer = [] ++ finally: ++ self.release() + + def close(self): + """ + Flush, set the target to None and lose the buffer. + """ + self.flush() +- self.target = None +- BufferingHandler.close(self) ++ self.acquire() ++ try: ++ self.target = None ++ BufferingHandler.close(self) ++ finally: ++ self.release() + + + class QueueHandler(logging.Handler): +diff -r 3d0686d90f55 Lib/mailbox.py +--- a/Lib/mailbox.py ++++ b/Lib/mailbox.py +@@ -587,16 +587,19 @@ + self._file = f + self._toc = None + self._next_key = 0 +- self._pending = False # No changes require rewriting the file. ++ self._pending = False # No changes require rewriting the file. ++ self._pending_sync = False # No need to sync the file + self._locked = False +- self._file_length = None # Used to record mailbox size ++ self._file_length = None # Used to record mailbox size + + def add(self, message): + """Add message and return assigned key.""" + self._lookup() + self._toc[self._next_key] = self._append_message(message) + self._next_key += 1 +- self._pending = True ++ # _append_message appends the message to the mailbox file. We ++ # don't need a full rewrite + rename, sync is enough. ++ self._pending_sync = True + return self._next_key - 1 + + def remove(self, key): +@@ -642,6 +645,11 @@ + def flush(self): + """Write any pending changes to disk.""" + if not self._pending: ++ if self._pending_sync: ++ # Messages have only been added, so syncing the file ++ # is enough. ++ _sync_flush(self._file) ++ self._pending_sync = False + return + + # In order to be writing anything out at all, self._toc must +@@ -675,6 +683,7 @@ + new_file.write(buffer) + new_toc[key] = (new_start, new_file.tell()) + self._post_message_hook(new_file) ++ self._file_length = new_file.tell() + except: + new_file.close() + os.remove(new_file.name) +@@ -682,6 +691,9 @@ + _sync_close(new_file) + # self._file is about to get replaced, so no need to sync. + self._file.close() ++ # Make sure the new file's mode is the same as the old file's ++ mode = os.stat(self._path).st_mode ++ os.chmod(new_file.name, mode) + try: + os.rename(new_file.name, self._path) + except OSError as e: +@@ -694,6 +706,7 @@ + self._file = open(self._path, 'rb+') + self._toc = new_toc + self._pending = False ++ self._pending_sync = False + if self._locked: + _lock_file(self._file, dotlock=False) + +@@ -730,6 +743,12 @@ + """Append message to mailbox and return (start, stop) offsets.""" + self._file.seek(0, 2) + before = self._file.tell() ++ if len(self._toc) == 0 and not self._pending: ++ # This is the first message, and the _pre_mailbox_hook ++ # hasn't yet been called. If self._pending is True, ++ # messages have been removed, so _pre_mailbox_hook must ++ # have been called already. ++ self._pre_mailbox_hook(self._file) + try: + self._pre_message_hook(self._file) + offsets = self._install_message(message) +diff -r 3d0686d90f55 Lib/multiprocessing/connection.py +--- a/Lib/multiprocessing/connection.py ++++ b/Lib/multiprocessing/connection.py +@@ -94,6 +94,17 @@ + else: + raise ValueError('unrecognized family') + ++def _validate_family(family): ++ ''' ++ Checks if the family is valid for the current environment. ++ ''' ++ if sys.platform != 'win32' and family == 'AF_PIPE': ++ raise ValueError('Family %s is not recognized.' % family) ++ ++ if sys.platform == 'win32' and family == 'AF_UNIX': ++ # double check ++ if not hasattr(socket, family): ++ raise ValueError('Family %s is not recognized.' % family) + + def address_type(address): + ''' +@@ -126,6 +137,7 @@ + or default_family + address = address or arbitrary_address(family) + ++ _validate_family(family) + if family == 'AF_PIPE': + self._listener = PipeListener(address, backlog) + else: +@@ -163,6 +175,7 @@ + Returns a connection to the address of a `Listener` + ''' + family = family or address_type(address) ++ _validate_family(family) + if family == 'AF_PIPE': + c = PipeClient(address) + else: +@@ -347,7 +360,10 @@ + try: + win32.ConnectNamedPipe(handle, win32.NULL) + except WindowsError as e: +- if e.args[0] != win32.ERROR_PIPE_CONNECTED: ++ # ERROR_NO_DATA can occur if a client has already connected, ++ # written data and then disconnected -- see Issue 14725. ++ if e.args[0] not in (win32.ERROR_PIPE_CONNECTED, ++ win32.ERROR_NO_DATA): + raise + return _multiprocessing.PipeConnection(handle) + +diff -r 3d0686d90f55 Lib/multiprocessing/dummy/__init__.py +--- a/Lib/multiprocessing/dummy/__init__.py ++++ b/Lib/multiprocessing/dummy/__init__.py +@@ -70,7 +70,8 @@ + def start(self): + assert self._parent is current_process() + self._start_called = True +- self._parent._children[self] = None ++ if hasattr(self._parent, '_children'): ++ self._parent._children[self] = None + threading.Thread.start(self) + + @property +diff -r 3d0686d90f55 Lib/multiprocessing/pool.py +--- a/Lib/multiprocessing/pool.py ++++ b/Lib/multiprocessing/pool.py +@@ -493,7 +493,8 @@ + # We must wait for the worker handler to exit before terminating + # workers because we don't want workers to be restarted behind our back. + debug('joining worker handler') +- worker_handler.join() ++ if threading.current_thread() is not worker_handler: ++ worker_handler.join() + + # Terminate workers which haven't already finished. + if pool and hasattr(pool[0], 'terminate'): +@@ -503,10 +504,12 @@ + p.terminate() + + debug('joining task handler') +- task_handler.join() ++ if threading.current_thread() is not task_handler: ++ task_handler.join() + + debug('joining result handler') +- result_handler.join() ++ if threading.current_thread() is not result_handler: ++ result_handler.join() + + if pool and hasattr(pool[0], 'terminate'): + debug('joining pool workers') +@@ -584,6 +587,7 @@ + if chunksize <= 0: + self._number_left = 0 + self._ready = True ++ del cache[self._job] + else: + self._number_left = length//chunksize + bool(length % chunksize) + +diff -r 3d0686d90f55 Lib/multiprocessing/process.py +--- a/Lib/multiprocessing/process.py ++++ b/Lib/multiprocessing/process.py +@@ -271,11 +271,11 @@ + except SystemExit as e: + if not e.args: + exitcode = 1 +- elif type(e.args[0]) is int: ++ elif isinstance(e.args[0], int): + exitcode = e.args[0] + else: +- sys.stderr.write(e.args[0] + '\n') +- exitcode = 1 ++ sys.stderr.write(str(e.args[0]) + '\n') ++ exitcode = 0 if isinstance(e.args[0], str) else 1 + except: + exitcode = 1 + import traceback +diff -r 3d0686d90f55 Lib/os.py +--- a/Lib/os.py ++++ b/Lib/os.py +@@ -152,8 +152,17 @@ + mkdir(name, mode) + except OSError as e: + import stat as st +- if not (e.errno == errno.EEXIST and exist_ok and path.isdir(name) and +- st.S_IMODE(lstat(name).st_mode) == _get_masked_mode(mode)): ++ dir_exists = path.isdir(name) ++ expected_mode = _get_masked_mode(mode) ++ if dir_exists: ++ # S_ISGID is automatically copied by the OS from parent to child ++ # directories on mkdir. Don't consider it being set to be a mode ++ # mismatch as mkdir does not unset it when not specified in mode. ++ actual_mode = st.S_IMODE(lstat(name).st_mode) & ~st.S_ISGID ++ else: ++ actual_mode = -1 ++ if not (e.errno == errno.EEXIST and exist_ok and dir_exists and ++ actual_mode == expected_mode): + raise + + def removedirs(name): +diff -r 3d0686d90f55 Lib/posixpath.py +--- a/Lib/posixpath.py ++++ b/Lib/posixpath.py +@@ -266,8 +266,8 @@ + root = b'/' + else: + root = '/' +- userhome = userhome.rstrip(root) or userhome +- return userhome + path[i:] ++ userhome = userhome.rstrip(root) ++ return (userhome + path[i:]) or root + + + # Expand paths containing shell variable substitutions. +diff -r 3d0686d90f55 Lib/pyclbr.py +--- a/Lib/pyclbr.py ++++ b/Lib/pyclbr.py +@@ -128,6 +128,8 @@ + parent = _readmodule(package, path, inpackage) + if inpackage is not None: + package = "%s.%s" % (inpackage, package) ++ if not '__path__' in parent: ++ raise ImportError('No package named {}'.format(package)) + return _readmodule(submodule, parent['__path__'], package) + + # Search the path for the module +diff -r 3d0686d90f55 Lib/pydoc.py +--- a/Lib/pydoc.py ++++ b/Lib/pydoc.py +@@ -1525,7 +1525,8 @@ + raise ImportError('no Python documentation found for %r' % thing) + return object, thing + else: +- return thing, getattr(thing, '__name__', None) ++ name = getattr(thing, '__name__', None) ++ return thing, name if isinstance(name, str) else None + + def render_doc(thing, title='Python Library Documentation: %s', forceload=0, + renderer=None): +@@ -1829,7 +1830,7 @@ + Welcome to Python %s! This is the online help utility. + + If this is your first time using Python, you should definitely check out +-the tutorial on the Internet at http://docs.python.org/tutorial/. ++the tutorial on the Internet at http://docs.python.org/%s/tutorial/. + + Enter the name of any module, keyword, or topic to get help on writing + Python programs and using Python modules. To quit this help utility and +@@ -1839,7 +1840,7 @@ + "keywords", or "topics". Each module also comes with a one-line summary + of what it does; to list the modules whose summaries contain a given word + such as "spam", type "modules spam". +-''' % sys.version[:3]) ++''' % tuple([sys.version[:3]]*2)) + + def list(self, items, columns=4, width=80): + items = list(sorted(items)) +diff -r 3d0686d90f55 Lib/random.py +--- a/Lib/random.py ++++ b/Lib/random.py +@@ -96,7 +96,7 @@ + None or no argument seeds from current time or from an operating + system specific randomness source if available. + +- For version 2 (the default), all of the bits are used if *a *is a str, ++ For version 2 (the default), all of the bits are used if *a* is a str, + bytes, or bytearray. For version 1, the hash() of *a* is used instead. + + If *a* is an int, all bits are used. +diff -r 3d0686d90f55 Lib/re.py +--- a/Lib/re.py ++++ b/Lib/re.py +@@ -69,8 +69,11 @@ + In string patterns without the ASCII flag, it will match the whole + range of Unicode digits. + \D Matches any non-digit character; equivalent to [^\d]. +- \s Matches any whitespace character; equivalent to [ \t\n\r\f\v]. +- \S Matches any non-whitespace character; equiv. to [^ \t\n\r\f\v]. ++ \s Matches any whitespace character; equivalent to [ \t\n\r\f\v] in ++ bytes patterns or string patterns with the ASCII flag. ++ In string patterns without the ASCII flag, it will match the whole ++ range of Unicode whitespace characters. ++ \S Matches any non-whitespace character; equivalent to [^\s]. + \w Matches any alphanumeric character; equivalent to [a-zA-Z0-9_] + in bytes patterns or string patterns with the ASCII flag. + In string patterns without the ASCII flag, it will match the +@@ -179,14 +182,19 @@ + + def split(pattern, string, maxsplit=0, flags=0): + """Split the source string by the occurrences of the pattern, +- returning a list containing the resulting substrings.""" ++ returning a list containing the resulting substrings. If ++ capturing parentheses are used in pattern, then the text of all ++ groups in the pattern are also returned as part of the resulting ++ list. If maxsplit is nonzero, at most maxsplit splits occur, ++ and the remainder of the string is returned as the final element ++ of the list.""" + return _compile(pattern, flags).split(string, maxsplit) + + def findall(pattern, string, flags=0): + """Return a list of all non-overlapping matches in the string. + +- If one or more groups are present in the pattern, return a +- list of groups; this will be a list of tuples if the pattern ++ If one or more capturing groups are present in the pattern, return ++ a list of groups; this will be a list of tuples if the pattern + has more than one group. + + Empty matches are included in the result.""" +diff -r 3d0686d90f55 Lib/rlcompleter.py +--- a/Lib/rlcompleter.py ++++ b/Lib/rlcompleter.py +@@ -1,13 +1,11 @@ +-"""Word completion for GNU readline 2.0. ++"""Word completion for GNU readline. + +-This requires the latest extension to the readline module. The completer +-completes keywords, built-ins and globals in a selectable namespace (which +-defaults to __main__); when completing NAME.NAME..., it evaluates (!) the +-expression up to the last dot and completes its attributes. ++The completer completes keywords, built-ins and globals in a selectable ++namespace (which defaults to __main__); when completing NAME.NAME..., it ++evaluates (!) the expression up to the last dot and completes its attributes. + +-It's very cool to do "import sys" type "sys.", hit the +-completion key (twice), and see the list of names defined by the +-sys module! ++It's very cool to do "import sys" type "sys.", hit the completion key (twice), ++and see the list of names defined by the sys module! + + Tip: to use the tab key as the completion key, call + +@@ -15,21 +13,19 @@ + + Notes: + +-- Exceptions raised by the completer function are *ignored* (and +-generally cause the completion to fail). This is a feature -- since +-readline sets the tty device in raw (or cbreak) mode, printing a +-traceback wouldn't work well without some complicated hoopla to save, +-reset and restore the tty state. ++- Exceptions raised by the completer function are *ignored* (and generally cause ++ the completion to fail). This is a feature -- since readline sets the tty ++ device in raw (or cbreak) mode, printing a traceback wouldn't work well ++ without some complicated hoopla to save, reset and restore the tty state. + +-- The evaluation of the NAME.NAME... form may cause arbitrary +-application defined code to be executed if an object with a +-__getattr__ hook is found. Since it is the responsibility of the +-application (or the user) to enable this feature, I consider this an +-acceptable risk. More complicated expressions (e.g. function calls or +-indexing operations) are *not* evaluated. ++- The evaluation of the NAME.NAME... form may cause arbitrary application ++ defined code to be executed if an object with a __getattr__ hook is found. ++ Since it is the responsibility of the application (or the user) to enable this ++ feature, I consider this an acceptable risk. More complicated expressions ++ (e.g. function calls or indexing operations) are *not* evaluated. + + - When the original stdin is not a tty device, GNU readline is never +-used, and this module (and the readline module) are silently inactive. ++ used, and this module (and the readline module) are silently inactive. + + """ + +diff -r 3d0686d90f55 Lib/shutil.py +--- a/Lib/shutil.py ++++ b/Lib/shutil.py +@@ -118,8 +118,10 @@ + try: + os.chflags(dst, st.st_flags) + except OSError as why: +- if (not hasattr(errno, 'EOPNOTSUPP') or +- why.errno != errno.EOPNOTSUPP): ++ for err in 'EOPNOTSUPP', 'ENOTSUP': ++ if hasattr(errno, err) and why.errno == getattr(errno, err): ++ break ++ else: + raise + + def copy(src, dst): +diff -r 3d0686d90f55 Lib/socket.py +--- a/Lib/socket.py ++++ b/Lib/socket.py +@@ -197,6 +197,17 @@ + if self._io_refs <= 0: + self._real_close() + ++ def detach(self): ++ """detach() -> file descriptor ++ ++ Close the socket object without closing the underlying file descriptor. ++ The object cannot be used after this call, but the file descriptor ++ can be reused for other purposes. The file descriptor is returned. ++ """ ++ self._closed = True ++ return super().detach() ++ ++ + def fromfd(fd, family, type, proto=0): + """ fromfd(fd, family, type[, proto]) -> socket object + +diff -r 3d0686d90f55 Lib/socketserver.py +--- a/Lib/socketserver.py ++++ b/Lib/socketserver.py +@@ -133,6 +133,7 @@ + import select + import sys + import os ++import errno + try: + import threading + except ImportError: +@@ -147,6 +148,15 @@ + "ThreadingUnixStreamServer", + "ThreadingUnixDatagramServer"]) + ++def _eintr_retry(func, *args): ++ """restart a system call interrupted by EINTR""" ++ while True: ++ try: ++ return func(*args) ++ except (OSError, select.error) as e: ++ if e.args[0] != errno.EINTR: ++ raise ++ + class BaseServer: + + """Base class for server classes. +@@ -222,7 +232,8 @@ + # connecting to the socket to wake this up instead of + # polling. Polling reduces our responsiveness to a + # shutdown request and wastes cpu at all other times. +- r, w, e = select.select([self], [], [], poll_interval) ++ r, w, e = _eintr_retry(select.select, [self], [], [], ++ poll_interval) + if self in r: + self._handle_request_noblock() + finally: +@@ -262,7 +273,7 @@ + timeout = self.timeout + elif self.timeout is not None: + timeout = min(timeout, self.timeout) +- fd_sets = select.select([self], [], [], timeout) ++ fd_sets = _eintr_retry(select.select, [self], [], [], timeout) + if not fd_sets[0]: + self.handle_timeout() + return +diff -r 3d0686d90f55 Lib/subprocess.py +--- a/Lib/subprocess.py ++++ b/Lib/subprocess.py +@@ -1075,7 +1075,17 @@ + def terminate(self): + """Terminates the process + """ +- _subprocess.TerminateProcess(self._handle, 1) ++ try: ++ _subprocess.TerminateProcess(self._handle, 1) ++ except OSError as e: ++ # ERROR_ACCESS_DENIED (winerror 5) is received when the ++ # process already died. ++ if e.winerror != 5: ++ raise ++ rc = _subprocess.GetExitCodeProcess(self._handle) ++ if rc == _subprocess.STILL_ACTIVE: ++ raise ++ self.returncode = rc + + kill = terminate + +diff -r 3d0686d90f55 Lib/tarfile.py +--- a/Lib/tarfile.py ++++ b/Lib/tarfile.py +@@ -2496,7 +2496,7 @@ + """ + if tarinfo.issym(): + # Always search the entire archive. +- linkname = os.path.dirname(tarinfo.name) + "/" + tarinfo.linkname ++ linkname = "/".join(filter(None, (os.path.dirname(tarinfo.name), tarinfo.linkname))) + limit = None + else: + # Search the archive before the link, because a hard link is +diff -r 3d0686d90f55 Lib/test/pickletester.py +--- a/Lib/test/pickletester.py ++++ b/Lib/test/pickletester.py +@@ -707,6 +707,11 @@ + def test_getinitargs(self): + pass + ++ def test_pop_empty_stack(self): ++ # Test issue7455 ++ s = b'0' ++ self.assertRaises((pickle.UnpicklingError, IndexError), self.loads, s) ++ + def test_metaclass(self): + a = use_metaclass() + for proto in protocols: +@@ -1383,9 +1388,6 @@ + # Test issue4298 + s = bytes([0x58, 0, 0, 0, 0x54]) + self.assertRaises(EOFError, pickle.loads, s) +- # Test issue7455 +- s = b'0' +- self.assertRaises(pickle.UnpicklingError, pickle.loads, s) + + + class AbstractPersistentPicklerTests(unittest.TestCase): +diff -r 3d0686d90f55 Lib/test/regrtest.py +--- a/Lib/test/regrtest.py ++++ b/Lib/test/regrtest.py +@@ -572,10 +572,14 @@ + output.put((None, None, None, None)) + return + # -E is needed by some tests, e.g. test_import ++ # Running the child from the same working directory ensures ++ # that TEMPDIR for the child is the same when ++ # sysconfig.is_python_build() is true. See issue 15300. + popen = Popen(base_cmd + ['--slaveargs', json.dumps(args_tuple)], + stdout=PIPE, stderr=PIPE, + universal_newlines=True, +- close_fds=(os.name != 'nt')) ++ close_fds=(os.name != 'nt'), ++ cwd=support.SAVEDCWD) + stdout, stderr = popen.communicate() + # Strip last refcount output line if it exists, since it + # comes from the shutdown of the interpreter in the subcommand. +@@ -610,6 +614,8 @@ + print(stdout) + if stderr: + print(stderr, file=sys.stderr) ++ sys.stdout.flush() ++ sys.stderr.flush() + if result[0] == INTERRUPTED: + assert result[1] == 'KeyboardInterrupt' + raise KeyboardInterrupt # What else? +@@ -677,10 +683,10 @@ + if bad: + print(count(len(bad), "test"), "failed:") + printlist(bad) +- if environment_changed: +- print("{} altered the execution environment:".format( +- count(len(environment_changed), "test"))) +- printlist(environment_changed) ++ if environment_changed: ++ print("{} altered the execution environment:".format( ++ count(len(environment_changed), "test"))) ++ printlist(environment_changed) + if skipped and not quiet: + print(count(len(skipped), "test"), "skipped:") + printlist(skipped) +@@ -890,7 +896,9 @@ + 'logging._handlers', 'logging._handlerList', + 'shutil.archive_formats', 'shutil.unpack_formats', + 'sys.warnoptions', 'threading._dangling', +- 'multiprocessing.process._dangling') ++ 'multiprocessing.process._dangling', ++ 'support.TESTFN', ++ ) + + def get_sys_argv(self): + return id(sys.argv), sys.argv, sys.argv[:] +@@ -1020,6 +1028,21 @@ + multiprocessing.process._dangling.clear() + multiprocessing.process._dangling.update(saved) + ++ def get_support_TESTFN(self): ++ if os.path.isfile(support.TESTFN): ++ result = 'f' ++ elif os.path.isdir(support.TESTFN): ++ result = 'd' ++ else: ++ result = None ++ return result ++ def restore_support_TESTFN(self, saved_value): ++ if saved_value is None: ++ if os.path.isfile(support.TESTFN): ++ os.unlink(support.TESTFN) ++ elif os.path.isdir(support.TESTFN): ++ shutil.rmtree(support.TESTFN) ++ + def resource_info(self): + for name in self.resources: + method_suffix = name.replace('.', '_') +diff -r 3d0686d90f55 Lib/test/sha256.pem +--- a/Lib/test/sha256.pem ++++ b/Lib/test/sha256.pem +@@ -2,41 +2,40 @@ + 0 s:/C=FR/postalCode=14000/ST=Calvados/L=CAEN/street=22 rue de Bretagne/O=TBS INTERNET/OU=0002 440443810/OU=sha-256 production/CN=sha256.tbs-internet.com + i:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA SGC + -----BEGIN CERTIFICATE----- +-MIIGXTCCBUWgAwIBAgIRAMmag+ygSAdxZsbyzYjhuW0wDQYJKoZIhvcNAQELBQAw ++MIIGXDCCBUSgAwIBAgIRAKpVmHgg9nfCodAVwcP4siwwDQYJKoZIhvcNAQELBQAw + gcQxCzAJBgNVBAYTAkZSMREwDwYDVQQIEwhDYWx2YWRvczENMAsGA1UEBxMEQ2Fl + bjEVMBMGA1UEChMMVEJTIElOVEVSTkVUMUgwRgYDVQQLEz9UZXJtcyBhbmQgQ29u + ZGl0aW9uczogaHR0cDovL3d3dy50YnMtaW50ZXJuZXQuY29tL0NBL3JlcG9zaXRv + cnkxGDAWBgNVBAsTD1RCUyBJTlRFUk5FVCBDQTEYMBYGA1UEAxMPVEJTIFg1MDkg +-Q0EgU0dDMB4XDTEwMDIxODAwMDAwMFoXDTEyMDIxOTIzNTk1OVowgcsxCzAJBgNV ++Q0EgU0dDMB4XDTEyMDEwNDAwMDAwMFoXDTE0MDIxNzIzNTk1OVowgcsxCzAJBgNV + BAYTAkZSMQ4wDAYDVQQREwUxNDAwMDERMA8GA1UECBMIQ2FsdmFkb3MxDTALBgNV + BAcTBENBRU4xGzAZBgNVBAkTEjIyIHJ1ZSBkZSBCcmV0YWduZTEVMBMGA1UEChMM + VEJTIElOVEVSTkVUMRcwFQYDVQQLEw4wMDAyIDQ0MDQ0MzgxMDEbMBkGA1UECxMS + c2hhLTI1NiBwcm9kdWN0aW9uMSAwHgYDVQQDExdzaGEyNTYudGJzLWludGVybmV0 +-LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbuM8VT7f0nntwu +-N3F7v9KIBlhKNAxqCrziOXU5iqUt8HrQB3DtHbdmII+CpVUlwlmepsx6G+srEZ9a +-MIGAy0nxi5aLb7watkyIdPjJTMvTUBQ/+RPWzt5JtYbbY9BlJ+yci0dctP74f4NU +-ISLtlrEjUbf2gTohLrcE01TfmOF6PDEbB5PKDi38cB3NzKfizWfrOaJW6Q1C1qOJ +-y4/4jkUREX1UFUIxzx7v62VfjXSGlcjGpBX1fvtABQOSLeE0a6gciDZs1REqroFf +-5eXtqYphpTa14Z83ITXMfgg5Nze1VtMnzI9Qx4blYBw4dgQVEuIsYr7FDBOITDzc +-VEVXZx0CAwEAAaOCAj8wggI7MB8GA1UdIwQYMBaAFAdEdoWTKLx/bXjSCuv6TEvf +-2YIfMB0GA1UdDgQWBBSJKI/AYVI9RQNY0QPIqc8ej2QivTAOBgNVHQ8BAf8EBAMC ++LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKQIX/zdJcyxty0m ++PM1XQSoSSifueS3AVcgqMsaIKS/u+rYzsv4hQ/qA6vLn5m5/ewUcZDj7zdi6rBVf ++PaVNXJ6YinLX0tkaW8TEjeVuZG5yksGZlhCt1CJ1Ho9XLiLaP4uJ7MCoNUntpJ+E ++LfrOdgsIj91kPmwjDJeztVcQCvKzhjVJA/KxdInc0JvOATn7rpaSmQI5bvIjufgo ++qVsTPwVFzuUYULXBk7KxRT7MiEqnd5HvviNh0285QC478zl3v0I0Fb5El4yD3p49 ++IthcRnxzMKc0UhU5ogi0SbONyBfm/mzONVfSxpM+MlyvZmJqrbuuLoEDzJD+t8PU ++xSuzgbcCAwEAAaOCAj4wggI6MB8GA1UdIwQYMBaAFAdEdoWTKLx/bXjSCuv6TEvf ++2YIfMB0GA1UdDgQWBBT/qTGYdaj+f61c2IRFL/B1eEsM8DAOBgNVHQ8BAf8EBAMC + BaAwDAYDVR0TAQH/BAIwADA0BgNVHSUELTArBggrBgEFBQcDAQYIKwYBBQUHAwIG +-CisGAQQBgjcKAwMGCWCGSAGG+EIEATBMBgNVHSAERTBDMEEGCysGAQQBgOU3AgQB +-MDIwMAYIKwYBBQUHAgEWJGh0dHBzOi8vd3d3LnRicy1pbnRlcm5ldC5jb20vQ0Ev +-Q1BTNDBtBgNVHR8EZjBkMDKgMKAuhixodHRwOi8vY3JsLnRicy1pbnRlcm5ldC5j +-b20vVEJTWDUwOUNBU0dDLmNybDAuoCygKoYoaHR0cDovL2NybC50YnMteDUwOS5j +-b20vVEJTWDUwOUNBU0dDLmNybDCBpgYIKwYBBQUHAQEEgZkwgZYwOAYIKwYBBQUH +-MAKGLGh0dHA6Ly9jcnQudGJzLWludGVybmV0LmNvbS9UQlNYNTA5Q0FTR0MuY3J0 +-MDQGCCsGAQUFBzAChihodHRwOi8vY3J0LnRicy14NTA5LmNvbS9UQlNYNTA5Q0FT +-R0MuY3J0MCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC50YnMteDUwOS5jb20wPwYD +-VR0RBDgwNoIXc2hhMjU2LnRicy1pbnRlcm5ldC5jb22CG3d3dy5zaGEyNTYudGJz +-LWludGVybmV0LmNvbTANBgkqhkiG9w0BAQsFAAOCAQEAA5NL0D4QSqhErhlkdPmz +-XtiMvdGL+ZehM4coTRIpasM/Agt36Rc0NzCvnQwKE+wkngg1Gy2qe7Q0E/ziqBtB +-fZYzdVgu1zdiL4kTaf+wFKYAFGsFbyeEmXysy+CMwaNoF2vpSjCU1UD56bEnTX/W +-fxVZYxtBQUpnu2wOsm8cDZuZRv9XrYgAhGj9Tt6F0aVHSDGn59uwShG1+BVF/uju +-SCyPTTjL1oc7YElJUzR/x4mQJYvtQI8gDIDAGEOs7v3R/gKa5EMfbUQUI4C84UbI +-Yz09Jdnws/MkC/Hm1BZEqk89u7Hvfv+oHqEb0XaUo0TDfsxE0M1sMdnLb91QNQBm +-UQ== ++CisGAQQBgjcKAwMGCWCGSAGG+EIEATBLBgNVHSAERDBCMEAGCisGAQQB5TcCBAEw ++MjAwBggrBgEFBQcCARYkaHR0cHM6Ly93d3cudGJzLWludGVybmV0LmNvbS9DQS9D ++UFM0MG0GA1UdHwRmMGQwMqAwoC6GLGh0dHA6Ly9jcmwudGJzLWludGVybmV0LmNv ++bS9UQlNYNTA5Q0FTR0MuY3JsMC6gLKAqhihodHRwOi8vY3JsLnRicy14NTA5LmNv ++bS9UQlNYNTA5Q0FTR0MuY3JsMIGmBggrBgEFBQcBAQSBmTCBljA4BggrBgEFBQcw ++AoYsaHR0cDovL2NydC50YnMtaW50ZXJuZXQuY29tL1RCU1g1MDlDQVNHQy5jcnQw ++NAYIKwYBBQUHMAKGKGh0dHA6Ly9jcnQudGJzLXg1MDkuY29tL1RCU1g1MDlDQVNH ++Qy5jcnQwJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLnRicy14NTA5LmNvbTA/BgNV ++HREEODA2ghdzaGEyNTYudGJzLWludGVybmV0LmNvbYIbd3d3LnNoYTI1Ni50YnMt ++aW50ZXJuZXQuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQA0pOuL8QvAa5yksTbGShzX ++ABApagunUGoEydv4YJT1MXy9tTp7DrWaozZSlsqBxrYAXP1d9r2fuKbEniYHxaQ0 ++UYaf1VSIlDo1yuC8wE7wxbHDIpQ/E5KAyxiaJ8obtDhFstWAPAH+UoGXq0kj2teN ++21sFQ5dXgA95nldvVFsFhrRUNB6xXAcaj0VZFhttI0ZfQZmQwEI/P+N9Jr40OGun ++aa+Dn0TMeUH4U20YntfLbu2nDcJcYfyurm+8/0Tr4HznLnedXu9pCPYj0TaddrgT ++XO0oFiyy7qGaY6+qKh71yD64Y3ycCJ/HR9Wm39mjZYc9ezYwT4noP6r7Lk8YO7/q + -----END CERTIFICATE----- + 1 s:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA SGC + i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root +diff -r 3d0686d90f55 Lib/test/support.py +--- a/Lib/test/support.py ++++ b/Lib/test/support.py +@@ -53,7 +53,7 @@ + "reap_children", "cpython_only", "check_impl_detail", "get_attribute", + "swap_item", "swap_attr", "requires_IEEE_754", + "TestHandler", "Matcher", "can_symlink", "skip_unless_symlink", +- "import_fresh_module", "failfast", ++ "import_fresh_module", "failfast", "run_with_tz" + ] + + class Error(Exception): +@@ -1021,6 +1021,39 @@ + return decorator + + #======================================================================= ++# Decorator for running a function in a specific timezone, correctly ++# resetting it afterwards. ++ ++def run_with_tz(tz): ++ def decorator(func): ++ def inner(*args, **kwds): ++ try: ++ tzset = time.tzset ++ except AttributeError: ++ raise unittest.SkipTest("tzset required") ++ if 'TZ' in os.environ: ++ orig_tz = os.environ['TZ'] ++ else: ++ orig_tz = None ++ os.environ['TZ'] = tz ++ tzset() ++ ++ # now run the function, resetting the tz on exceptions ++ try: ++ return func(*args, **kwds) ++ finally: ++ if orig_tz == None: ++ del os.environ['TZ'] ++ else: ++ os.environ['TZ'] = orig_tz ++ time.tzset() ++ ++ inner.__name__ = func.__name__ ++ inner.__doc__ = func.__doc__ ++ return inner ++ return decorator ++ ++#======================================================================= + # Big-memory-test support. Separate from 'resources' because memory use + # should be configurable. + +diff -r 3d0686d90f55 Lib/test/test_aifc.py +--- a/Lib/test/test_aifc.py ++++ b/Lib/test/test_aifc.py +@@ -1,7 +1,8 @@ +-from test.support import findfile, run_unittest, TESTFN ++from test.support import findfile, run_unittest, TESTFN, captured_stdout, unlink + import unittest + import os + import io ++import struct + + import aifc + +@@ -20,10 +21,8 @@ + self.fout.close() + except (aifc.Error, AttributeError): + pass +- try: +- os.remove(TESTFN) +- except OSError: +- pass ++ unlink(TESTFN) ++ unlink(TESTFN + '.aiff') + + def test_skipunknown(self): + #Issue 2245 +@@ -32,6 +31,7 @@ + + def test_params(self): + f = self.f = aifc.open(self.sndfilepath) ++ self.assertEqual(f.getfp().name, self.sndfilepath) + self.assertEqual(f.getnchannels(), 2) + self.assertEqual(f.getsampwidth(), 2) + self.assertEqual(f.getframerate(), 48000) +@@ -45,6 +45,7 @@ + + def test_read(self): + f = self.f = aifc.open(self.sndfilepath) ++ self.assertEqual(f.readframes(0), b'') + self.assertEqual(f.tell(), 0) + self.assertEqual(f.readframes(2), b'\x00\x00\x00\x00\x0b\xd4\x0b\xd4') + f.rewind() +@@ -58,6 +59,10 @@ + self.assertEqual(f.readframes(2), b'\x17t\x17t"\xad"\xad') + f.setpos(pos0) + self.assertEqual(f.readframes(2), b'\x00\x00\x00\x00\x0b\xd4\x0b\xd4') ++ with self.assertRaises(aifc.Error): ++ f.setpos(-1) ++ with self.assertRaises(aifc.Error): ++ f.setpos(f.getnframes() + 1) + + def test_write(self): + f = self.f = aifc.open(self.sndfilepath) +@@ -92,8 +97,6 @@ + self.assertEqual(f.getparams()[0:3], fout.getparams()[0:3]) + self.assertEqual(fout.getcomptype(), b'ULAW') + self.assertEqual(fout.getcompname(), b'foo') +- # XXX: this test fails, not sure if it should succeed or not +- # self.assertEqual(f.readframes(5), fout.readframes(5)) + + def test_close(self): + class Wrapfile(object): +@@ -112,7 +115,7 @@ + + def test_write_header_comptype_sampwidth(self): + for comptype in (b'ULAW', b'ulaw', b'ALAW', b'alaw', b'G722'): +- fout = self.fout = aifc.open(io.BytesIO(), 'wb') ++ fout = aifc.open(io.BytesIO(), 'wb') + fout.setnchannels(1) + fout.setframerate(1) + fout.setcomptype(comptype, b'') +@@ -121,7 +124,7 @@ + fout.initfp(None) + + def test_write_markers_values(self): +- fout = self.fout = aifc.open(io.BytesIO(), 'wb') ++ fout = aifc.open(io.BytesIO(), 'wb') + self.assertEqual(fout.getmarkers(), None) + fout.setmark(1, 0, b'foo1') + fout.setmark(1, 1, b'foo2') +@@ -179,6 +182,148 @@ + with self.assertRaises(ValueError): + aifc._write_string(f, b'too long' * 255) + ++ def test_wrong_open_mode(self): ++ with self.assertRaises(aifc.Error): ++ aifc.open(TESTFN, 'wrong_mode') ++ ++ def test_read_wrong_form(self): ++ b1 = io.BytesIO(b'WRNG' + struct.pack('>L', 0)) ++ b2 = io.BytesIO(b'FORM' + struct.pack('>L', 4) + b'WRNG') ++ self.assertRaises(aifc.Error, aifc.open, b1) ++ self.assertRaises(aifc.Error, aifc.open, b2) ++ ++ def test_read_no_comm_chunk(self): ++ b = io.BytesIO(b'FORM' + struct.pack('>L', 4) + b'AIFF') ++ self.assertRaises(aifc.Error, aifc.open, b) ++ ++ def test_read_wrong_compression_type(self): ++ b = b'FORM' + struct.pack('>L', 4) + b'AIFC' ++ b += b'COMM' + struct.pack('>LhlhhLL', 23, 0, 0, 0, 0, 0, 0) ++ b += b'WRNG' + struct.pack('B', 0) ++ self.assertRaises(aifc.Error, aifc.open, io.BytesIO(b)) ++ ++ def test_read_wrong_marks(self): ++ b = b'FORM' + struct.pack('>L', 4) + b'AIFF' ++ b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0) ++ b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8 ++ b += b'MARK' + struct.pack('>LhB', 3, 1, 1) ++ with captured_stdout() as s: ++ f = aifc.open(io.BytesIO(b)) ++ self.assertEqual( ++ s.getvalue(), ++ 'Warning: MARK chunk contains only 0 markers instead of 1\n') ++ self.assertEqual(f.getmarkers(), None) ++ ++ def test_read_comm_kludge_compname_even(self): ++ b = b'FORM' + struct.pack('>L', 4) + b'AIFC' ++ b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0) ++ b += b'NONE' + struct.pack('B', 4) + b'even' + b'\x00' ++ b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8 ++ with captured_stdout() as s: ++ f = aifc.open(io.BytesIO(b)) ++ self.assertEqual(s.getvalue(), 'Warning: bad COMM chunk size\n') ++ self.assertEqual(f.getcompname(), b'even') ++ ++ def test_read_comm_kludge_compname_odd(self): ++ b = b'FORM' + struct.pack('>L', 4) + b'AIFC' ++ b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0) ++ b += b'NONE' + struct.pack('B', 3) + b'odd' ++ b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8 ++ with captured_stdout() as s: ++ f = aifc.open(io.BytesIO(b)) ++ self.assertEqual(s.getvalue(), 'Warning: bad COMM chunk size\n') ++ self.assertEqual(f.getcompname(), b'odd') ++ ++ def test_write_params_raises(self): ++ fout = aifc.open(io.BytesIO(), 'wb') ++ wrong_params = (0, 0, 0, 0, b'WRNG', '') ++ self.assertRaises(aifc.Error, fout.setparams, wrong_params) ++ self.assertRaises(aifc.Error, fout.getparams) ++ self.assertRaises(aifc.Error, fout.setnchannels, 0) ++ self.assertRaises(aifc.Error, fout.getnchannels) ++ self.assertRaises(aifc.Error, fout.setsampwidth, 0) ++ self.assertRaises(aifc.Error, fout.getsampwidth) ++ self.assertRaises(aifc.Error, fout.setframerate, 0) ++ self.assertRaises(aifc.Error, fout.getframerate) ++ self.assertRaises(aifc.Error, fout.setcomptype, b'WRNG', '') ++ fout.aiff() ++ fout.setnchannels(1) ++ fout.setsampwidth(1) ++ fout.setframerate(1) ++ fout.setnframes(1) ++ fout.writeframes(b'\x00') ++ self.assertRaises(aifc.Error, fout.setparams, (1, 1, 1, 1, 1, 1)) ++ self.assertRaises(aifc.Error, fout.setnchannels, 1) ++ self.assertRaises(aifc.Error, fout.setsampwidth, 1) ++ self.assertRaises(aifc.Error, fout.setframerate, 1) ++ self.assertRaises(aifc.Error, fout.setnframes, 1) ++ self.assertRaises(aifc.Error, fout.setcomptype, b'NONE', '') ++ self.assertRaises(aifc.Error, fout.aiff) ++ self.assertRaises(aifc.Error, fout.aifc) ++ ++ def test_write_params_singles(self): ++ fout = aifc.open(io.BytesIO(), 'wb') ++ fout.aifc() ++ fout.setnchannels(1) ++ fout.setsampwidth(2) ++ fout.setframerate(3) ++ fout.setnframes(4) ++ fout.setcomptype(b'NONE', b'name') ++ self.assertEqual(fout.getnchannels(), 1) ++ self.assertEqual(fout.getsampwidth(), 2) ++ self.assertEqual(fout.getframerate(), 3) ++ self.assertEqual(fout.getnframes(), 0) ++ self.assertEqual(fout.tell(), 0) ++ self.assertEqual(fout.getcomptype(), b'NONE') ++ self.assertEqual(fout.getcompname(), b'name') ++ fout.writeframes(b'\x00' * 4 * fout.getsampwidth() * fout.getnchannels()) ++ self.assertEqual(fout.getnframes(), 4) ++ self.assertEqual(fout.tell(), 4) ++ ++ def test_write_params_bunch(self): ++ fout = aifc.open(io.BytesIO(), 'wb') ++ fout.aifc() ++ p = (1, 2, 3, 4, b'NONE', b'name') ++ fout.setparams(p) ++ self.assertEqual(fout.getparams(), p) ++ fout.initfp(None) ++ ++ def test_write_header_raises(self): ++ fout = aifc.open(io.BytesIO(), 'wb') ++ self.assertRaises(aifc.Error, fout.close) ++ fout.setnchannels(1) ++ self.assertRaises(aifc.Error, fout.close) ++ 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'): ++ fout = aifc.open(io.BytesIO(), 'wb') ++ fout.setsampwidth(1) ++ fout.setcomptype(comptype, b'') ++ self.assertRaises(aifc.Error, fout.close) ++ fout.initfp(None) ++ ++ def test_write_markers_raises(self): ++ fout = aifc.open(io.BytesIO(), 'wb') ++ self.assertRaises(aifc.Error, fout.setmark, 0, 0, b'') ++ self.assertRaises(aifc.Error, fout.setmark, 1, -1, b'') ++ self.assertRaises(aifc.Error, fout.setmark, 1, 0, None) ++ self.assertRaises(aifc.Error, fout.getmark, 1) ++ fout.initfp(None) ++ ++ def test_write_aiff_by_extension(self): ++ sampwidth = 2 ++ fout = self.fout = aifc.open(TESTFN + '.aiff', 'wb') ++ fout.setparams((1, sampwidth, 1, 1, b'ULAW', b'')) ++ frames = b'\x00' * fout.getnchannels() * sampwidth ++ fout.writeframes(frames) ++ fout.close() ++ f = self.f = aifc.open(TESTFN + '.aiff', 'rb') ++ self.assertEqual(f.getcomptype(), b'NONE') ++ f.close() ++ + + def test_main(): + run_unittest(AIFCTest) +diff -r 3d0686d90f55 Lib/test/test_ast.py +--- a/Lib/test/test_ast.py ++++ b/Lib/test/test_ast.py +@@ -195,12 +195,6 @@ + with self.assertRaises(AttributeError): + x.vararg + +- with self.assertRaises(AttributeError): +- x.foobar = 21 +- +- with self.assertRaises(AttributeError): +- ast.AST(lineno=2) +- + with self.assertRaises(TypeError): + # "_ast.AST constructor takes 0 positional arguments" + ast.AST(2) +@@ -224,6 +218,12 @@ + im = ast.parse("from . import y").body[0] + self.assertIsNone(im.module) + ++ def test_non_interned_future_from_ast(self): ++ mod = ast.parse("from __future__ import division") ++ self.assertIsInstance(mod.body[0], ast.ImportFrom) ++ mod.body[0].module = " __future__ ".strip() ++ compile(mod, "", "exec") ++ + def test_base_classes(self): + self.assertTrue(issubclass(ast.For, ast.stmt)) + self.assertTrue(issubclass(ast.Name, ast.expr)) +diff -r 3d0686d90f55 Lib/test/test_asyncore.py +--- a/Lib/test/test_asyncore.py ++++ b/Lib/test/test_asyncore.py +@@ -7,6 +7,7 @@ + import time + import warnings + import errno ++import struct + + from test import support + from test.support import TESTFN, run_unittest, unlink +@@ -730,6 +731,25 @@ + finally: + sock.close() + ++ @unittest.skipUnless(threading, 'Threading required for this test.') ++ @support.reap_threads ++ def test_quick_connect(self): ++ # see: http://bugs.python.org/issue10340 ++ server = TCPServer() ++ t = threading.Thread(target=lambda: asyncore.loop(timeout=0.1, count=500)) ++ t.start() ++ ++ for x in range(20): ++ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ++ s.settimeout(.2) ++ s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, ++ struct.pack('ii', 1, 0)) ++ try: ++ s.connect(server.address) ++ except socket.error: ++ pass ++ finally: ++ s.close() + + class TestAPI_UseSelect(BaseTestAPI): + use_poll = False +diff -r 3d0686d90f55 Lib/test/test_base64.py +--- a/Lib/test/test_base64.py ++++ b/Lib/test/test_base64.py +@@ -2,6 +2,7 @@ + from test import support + import base64 + import binascii ++import os + import sys + import subprocess + +@@ -227,6 +228,10 @@ + + + class TestMain(unittest.TestCase): ++ def tearDown(self): ++ if os.path.exists(support.TESTFN): ++ os.unlink(support.TESTFN) ++ + def get_output(self, *args, **options): + args = (sys.executable, '-m', 'base64') + args + return subprocess.check_output(args, **options) +diff -r 3d0686d90f55 Lib/test/test_bisect.py +--- a/Lib/test/test_bisect.py ++++ b/Lib/test/test_bisect.py +@@ -23,6 +23,28 @@ + import bisect as c_bisect + + ++class Range(object): ++ """A trivial range()-like object without any integer width limitations.""" ++ def __init__(self, start, stop): ++ self.start = start ++ self.stop = stop ++ self.last_insert = None ++ ++ def __len__(self): ++ return self.stop - self.start ++ ++ def __getitem__(self, idx): ++ n = self.stop - self.start ++ if idx < 0: ++ idx += n ++ if idx >= n: ++ raise IndexError(idx) ++ return self.start + idx ++ ++ def insert(self, idx, item): ++ self.last_insert = idx, item ++ ++ + class TestBisect(unittest.TestCase): + module = None + +@@ -122,6 +144,32 @@ + self.assertRaises(ValueError, mod.insort_left, [1, 2, 3], 5, -1, 3), + self.assertRaises(ValueError, mod.insort_right, [1, 2, 3], 5, -1, 3), + ++ def test_large_range(self): ++ # Issue 13496 ++ mod = self.module ++ n = sys.maxsize ++ data = range(n-1) ++ self.assertEqual(mod.bisect_left(data, n-3), n-3) ++ self.assertEqual(mod.bisect_right(data, n-3), n-2) ++ self.assertEqual(mod.bisect_left(data, n-3, n-10, n), n-3) ++ self.assertEqual(mod.bisect_right(data, n-3, n-10, n), n-2) ++ ++ def test_large_pyrange(self): ++ # Same as above, but without C-imposed limits on range() parameters ++ mod = self.module ++ n = sys.maxsize ++ data = Range(0, n-1) ++ self.assertEqual(mod.bisect_left(data, n-3), n-3) ++ self.assertEqual(mod.bisect_right(data, n-3), n-2) ++ self.assertEqual(mod.bisect_left(data, n-3, n-10, n), n-3) ++ self.assertEqual(mod.bisect_right(data, n-3, n-10, n), n-2) ++ x = n - 100 ++ mod.insort_left(data, x, x - 50, x + 50) ++ self.assertEqual(data.last_insert, (x, x)) ++ x = n - 200 ++ mod.insort_right(data, x, x - 50, x + 50) ++ self.assertEqual(data.last_insert, (x + 1, x)) ++ + def test_random(self, n=25): + from random import randrange + for i in range(n): +diff -r 3d0686d90f55 Lib/test/test_cgi.py +--- a/Lib/test/test_cgi.py ++++ b/Lib/test/test_cgi.py +@@ -118,6 +118,11 @@ + + class CgiTests(unittest.TestCase): + ++ def test_escape(self): ++ self.assertEqual("test & string", cgi.escape("test & string")) ++ self.assertEqual("<test string>", cgi.escape("")) ++ self.assertEqual(""test string"", cgi.escape('"test string"', True)) ++ + def test_strict(self): + for orig, expect in parse_strict_test_cases: + # Test basic parsing +diff -r 3d0686d90f55 Lib/test/test_cmd_line_script.py +--- a/Lib/test/test_cmd_line_script.py ++++ b/Lib/test/test_cmd_line_script.py +@@ -13,6 +13,8 @@ + + verbose = support.verbose + ++example_args = ['test1', 'test2', 'test3'] ++ + test_source = """\ + # Script may be run with optimisation enabled, so don't rely on assert + # statements being executed +@@ -36,6 +38,9 @@ + # Check the sys module + import sys + assertIdentical(globals(), sys.modules[__name__].__dict__) ++from test import test_cmd_line_script ++example_args_list = test_cmd_line_script.example_args ++assertEqual(sys.argv[1:], example_args_list) + print('sys.argv[0]==%a' % sys.argv[0]) + print('sys.path[0]==%a' % sys.path[0]) + # Check the working directory +@@ -100,7 +105,7 @@ + *cmd_line_switches): + if not __debug__: + cmd_line_switches += ('-' + 'O' * sys.flags.optimize,) +- run_args = cmd_line_switches + (script_name,) ++ run_args = cmd_line_switches + (script_name,) + tuple(example_args) + rc, out, err = assert_python_ok(*run_args) + self._check_output(script_name, rc, out + err, expected_file, + expected_argv0, expected_path0, expected_package) +@@ -240,9 +245,9 @@ + pkg_dir = os.path.join(script_dir, 'test_pkg') + make_pkg(pkg_dir, "import sys; print('init_argv0==%r' % sys.argv[0])") + script_name = _make_test_script(pkg_dir, 'script') +- rc, out, err = assert_python_ok('-m', 'test_pkg.script') ++ rc, out, err = assert_python_ok('-m', 'test_pkg.script', *example_args) + if verbose > 1: +- print(data) ++ print(out) + expected = "init_argv0==%r" % '-m' + self.assertIn(expected.encode('utf-8'), out) + self._check_output(script_name, rc, out, +@@ -270,10 +275,25 @@ + with support.temp_cwd(path=script_dir): + with open("-m", "w") as f: + f.write("data") +- rc, out, err = assert_python_ok('-m', 'other') ++ rc, out, err = assert_python_ok('-m', 'other', *example_args) + self._check_output(script_name, rc, out, + script_name, script_name, '', '') + ++ def test_dash_m_error_code_is_one(self): ++ # If a module is invoked with the -m command line flag ++ # and results in an error that the return code to the ++ # shell is '1' ++ with temp_dir() as script_dir: ++ with support.temp_cwd(path=script_dir): ++ pkg_dir = os.path.join(script_dir, 'test_pkg') ++ make_pkg(pkg_dir) ++ script_name = _make_test_script(pkg_dir, 'other', ++ "if __name__ == '__main__': raise ValueError") ++ rc, out, err = assert_python_failure('-m', 'test_pkg.other', *example_args) ++ if verbose > 1: ++ print(out) ++ self.assertEqual(rc, 1) ++ + def test_main(): + support.run_unittest(CmdLineTest) + support.reap_children() +diff -r 3d0686d90f55 Lib/test/test_concurrent_futures.py +--- a/Lib/test/test_concurrent_futures.py ++++ b/Lib/test/test_concurrent_futures.py +@@ -183,7 +183,9 @@ + for p in processes: + p.join() + ++ + class WaitTests(unittest.TestCase): ++ + def test_first_completed(self): + future1 = self.executor.submit(mul, 21, 2) + future2 = self.executor.submit(time.sleep, 1.5) +@@ -284,7 +286,21 @@ + + + class ThreadPoolWaitTests(ThreadPoolMixin, WaitTests): +- pass ++ ++ def test_pending_calls_race(self): ++ # Issue #14406: multi-threaded race condition when waiting on all ++ # futures. ++ event = threading.Event() ++ def future_func(): ++ event.wait() ++ oldswitchinterval = sys.getswitchinterval() ++ sys.setswitchinterval(1e-6) ++ try: ++ fs = {self.executor.submit(future_func) for i in range(100)} ++ event.set() ++ futures.wait(fs, return_when=futures.ALL_COMPLETED) ++ finally: ++ sys.setswitchinterval(oldswitchinterval) + + + class ProcessPoolWaitTests(ProcessPoolMixin, WaitTests): +diff -r 3d0686d90f55 Lib/test/test_descr.py +--- a/Lib/test/test_descr.py ++++ b/Lib/test/test_descr.py +@@ -1,8 +1,10 @@ + import builtins ++import gc + import sys + import types + import math + import unittest ++import weakref + + from copy import deepcopy + from test import support +@@ -1186,7 +1188,6 @@ + self.assertEqual(Counted.counter, 0) + + # Test lookup leaks [SF bug 572567] +- import gc + if hasattr(gc, 'get_objects'): + class G(object): + def __eq__(self, other): +@@ -1457,6 +1458,22 @@ + self.assertEqual(x, spam.spamlist) + self.assertEqual(a, a1) + self.assertEqual(d, d1) ++ spam_cm = spam.spamlist.__dict__['classmeth'] ++ x2, a2, d2 = spam_cm(spam.spamlist, *a, **d) ++ self.assertEqual(x2, spam.spamlist) ++ self.assertEqual(a2, a1) ++ self.assertEqual(d2, d1) ++ class SubSpam(spam.spamlist): pass ++ x2, a2, d2 = spam_cm(SubSpam, *a, **d) ++ self.assertEqual(x2, SubSpam) ++ self.assertEqual(a2, a1) ++ self.assertEqual(d2, d1) ++ with self.assertRaises(TypeError): ++ spam_cm() ++ with self.assertRaises(TypeError): ++ spam_cm(spam.spamlist()) ++ with self.assertRaises(TypeError): ++ spam_cm(list) + + def test_staticmethods(self): + # Testing static methods... +@@ -4380,7 +4397,6 @@ + self.assertRaises(AttributeError, getattr, C(), "attr") + self.assertEqual(descr.counter, 4) + +- import gc + class EvilGetattribute(object): + # This used to segfault + def __getattr__(self, name): +@@ -4393,6 +4409,9 @@ + + self.assertRaises(AttributeError, getattr, EvilGetattribute(), "attr") + ++ def test_type___getattribute__(self): ++ self.assertRaises(TypeError, type.__getattribute__, list, type) ++ + def test_abstractmethods(self): + # type pretends not to have __abstractmethods__. + self.assertRaises(AttributeError, getattr, type, "__abstractmethods__") +@@ -4427,7 +4446,30 @@ + pass + Foo.__repr__ = Foo.__str__ + foo = Foo() +- str(foo) ++ self.assertRaises(RuntimeError, str, foo) ++ self.assertRaises(RuntimeError, repr, foo) ++ ++ def test_mixing_slot_wrappers(self): ++ class X(dict): ++ __setattr__ = dict.__setitem__ ++ x = X() ++ x.y = 42 ++ self.assertEqual(x["y"], 42) ++ ++ def test_cycle_through_dict(self): ++ # See bug #1469629 ++ class X(dict): ++ def __init__(self): ++ dict.__init__(self) ++ self.__dict__ = self ++ x = X() ++ x.attr = 42 ++ wr = weakref.ref(x) ++ del x ++ support.gc_collect() ++ self.assertIsNone(wr()) ++ for o in gc.get_objects(): ++ self.assertIsNot(type(o), X) + + class DictProxyTests(unittest.TestCase): + def setUp(self): +diff -r 3d0686d90f55 Lib/test/test_dict.py +--- a/Lib/test/test_dict.py ++++ b/Lib/test/test_dict.py +@@ -299,6 +299,26 @@ + x.fail = True + self.assertRaises(Exc, d.setdefault, x, []) + ++ def test_setdefault_atomic(self): ++ # Issue #13521: setdefault() calls __hash__ and __eq__ only once. ++ class Hashed(object): ++ def __init__(self): ++ self.hash_count = 0 ++ self.eq_count = 0 ++ def __hash__(self): ++ self.hash_count += 1 ++ return 42 ++ def __eq__(self, other): ++ self.eq_count += 1 ++ return id(self) == id(other) ++ hashed1 = Hashed() ++ y = {hashed1: 5} ++ hashed2 = Hashed() ++ y.setdefault(hashed2, []) ++ self.assertEqual(hashed1.hash_count, 1) ++ self.assertEqual(hashed2.hash_count, 1) ++ self.assertEqual(hashed1.eq_count + hashed2.eq_count, 1) ++ + def test_popitem(self): + # dict.popitem() + for copymode in -1, +1: +diff -r 3d0686d90f55 Lib/test/test_exceptions.py +--- a/Lib/test/test_exceptions.py ++++ b/Lib/test/test_exceptions.py +@@ -38,7 +38,7 @@ + try: + try: + import marshal +- marshal.loads('') ++ marshal.loads(b'') + except EOFError: + pass + finally: +diff -r 3d0686d90f55 Lib/test/test_file_eintr.py +--- /dev/null ++++ b/Lib/test/test_file_eintr.py +@@ -0,0 +1,236 @@ ++# Written to test interrupted system calls interfering with our many buffered ++# IO implementations. http://bugs.python.org/issue12268 ++# ++# It was suggested that this code could be merged into test_io and the tests ++# made to work using the same method as the existing signal tests in test_io. ++# I was unable to get single process tests using alarm or setitimer that way ++# to reproduce the EINTR problems. This process based test suite reproduces ++# the problems prior to the issue12268 patch reliably on Linux and OSX. ++# - gregory.p.smith ++ ++import os ++import select ++import signal ++import subprocess ++import sys ++from test.support import run_unittest ++import time ++import unittest ++ ++# Test import all of the things we're about to try testing up front. ++from _io import FileIO ++ ++ ++@unittest.skipUnless(os.name == 'posix', 'tests requires a posix system.') ++class TestFileIOSignalInterrupt(unittest.TestCase): ++ def setUp(self): ++ self._process = None ++ ++ def tearDown(self): ++ if self._process and self._process.poll() is None: ++ try: ++ self._process.kill() ++ except OSError: ++ pass ++ ++ def _generate_infile_setup_code(self): ++ """Returns the infile = ... line of code for the reader process. ++ ++ subclasseses should override this to test different IO objects. ++ """ ++ return ('import _io ;' ++ 'infile = _io.FileIO(sys.stdin.fileno(), "rb")') ++ ++ def fail_with_process_info(self, why, stdout=b'', stderr=b'', ++ communicate=True): ++ """A common way to cleanup and fail with useful debug output. ++ ++ Kills the process if it is still running, collects remaining output ++ and fails the test with an error message including the output. ++ ++ Args: ++ why: Text to go after "Error from IO process" in the message. ++ stdout, stderr: standard output and error from the process so ++ far to include in the error message. ++ communicate: bool, when True we call communicate() on the process ++ after killing it to gather additional output. ++ """ ++ if self._process.poll() is None: ++ time.sleep(0.1) # give it time to finish printing the error. ++ try: ++ self._process.terminate() # Ensure it dies. ++ except OSError: ++ pass ++ if communicate: ++ stdout_end, stderr_end = self._process.communicate() ++ stdout += stdout_end ++ stderr += stderr_end ++ self.fail('Error from IO process %s:\nSTDOUT:\n%sSTDERR:\n%s\n' % ++ (why, stdout.decode(), stderr.decode())) ++ ++ def _test_reading(self, data_to_write, read_and_verify_code): ++ """Generic buffered read method test harness to validate EINTR behavior. ++ ++ Also validates that Python signal handlers are run during the read. ++ ++ Args: ++ data_to_write: String to write to the child process for reading ++ before sending it a signal, confirming the signal was handled, ++ writing a final newline and closing the infile pipe. ++ read_and_verify_code: Single "line" of code to read from a file ++ object named 'infile' and validate the result. This will be ++ executed as part of a python subprocess fed data_to_write. ++ """ ++ infile_setup_code = self._generate_infile_setup_code() ++ # Total pipe IO in this function is smaller than the minimum posix OS ++ # pipe buffer size of 512 bytes. No writer should block. ++ assert len(data_to_write) < 512, 'data_to_write must fit in pipe buf.' ++ ++ # Start a subprocess to call our read method while handling a signal. ++ self._process = subprocess.Popen( ++ [sys.executable, '-u', '-c', ++ 'import signal, sys ;' ++ 'signal.signal(signal.SIGINT, ' ++ 'lambda s, f: sys.stderr.write("$\\n")) ;' ++ + infile_setup_code + ' ;' + ++ 'sys.stderr.write("Worm Sign!\\n") ;' ++ + read_and_verify_code + ' ;' + ++ 'infile.close()' ++ ], ++ stdin=subprocess.PIPE, stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE) ++ ++ # Wait for the signal handler to be installed. ++ worm_sign = self._process.stderr.read(len(b'Worm Sign!\n')) ++ if worm_sign != b'Worm Sign!\n': # See also, Dune by Frank Herbert. ++ self.fail_with_process_info('while awaiting a sign', ++ stderr=worm_sign) ++ self._process.stdin.write(data_to_write) ++ ++ signals_sent = 0 ++ rlist = [] ++ # We don't know when the read_and_verify_code in our child is actually ++ # executing within the read system call we want to interrupt. This ++ # loop waits for a bit before sending the first signal to increase ++ # the likelihood of that. Implementations without correct EINTR ++ # and signal handling usually fail this test. ++ while not rlist: ++ rlist, _, _ = select.select([self._process.stderr], (), (), 0.05) ++ self._process.send_signal(signal.SIGINT) ++ signals_sent += 1 ++ if signals_sent > 200: ++ self._process.kill() ++ self.fail('reader process failed to handle our signals.') ++ # This assumes anything unexpected that writes to stderr will also ++ # write a newline. That is true of the traceback printing code. ++ signal_line = self._process.stderr.readline() ++ if signal_line != b'$\n': ++ self.fail_with_process_info('while awaiting signal', ++ stderr=signal_line) ++ ++ # We append a newline to our input so that a readline call can ++ # end on its own before the EOF is seen and so that we're testing ++ # the read call that was interrupted by a signal before the end of ++ # the data stream has been reached. ++ stdout, stderr = self._process.communicate(input=b'\n') ++ if self._process.returncode: ++ self.fail_with_process_info( ++ 'exited rc=%d' % self._process.returncode, ++ stdout, stderr, communicate=False) ++ # PASS! ++ ++ # String format for the read_and_verify_code used by read methods. ++ _READING_CODE_TEMPLATE = ( ++ 'got = infile.{read_method_name}() ;' ++ 'expected = {expected!r} ;' ++ 'assert got == expected, (' ++ '"{read_method_name} returned wrong data.\\n"' ++ '"got data %r\\nexpected %r" % (got, expected))' ++ ) ++ ++ def test_readline(self): ++ """readline() must handle signals and not lose data.""" ++ self._test_reading( ++ data_to_write=b'hello, world!', ++ read_and_verify_code=self._READING_CODE_TEMPLATE.format( ++ read_method_name='readline', ++ expected=b'hello, world!\n')) ++ ++ def test_readlines(self): ++ """readlines() must handle signals and not lose data.""" ++ self._test_reading( ++ data_to_write=b'hello\nworld!', ++ read_and_verify_code=self._READING_CODE_TEMPLATE.format( ++ read_method_name='readlines', ++ expected=[b'hello\n', b'world!\n'])) ++ ++ def test_readall(self): ++ """readall() must handle signals and not lose data.""" ++ self._test_reading( ++ data_to_write=b'hello\nworld!', ++ read_and_verify_code=self._READING_CODE_TEMPLATE.format( ++ read_method_name='readall', ++ expected=b'hello\nworld!\n')) ++ # read() is the same thing as readall(). ++ self._test_reading( ++ data_to_write=b'hello\nworld!', ++ read_and_verify_code=self._READING_CODE_TEMPLATE.format( ++ read_method_name='read', ++ expected=b'hello\nworld!\n')) ++ ++ ++class TestBufferedIOSignalInterrupt(TestFileIOSignalInterrupt): ++ def _generate_infile_setup_code(self): ++ """Returns the infile = ... line of code to make a BufferedReader.""" ++ return ('infile = open(sys.stdin.fileno(), "rb") ;' ++ 'import _io ;assert isinstance(infile, _io.BufferedReader)') ++ ++ def test_readall(self): ++ """BufferedReader.read() must handle signals and not lose data.""" ++ self._test_reading( ++ data_to_write=b'hello\nworld!', ++ read_and_verify_code=self._READING_CODE_TEMPLATE.format( ++ read_method_name='read', ++ expected=b'hello\nworld!\n')) ++ ++ ++class TestTextIOSignalInterrupt(TestFileIOSignalInterrupt): ++ def _generate_infile_setup_code(self): ++ """Returns the infile = ... line of code to make a TextIOWrapper.""" ++ return ('infile = open(sys.stdin.fileno(), "rt", newline=None) ;' ++ 'import _io ;assert isinstance(infile, _io.TextIOWrapper)') ++ ++ def test_readline(self): ++ """readline() must handle signals and not lose data.""" ++ self._test_reading( ++ data_to_write=b'hello, world!', ++ read_and_verify_code=self._READING_CODE_TEMPLATE.format( ++ read_method_name='readline', ++ expected='hello, world!\n')) ++ ++ def test_readlines(self): ++ """readlines() must handle signals and not lose data.""" ++ self._test_reading( ++ data_to_write=b'hello\r\nworld!', ++ read_and_verify_code=self._READING_CODE_TEMPLATE.format( ++ read_method_name='readlines', ++ expected=['hello\n', 'world!\n'])) ++ ++ def test_readall(self): ++ """read() must handle signals and not lose data.""" ++ self._test_reading( ++ data_to_write=b'hello\nworld!', ++ read_and_verify_code=self._READING_CODE_TEMPLATE.format( ++ read_method_name='read', ++ expected="hello\nworld!\n")) ++ ++ ++def test_main(): ++ test_cases = [ ++ tc for tc in globals().values() ++ if isinstance(tc, type) and issubclass(tc, unittest.TestCase)] ++ run_unittest(*test_cases) ++ ++ ++if __name__ == '__main__': ++ test_main() +diff -r 3d0686d90f55 Lib/test/test_fileio.py +--- a/Lib/test/test_fileio.py ++++ b/Lib/test/test_fileio.py +@@ -127,6 +127,14 @@ + else: + self.fail("Should have raised IOError") + ++ @unittest.skipIf(os.name == 'nt', "test only works on a POSIX-like system") ++ def testOpenDirFD(self): ++ fd = os.open('.', os.O_RDONLY) ++ with self.assertRaises(IOError) as cm: ++ _FileIO(fd, 'r') ++ os.close(fd) ++ self.assertEqual(cm.exception.errno, errno.EISDIR) ++ + #A set of functions testing that we get expected behaviour if someone has + #manually closed the internal file descriptor. First, a decorator: + def ClosedFD(func): +@@ -403,6 +411,17 @@ + self.assertRaises(ValueError, _FileIO, "/some/invalid/name", "rt") + self.assertEqual(w.warnings, []) + ++ def testUnclosedFDOnException(self): ++ class MyException(Exception): pass ++ class MyFileIO(_FileIO): ++ def __setattr__(self, name, value): ++ if name == "name": ++ raise MyException("blocked setting name") ++ return super(MyFileIO, self).__setattr__(name, value) ++ fd = os.open(__file__, os.O_RDONLY) ++ self.assertRaises(MyException, MyFileIO, fd) ++ os.close(fd) # should not raise OSError(EBADF) ++ + + def test_main(): + # Historically, these tests have been sloppy about removing TESTFN. +diff -r 3d0686d90f55 Lib/test/test_fractions.py +--- a/Lib/test/test_fractions.py ++++ b/Lib/test/test_fractions.py +@@ -6,6 +6,7 @@ + import numbers + import operator + import fractions ++import sys + import unittest + from copy import copy, deepcopy + from pickle import dumps, loads +@@ -76,6 +77,9 @@ + def __float__(self): + assert False, "__float__ should not be invoked" + ++class DummyFraction(fractions.Fraction): ++ """Dummy Fraction subclass for copy and deepcopy testing.""" ++ + class GcdTest(unittest.TestCase): + + def testMisc(self): +@@ -286,9 +290,14 @@ + self.assertEqual(F(201, 200).limit_denominator(100), F(1)) + self.assertEqual(F(201, 200).limit_denominator(101), F(102, 101)) + self.assertEqual(F(0).limit_denominator(10000), F(0)) ++ for i in (0, -1): ++ self.assertRaisesMessage( ++ ValueError, "max_denominator should be at least 1", ++ F(1).limit_denominator, i) + + def testConversions(self): + self.assertTypedEquals(-1, math.trunc(F(-11, 10))) ++ self.assertTypedEquals(1, math.trunc(F(11, 10))) + self.assertTypedEquals(-2, math.floor(F(-11, 10))) + self.assertTypedEquals(-1, math.ceil(F(-11, 10))) + self.assertTypedEquals(-1, math.ceil(F(-10, 10))) +@@ -329,6 +338,7 @@ + self.assertEqual(F(8, 27), F(2, 3) ** F(3)) + self.assertEqual(F(27, 8), F(2, 3) ** F(-3)) + self.assertTypedEquals(2.0, F(4) ** F(1, 2)) ++ self.assertEqual(F(1, 1), +F(1, 1)) + z = pow(F(-1), F(1, 2)) + self.assertAlmostEqual(z.real, 0) + self.assertEqual(z.imag, 1) +@@ -395,6 +405,10 @@ + TypeError, + "unsupported operand type(s) for +: 'Fraction' and 'Decimal'", + operator.add, F(3,11), Decimal('3.1415926')) ++ self.assertRaisesMessage( ++ TypeError, ++ "unsupported operand type(s) for +: 'Decimal' and 'Fraction'", ++ operator.add, Decimal('3.1415926'), F(3,11)) + + def testComparisons(self): + self.assertTrue(F(1, 2) < F(2, 3)) +@@ -538,9 +552,12 @@ + self.assertEqual("7", str(F(7, 1))) + + def testHash(self): ++ hmod = sys.hash_info.modulus ++ hinf = sys.hash_info.inf + self.assertEqual(hash(2.5), hash(F(5, 2))) + self.assertEqual(hash(10**50), hash(F(10**50))) + self.assertNotEqual(hash(float(10**23)), hash(F(10**23))) ++ self.assertEqual(hinf, hash(F(1, hmod))) + # Check that __hash__ produces the same value as hash(), for + # consistency with int and Decimal. (See issue #10356.) + self.assertEqual(hash(F(-1)), F(-1).__hash__()) +@@ -574,9 +591,14 @@ + + def test_copy_deepcopy_pickle(self): + r = F(13, 7) ++ dr = DummyFraction(13, 7) + self.assertEqual(r, loads(dumps(r))) + self.assertEqual(id(r), id(copy(r))) + self.assertEqual(id(r), id(deepcopy(r))) ++ self.assertNotEqual(id(dr), id(copy(dr))) ++ self.assertNotEqual(id(dr), id(deepcopy(dr))) ++ self.assertTypedEquals(dr, copy(dr)) ++ self.assertTypedEquals(dr, deepcopy(dr)) + + def test_slots(self): + # Issue 4998 +diff -r 3d0686d90f55 Lib/test/test_gdb.py +--- a/Lib/test/test_gdb.py ++++ b/Lib/test/test_gdb.py +@@ -32,6 +32,15 @@ + if gdbpy_version == b'': + raise unittest.SkipTest("gdb not built with embedded python support") + ++# Verify that "gdb" can load our custom hooks ++p = subprocess.Popen(["gdb", "--batch", cmd, ++ "--args", sys.executable], ++ stdout=subprocess.PIPE, stderr=subprocess.PIPE) ++__, gdbpy_errors = p.communicate() ++if b"auto-loading has been declined" in gdbpy_errors: ++ msg = "gdb security settings prevent use of custom hooks: %s" ++ raise unittest.SkipTest(msg % gdbpy_errors) ++ + def gdb_has_frame_select(): + # Does this build of gdb have gdb.Frame.select ? + cmd = "--eval-command=python print(dir(gdb.Frame))" +diff -r 3d0686d90f55 Lib/test/test_gzip.py +--- a/Lib/test/test_gzip.py ++++ b/Lib/test/test_gzip.py +@@ -331,6 +331,20 @@ + with gzip.GzipFile(fileobj=f, mode="w") as g: + pass + ++ def test_bytes_filename(self): ++ str_filename = self.filename ++ try: ++ bytes_filename = str_filename.encode("ascii") ++ except UnicodeEncodeError: ++ self.skipTest("Temporary file name needs to be ASCII") ++ with gzip.GzipFile(bytes_filename, "wb") as f: ++ f.write(data1 * 50) ++ with gzip.GzipFile(bytes_filename, "rb") as f: ++ self.assertEqual(f.read(), data1 * 50) ++ # Sanity check that we are actually operating on the right file. ++ with gzip.GzipFile(str_filename, "rb") as f: ++ self.assertEqual(f.read(), data1 * 50) ++ + # Testing compress/decompress shortcut functions + + def test_compress(self): +diff -r 3d0686d90f55 Lib/test/test_htmlparser.py +--- a/Lib/test/test_htmlparser.py ++++ b/Lib/test/test_htmlparser.py +@@ -409,6 +409,16 @@ + ('starttag', 'a', [('foo', None), ('=', None), ('bar', None)]) + ] + self._run_check(html, expected) ++ #see issue #14538 ++ html = ('' ++ '') ++ expected = [ ++ ('starttag', 'meta', []), ('starttag', 'meta', []), ++ ('starttag', 'meta', []), ('starttag', 'meta', []), ++ ('startendtag', 'meta', []), ('startendtag', 'meta', []), ++ ('startendtag', 'meta', []), ('startendtag', 'meta', []), ++ ] ++ self._run_check(html, expected) + + def test_declaration_junk_chars(self): + self._run_check("", [('decl', 'DOCTYPE foo $ ')]) +diff -r 3d0686d90f55 Lib/test/test_http_cookies.py +--- a/Lib/test/test_http_cookies.py ++++ b/Lib/test/test_http_cookies.py +@@ -86,13 +86,13 @@ + + # loading 'expires' + C = cookies.SimpleCookie() +- C.load('Customer="W"; expires=Wed, 01-Jan-2010 00:00:00 GMT') ++ C.load('Customer="W"; expires=Wed, 01 Jan 2010 00:00:00 GMT') + self.assertEqual(C['Customer']['expires'], +- 'Wed, 01-Jan-2010 00:00:00 GMT') ++ 'Wed, 01 Jan 2010 00:00:00 GMT') + C = cookies.SimpleCookie() +- C.load('Customer="W"; expires=Wed, 01-Jan-98 00:00:00 GMT') ++ C.load('Customer="W"; expires=Wed, 01 Jan 98 00:00:00 GMT') + self.assertEqual(C['Customer']['expires'], +- 'Wed, 01-Jan-98 00:00:00 GMT') ++ 'Wed, 01 Jan 98 00:00:00 GMT') + + # 'max-age' + C = cookies.SimpleCookie('Customer="WILE_E_COYOTE"') +diff -r 3d0686d90f55 Lib/test/test_httplib.py +--- a/Lib/test/test_httplib.py ++++ b/Lib/test/test_httplib.py +@@ -99,6 +99,34 @@ + conn.request('POST', '/', body, headers) + self.assertEqual(conn._buffer.count[header.lower()], 1) + ++ def test_content_length_0(self): ++ ++ class ContentLengthChecker(list): ++ def __init__(self): ++ list.__init__(self) ++ self.content_length = None ++ def append(self, item): ++ kv = item.split(b':', 1) ++ if len(kv) > 1 and kv[0].lower() == b'content-length': ++ self.content_length = kv[1].strip() ++ list.append(self, item) ++ ++ # POST with empty body ++ conn = client.HTTPConnection('example.com') ++ conn.sock = FakeSocket(None) ++ conn._buffer = ContentLengthChecker() ++ conn.request('POST', '/', '') ++ self.assertEqual(conn._buffer.content_length, b'0', ++ 'Header Content-Length not set') ++ ++ # PUT request with empty body ++ conn = client.HTTPConnection('example.com') ++ conn.sock = FakeSocket(None) ++ conn._buffer = ContentLengthChecker() ++ conn.request('PUT', '/', '') ++ self.assertEqual(conn._buffer.content_length, b'0', ++ 'Header Content-Length not set') ++ + def test_putheader(self): + conn = client.HTTPConnection('example.com') + conn.sock = FakeSocket(None) +@@ -369,6 +397,15 @@ + resp.begin() + self.assertRaises(client.LineTooLong, resp.read) + ++ def test_early_eof(self): ++ # Test httpresponse with no \r\n termination, ++ body = "HTTP/1.1 200 Ok" ++ sock = FakeSocket(body) ++ resp = client.HTTPResponse(sock) ++ resp.begin() ++ self.assertEqual(resp.read(), b'') ++ self.assertTrue(resp.isclosed()) ++ + class OfflineTest(TestCase): + def test_responses(self): + self.assertEqual(client.responses[client.NOT_FOUND], "Not Found") +diff -r 3d0686d90f55 Lib/test/test_httpservers.py +--- a/Lib/test/test_httpservers.py ++++ b/Lib/test/test_httpservers.py +@@ -366,41 +366,44 @@ + finally: + BaseTestCase.tearDown(self) + +- def test_url_collapse_path_split(self): ++ def test_url_collapse_path(self): ++ # verify tail is the last portion and head is the rest on proper urls + test_vectors = { +- '': ('/', ''), ++ '': '//', + '..': IndexError, + '/.//..': IndexError, +- '/': ('/', ''), +- '//': ('/', ''), +- '/\\': ('/', '\\'), +- '/.//': ('/', ''), +- 'cgi-bin/file1.py': ('/cgi-bin', 'file1.py'), +- '/cgi-bin/file1.py': ('/cgi-bin', 'file1.py'), +- 'a': ('/', 'a'), +- '/a': ('/', 'a'), +- '//a': ('/', 'a'), +- './a': ('/', 'a'), +- './C:/': ('/C:', ''), +- '/a/b': ('/a', 'b'), +- '/a/b/': ('/a/b', ''), +- '/a/b/c/..': ('/a/b', ''), +- '/a/b/c/../d': ('/a/b', 'd'), +- '/a/b/c/../d/e/../f': ('/a/b/d', 'f'), +- '/a/b/c/../d/e/../../f': ('/a/b', 'f'), +- '/a/b/c/../d/e/.././././..//f': ('/a/b', 'f'), ++ '/': '//', ++ '//': '//', ++ '/\\': '//\\', ++ '/.//': '//', ++ 'cgi-bin/file1.py': '/cgi-bin/file1.py', ++ '/cgi-bin/file1.py': '/cgi-bin/file1.py', ++ 'a': '//a', ++ '/a': '//a', ++ '//a': '//a', ++ './a': '//a', ++ './C:/': '/C:/', ++ '/a/b': '/a/b', ++ '/a/b/': '/a/b/', ++ '/a/b/.': '/a/b/', ++ '/a/b/c/..': '/a/b/', ++ '/a/b/c/../d': '/a/b/d', ++ '/a/b/c/../d/e/../f': '/a/b/d/f', ++ '/a/b/c/../d/e/../../f': '/a/b/f', ++ '/a/b/c/../d/e/.././././..//f': '/a/b/f', + '../a/b/c/../d/e/.././././..//f': IndexError, +- '/a/b/c/../d/e/../../../f': ('/a', 'f'), +- '/a/b/c/../d/e/../../../../f': ('/', 'f'), ++ '/a/b/c/../d/e/../../../f': '/a/f', ++ '/a/b/c/../d/e/../../../../f': '//f', + '/a/b/c/../d/e/../../../../../f': IndexError, +- '/a/b/c/../d/e/../../../../f/..': ('/', ''), ++ '/a/b/c/../d/e/../../../../f/..': '//', ++ '/a/b/c/../d/e/../../../../f/../.': '//', + } + for path, expected in test_vectors.items(): + if isinstance(expected, type) and issubclass(expected, Exception): + self.assertRaises(expected, +- server._url_collapse_path_split, path) ++ server._url_collapse_path, path) + else: +- actual = server._url_collapse_path_split(path) ++ actual = server._url_collapse_path(path) + self.assertEqual(expected, actual, + msg='path = %r\nGot: %r\nWanted: %r' % + (path, actual, expected)) +diff -r 3d0686d90f55 Lib/test/test_imaplib.py +--- a/Lib/test/test_imaplib.py ++++ b/Lib/test/test_imaplib.py +@@ -11,7 +11,7 @@ + import time + import calendar + +-from test.support import reap_threads, verbose, transient_internet ++from test.support import reap_threads, verbose, transient_internet, run_with_tz + import unittest + + try: +@@ -36,6 +36,13 @@ + b'25 (INTERNALDATE "31-Dec-1999 12:30:00 -1130")') + self.assertEqual(time.mktime(tt), t0) + ++ @run_with_tz('MST+07MDT,M4.1.0,M10.5.0') ++ def test_Internaldate2tuple_issue10941(self): ++ self.assertNotEqual(imaplib.Internaldate2tuple( ++ b'25 (INTERNALDATE "02-Apr-2000 02:30:00 +0000")'), ++ imaplib.Internaldate2tuple( ++ b'25 (INTERNALDATE "02-Apr-2000 03:30:00 +0000")')) ++ + def test_that_Time2Internaldate_returns_a_result(self): + # We can check only that it successfully produces a result, + # not the correctness of the result itself, since the result +@@ -226,8 +233,8 @@ + with transient_internet(self.host): + for cap in self.server.capabilities: + self.assertIsInstance(cap, str) +- self.assertTrue('LOGINDISABLED' in self.server.capabilities) +- self.assertTrue('AUTH=ANONYMOUS' in self.server.capabilities) ++ self.assertIn('LOGINDISABLED', self.server.capabilities) ++ self.assertIn('AUTH=ANONYMOUS', self.server.capabilities) + rs = self.server.login(self.username, self.password) + self.assertEqual(rs[0], 'OK') + +@@ -250,7 +257,7 @@ + def test_logincapa(self): + for cap in self.server.capabilities: + self.assertIsInstance(cap, str) +- self.assertFalse('LOGINDISABLED' in self.server.capabilities) ++ self.assertNotIn('LOGINDISABLED', self.server.capabilities) + + + @unittest.skipUnless(ssl, "SSL not available") +@@ -261,8 +268,8 @@ + def test_logincapa(self): + for cap in self.server.capabilities: + self.assertIsInstance(cap, str) +- self.assertFalse('LOGINDISABLED' in self.server.capabilities) +- self.assertTrue('AUTH=PLAIN' in self.server.capabilities) ++ self.assertNotIn('LOGINDISABLED', self.server.capabilities) ++ self.assertIn('AUTH=PLAIN', self.server.capabilities) + + + def test_main(): +diff -r 3d0686d90f55 Lib/test/test_io.py +--- a/Lib/test/test_io.py ++++ b/Lib/test/test_io.py +@@ -634,6 +634,19 @@ + for obj in test: + self.assertTrue(hasattr(obj, "__dict__")) + ++ def test_fileio_closefd(self): ++ # Issue #4841 ++ with self.open(__file__, 'rb') as f1, \ ++ self.open(__file__, 'rb') as f2: ++ fileio = self.FileIO(f1.fileno(), closefd=False) ++ # .__init__() must not close f1 ++ fileio.__init__(f2.fileno(), closefd=False) ++ f1.readline() ++ # .close() must not close f2 ++ fileio.close() ++ f2.readline() ++ ++ + class CIOTest(IOTest): + + def test_IOBase_finalize(self): +diff -r 3d0686d90f55 Lib/test/test_keywordonlyarg.py +--- a/Lib/test/test_keywordonlyarg.py ++++ b/Lib/test/test_keywordonlyarg.py +@@ -170,6 +170,12 @@ + # used to fail with a SystemError. + lambda *, k1=unittest: None + ++ def test_mangling(self): ++ class X: ++ def f(self, *, __a=42): ++ return __a ++ self.assertEqual(X().f(), 42) ++ + def test_main(): + run_unittest(KeywordOnlyArgTestCase) + +diff -r 3d0686d90f55 Lib/test/test_logging.py +--- a/Lib/test/test_logging.py ++++ b/Lib/test/test_logging.py +@@ -1,6 +1,6 @@ + #!/usr/bin/env python + # +-# Copyright 2001-2011 by Vinay Sajip. All Rights Reserved. ++# Copyright 2001-2012 by Vinay Sajip. All Rights Reserved. + # + # Permission to use, copy, modify, and distribute this software and its + # documentation for any purpose and without fee is hereby granted, +@@ -18,7 +18,7 @@ + + """Test harness for the logging module. Run all tests. + +-Copyright (C) 2001-2011 Vinay Sajip. All Rights Reserved. ++Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved. + """ + + import logging +@@ -33,6 +33,7 @@ + import json + import os + import queue ++import random + import re + import select + import socket +@@ -43,6 +44,7 @@ + from test.support import captured_stdout, run_with_locale, run_unittest + from test.support import TestHandler, Matcher + import textwrap ++import time + import unittest + import warnings + import weakref +@@ -2301,7 +2303,6 @@ + # Failures occur on some systems for MIDNIGHT and W0. + # Print detailed calculation for MIDNIGHT so we can try to see + # what's going on +- import time + if when == 'MIDNIGHT': + try: + if rh.utc: +@@ -2328,6 +2329,44 @@ + rh.close() + setattr(TimedRotatingFileHandlerTest, "test_compute_rollover_%s" % when, test_compute_rollover) + ++class HandlerTest(BaseTest): ++ ++ @unittest.skipIf(os.name == 'nt', 'WatchedFileHandler not appropriate for Windows.') ++ @unittest.skipUnless(threading, 'Threading required for this test.') ++ def test_race(self): ++ # Issue #14632 refers. ++ def remove_loop(fname, tries): ++ for _ in range(tries): ++ try: ++ os.unlink(fname) ++ except OSError: ++ pass ++ time.sleep(0.004 * random.randint(0, 4)) ++ ++ del_count = 500 ++ log_count = 500 ++ ++ for delay in (False, True): ++ fd, fn = tempfile.mkstemp('.log', 'test_logging-3-') ++ os.close(fd) ++ remover = threading.Thread(target=remove_loop, args=(fn, del_count)) ++ remover.daemon = True ++ remover.start() ++ h = logging.handlers.WatchedFileHandler(fn, delay=delay) ++ f = logging.Formatter('%(asctime)s: %(levelname)s: %(message)s') ++ h.setFormatter(f) ++ try: ++ for _ in range(log_count): ++ time.sleep(0.005) ++ r = logging.makeLogRecord({'msg': 'testing' }) ++ h.handle(r) ++ finally: ++ remover.join() ++ h.close() ++ if os.path.exists(fn): ++ os.unlink(fn) ++ ++ + # Set the locale to the platform-dependent default. I have no idea + # why the test does this, but in any case we save the current locale + # first and restore it at the end. +@@ -2341,7 +2380,7 @@ + LogRecordFactoryTest, ChildLoggerTest, QueueHandlerTest, + RotatingFileHandlerTest, + LastResortTest, +- TimedRotatingFileHandlerTest ++ TimedRotatingFileHandlerTest, HandlerTest, + ) + + if __name__ == "__main__": +diff -r 3d0686d90f55 Lib/test/test_long.py +--- a/Lib/test/test_long.py ++++ b/Lib/test/test_long.py +@@ -1148,6 +1148,20 @@ + self.assertRaises(TypeError, myint.from_bytes, 0, 'big') + self.assertRaises(TypeError, int.from_bytes, 0, 'big', True) + ++ def test_access_to_nonexistent_digit_0(self): ++ # http://bugs.python.org/issue14630: A bug in _PyLong_Copy meant that ++ # ob_digit[0] was being incorrectly accessed for instances of a ++ # subclass of int, with value 0. ++ class Integer(int): ++ def __new__(cls, value=0): ++ self = int.__new__(cls, value) ++ self.foo = 'foo' ++ return self ++ ++ integers = [Integer(0) for i in range(1000)] ++ for n in map(int, integers): ++ self.assertEqual(n, 0) ++ + + def test_main(): + support.run_unittest(LongTest) +diff -r 3d0686d90f55 Lib/test/test_mailbox.py +--- a/Lib/test/test_mailbox.py ++++ b/Lib/test/test_mailbox.py +@@ -7,6 +7,7 @@ + import email.message + import re + import io ++import shutil + import tempfile + from test import support + import unittest +@@ -19,7 +20,7 @@ + pass + + +-class TestBase(unittest.TestCase): ++class TestBase: + + def _check_sample(self, msg): + # Inspect a mailbox.Message representation of the sample message +@@ -38,12 +39,7 @@ + def _delete_recursively(self, target): + # Delete a file or delete a directory recursively + if os.path.isdir(target): +- for path, dirs, files in os.walk(target, topdown=False): +- for name in files: +- os.remove(os.path.join(path, name)) +- for name in dirs: +- os.rmdir(os.path.join(path, name)) +- os.rmdir(target) ++ shutil.rmtree(target) + elif os.path.exists(target): + os.remove(target) + +@@ -115,10 +111,10 @@ + self.assertMailboxEmpty() + + def test_add_that_raises_leaves_mailbox_empty(self): +- # XXX This test will start failing when Message learns to handle +- # non-ASCII string headers, and a different internal failure will +- # need to be found or manufactured. +- with self.assertRaises(ValueError): ++ def raiser(*args, **kw): ++ raise Exception("a fake error") ++ support.patch(self, email.generator.BytesGenerator, 'flatten', raiser) ++ with self.assertRaises(Exception): + self._box.add(email.message_from_string("From: Alphöso")) + self.assertEqual(len(self._box), 0) + self._box.close() +@@ -504,6 +500,17 @@ + # Write changes to disk + self._test_flush_or_close(self._box.flush, True) + ++ def test_popitem_and_flush_twice(self): ++ # See #15036. ++ self._box.add(self._template % 0) ++ self._box.add(self._template % 1) ++ self._box.flush() ++ ++ self._box.popitem() ++ self._box.flush() ++ self._box.popitem() ++ self._box.flush() ++ + def test_lock_unlock(self): + # Lock and unlock the mailbox + self.assertFalse(os.path.exists(self._get_lock_path())) +@@ -549,7 +556,7 @@ + return self._path + '.lock' + + +-class TestMailboxSuperclass(TestBase): ++class TestMailboxSuperclass(TestBase, unittest.TestCase): + + def test_notimplemented(self): + # Test that all Mailbox methods raise NotImplementedException. +@@ -585,7 +592,7 @@ + self.assertRaises(NotImplementedError, lambda: box.close()) + + +-class TestMaildir(TestMailbox): ++class TestMaildir(TestMailbox, unittest.TestCase): + + _factory = lambda self, path, factory=None: mailbox.Maildir(path, factory) + +@@ -935,7 +942,49 @@ + self._box._refresh() + self.assertTrue(refreshed()) + +-class _TestMboxMMDF(TestMailbox): ++ ++class _TestSingleFile(TestMailbox): ++ '''Common tests for single-file mailboxes''' ++ ++ def test_add_doesnt_rewrite(self): ++ # When only adding messages, flush() should not rewrite the ++ # mailbox file. See issue #9559. ++ ++ # Inode number changes if the contents are written to another ++ # file which is then renamed over the original file. So we ++ # must check that the inode number doesn't change. ++ inode_before = os.stat(self._path).st_ino ++ ++ self._box.add(self._template % 0) ++ self._box.flush() ++ ++ inode_after = os.stat(self._path).st_ino ++ self.assertEqual(inode_before, inode_after) ++ ++ # Make sure the message was really added ++ self._box.close() ++ self._box = self._factory(self._path) ++ self.assertEqual(len(self._box), 1) ++ ++ def test_permissions_after_flush(self): ++ # See issue #5346 ++ ++ # Make the mailbox world writable. It's unlikely that the new ++ # mailbox file would have these permissions after flush(), ++ # because umask usually prevents it. ++ mode = os.stat(self._path).st_mode | 0o666 ++ os.chmod(self._path, mode) ++ ++ self._box.add(self._template % 0) ++ i = self._box.add(self._template % 1) ++ # Need to remove one message to make flush() create a new file ++ self._box.remove(i) ++ self._box.flush() ++ ++ self.assertEqual(os.stat(self._path).st_mode, mode) ++ ++ ++class _TestMboxMMDF(_TestSingleFile): + + def tearDown(self): + super().tearDown() +@@ -1047,7 +1096,7 @@ + self._box.close() + + +-class TestMbox(_TestMboxMMDF): ++class TestMbox(_TestMboxMMDF, unittest.TestCase): + + _factory = lambda self, path, factory=None: mailbox.mbox(path, factory) + +@@ -1070,12 +1119,12 @@ + perms = st.st_mode + self.assertFalse((perms & 0o111)) # Execute bits should all be off. + +-class TestMMDF(_TestMboxMMDF): ++class TestMMDF(_TestMboxMMDF, unittest.TestCase): + + _factory = lambda self, path, factory=None: mailbox.MMDF(path, factory) + + +-class TestMH(TestMailbox): ++class TestMH(TestMailbox, unittest.TestCase): + + _factory = lambda self, path, factory=None: mailbox.MH(path, factory) + +@@ -1210,7 +1259,7 @@ + return os.path.join(self._path, '.mh_sequences.lock') + + +-class TestBabyl(TestMailbox): ++class TestBabyl(_TestSingleFile, unittest.TestCase): + + _factory = lambda self, path, factory=None: mailbox.Babyl(path, factory) + +@@ -1275,7 +1324,7 @@ + self.assertTrue(box.files[i].closed) + + +-class TestMessage(TestBase): ++class TestMessage(TestBase, unittest.TestCase): + + _factory = mailbox.Message # Overridden by subclasses to reuse tests + +@@ -1355,7 +1404,7 @@ + pass + + +-class TestMaildirMessage(TestMessage): ++class TestMaildirMessage(TestMessage, unittest.TestCase): + + _factory = mailbox.MaildirMessage + +@@ -1429,7 +1478,7 @@ + self._check_sample(msg) + + +-class _TestMboxMMDFMessage(TestMessage): ++class _TestMboxMMDFMessage: + + _factory = mailbox._mboxMMDFMessage + +@@ -1476,12 +1525,12 @@ + r"\d{2} \d{4}", msg.get_from()) is not None) + + +-class TestMboxMessage(_TestMboxMMDFMessage): ++class TestMboxMessage(_TestMboxMMDFMessage, TestMessage): + + _factory = mailbox.mboxMessage + + +-class TestMHMessage(TestMessage): ++class TestMHMessage(TestMessage, unittest.TestCase): + + _factory = mailbox.MHMessage + +@@ -1512,7 +1561,7 @@ + self.assertEqual(msg.get_sequences(), ['foobar', 'replied']) + + +-class TestBabylMessage(TestMessage): ++class TestBabylMessage(TestMessage, unittest.TestCase): + + _factory = mailbox.BabylMessage + +@@ -1567,12 +1616,12 @@ + self.assertEqual(visible[header], msg[header]) + + +-class TestMMDFMessage(_TestMboxMMDFMessage): ++class TestMMDFMessage(_TestMboxMMDFMessage, TestMessage): + + _factory = mailbox.MMDFMessage + + +-class TestMessageConversion(TestBase): ++class TestMessageConversion(TestBase, unittest.TestCase): + + def test_plain_to_x(self): + # Convert Message to all formats +@@ -1913,7 +1962,7 @@ + self.assertTrue(proxy.closed) + + +-class TestProxyFile(TestProxyFileBase): ++class TestProxyFile(TestProxyFileBase, unittest.TestCase): + + def setUp(self): + self._path = support.TESTFN +@@ -1962,7 +2011,7 @@ + self._test_close(mailbox._ProxyFile(self._file)) + + +-class TestPartialFile(TestProxyFileBase): ++class TestPartialFile(TestProxyFileBase, unittest.TestCase): + + def setUp(self): + self._path = support.TESTFN +@@ -2029,6 +2078,10 @@ + def setUp(self): + # create a new maildir mailbox to work with: + self._dir = support.TESTFN ++ if os.path.isdir(self._dir): ++ shutil.rmtree(self._dir) ++ elif os.path.isfile(self._dir): ++ os.unlink(self._dir) + os.mkdir(self._dir) + os.mkdir(os.path.join(self._dir, "cur")) + os.mkdir(os.path.join(self._dir, "tmp")) +diff -r 3d0686d90f55 Lib/test/test_marshal.py +--- a/Lib/test/test_marshal.py ++++ b/Lib/test/test_marshal.py +@@ -1,6 +1,7 @@ + #!/usr/bin/env python3 + + from test import support ++import array + import marshal + import sys + import unittest +@@ -137,6 +138,27 @@ + for constructor in (set, frozenset): + self.helper(constructor(self.d.keys())) + ++ ++class BufferTestCase(unittest.TestCase, HelperMixin): ++ ++ def test_bytearray(self): ++ b = bytearray(b"abc") ++ self.helper(b) ++ new = marshal.loads(marshal.dumps(b)) ++ self.assertEqual(type(new), bytes) ++ ++ def test_memoryview(self): ++ b = memoryview(b"abc") ++ self.helper(b) ++ new = marshal.loads(marshal.dumps(b)) ++ self.assertEqual(type(new), bytes) ++ ++ def test_array(self): ++ a = array.array('B', b"abc") ++ new = marshal.loads(marshal.dumps(a)) ++ self.assertEqual(new, b"abc") ++ ++ + class BugsTestCase(unittest.TestCase): + def test_bug_5888452(self): + # Simple-minded check for SF 588452: Debug build crashes +@@ -162,7 +184,7 @@ + pass + + def test_loads_recursion(self): +- s = 'c' + ('X' * 4*4) + '{' * 2**20 ++ s = b'c' + (b'X' * 4*4) + b'{' * 2**20 + self.assertRaises(ValueError, marshal.loads, s) + + def test_recursion_limit(self): +@@ -235,6 +257,11 @@ + finally: + support.unlink(support.TESTFN) + ++ def test_loads_reject_unicode_strings(self): ++ # Issue #14177: marshal.loads() should not accept unicode strings ++ unicode_string = 'T' ++ self.assertRaises(TypeError, marshal.loads, unicode_string) ++ + + def test_main(): + support.run_unittest(IntTestCase, +@@ -243,6 +270,7 @@ + CodeTestCase, + ContainerTestCase, + ExceptionTestCase, ++ BufferTestCase, + BugsTestCase) + + if __name__ == "__main__": +diff -r 3d0686d90f55 Lib/test/test_minidom.py +--- a/Lib/test/test_minidom.py ++++ b/Lib/test/test_minidom.py +@@ -350,13 +350,31 @@ + def testGetAttrList(self): + pass + +- def testGetAttrValues(self): pass ++ def testGetAttrValues(self): ++ pass + +- def testGetAttrLength(self): pass ++ def testGetAttrLength(self): ++ pass + +- def testGetAttribute(self): pass ++ def testGetAttribute(self): ++ dom = Document() ++ child = dom.appendChild( ++ dom.createElementNS("http://www.python.org", "python:abc")) ++ self.assertEqual(child.getAttribute('missing'), '') + +- def testGetAttributeNS(self): pass ++ def testGetAttributeNS(self): ++ dom = Document() ++ child = dom.appendChild( ++ dom.createElementNS("http://www.python.org", "python:abc")) ++ child.setAttributeNS("http://www.w3.org", "xmlns:python", ++ "http://www.python.org") ++ self.assertEqual(child.getAttributeNS("http://www.w3.org", "python"), ++ 'http://www.python.org') ++ self.assertEqual(child.getAttributeNS("http://www.w3.org", "other"), ++ '') ++ child2 = child.appendChild(dom.createElement('abc')) ++ self.assertEqual(child2.getAttributeNS("http://www.python.org", "missing"), ++ '') + + def testGetAttributeNode(self): pass + +diff -r 3d0686d90f55 Lib/test/test_multiprocessing.py +--- a/Lib/test/test_multiprocessing.py ++++ b/Lib/test/test_multiprocessing.py +@@ -390,6 +390,36 @@ + 1/0 # MARKER + + ++ @classmethod ++ def _test_sys_exit(cls, reason, testfn): ++ sys.stderr = open(testfn, 'w') ++ sys.exit(reason) ++ ++ def test_sys_exit(self): ++ # See Issue 13854 ++ if self.TYPE == 'threads': ++ return ++ ++ testfn = test.support.TESTFN ++ self.addCleanup(test.support.unlink, testfn) ++ ++ for reason, code in (([1, 2, 3], 1), ('ignore this', 0)): ++ p = self.Process(target=self._test_sys_exit, args=(reason, testfn)) ++ p.daemon = True ++ p.start() ++ p.join(5) ++ self.assertEqual(p.exitcode, code) ++ ++ with open(testfn, 'r') as f: ++ self.assertEqual(f.read().rstrip(), str(reason)) ++ ++ for reason in (True, False, 8): ++ p = self.Process(target=sys.exit, args=(reason,)) ++ p.daemon = True ++ p.start() ++ p.join(5) ++ self.assertEqual(p.exitcode, reason) ++ + # + # + # +@@ -1178,6 +1208,18 @@ + join() + self.assertLess(join.elapsed, 0.5) + ++ def test_empty_iterable(self): ++ # See Issue 12157 ++ p = self.Pool(1) ++ ++ self.assertEqual(p.map(sqr, []), []) ++ self.assertEqual(list(p.imap(sqr, [])), []) ++ self.assertEqual(list(p.imap_unordered(sqr, [])), []) ++ self.assertEqual(p.map_async(sqr, []).get(), []) ++ ++ p.close() ++ p.join() ++ + def raising(): + raise KeyError("key") + +@@ -1732,6 +1774,23 @@ + self.assertEqual(conn.recv(), 'hello') + p.join() + l.close() ++ ++ def test_issue14725(self): ++ l = self.connection.Listener() ++ p = self.Process(target=self._test, args=(l.address,)) ++ p.daemon = True ++ p.start() ++ time.sleep(1) ++ # On Windows the client process should by now have connected, ++ # written data and closed the pipe handle by now. This causes ++ # ConnectNamdedPipe() to fail with ERROR_NO_DATA. See Issue ++ # 14725. ++ conn = l.accept() ++ self.assertEqual(conn.recv(), 'hello') ++ conn.close() ++ p.join() ++ l.close() ++ + # + # Test of sending connection and socket objects between processes + # +@@ -2159,7 +2218,7 @@ + 'Queue', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', + 'Condition', 'Event', 'Value', 'Array', 'RawValue', + 'RawArray', 'current_process', 'active_children', 'Pipe', +- 'connection', 'JoinableQueue' ++ 'connection', 'JoinableQueue', 'Pool' + ))) + + testcases_processes = create_test_cases(ProcessesMixin, type='processes') +@@ -2173,7 +2232,7 @@ + locals().update(get_attributes(manager, ( + 'Queue', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', + 'Condition', 'Event', 'Value', 'Array', 'list', 'dict', +- 'Namespace', 'JoinableQueue' ++ 'Namespace', 'JoinableQueue', 'Pool' + ))) + + testcases_manager = create_test_cases(ManagerMixin, type='manager') +@@ -2187,7 +2246,7 @@ + 'Queue', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', + 'Condition', 'Event', 'Value', 'Array', 'current_process', + 'active_children', 'Pipe', 'connection', 'dict', 'list', +- 'Namespace', 'JoinableQueue' ++ 'Namespace', 'JoinableQueue', 'Pool' + ))) + + testcases_threads = create_test_cases(ThreadsMixin, type='threads') +@@ -2319,8 +2378,26 @@ + flike.flush() + assert sio.getvalue() == 'foo' + ++ ++# ++# Issue 14151: Test invalid family on invalid environment ++# ++ ++class TestInvalidFamily(unittest.TestCase): ++ ++ @unittest.skipIf(WIN32, "skipped on Windows") ++ def test_invalid_family(self): ++ with self.assertRaises(ValueError): ++ multiprocessing.connection.Listener(r'\\.\test') ++ ++ @unittest.skipUnless(WIN32, "skipped on non-Windows platforms") ++ def test_invalid_family_win32(self): ++ with self.assertRaises(ValueError): ++ multiprocessing.connection.Listener('/var/test.pipe') ++ ++ + testcases_other = [OtherTest, TestInvalidHandle, TestInitializers, +- TestStdinBadfiledescriptor] ++ TestStdinBadfiledescriptor, TestInvalidFamily] + + # + # +diff -r 3d0686d90f55 Lib/test/test_nntplib.py +--- a/Lib/test/test_nntplib.py ++++ b/Lib/test/test_nntplib.py +@@ -176,7 +176,13 @@ + resp, article = self.server.article(art_num) + self.assertTrue(resp.startswith("220 "), resp) + self.check_article_resp(resp, article, art_num) +- self.assertEqual(article.lines, head.lines + [b''] + body.lines) ++ # Tolerate running the tests from behind a NNTP virus checker ++ blacklist = lambda line: line.startswith(b'X-Antivirus') ++ filtered_head_lines = [line for line in head.lines ++ if not blacklist(line)] ++ filtered_lines = [line for line in article.lines ++ if not blacklist(line)] ++ self.assertEqual(filtered_lines, filtered_head_lines + [b''] + body.lines) + + def test_capabilities(self): + # The server under test implements NNTP version 2 and has a +diff -r 3d0686d90f55 Lib/test/test_os.py +--- a/Lib/test/test_os.py ++++ b/Lib/test/test_os.py +@@ -15,6 +15,7 @@ + import contextlib + import mmap + import uuid ++import stat + from test.script_helper import assert_python_ok + + # Detect whether we're on a Linux system that uses the (now outdated +@@ -574,12 +575,39 @@ + path = os.path.join(support.TESTFN, 'dir1') + mode = 0o777 + old_mask = os.umask(0o022) +- os.makedirs(path, mode) +- self.assertRaises(OSError, os.makedirs, path, mode) +- self.assertRaises(OSError, os.makedirs, path, mode, exist_ok=False) +- self.assertRaises(OSError, os.makedirs, path, 0o776, exist_ok=True) +- os.makedirs(path, mode=mode, exist_ok=True) +- os.umask(old_mask) ++ try: ++ os.makedirs(path, mode) ++ self.assertRaises(OSError, os.makedirs, path, mode) ++ self.assertRaises(OSError, os.makedirs, path, mode, exist_ok=False) ++ self.assertRaises(OSError, os.makedirs, path, 0o776, exist_ok=True) ++ os.makedirs(path, mode=mode, exist_ok=True) ++ finally: ++ os.umask(old_mask) ++ ++ def test_exist_ok_s_isgid_directory(self): ++ path = os.path.join(support.TESTFN, 'dir1') ++ S_ISGID = stat.S_ISGID ++ mode = 0o777 ++ old_mask = os.umask(0o022) ++ try: ++ existing_testfn_mode = stat.S_IMODE( ++ os.lstat(support.TESTFN).st_mode) ++ os.chmod(support.TESTFN, existing_testfn_mode | S_ISGID) ++ if (os.lstat(support.TESTFN).st_mode & S_ISGID != S_ISGID): ++ raise unittest.SkipTest('No support for S_ISGID dir mode.') ++ # The os should apply S_ISGID from the parent dir for us, but ++ # this test need not depend on that behavior. Be explicit. ++ os.makedirs(path, mode | S_ISGID) ++ # http://bugs.python.org/issue14992 ++ # Should not fail when the bit is already set. ++ os.makedirs(path, mode, exist_ok=True) ++ # remove the bit. ++ os.chmod(path, stat.S_IMODE(os.lstat(path).st_mode) & ~S_ISGID) ++ with self.assertRaises(OSError): ++ # Should fail when the bit is not already set when demanded. ++ os.makedirs(path, mode | S_ISGID, exist_ok=True) ++ finally: ++ os.umask(old_mask) + + def test_exist_ok_existing_regular_file(self): + base = support.TESTFN +diff -r 3d0686d90f55 Lib/test/test_parser.py +--- a/Lib/test/test_parser.py ++++ b/Lib/test/test_parser.py +@@ -57,6 +57,16 @@ + " if (yield):\n" + " yield x\n") + ++ def test_nonlocal_statement(self): ++ self.check_suite("def f():\n" ++ " x = 0\n" ++ " def g():\n" ++ " nonlocal x\n") ++ self.check_suite("def f():\n" ++ " x = y = 0\n" ++ " def g():\n" ++ " nonlocal x, y\n") ++ + def test_expressions(self): + self.check_expr("foo(1)") + self.check_expr("[1, 2, 3]") +@@ -96,6 +106,8 @@ + self.check_expr("lambda x, *y, **z: 0") + self.check_expr("(x for x in range(10))") + self.check_expr("foo(x for x in range(10))") ++ self.check_expr("...") ++ self.check_expr("a[...]") + + def test_simple_expression(self): + # expr_stmt +@@ -146,6 +158,27 @@ + self.check_suite("@funcattrs()\n" + "def f(): pass") + ++ # keyword-only arguments ++ self.check_suite("def f(*, a): pass") ++ self.check_suite("def f(*, a = 5): pass") ++ self.check_suite("def f(*, a = 5, b): pass") ++ self.check_suite("def f(*, a, b = 5): pass") ++ self.check_suite("def f(*, a, b = 5, **kwds): pass") ++ self.check_suite("def f(*args, a): pass") ++ self.check_suite("def f(*args, a = 5): pass") ++ self.check_suite("def f(*args, a = 5, b): pass") ++ self.check_suite("def f(*args, a, b = 5): pass") ++ self.check_suite("def f(*args, a, b = 5, **kwds): pass") ++ ++ # function annotations ++ self.check_suite("def f(a: int): pass") ++ self.check_suite("def f(a: int = 5): pass") ++ self.check_suite("def f(*args: list): pass") ++ self.check_suite("def f(**kwds: dict): pass") ++ self.check_suite("def f(*, a: int): pass") ++ self.check_suite("def f(*, a: int = 5): pass") ++ self.check_suite("def f() -> int: pass") ++ + def test_class_defs(self): + self.check_suite("class foo():pass") + self.check_suite("class foo(object):pass") +@@ -266,6 +299,37 @@ + self.check_suite("[*a, *b] = y") + self.check_suite("for [*x, b] in x: pass") + ++ def test_raise_statement(self): ++ self.check_suite("raise\n") ++ self.check_suite("raise e\n") ++ self.check_suite("try:\n" ++ " suite\n" ++ "except Exception as e:\n" ++ " raise ValueError from e\n") ++ ++ def test_set_displays(self): ++ self.check_expr('{2}') ++ self.check_expr('{2,}') ++ self.check_expr('{2, 3}') ++ self.check_expr('{2, 3,}') ++ ++ def test_dict_displays(self): ++ self.check_expr('{}') ++ self.check_expr('{a:b}') ++ self.check_expr('{a:b,}') ++ self.check_expr('{a:b, c:d}') ++ self.check_expr('{a:b, c:d,}') ++ ++ def test_set_comprehensions(self): ++ self.check_expr('{x for x in seq}') ++ self.check_expr('{f(x) for x in seq}') ++ self.check_expr('{f(x) for x in seq if condition(x)}') ++ ++ def test_dict_comprehensions(self): ++ self.check_expr('{x:x for x in seq}') ++ self.check_expr('{x**2:x[3] for x in seq if condition(x)}') ++ self.check_expr('{x:x for x in seq1 for y in seq2 if condition(x, y)}') ++ + + # + # Second, we take *invalid* trees and make sure we get ParserError +diff -r 3d0686d90f55 Lib/test/test_pdb.py +--- a/Lib/test/test_pdb.py ++++ b/Lib/test/test_pdb.py +@@ -5,6 +5,7 @@ + import sys + import unittest + import subprocess ++import textwrap + + from test import support + # This little helper class is essential for testing pdb under doctest. +@@ -595,6 +596,23 @@ + + class PdbTestCase(unittest.TestCase): + ++ def run_pdb(self, script, commands): ++ """Run 'script' lines with pdb and the pdb 'commands'.""" ++ filename = 'main.py' ++ with open(filename, 'w') as f: ++ f.write(textwrap.dedent(script)) ++ self.addCleanup(support.unlink, filename) ++ cmd = [sys.executable, '-m', 'pdb', filename] ++ stdout = stderr = None ++ with subprocess.Popen(cmd, stdout=subprocess.PIPE, ++ stdin=subprocess.PIPE, ++ stderr=subprocess.STDOUT, ++ ) as proc: ++ stdout, stderr = proc.communicate(str.encode(commands)) ++ stdout = stdout and bytes.decode(stdout) ++ stderr = stderr and bytes.decode(stderr) ++ return stdout, stderr ++ + def test_issue7964(self): + # open the file as binary so we can force \r\n newline + with open(support.TESTFN, 'wb') as f: +@@ -610,6 +628,42 @@ + self.assertNotIn(b'SyntaxError', stdout, + "Got a syntax error running test script under PDB") + ++ def test_issue13183(self): ++ script = """ ++ from bar import bar ++ ++ def foo(): ++ bar() ++ ++ def nope(): ++ pass ++ ++ def foobar(): ++ foo() ++ nope() ++ ++ foobar() ++ """ ++ commands = """ ++ from bar import bar ++ break bar ++ continue ++ step ++ step ++ quit ++ """ ++ bar = """ ++ def bar(): ++ pass ++ """ ++ with open('bar.py', 'w') as f: ++ f.write(textwrap.dedent(bar)) ++ self.addCleanup(support.unlink, 'bar.py') ++ stdout, stderr = self.run_pdb(script, commands) ++ self.assertTrue( ++ any('main.py(5)foo()->None' in l for l in stdout.splitlines()), ++ 'Fail to step into the caller after a return') ++ + def tearDown(self): + support.unlink(support.TESTFN) + +diff -r 3d0686d90f55 Lib/test/test_pkgutil.py +--- a/Lib/test/test_pkgutil.py ++++ b/Lib/test/test_pkgutil.py +@@ -1,4 +1,4 @@ +-from test.support import run_unittest ++from test.support import run_unittest, unload + import unittest + import sys + import imp +@@ -137,8 +137,99 @@ + self.assertEqual(foo.loads, 1) + del sys.modules['foo'] + ++ ++class ExtendPathTests(unittest.TestCase): ++ def create_init(self, pkgname): ++ dirname = tempfile.mkdtemp() ++ self.addCleanup(shutil.rmtree, dirname) ++ sys.path.insert(0, dirname) ++ ++ pkgdir = os.path.join(dirname, pkgname) ++ os.mkdir(pkgdir) ++ with open(os.path.join(pkgdir, '__init__.py'), 'w') as fl: ++ fl.write('from pkgutil import extend_path\n__path__ = extend_path(__path__, __name__)\n') ++ ++ return dirname ++ ++ def create_submodule(self, dirname, pkgname, submodule_name, value): ++ module_name = os.path.join(dirname, pkgname, submodule_name + '.py') ++ with open(module_name, 'w') as fl: ++ print('value={}'.format(value), file=fl) ++ ++ def setUp(self): ++ # Create 2 directories on sys.path ++ self.pkgname = 'foo' ++ self.dirname_0 = self.create_init(self.pkgname) ++ self.dirname_1 = self.create_init(self.pkgname) ++ ++ def tearDown(self): ++ del sys.path[0] ++ del sys.path[0] ++ del sys.modules['foo'] ++ del sys.modules['foo.bar'] ++ del sys.modules['foo.baz'] ++ ++ def test_simple(self): ++ self.create_submodule(self.dirname_0, self.pkgname, 'bar', 0) ++ self.create_submodule(self.dirname_1, self.pkgname, 'baz', 1) ++ import foo.bar ++ import foo.baz ++ # Ensure we read the expected values ++ self.assertEqual(foo.bar.value, 0) ++ self.assertEqual(foo.baz.value, 1) ++ ++ # Ensure the path is set up correctly ++ self.assertEqual(sorted(foo.__path__), ++ sorted([os.path.join(self.dirname_0, self.pkgname), ++ os.path.join(self.dirname_1, self.pkgname)])) ++ ++ # XXX: test .pkg files ++ ++ ++class NestedNamespacePackageTest(unittest.TestCase): ++ ++ def setUp(self): ++ self.basedir = tempfile.mkdtemp() ++ self.old_path = sys.path[:] ++ ++ def tearDown(self): ++ sys.path[:] = self.old_path ++ shutil.rmtree(self.basedir) ++ ++ def create_module(self, name, contents): ++ base, final = name.rsplit('.', 1) ++ base_path = os.path.join(self.basedir, base.replace('.', os.path.sep)) ++ os.makedirs(base_path, exist_ok=True) ++ with open(os.path.join(base_path, final + ".py"), 'w') as f: ++ f.write(contents) ++ ++ def test_nested(self): ++ pkgutil_boilerplate = ( ++ 'import pkgutil; ' ++ '__path__ = pkgutil.extend_path(__path__, __name__)') ++ self.create_module('a.pkg.__init__', pkgutil_boilerplate) ++ self.create_module('b.pkg.__init__', pkgutil_boilerplate) ++ self.create_module('a.pkg.subpkg.__init__', pkgutil_boilerplate) ++ self.create_module('b.pkg.subpkg.__init__', pkgutil_boilerplate) ++ self.create_module('a.pkg.subpkg.c', 'c = 1') ++ self.create_module('b.pkg.subpkg.d', 'd = 2') ++ sys.path.insert(0, os.path.join(self.basedir, 'a')) ++ sys.path.insert(0, os.path.join(self.basedir, 'b')) ++ import pkg ++ self.addCleanup(unload, 'pkg') ++ self.assertEqual(len(pkg.__path__), 2) ++ import pkg.subpkg ++ self.addCleanup(unload, 'pkg.subpkg') ++ self.assertEqual(len(pkg.subpkg.__path__), 2) ++ from pkg.subpkg.c import c ++ from pkg.subpkg.d import d ++ self.assertEqual(c, 1) ++ self.assertEqual(d, 2) ++ ++ + def test_main(): +- run_unittest(PkgutilTests, PkgutilPEP302Tests) ++ run_unittest(PkgutilTests, PkgutilPEP302Tests, ExtendPathTests, ++ NestedNamespacePackageTest) + # this is necessary if test is run repeated (like when finding leaks) + import zipimport + zipimport._zip_directory_cache.clear() +diff -r 3d0686d90f55 Lib/test/test_posix.py +--- a/Lib/test/test_posix.py ++++ b/Lib/test/test_posix.py +@@ -9,6 +9,7 @@ + import sys + import time + import os ++import platform + import pwd + import shutil + import stat +@@ -106,7 +107,11 @@ + # If a non-privileged user invokes it, it should fail with OSError + # EPERM. + if os.getuid() != 0: +- name = pwd.getpwuid(posix.getuid()).pw_name ++ try: ++ name = pwd.getpwuid(posix.getuid()).pw_name ++ except KeyError: ++ # the current UID may not have a pwd entry ++ raise unittest.SkipTest("need a pwd entry") + try: + posix.initgroups(name, 13) + except OSError as e: +@@ -229,6 +234,9 @@ + + def _test_all_chown_common(self, chown_func, first_param): + """Common code for chown, fchown and lchown tests.""" ++ # test a successful chown call ++ chown_func(first_param, os.getuid(), os.getgid()) ++ + if os.getuid() == 0: + try: + # Many linux distros have a nfsnobody user as MAX_UID-2 +@@ -240,12 +248,15 @@ + chown_func(first_param, ent.pw_uid, ent.pw_gid) + except KeyError: + pass ++ elif platform.system() in ('HP-UX', 'SunOS'): ++ # HP-UX and Solaris can allow a non-root user to chown() to root ++ # (issue #5113) ++ raise unittest.SkipTest("Skipping because of non-standard chown() " ++ "behavior") + else: + # non-root cannot chown to root, raises OSError + self.assertRaises(OSError, chown_func, + first_param, 0, 0) +- # test a successful chown call +- chown_func(first_param, os.getuid(), os.getgid()) + + @unittest.skipUnless(hasattr(posix, 'chown'), "test needs os.chown()") + def test_chown(self): +@@ -414,8 +425,9 @@ + def test_getgroups(self): + with os.popen('id -G') as idg: + groups = idg.read().strip() ++ ret = idg.close() + +- if not groups: ++ if ret != None or not groups: + raise unittest.SkipTest("need working 'id -G'") + + # 'id -G' and 'os.getgroups()' should return the same +diff -r 3d0686d90f55 Lib/test/test_posixpath.py +--- a/Lib/test/test_posixpath.py ++++ b/Lib/test/test_posixpath.py +@@ -298,6 +298,7 @@ + with support.EnvironmentVarGuard() as env: + env['HOME'] = '/' + self.assertEqual(posixpath.expanduser("~"), "/") ++ self.assertEqual(posixpath.expanduser("~/foo"), "/foo") + # expanduser should fall back to using the password database + del env['HOME'] + home = pwd.getpwuid(os.getuid()).pw_dir +diff -r 3d0686d90f55 Lib/test/test_pyclbr.py +--- a/Lib/test/test_pyclbr.py ++++ b/Lib/test/test_pyclbr.py +@@ -167,6 +167,11 @@ + cm('email.parser') + cm('test.test_pyclbr') + ++ def test_issue_14798(self): ++ # test ImportError is raised when the first part of a dotted name is ++ # not a package ++ self.assertRaises(ImportError, pyclbr.readmodule_ex, 'asyncore.foo') ++ + + def test_main(): + run_unittest(PyclbrTest) +diff -r 3d0686d90f55 Lib/test/test_pydoc.py +--- a/Lib/test/test_pydoc.py ++++ b/Lib/test/test_pydoc.py +@@ -282,6 +282,17 @@ + result, doc_loc = get_pydoc_text(xml.etree) + self.assertEqual(doc_loc, "", "MODULE DOCS incorrectly includes a link") + ++ def test_non_str_name(self): ++ # issue14638 ++ # Treat illegal (non-str) name like no name ++ class A: ++ __name__ = 42 ++ class B: ++ pass ++ adoc = pydoc.render_doc(A()) ++ bdoc = pydoc.render_doc(B()) ++ self.assertEqual(adoc.replace("A", "B"), bdoc) ++ + def test_not_here(self): + missing_module = "test.i_am_not_here" + result = str(run_pydoc(missing_module), 'ascii') +diff -r 3d0686d90f55 Lib/test/test_queue.py +--- a/Lib/test/test_queue.py ++++ b/Lib/test/test_queue.py +@@ -82,7 +82,7 @@ + self.fail("trigger thread ended but event never set") + + +-class BaseQueueTest(unittest.TestCase, BlockingTestMixin): ++class BaseQueueTestMixin(BlockingTestMixin): + def setUp(self): + self.cum = 0 + self.cumlock = threading.Lock() +@@ -229,13 +229,13 @@ + with self.assertRaises(queue.Full): + q.put_nowait(4) + +-class QueueTest(BaseQueueTest): ++class QueueTest(BaseQueueTestMixin, unittest.TestCase): + type2test = queue.Queue + +-class LifoQueueTest(BaseQueueTest): ++class LifoQueueTest(BaseQueueTestMixin, unittest.TestCase): + type2test = queue.LifoQueue + +-class PriorityQueueTest(BaseQueueTest): ++class PriorityQueueTest(BaseQueueTestMixin, unittest.TestCase): + type2test = queue.PriorityQueue + + +diff -r 3d0686d90f55 Lib/test/test_re.py +--- a/Lib/test/test_re.py ++++ b/Lib/test/test_re.py +@@ -1,4 +1,5 @@ +-from test.support import verbose, run_unittest ++from test.support import verbose, run_unittest, gc_collect ++import io + import re + from re import Scanner + import sys +@@ -16,6 +17,17 @@ + + class ReTests(unittest.TestCase): + ++ def test_keep_buffer(self): ++ # See bug 14212 ++ b = bytearray(b'x') ++ it = re.finditer(b'a', b) ++ with self.assertRaises(BufferError): ++ b.extend(b'x'*400) ++ list(it) ++ del it ++ gc_collect() ++ b.extend(b'x'*400) ++ + def test_weakref(self): + s = 'QabbbcR' + x = re.compile('ab+c') +@@ -355,6 +367,32 @@ + self.assertEqual(re.search(r"\d\D\w\W\s\S", + "1aa! a", re.UNICODE).group(0), "1aa! a") + ++ def test_string_boundaries(self): ++ # See http://bugs.python.org/issue10713 ++ self.assertEqual(re.search(r"\b(abc)\b", "abc").group(1), ++ "abc") ++ # There's a word boundary at the start of a string. ++ self.assertTrue(re.match(r"\b", "abc")) ++ # A non-empty string includes a non-boundary zero-length match. ++ self.assertTrue(re.search(r"\B", "abc")) ++ # There is no non-boundary match at the start of a string. ++ self.assertFalse(re.match(r"\B", "abc")) ++ # However, an empty string contains no word boundaries, and also no ++ # non-boundaries. ++ self.assertEqual(re.search(r"\B", ""), None) ++ # This one is questionable and different from the perlre behaviour, ++ # but describes current behavior. ++ self.assertEqual(re.search(r"\b", ""), None) ++ # A single word-character string has two boundaries, but no ++ # non-boundary gaps. ++ self.assertEqual(len(re.findall(r"\b", "a")), 2) ++ self.assertEqual(len(re.findall(r"\B", "a")), 0) ++ # If there are no words, there are no boundaries ++ self.assertEqual(len(re.findall(r"\b", " ")), 0) ++ self.assertEqual(len(re.findall(r"\b", " ")), 0) ++ # Can match around the whitespace. ++ self.assertEqual(len(re.findall(r"\B", " ")), 2) ++ + def test_bigcharset(self): + self.assertEqual(re.match("([\u2222\u2223])", + "\u2222").group(1), "\u2222") +@@ -780,6 +818,16 @@ + self.assertRaises(OverflowError, _sre.compile, "abc", 0, [long_overflow]) + self.assertRaises(TypeError, _sre.compile, {}, 0, []) + ++ def test_compile(self): ++ # Test return value when given string and pattern as parameter ++ pattern = re.compile('random pattern') ++ self.assertIsInstance(pattern, re._pattern_type) ++ same_pattern = re.compile(pattern) ++ self.assertIsInstance(same_pattern, re._pattern_type) ++ self.assertIs(same_pattern, pattern) ++ # Test behaviour when not given a string or pattern as parameter ++ self.assertRaises(TypeError, re.compile, 0) ++ + def run_re_tests(): + from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR + if verbose: +diff -r 3d0686d90f55 Lib/test/test_shutil.py +--- a/Lib/test/test_shutil.py ++++ b/Lib/test/test_shutil.py +@@ -8,6 +8,7 @@ + import os + import os.path + import functools ++import errno + from test import support + from test.support import TESTFN + from os.path import splitdrive +@@ -307,6 +308,35 @@ + finally: + shutil.rmtree(TESTFN, ignore_errors=True) + ++ @unittest.skipUnless(hasattr(os, 'chflags') and ++ hasattr(errno, 'EOPNOTSUPP') and ++ hasattr(errno, 'ENOTSUP'), ++ "requires os.chflags, EOPNOTSUPP & ENOTSUP") ++ def test_copystat_handles_harmless_chflags_errors(self): ++ tmpdir = self.mkdtemp() ++ file1 = os.path.join(tmpdir, 'file1') ++ file2 = os.path.join(tmpdir, 'file2') ++ self.write_file(file1, 'xxx') ++ self.write_file(file2, 'xxx') ++ ++ def make_chflags_raiser(err): ++ ex = OSError() ++ ++ def _chflags_raiser(path, flags): ++ ex.errno = err ++ raise ex ++ return _chflags_raiser ++ old_chflags = os.chflags ++ try: ++ for err in errno.EOPNOTSUPP, errno.ENOTSUP: ++ os.chflags = make_chflags_raiser(err) ++ shutil.copystat(file1, file2) ++ # assert others errors break it ++ os.chflags = make_chflags_raiser(errno.EOPNOTSUPP + errno.ENOTSUP) ++ self.assertRaises(OSError, shutil.copystat, file1, file2) ++ finally: ++ os.chflags = old_chflags ++ + @support.skip_unless_symlink + def test_dont_copy_file_onto_symlink_to_itself(self): + # bug 851123. +diff -r 3d0686d90f55 Lib/test/test_socket.py +--- a/Lib/test/test_socket.py ++++ b/Lib/test/test_socket.py +@@ -951,6 +951,7 @@ + f = self.cli_conn.detach() + self.assertEqual(f, fileno) + # cli_conn cannot be used anymore... ++ self.assertTrue(self.cli_conn._closed) + self.assertRaises(socket.error, self.cli_conn.recv, 1024) + self.cli_conn.close() + # ...but we can create another socket using the (still open) +diff -r 3d0686d90f55 Lib/test/test_socketserver.py +--- a/Lib/test/test_socketserver.py ++++ b/Lib/test/test_socketserver.py +@@ -8,6 +8,8 @@ + import select + import signal + import socket ++import select ++import errno + import tempfile + import unittest + import socketserver +@@ -32,8 +34,11 @@ + if hasattr(signal, 'alarm'): + signal.alarm(n) + ++# Remember real select() to avoid interferences with mocking ++_real_select = select.select ++ + def receive(sock, n, timeout=20): +- r, w, x = select.select([sock], [], [], timeout) ++ r, w, x = _real_select([sock], [], [], timeout) + if sock in r: + return sock.recv(n) + else: +@@ -226,6 +231,38 @@ + socketserver.DatagramRequestHandler, + self.dgram_examine) + ++ @contextlib.contextmanager ++ def mocked_select_module(self): ++ """Mocks the select.select() call to raise EINTR for first call""" ++ old_select = select.select ++ ++ class MockSelect: ++ def __init__(self): ++ self.called = 0 ++ ++ def __call__(self, *args): ++ self.called += 1 ++ if self.called == 1: ++ # raise the exception on first call ++ raise select.error(errno.EINTR, os.strerror(errno.EINTR)) ++ else: ++ # Return real select value for consecutive calls ++ return old_select(*args) ++ ++ select.select = MockSelect() ++ try: ++ yield select.select ++ finally: ++ select.select = old_select ++ ++ def test_InterruptServerSelectCall(self): ++ with self.mocked_select_module() as mock_select: ++ pid = self.run_server(socketserver.TCPServer, ++ socketserver.StreamRequestHandler, ++ self.stream_examine) ++ # Make sure select was called again: ++ self.assertGreater(mock_select.called, 1) ++ + # Alas, on Linux (at least) recvfrom() doesn't return a meaningful + # client address so this cannot work: + +diff -r 3d0686d90f55 Lib/test/test_ssl.py +--- a/Lib/test/test_ssl.py ++++ b/Lib/test/test_ssl.py +@@ -713,13 +713,18 @@ + # SHA256 was added in OpenSSL 0.9.8 + if ssl.OPENSSL_VERSION_INFO < (0, 9, 8, 0, 15): + self.skipTest("SHA256 not available on %r" % ssl.OPENSSL_VERSION) ++ # sha256.tbs-internet.com needs SNI to use the correct certificate ++ if not ssl.HAS_SNI: ++ self.skipTest("SNI needed for this test") + # https://sha2.hboeck.de/ was used until 2011-01-08 (no route to host) + remote = ("sha256.tbs-internet.com", 443) + sha256_cert = os.path.join(os.path.dirname(__file__), "sha256.pem") + with support.transient_internet("sha256.tbs-internet.com"): +- s = ssl.wrap_socket(socket.socket(socket.AF_INET), +- cert_reqs=ssl.CERT_REQUIRED, +- ca_certs=sha256_cert,) ++ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ++ ctx.verify_mode = ssl.CERT_REQUIRED ++ ctx.load_verify_locations(sha256_cert) ++ s = ctx.wrap_socket(socket.socket(socket.AF_INET), ++ server_hostname="sha256.tbs-internet.com") + try: + s.connect(remote) + if support.verbose: +diff -r 3d0686d90f55 Lib/test/test_strptime.py +--- a/Lib/test/test_strptime.py ++++ b/Lib/test/test_strptime.py +@@ -38,9 +38,9 @@ + comparison = testing[self.time_tuple[tuple_position]] + self.assertIn(strftime_output, testing, + "%s: not found in tuple" % error_msg) +- self.assertTrue(comparison == strftime_output, +- "%s: position within tuple incorrect; %s != %s" % +- (error_msg, comparison, strftime_output)) ++ self.assertEqual(comparison, strftime_output, ++ "%s: position within tuple incorrect; %s != %s" % ++ (error_msg, comparison, strftime_output)) + + def test_weekday(self): + # Make sure that full and abbreviated weekday names are correct in +@@ -65,8 +65,8 @@ + "AM/PM representation not in tuple") + if self.time_tuple[3] < 12: position = 0 + else: position = 1 +- self.assertTrue(strftime_output == self.LT_ins.am_pm[position], +- "AM/PM representation in the wrong position within the tuple") ++ self.assertEqual(self.LT_ins.am_pm[position], strftime_output, ++ "AM/PM representation in the wrong position within the tuple") + + def test_timezone(self): + # Make sure timezone is correct +@@ -86,17 +86,14 @@ + # output. + magic_date = (1999, 3, 17, 22, 44, 55, 2, 76, 0) + strftime_output = time.strftime("%c", magic_date) +- self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_date_time, +- magic_date), +- "LC_date_time incorrect") ++ self.assertEqual(time.strftime(self.LT_ins.LC_date_time, magic_date), ++ strftime_output, "LC_date_time incorrect") + strftime_output = time.strftime("%x", magic_date) +- self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_date, +- magic_date), +- "LC_date incorrect") ++ self.assertEqual(time.strftime(self.LT_ins.LC_date, magic_date), ++ strftime_output, "LC_date incorrect") + strftime_output = time.strftime("%X", magic_date) +- self.assertTrue(strftime_output == time.strftime(self.LT_ins.LC_time, +- magic_date), +- "LC_time incorrect") ++ self.assertEqual(time.strftime(self.LT_ins.LC_time, magic_date), ++ strftime_output, "LC_time incorrect") + LT = _strptime.LocaleTime() + LT.am_pm = ('', '') + self.assertTrue(LT.LC_time, "LocaleTime's LC directives cannot handle " +@@ -168,8 +165,8 @@ + # Fixes bug #661354 + test_locale = _strptime.LocaleTime() + test_locale.timezone = (frozenset(), frozenset()) +- self.assertTrue(_strptime.TimeRE(test_locale).pattern("%Z") == '', +- "with timezone == ('',''), TimeRE().pattern('%Z') != ''") ++ self.assertEqual(_strptime.TimeRE(test_locale).pattern("%Z"), '', ++ "with timezone == ('',''), TimeRE().pattern('%Z') != ''") + + def test_matching_with_escapes(self): + # Make sure a format that requires escaping of characters works +@@ -195,7 +192,7 @@ + # so as to not allow to subpatterns to end up next to each other and + # "steal" characters from each other. + pattern = self.time_re.pattern('%j %H') +- self.assertTrue(not re.match(pattern, "180")) ++ self.assertFalse(re.match(pattern, "180")) + self.assertTrue(re.match(pattern, "18 0")) + + +@@ -381,6 +378,14 @@ + need_escaping = ".^$*+?{}\[]|)(" + self.assertTrue(_strptime._strptime_time(need_escaping, need_escaping)) + ++ def test_feb29_on_leap_year_without_year(self): ++ time.strptime("Feb 29", "%b %d") ++ ++ def test_mar1_comes_after_feb29_even_when_omitting_the_year(self): ++ self.assertLess( ++ time.strptime("Feb 29", "%b %d"), ++ time.strptime("Mar 1", "%b %d")) ++ + class Strptime12AMPMTests(unittest.TestCase): + """Test a _strptime regression in '%I %p' at 12 noon (12 PM)""" + +diff -r 3d0686d90f55 Lib/test/test_subprocess.py +--- a/Lib/test/test_subprocess.py ++++ b/Lib/test/test_subprocess.py +@@ -989,6 +989,27 @@ + getattr(p, method)(*args) + return p + ++ def _kill_dead_process(self, method, *args): ++ # Do not inherit file handles from the parent. ++ # It should fix failures on some platforms. ++ p = subprocess.Popen([sys.executable, "-c", """if 1: ++ import sys, time ++ sys.stdout.write('x\\n') ++ sys.stdout.flush() ++ """], ++ close_fds=True, ++ stdin=subprocess.PIPE, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE) ++ # Wait for the interpreter to be completely initialized before ++ # sending any signal. ++ p.stdout.read(1) ++ # The process should end after this ++ time.sleep(1) ++ # This shouldn't raise even though the child is now dead ++ getattr(p, method)(*args) ++ p.communicate() ++ + def test_send_signal(self): + p = self._kill_process('send_signal', signal.SIGINT) + _, stderr = p.communicate() +@@ -1007,6 +1028,18 @@ + self.assertStderrEqual(stderr, b'') + self.assertEqual(p.wait(), -signal.SIGTERM) + ++ def test_send_signal_dead(self): ++ # Sending a signal to a dead process ++ self._kill_dead_process('send_signal', signal.SIGINT) ++ ++ def test_kill_dead(self): ++ # Killing a dead process ++ self._kill_dead_process('kill') ++ ++ def test_terminate_dead(self): ++ # Terminating a dead process ++ self._kill_dead_process('terminate') ++ + def check_close_std_fds(self, fds): + # Issue #9905: test that subprocess pipes still work properly with + # some standard fds closed +@@ -1568,6 +1601,31 @@ + returncode = p.wait() + self.assertNotEqual(returncode, 0) + ++ def _kill_dead_process(self, method, *args): ++ p = subprocess.Popen([sys.executable, "-c", """if 1: ++ import sys, time ++ sys.stdout.write('x\\n') ++ sys.stdout.flush() ++ sys.exit(42) ++ """], ++ stdin=subprocess.PIPE, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE) ++ self.addCleanup(p.stdout.close) ++ self.addCleanup(p.stderr.close) ++ self.addCleanup(p.stdin.close) ++ # Wait for the interpreter to be completely initialized before ++ # sending any signal. ++ p.stdout.read(1) ++ # The process should end after this ++ time.sleep(1) ++ # This shouldn't raise even though the child is now dead ++ getattr(p, method)(*args) ++ _, stderr = p.communicate() ++ self.assertStderrEqual(stderr, b'') ++ rc = p.wait() ++ self.assertEqual(rc, 42) ++ + def test_send_signal(self): + self._kill_process('send_signal', signal.SIGTERM) + +@@ -1577,6 +1635,15 @@ + def test_terminate(self): + self._kill_process('terminate') + ++ def test_send_signal_dead(self): ++ self._kill_dead_process('send_signal', signal.SIGTERM) ++ ++ def test_kill_dead(self): ++ self._kill_dead_process('kill') ++ ++ def test_terminate_dead(self): ++ self._kill_dead_process('terminate') ++ + + # The module says: + # "NB This only works (and is only relevant) for UNIX." +diff -r 3d0686d90f55 Lib/test/test_sys_settrace.py +--- a/Lib/test/test_sys_settrace.py ++++ b/Lib/test/test_sys_settrace.py +@@ -671,6 +671,14 @@ + no_jump_to_non_integers.jump = (2, "Spam") + no_jump_to_non_integers.output = [True] + ++def jump_across_with(output): ++ with open(support.TESTFN, "wb") as fp: ++ pass ++ with open(support.TESTFN, "wb") as fp: ++ pass ++jump_across_with.jump = (1, 3) ++jump_across_with.output = [] ++ + # This verifies that you can't set f_lineno via _getframe or similar + # trickery. + def no_jump_without_trace_function(): +@@ -740,6 +748,9 @@ + self.run_test(no_jump_to_non_integers) + def test_19_no_jump_without_trace_function(self): + no_jump_without_trace_function() ++ def test_jump_across_with(self): ++ self.addCleanup(support.unlink, support.TESTFN) ++ self.run_test(jump_across_with) + + def test_20_large_function(self): + d = {} +diff -r 3d0686d90f55 Lib/test/test_tarfile.py +--- a/Lib/test/test_tarfile.py ++++ b/Lib/test/test_tarfile.py +@@ -166,6 +166,9 @@ + def test_fileobj_symlink2(self): + self._test_fileobj_link("./ustar/linktest2/symtype", "ustar/linktest1/regtype") + ++ def test_issue14160(self): ++ self._test_fileobj_link("symtype2", "ustar/regtype") ++ + + class CommonReadTest(ReadTest): + +diff -r 3d0686d90f55 Lib/test/test_thread.py +--- a/Lib/test/test_thread.py ++++ b/Lib/test/test_thread.py +@@ -128,6 +128,29 @@ + time.sleep(0.01) + self.assertEqual(thread._count(), orig) + ++ def test_save_exception_state_on_error(self): ++ # See issue #14474 ++ def task(): ++ started.release() ++ raise SyntaxError ++ def mywrite(self, *args): ++ try: ++ raise ValueError ++ except ValueError: ++ pass ++ real_write(self, *args) ++ c = thread._count() ++ started = thread.allocate_lock() ++ with support.captured_output("stderr") as stderr: ++ real_write = stderr.write ++ stderr.write = mywrite ++ started.acquire() ++ thread.start_new_thread(task, ()) ++ started.acquire() ++ while thread._count() > c: ++ time.sleep(0.01) ++ self.assertIn("Traceback", stderr.getvalue()) ++ + + class Barrier: + def __init__(self, num_threads): +diff -r 3d0686d90f55 Lib/test/test_threading.py +--- a/Lib/test/test_threading.py ++++ b/Lib/test/test_threading.py +@@ -2,6 +2,8 @@ + + import test.support + from test.support import verbose, strip_python_stderr, import_module ++from test.script_helper import assert_python_ok ++ + import random + import re + import sys +@@ -407,6 +409,33 @@ + t.daemon = True + self.assertTrue('daemon' in repr(t)) + ++ @unittest.skipUnless(hasattr(os, 'fork'), 'test needs fork()') ++ def test_dummy_thread_after_fork(self): ++ # Issue #14308: a dummy thread in the active list doesn't mess up ++ # the after-fork mechanism. ++ code = """if 1: ++ import _thread, threading, os, time ++ ++ def background_thread(evt): ++ # Creates and registers the _DummyThread instance ++ threading.current_thread() ++ evt.set() ++ time.sleep(10) ++ ++ evt = threading.Event() ++ _thread.start_new_thread(background_thread, (evt,)) ++ evt.wait() ++ assert threading.active_count() == 2, threading.active_count() ++ if os.fork() == 0: ++ assert threading.active_count() == 1, threading.active_count() ++ os._exit(0) ++ else: ++ os.wait() ++ """ ++ _, out, err = assert_python_ok("-c", code) ++ self.assertEqual(out, b'') ++ self.assertEqual(err, b'') ++ + + class ThreadJoinOnShutdown(BaseTestCase): + +@@ -624,6 +653,7 @@ + output = "end of worker thread\nend of main thread\n" + self.assertScriptHasOutput(script, output) + ++ @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") + def test_6_daemon_threads(self): + # Check that a daemon thread cannot crash the interpreter on shutdown + # by manipulating internal structures that are being disposed of in +@@ -738,10 +768,10 @@ + """ + expected_output = "end of main thread\n" + p = subprocess.Popen([sys.executable, "-c", script], +- stdout=subprocess.PIPE) ++ stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = p.communicate() + data = stdout.decode().replace('\r', '') +- self.assertEqual(p.returncode, 0, "Unexpected error") ++ self.assertEqual(p.returncode, 0, "Unexpected error: " + stderr.decode()) + self.assertEqual(data, expected_output) + + class LockTests(lock_tests.LockTests): +diff -r 3d0686d90f55 Lib/test/test_tokenize.py +--- a/Lib/test/test_tokenize.py ++++ b/Lib/test/test_tokenize.py +@@ -674,6 +674,10 @@ + f = 'tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt' + self.assertTrue(self._testFile(f)) + ++ def test_bad_coding_cookie(self): ++ self.assertRaises(SyntaxError, self._testFile, 'bad_coding.py') ++ self.assertRaises(SyntaxError, self._testFile, 'bad_coding2.py') ++ + + class Test_Tokenize(TestCase): + +@@ -825,6 +829,16 @@ + found, consumed_lines = detect_encoding(rl) + self.assertEqual(found, "iso-8859-1") + ++ def test_syntaxerror_latin1(self): ++ # Issue 14629: need to raise SyntaxError if the first ++ # line(s) have non-UTF-8 characters ++ lines = ( ++ b'print("\xdf")', # Latin-1: LATIN SMALL LETTER SHARP S ++ ) ++ readline = self.get_readline(lines) ++ self.assertRaises(SyntaxError, detect_encoding, readline) ++ ++ + def test_utf8_normalization(self): + # See get_normal_name() in tokenizer.c. + encodings = ("utf-8", "utf-8-mac", "utf-8-unix") +diff -r 3d0686d90f55 Lib/test/test_tools.py +--- /dev/null ++++ b/Lib/test/test_tools.py +@@ -0,0 +1,108 @@ ++"""Tests for scripts in the Tools directory. ++ ++This file contains regression tests for some of the scripts found in the ++Tools directory of a Python checkout or tarball, such as reindent.py. ++""" ++ ++import os ++import sys ++import imp ++import unittest ++import sysconfig ++import tempfile ++from test import support ++from test.script_helper import assert_python_ok ++ ++if not sysconfig.is_python_build(): ++ # XXX some installers do contain the tools, should we detect that ++ # and run the tests in that case too? ++ raise unittest.SkipTest('test irrelevant for an installed Python') ++ ++srcdir = sysconfig.get_config_var('projectbase') ++basepath = os.path.join(os.getcwd(), srcdir, 'Tools') ++scriptsdir = os.path.join(basepath, 'scripts') ++ ++ ++class ReindentTests(unittest.TestCase): ++ script = os.path.join(scriptsdir, 'reindent.py') ++ ++ def test_noargs(self): ++ assert_python_ok(self.script) ++ ++ def test_help(self): ++ rc, out, err = assert_python_ok(self.script, '-h') ++ self.assertEqual(out, b'') ++ self.assertGreater(err, b'') ++ ++ ++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. ++ ++ # scripts that have independent tests. ++ whitelist = ['reindent.py'] ++ # scripts that can't be imported without running ++ blacklist = ['make_ctype.py'] ++ # scripts that use windows-only modules ++ windows_only = ['win_add2path.py'] ++ # blacklisted for other reasons ++ other = ['analyze_dxp.py'] ++ ++ skiplist = blacklist + whitelist + windows_only + other ++ ++ def setUp(self): ++ cm = support.DirsOnSysPath(scriptsdir) ++ cm.__enter__() ++ self.addCleanup(cm.__exit__) ++ ++ def test_sundry(self): ++ for fn in os.listdir(scriptsdir): ++ if fn.endswith('.py') and fn not in self.skiplist: ++ __import__(fn[:-3]) ++ ++ @unittest.skipIf(sys.platform != "win32", "Windows-only test") ++ def test_sundry_windows(self): ++ for fn in self.windows_only: ++ __import__(fn[:-3]) ++ ++ @unittest.skipIf(not support.threading, "test requires _thread module") ++ def test_analyze_dxp_import(self): ++ if hasattr(sys, 'getdxp'): ++ import analyze_dxp ++ else: ++ with self.assertRaises(RuntimeError): ++ import analyze_dxp ++ ++ ++class PdepsTests(unittest.TestCase): ++ ++ @classmethod ++ def setUpClass(self): ++ path = os.path.join(scriptsdir, 'pdeps.py') ++ self.pdeps = imp.load_source('pdeps', path) ++ ++ @classmethod ++ def tearDownClass(self): ++ if 'pdeps' in sys.modules: ++ del sys.modules['pdeps'] ++ ++ def test_process_errors(self): ++ # Issue #14492: m_import.match(line) can be None. ++ with tempfile.TemporaryDirectory() as tmpdir: ++ fn = os.path.join(tmpdir, 'foo') ++ with open(fn, 'w') as stream: ++ stream.write("#!/this/will/fail") ++ self.pdeps.process(fn, {}) ++ ++ def test_inverse_attribute_error(self): ++ # Issue #14492: this used to fail with an AttributeError. ++ self.pdeps.inverse({'a': []}) ++ ++ ++def test_main(): ++ support.run_unittest(*[obj for obj in globals().values() ++ if isinstance(obj, type)]) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff -r 3d0686d90f55 Lib/test/test_unicode.py +--- a/Lib/test/test_unicode.py ++++ b/Lib/test/test_unicode.py +@@ -891,12 +891,15 @@ + self.assertEqual('{foo._x}'.format_map({'foo': C(20)}), '20') + + # test various errors +- self.assertRaises(TypeError, '{'.format_map) +- self.assertRaises(TypeError, '}'.format_map) +- self.assertRaises(TypeError, 'a{'.format_map) +- self.assertRaises(TypeError, 'a}'.format_map) +- self.assertRaises(TypeError, '{a'.format_map) +- self.assertRaises(TypeError, '}a'.format_map) ++ self.assertRaises(TypeError, ''.format_map) ++ self.assertRaises(TypeError, 'a'.format_map) ++ ++ self.assertRaises(ValueError, '{'.format_map, {}) ++ self.assertRaises(ValueError, '}'.format_map, {}) ++ self.assertRaises(ValueError, 'a{'.format_map, {}) ++ self.assertRaises(ValueError, 'a}'.format_map, {}) ++ self.assertRaises(ValueError, '{a'.format_map, {}) ++ self.assertRaises(ValueError, '}a'.format_map, {}) + + # issue #12579: can't supply positional params to format_map + self.assertRaises(ValueError, '{}'.format_map, {'a' : 2}) +diff -r 3d0686d90f55 Lib/test/test_urllib2.py +--- a/Lib/test/test_urllib2.py ++++ b/Lib/test/test_urllib2.py +@@ -1218,6 +1218,22 @@ + def test_basic_auth_with_single_quoted_realm(self): + self.test_basic_auth(quote_char="'") + ++ def test_basic_auth_with_unquoted_realm(self): ++ opener = OpenerDirector() ++ password_manager = MockPasswordManager() ++ auth_handler = urllib.request.HTTPBasicAuthHandler(password_manager) ++ realm = "ACME Widget Store" ++ http_handler = MockHTTPHandler( ++ 401, 'WWW-Authenticate: Basic realm=%s\r\n\r\n' % realm) ++ opener.add_handler(auth_handler) ++ opener.add_handler(http_handler) ++ with self.assertWarns(UserWarning): ++ self._test_basic_auth(opener, auth_handler, "Authorization", ++ realm, http_handler, password_manager, ++ "http://acme.example.com/protected", ++ "http://acme.example.com/protected", ++ ) ++ + def test_proxy_basic_auth(self): + opener = OpenerDirector() + ph = urllib.request.ProxyHandler(dict(http="proxy.example.com:3128")) +diff -r 3d0686d90f55 Lib/test/test_urlparse.py +--- a/Lib/test/test_urlparse.py ++++ b/Lib/test/test_urlparse.py +@@ -524,6 +524,11 @@ + self.assertEqual(p.port, 80) + self.assertEqual(p.geturl(), url) + ++ # Verify an illegal port is returned as None ++ url = b"HTTP://WWW.PYTHON.ORG:65536/doc/#frag" ++ p = urllib.parse.urlsplit(url) ++ self.assertEqual(p.port, None) ++ + def test_attributes_bad_port(self): + """Check handling of non-integer ports.""" + p = urllib.parse.urlsplit("http://www.example.net:foo") +@@ -636,11 +641,20 @@ + ('s3', 'foo.com', '/stuff', '', '', '')) + self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff"), + ('x-newscheme', 'foo.com', '/stuff', '', '', '')) ++ self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff?query#fragment"), ++ ('x-newscheme', 'foo.com', '/stuff', '', 'query', 'fragment')) ++ self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff?query"), ++ ('x-newscheme', 'foo.com', '/stuff', '', 'query', '')) ++ + # And for bytes... + self.assertEqual(urllib.parse.urlparse(b"s3://foo.com/stuff"), + (b's3', b'foo.com', b'/stuff', b'', b'', b'')) + self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff"), + (b'x-newscheme', b'foo.com', b'/stuff', b'', b'', b'')) ++ self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff?query#fragment"), ++ (b'x-newscheme', b'foo.com', b'/stuff', b'', b'query', b'fragment')) ++ self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff?query"), ++ (b'x-newscheme', b'foo.com', b'/stuff', b'', b'query', b'')) + + def test_mixed_types_rejected(self): + # Several functions that process either strings or ASCII encoded bytes +@@ -797,6 +811,13 @@ + encoding='utf-8') + self.assertRaises(TypeError, urllib.parse.quote, b'foo', errors='strict') + ++ def test_issue14072(self): ++ p1 = urllib.parse.urlsplit('tel:+31-641044153') ++ self.assertEqual(p1.scheme, 'tel') ++ self.assertEqual(p1.path, '+31-641044153') ++ p2 = urllib.parse.urlsplit('tel:+31641044153') ++ self.assertEqual(p2.scheme, 'tel') ++ self.assertEqual(p2.path, '+31641044153') + + def test_main(): + support.run_unittest(UrlParseTestCase) +diff -r 3d0686d90f55 Lib/test/test_weakref.py +--- a/Lib/test/test_weakref.py ++++ b/Lib/test/test_weakref.py +@@ -812,11 +812,71 @@ + def __hash__(self): + return hash(self.arg) + ++class RefCycle: ++ def __init__(self): ++ self.cycle = self ++ + + class MappingTestCase(TestBase): + + COUNT = 10 + ++ def check_len_cycles(self, dict_type, cons): ++ N = 20 ++ items = [RefCycle() for i in range(N)] ++ dct = dict_type(cons(o) for o in items) ++ # Keep an iterator alive ++ it = dct.items() ++ try: ++ next(it) ++ except StopIteration: ++ pass ++ del items ++ gc.collect() ++ n1 = len(dct) ++ del it ++ gc.collect() ++ n2 = len(dct) ++ # one item may be kept alive inside the iterator ++ self.assertIn(n1, (0, 1)) ++ self.assertEqual(n2, 0) ++ ++ def test_weak_keyed_len_cycles(self): ++ self.check_len_cycles(weakref.WeakKeyDictionary, lambda k: (k, 1)) ++ ++ def test_weak_valued_len_cycles(self): ++ self.check_len_cycles(weakref.WeakValueDictionary, lambda k: (1, k)) ++ ++ def check_len_race(self, dict_type, cons): ++ # Extended sanity checks for len() in the face of cyclic collection ++ self.addCleanup(gc.set_threshold, *gc.get_threshold()) ++ for th in range(1, 100): ++ N = 20 ++ gc.collect(0) ++ gc.set_threshold(th, th, th) ++ items = [RefCycle() for i in range(N)] ++ dct = dict_type(cons(o) for o in items) ++ del items ++ # All items will be collected at next garbage collection pass ++ it = dct.items() ++ try: ++ next(it) ++ except StopIteration: ++ pass ++ n1 = len(dct) ++ del it ++ n2 = len(dct) ++ self.assertGreaterEqual(n1, 0) ++ self.assertLessEqual(n1, N) ++ self.assertGreaterEqual(n2, 0) ++ self.assertLessEqual(n2, n1) ++ ++ def test_weak_keyed_len_race(self): ++ self.check_len_race(weakref.WeakKeyDictionary, lambda k: (k, 1)) ++ ++ def test_weak_valued_len_race(self): ++ self.check_len_race(weakref.WeakValueDictionary, lambda k: (1, k)) ++ + def test_weak_values(self): + # + # This exercises d.copy(), d.items(), d[], del d[], len(d). +diff -r 3d0686d90f55 Lib/test/test_weakset.py +--- a/Lib/test/test_weakset.py ++++ b/Lib/test/test_weakset.py +@@ -17,6 +17,10 @@ + class Foo: + pass + ++class RefCycle: ++ def __init__(self): ++ self.cycle = self ++ + + class TestWeakSet(unittest.TestCase): + +@@ -24,6 +28,12 @@ + # need to keep references to them + self.items = [ustr(c) for c in ('a', 'b', 'c')] + self.items2 = [ustr(c) for c in ('x', 'y', 'z')] ++ self.ab_items = [ustr(c) for c in 'ab'] ++ self.abcde_items = [ustr(c) for c in 'abcde'] ++ self.def_items = [ustr(c) for c in 'def'] ++ self.ab_weakset = WeakSet(self.ab_items) ++ self.abcde_weakset = WeakSet(self.abcde_items) ++ self.def_weakset = WeakSet(self.def_items) + self.letters = [ustr(c) for c in string.ascii_letters] + self.s = WeakSet(self.items) + self.d = dict.fromkeys(self.items) +@@ -67,6 +77,11 @@ + x = WeakSet(self.items + self.items2) + c = C(self.items2) + self.assertEqual(self.s.union(c), x) ++ del c ++ self.assertEqual(len(u), len(self.items) + len(self.items2)) ++ self.items2.pop() ++ gc.collect() ++ self.assertEqual(len(u), len(self.items) + len(self.items2)) + + def test_or(self): + i = self.s.union(self.items2) +@@ -74,14 +89,19 @@ + self.assertEqual(self.s | frozenset(self.items2), i) + + def test_intersection(self): +- i = self.s.intersection(self.items2) ++ s = WeakSet(self.letters) ++ i = s.intersection(self.items2) + for c in self.letters: +- self.assertEqual(c in i, c in self.d and c in self.items2) +- self.assertEqual(self.s, WeakSet(self.items)) ++ self.assertEqual(c in i, c in self.items2 and c in self.letters) ++ self.assertEqual(s, WeakSet(self.letters)) + self.assertEqual(type(i), WeakSet) + for C in set, frozenset, dict.fromkeys, list, tuple: + x = WeakSet([]) +- self.assertEqual(self.s.intersection(C(self.items2)), x) ++ self.assertEqual(i.intersection(C(self.items)), x) ++ self.assertEqual(len(i), len(self.items2)) ++ self.items2.pop() ++ gc.collect() ++ self.assertEqual(len(i), len(self.items2)) + + def test_isdisjoint(self): + self.assertTrue(self.s.isdisjoint(WeakSet(self.items2))) +@@ -112,6 +132,10 @@ + self.assertEqual(self.s, WeakSet(self.items)) + self.assertEqual(type(i), WeakSet) + self.assertRaises(TypeError, self.s.symmetric_difference, [[]]) ++ self.assertEqual(len(i), len(self.items) + len(self.items2)) ++ self.items2.pop() ++ gc.collect() ++ self.assertEqual(len(i), len(self.items) + len(self.items2)) + + def test_xor(self): + i = self.s.symmetric_difference(self.items2) +@@ -119,22 +143,28 @@ + self.assertEqual(self.s ^ frozenset(self.items2), i) + + def test_sub_and_super(self): +- pl, ql, rl = map(lambda s: [ustr(c) for c in s], ['ab', 'abcde', 'def']) +- p, q, r = map(WeakSet, (pl, ql, rl)) +- self.assertTrue(p < q) +- self.assertTrue(p <= q) +- self.assertTrue(q <= q) +- self.assertTrue(q > p) +- self.assertTrue(q >= p) +- self.assertFalse(q < r) +- self.assertFalse(q <= r) +- self.assertFalse(q > r) +- self.assertFalse(q >= r) ++ self.assertTrue(self.ab_weakset <= self.abcde_weakset) ++ self.assertTrue(self.abcde_weakset <= self.abcde_weakset) ++ self.assertTrue(self.abcde_weakset >= self.ab_weakset) ++ self.assertFalse(self.abcde_weakset <= self.def_weakset) ++ self.assertFalse(self.abcde_weakset >= self.def_weakset) + self.assertTrue(set('a').issubset('abc')) + self.assertTrue(set('abc').issuperset('a')) + self.assertFalse(set('a').issubset('cbs')) + self.assertFalse(set('cbs').issuperset('a')) + ++ def test_lt(self): ++ self.assertTrue(self.ab_weakset < self.abcde_weakset) ++ self.assertFalse(self.abcde_weakset < self.def_weakset) ++ self.assertFalse(self.ab_weakset < self.ab_weakset) ++ self.assertFalse(WeakSet() < WeakSet()) ++ ++ def test_gt(self): ++ self.assertTrue(self.abcde_weakset > self.ab_weakset) ++ self.assertFalse(self.abcde_weakset > self.def_weakset) ++ self.assertFalse(self.ab_weakset > self.ab_weakset) ++ self.assertFalse(WeakSet() > WeakSet()) ++ + def test_gc(self): + # Create a nest of cycles to exercise overall ref count check + s = WeakSet(Foo() for i in range(1000)) +@@ -359,6 +389,49 @@ + s.clear() + self.assertEqual(len(s), 0) + ++ def test_len_cycles(self): ++ N = 20 ++ items = [RefCycle() for i in range(N)] ++ s = WeakSet(items) ++ del items ++ it = iter(s) ++ try: ++ next(it) ++ except StopIteration: ++ pass ++ gc.collect() ++ n1 = len(s) ++ del it ++ gc.collect() ++ n2 = len(s) ++ # one item may be kept alive inside the iterator ++ self.assertIn(n1, (0, 1)) ++ self.assertEqual(n2, 0) ++ ++ def test_len_race(self): ++ # Extended sanity checks for len() in the face of cyclic collection ++ self.addCleanup(gc.set_threshold, *gc.get_threshold()) ++ for th in range(1, 100): ++ N = 20 ++ gc.collect(0) ++ gc.set_threshold(th, th, th) ++ items = [RefCycle() for i in range(N)] ++ s = WeakSet(items) ++ del items ++ # All items will be collected at next garbage collection pass ++ it = iter(s) ++ try: ++ next(it) ++ except StopIteration: ++ pass ++ n1 = len(s) ++ del it ++ n2 = len(s) ++ self.assertGreaterEqual(n1, 0) ++ self.assertLessEqual(n1, N) ++ self.assertGreaterEqual(n2, 0) ++ self.assertLessEqual(n2, n1) ++ + + def test_main(verbose=None): + support.run_unittest(TestWeakSet) +diff -r 3d0686d90f55 Lib/test/test_xmlrpc_net.py +--- a/Lib/test/test_xmlrpc_net.py ++++ b/Lib/test/test_xmlrpc_net.py +@@ -39,7 +39,7 @@ + def test_python_builders(self): + # Get the list of builders from the XMLRPC buildbot interface at + # python.org. +- server = xmlrpclib.ServerProxy("http://www.python.org/dev/buildbot/all/xmlrpc/") ++ server = xmlrpclib.ServerProxy("http://buildbot.python.org/all/xmlrpc/") + try: + builders = server.getAllBuilders() + except socket.error as e: +diff -r 3d0686d90f55 Lib/test/test_zipfile.py +--- a/Lib/test/test_zipfile.py ++++ b/Lib/test/test_zipfile.py +@@ -972,6 +972,46 @@ + with zipfile.ZipFile(TESTFN, mode="r") as zipfr: + self.assertEqual(zipfr.comment, comment2) + ++ # check that comments are correctly modified in append mode ++ with zipfile.ZipFile(TESTFN,mode="w") as zipf: ++ zipf.comment = b"original comment" ++ zipf.writestr("foo.txt", "O, for a Muse of Fire!") ++ with zipfile.ZipFile(TESTFN,mode="a") as zipf: ++ zipf.comment = b"an updated comment" ++ with zipfile.ZipFile(TESTFN,mode="r") as zipf: ++ self.assertEqual(zipf.comment, b"an updated comment") ++ ++ # check that comments are correctly shortened in append mode ++ with zipfile.ZipFile(TESTFN,mode="w") as zipf: ++ zipf.comment = b"original comment that's longer" ++ zipf.writestr("foo.txt", "O, for a Muse of Fire!") ++ with zipfile.ZipFile(TESTFN,mode="a") as zipf: ++ zipf.comment = b"shorter comment" ++ with zipfile.ZipFile(TESTFN,mode="r") as zipf: ++ self.assertEqual(zipf.comment, b"shorter comment") ++ ++ def test_unicode_comment(self): ++ with zipfile.ZipFile(TESTFN, "w", zipfile.ZIP_STORED) as zipf: ++ zipf.writestr("foo.txt", "O, for a Muse of Fire!") ++ with self.assertRaises(TypeError): ++ zipf.comment = "this is an error" ++ ++ def test_change_comment_in_empty_archive(self): ++ with zipfile.ZipFile(TESTFN, "a", zipfile.ZIP_STORED) as zipf: ++ self.assertFalse(zipf.filelist) ++ zipf.comment = b"this is a comment" ++ with zipfile.ZipFile(TESTFN, "r") as zipf: ++ self.assertEqual(zipf.comment, b"this is a comment") ++ ++ def test_change_comment_in_nonempty_archive(self): ++ with zipfile.ZipFile(TESTFN, "w", zipfile.ZIP_STORED) as zipf: ++ zipf.writestr("foo.txt", "O, for a Muse of Fire!") ++ with zipfile.ZipFile(TESTFN, "a", zipfile.ZIP_STORED) as zipf: ++ self.assertTrue(zipf.filelist) ++ zipf.comment = b"this is a comment" ++ with zipfile.ZipFile(TESTFN, "r") as zipf: ++ self.assertEqual(zipf.comment, b"this is a comment") ++ + def check_testzip_with_bad_crc(self, compression): + """Tests that files with bad CRCs return their name from testzip.""" + zipdata = self.zips_with_bad_crc[compression] +diff -r 3d0686d90f55 Lib/test/test_zlib.py +--- a/Lib/test/test_zlib.py ++++ b/Lib/test/test_zlib.py +@@ -66,24 +66,11 @@ + # Issue #10276 - check that inputs >=4GB are handled correctly. + class ChecksumBigBufferTestCase(unittest.TestCase): + +- def setUp(self): +- with open(support.TESTFN, "wb+") as f: +- f.seek(_4G) +- f.write(b"asdf") +- f.flush() +- self.mapping = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) +- +- def tearDown(self): +- self.mapping.close() +- support.unlink(support.TESTFN) +- +- @unittest.skipUnless(mmap, "mmap() is not available.") +- @unittest.skipUnless(sys.maxsize > _4G, "Can't run on a 32-bit system.") +- @unittest.skipUnless(support.is_resource_enabled("largefile"), +- "May use lots of disk space.") +- def test_big_buffer(self): +- self.assertEqual(zlib.crc32(self.mapping), 3058686908) +- self.assertEqual(zlib.adler32(self.mapping), 82837919) ++ @bigmemtest(size=_4G + 4, memuse=1, dry_run=False) ++ def test_big_buffer(self, size): ++ data = b"nyan" * (_1G + 1) ++ self.assertEqual(zlib.crc32(data), 1044521549) ++ self.assertEqual(zlib.adler32(data), 2256789997) + + + class ExceptionTestCase(unittest.TestCase): +diff -r 3d0686d90f55 Lib/test/testtar.tar +Binary file Lib/test/testtar.tar has changed +diff -r 3d0686d90f55 Lib/threading.py +--- a/Lib/threading.py ++++ b/Lib/threading.py +@@ -1007,6 +1007,9 @@ + def _set_daemon(self): + return True + ++ def _stop(self): ++ pass ++ + def join(self, timeout=None): + assert False, "cannot join a dummy thread" + +diff -r 3d0686d90f55 Lib/tkinter/__init__.py +--- a/Lib/tkinter/__init__.py ++++ b/Lib/tkinter/__init__.py +@@ -526,12 +526,19 @@ + + The type keyword specifies the form in which the data is + to be returned and should be an atom name such as STRING +- or FILE_NAME. Type defaults to STRING. ++ or FILE_NAME. Type defaults to STRING, except on X11, where the default ++ is to try UTF8_STRING and fall back to STRING. + + This command is equivalent to: + + selection_get(CLIPBOARD) + """ ++ if 'type' not in kw and self._windowingsystem == 'x11': ++ try: ++ kw['type'] = 'UTF8_STRING' ++ return self.tk.call(('clipboard', 'get') + self._options(kw)) ++ except TclError: ++ del kw['type'] + return self.tk.call(('clipboard', 'get') + self._options(kw)) + + def clipboard_clear(self, **kw): +@@ -613,8 +620,16 @@ + A keyword parameter selection specifies the name of + the selection and defaults to PRIMARY. A keyword + parameter displayof specifies a widget on the display +- to use.""" ++ to use. A keyword parameter type specifies the form of data to be ++ fetched, defaulting to STRING except on X11, where UTF8_STRING is tried ++ before STRING.""" + if 'displayof' not in kw: kw['displayof'] = self._w ++ if 'type' not in kw and self._windowingsystem == 'x11': ++ try: ++ kw['type'] = 'UTF8_STRING' ++ return self.tk.call(('selection', 'get') + self._options(kw)) ++ except TclError: ++ del kw['type'] + return self.tk.call(('selection', 'get') + self._options(kw)) + def selection_handle(self, command, **kw): + """Specify a function COMMAND to call if the X +@@ -1029,6 +1044,15 @@ + if displayof is None: + return ('-displayof', self._w) + return () ++ @property ++ def _windowingsystem(self): ++ """Internal function.""" ++ try: ++ return self._root()._windowingsystem_cached ++ except AttributeError: ++ ws = self._root()._windowingsystem_cached = \ ++ self.tk.call('tk', 'windowingsystem') ++ return ws + def _options(self, cnf, kw = None): + """Internal function.""" + if kw: +diff -r 3d0686d90f55 Lib/tkinter/ttk.py +--- a/Lib/tkinter/ttk.py ++++ b/Lib/tkinter/ttk.py +@@ -1253,7 +1253,7 @@ + + + def exists(self, item): +- """Returns True if the specified item is present in the three, ++ """Returns True if the specified item is present in the tree, + False otherwise.""" + return bool(self.tk.call(self._w, "exists", item)) + +diff -r 3d0686d90f55 Lib/tokenize.py +--- a/Lib/tokenize.py ++++ b/Lib/tokenize.py +@@ -292,9 +292,12 @@ + + def find_cookie(line): + try: +- line_string = line.decode('ascii') ++ # Decode as UTF-8. Either the line is an encoding declaration, ++ # in which case it should be pure ASCII, or it must be UTF-8 ++ # per default encoding. ++ line_string = line.decode('utf-8') + except UnicodeDecodeError: +- return None ++ raise SyntaxError("invalid or missing encoding declaration") + + matches = cookie_re.findall(line_string) + if not matches: +@@ -307,7 +310,7 @@ + raise SyntaxError("unknown encoding: " + encoding) + + if bom_found: +- if codec.name != 'utf-8': ++ if encoding != 'utf-8': + # This behaviour mimics the Python interpreter + raise SyntaxError('encoding problem: utf-8') + encoding += '-sig' +diff -r 3d0686d90f55 Lib/unittest/case.py +--- a/Lib/unittest/case.py ++++ b/Lib/unittest/case.py +@@ -62,7 +62,7 @@ + Unconditionally skip a test. + """ + def decorator(test_item): +- if not (isinstance(test_item, type) and issubclass(test_item, TestCase)): ++ if not isinstance(test_item, type): + @functools.wraps(test_item) + def skip_wrapper(*args, **kwargs): + raise SkipTest(reason) +diff -r 3d0686d90f55 Lib/unittest/loader.py +--- a/Lib/unittest/loader.py ++++ b/Lib/unittest/loader.py +@@ -34,6 +34,11 @@ + TestClass = type(classname, (case.TestCase,), attrs) + return suiteClass((TestClass(methodname),)) + ++def _jython_aware_splitext(path): ++ if path.lower().endswith('$py.class'): ++ return path[:-9] ++ return os.path.splitext(path)[0] ++ + + class TestLoader(object): + """ +@@ -221,7 +226,7 @@ + return os.path.dirname(full_path) + + def _get_name_from_path(self, path): +- path = os.path.splitext(os.path.normpath(path))[0] ++ path = _jython_aware_splitext(os.path.normpath(path)) + + _relpath = os.path.relpath(path, self._top_level_dir) + assert not os.path.isabs(_relpath), "Path must be within the project" +@@ -258,11 +263,11 @@ + yield _make_failed_import_test(name, self.suiteClass) + else: + mod_file = os.path.abspath(getattr(module, '__file__', full_path)) +- realpath = os.path.splitext(mod_file)[0] +- fullpath_noext = os.path.splitext(full_path)[0] ++ realpath = _jython_aware_splitext(mod_file) ++ fullpath_noext = _jython_aware_splitext(full_path) + if realpath.lower() != fullpath_noext.lower(): + module_dir = os.path.dirname(realpath) +- mod_name = os.path.splitext(os.path.basename(full_path))[0] ++ mod_name = _jython_aware_splitext(os.path.basename(full_path)) + expected_dir = os.path.dirname(full_path) + msg = ("%r module incorrectly imported from %r. Expected %r. " + "Is this module globally installed?") +diff -r 3d0686d90f55 Lib/unittest/test/test_skipping.py +--- a/Lib/unittest/test/test_skipping.py ++++ b/Lib/unittest/test/test_skipping.py +@@ -66,6 +66,21 @@ + self.assertEqual(result.skipped, [(test, "testing")]) + self.assertEqual(record, []) + ++ def test_skip_non_unittest_class(self): ++ @unittest.skip("testing") ++ class Mixin: ++ def test_1(self): ++ record.append(1) ++ class Foo(Mixin, unittest.TestCase): ++ pass ++ record = [] ++ result = unittest.TestResult() ++ test = Foo("test_1") ++ suite = unittest.TestSuite([test]) ++ suite.run(result) ++ self.assertEqual(result.skipped, [(test, "testing")]) ++ self.assertEqual(record, []) ++ + def test_expected_failure(self): + class Foo(unittest.TestCase): + @unittest.expectedFailure +diff -r 3d0686d90f55 Lib/urllib/parse.py +--- a/Lib/urllib/parse.py ++++ b/Lib/urllib/parse.py +@@ -44,16 +44,9 @@ + 'imap', 'wais', 'file', 'mms', 'https', 'shttp', + 'snews', 'prospero', 'rtsp', 'rtspu', 'rsync', '', + 'svn', 'svn+ssh', 'sftp', 'nfs', 'git', 'git+ssh'] +-non_hierarchical = ['gopher', 'hdl', 'mailto', 'news', +- 'telnet', 'wais', 'imap', 'snews', 'sip', 'sips'] + uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap', + 'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips', + 'mms', '', 'sftp'] +-uses_query = ['http', 'wais', 'imap', 'https', 'shttp', 'mms', +- 'gopher', 'rtsp', 'rtspu', 'sip', 'sips', ''] +-uses_fragment = ['ftp', 'hdl', 'http', 'gopher', 'news', +- 'nntp', 'wais', 'https', 'shttp', 'snews', +- 'file', 'prospero', ''] + + # Characters valid in scheme names + scheme_chars = ('abcdefghijklmnopqrstuvwxyz' +@@ -150,6 +143,9 @@ + port = self._hostinfo[1] + if port is not None: + port = int(port, 10) ++ # Return None on an illegal port ++ if not ( 0 <= port <= 65535): ++ return None + return port + + +@@ -283,8 +279,8 @@ + Note that we don't break the components up in smaller bits + (e.g. netloc is a single string) and we don't expand % escapes.""" + url, scheme, _coerce_result = _coerce_args(url, scheme) +- tuple = urlsplit(url, scheme, allow_fragments) +- scheme, netloc, url, query, fragment = tuple ++ splitresult = urlsplit(url, scheme, allow_fragments) ++ scheme, netloc, url, query, fragment = splitresult + if scheme in uses_params and ';' in url: + url, params = _splitparams(url) + else: +@@ -345,21 +341,21 @@ + if c not in scheme_chars: + break + else: +- try: +- # make sure "url" is not actually a port number (in which case +- # "scheme" is really part of the path +- _testportnum = int(url[i+1:]) +- except ValueError: +- scheme, url = url[:i].lower(), url[i+1:] ++ # make sure "url" is not actually a port number (in which case ++ # "scheme" is really part of the path) ++ rest = url[i+1:] ++ if not rest or any(c not in '0123456789' for c in rest): ++ # not a port number ++ scheme, url = url[:i].lower(), rest + + if url[:2] == '//': + netloc, url = _splitnetloc(url, 2) + if (('[' in netloc and ']' not in netloc) or + (']' in netloc and '[' not in netloc)): + raise ValueError("Invalid IPv6 URL") +- if allow_fragments and scheme in uses_fragment and '#' in url: ++ if allow_fragments and '#' in url: + url, fragment = url.split('#', 1) +- if scheme in uses_query and '?' in url: ++ if '?' in url: + url, query = url.split('?', 1) + v = SplitResult(scheme, netloc, url, query, fragment) + _parse_cache[key] = v +@@ -551,15 +547,15 @@ + encoding and errors: specify how to decode percent-encoded sequences + into Unicode characters, as accepted by the bytes.decode() method. + """ +- dict = {} ++ parsed_result = {} + pairs = parse_qsl(qs, keep_blank_values, strict_parsing, + encoding=encoding, errors=errors) + for name, value in pairs: +- if name in dict: +- dict[name].append(value) ++ if name in parsed_result: ++ parsed_result[name].append(value) + else: +- dict[name] = [value] +- return dict ++ parsed_result[name] = [value] ++ return parsed_result + + def parse_qsl(qs, keep_blank_values=False, strict_parsing=False, + encoding='utf-8', errors='replace'): +@@ -711,7 +707,7 @@ + def quote_from_bytes(bs, safe='/'): + """Like quote(), but accepts a bytes object rather than a str, and does + not perform string-to-bytes encoding. It always returns an ASCII string. +- quote_from_bytes(b'abc def\xab') -> 'abc%20def%AB' ++ quote_from_bytes(b'abc def\x3f') -> 'abc%20def%3f' + """ + if not isinstance(bs, (bytes, bytearray)): + raise TypeError("quote_from_bytes() expected bytes") +diff -r 3d0686d90f55 Lib/urllib/request.py +--- a/Lib/urllib/request.py ++++ b/Lib/urllib/request.py +@@ -95,6 +95,7 @@ + import sys + import time + import collections ++import warnings + + from urllib.error import URLError, HTTPError, ContentTooShortError + from urllib.parse import ( +@@ -794,7 +795,7 @@ + # allow for double- and single-quoted realm values + # (single quotes are a violation of the RFC, but appear in the wild) + rx = re.compile('(?:.*,)*[ \t]*([^ \t]+)[ \t]+' +- 'realm=(["\'])(.*?)\\2', re.I) ++ 'realm=(["\']?)([^"\']*)\\2', re.I) + + # XXX could pre-emptively send auth info already accepted (RFC 2617, + # end of section 2, and section 1.2 immediately after "credentials" +@@ -827,6 +828,9 @@ + mo = AbstractBasicAuthHandler.rx.search(authreq) + if mo: + scheme, quote, realm = mo.groups() ++ if quote not in ["'", '"']: ++ warnings.warn("Basic Auth Realm was unquoted", ++ UserWarning, 2) + if scheme.lower() == 'basic': + response = self.retry_http_basic_auth(host, req, realm) + if response and response.code != 401: +@@ -1062,8 +1066,9 @@ + if request.data is not None: # POST + data = request.data + if isinstance(data, str): +- raise TypeError("POST data should be bytes" +- " or an iterable of bytes. It cannot be str.") ++ msg = "POST data should be bytes or an iterable of bytes. "\ ++ "It cannot be of type str." ++ raise TypeError(msg) + if not request.has_header('Content-type'): + request.add_unredirected_header( + 'Content-type', +diff -r 3d0686d90f55 Lib/urllib/response.py +--- a/Lib/urllib/response.py ++++ b/Lib/urllib/response.py +@@ -61,11 +61,11 @@ + self.hookargs = hookargs + + def close(self): +- addbase.close(self) + if self.closehook: + self.closehook(*self.hookargs) + self.closehook = None + self.hookargs = None ++ addbase.close(self) + + class addinfo(addbase): + """class to add an info() method to an open file.""" +diff -r 3d0686d90f55 Lib/weakref.py +--- a/Lib/weakref.py ++++ b/Lib/weakref.py +@@ -78,7 +78,7 @@ + del self.data[key] + + def __len__(self): +- return sum(wr() is not None for wr in self.data.values()) ++ return len(self.data) - len(self._pending_removals) + + def __contains__(self, key): + try: +@@ -290,7 +290,7 @@ + return self.data[ref(key)] + + def __len__(self): +- return len(self.data) ++ return len(self.data) - len(self._pending_removals) + + def __repr__(self): + return "" % id(self) +diff -r 3d0686d90f55 Lib/xmlrpc/server.py +--- a/Lib/xmlrpc/server.py ++++ b/Lib/xmlrpc/server.py +@@ -1,4 +1,4 @@ +-"""XML-RPC Servers. ++r"""XML-RPC Servers. + + This module can be used to create simple XML-RPC servers + by creating a server and either installing functions, a +diff -r 3d0686d90f55 Lib/zipfile.py +--- a/Lib/zipfile.py ++++ b/Lib/zipfile.py +@@ -698,7 +698,7 @@ + self.compression = compression # Method of compression + self.mode = key = mode.replace('b', '')[0] + self.pwd = None +- self.comment = b'' ++ self._comment = b'' + + # Check if we were passed a file-like object + if isinstance(file, str): +@@ -774,7 +774,7 @@ + print(endrec) + size_cd = endrec[_ECD_SIZE] # bytes in central directory + offset_cd = endrec[_ECD_OFFSET] # offset of central directory +- self.comment = endrec[_ECD_COMMENT] # archive comment ++ self._comment = endrec[_ECD_COMMENT] # archive comment + + # "concat" is zero, unless zip was concatenated to another file + concat = endrec[_ECD_LOCATION] - size_cd - offset_cd +@@ -886,6 +886,24 @@ + else: + self.pwd = None + ++ @property ++ def comment(self): ++ """The comment text associated with the ZIP file.""" ++ return self._comment ++ ++ @comment.setter ++ def comment(self, comment): ++ if not isinstance(comment, bytes): ++ raise TypeError("comment: expected bytes, got %s" % type(comment)) ++ # check for valid comment length ++ if len(comment) >= ZIP_MAX_COMMENT: ++ if self.debug: ++ print('Archive comment is too long; truncating to %d bytes' ++ % ZIP_MAX_COMMENT) ++ comment = comment[:ZIP_MAX_COMMENT] ++ self._comment = comment ++ self._didModify = True ++ + def read(self, name, pwd=None): + """Return file bytes (as a string) for name.""" + with self.open(name, "r", pwd) as fp: +@@ -1287,18 +1305,11 @@ + centDirSize = min(centDirSize, 0xFFFFFFFF) + centDirOffset = min(centDirOffset, 0xFFFFFFFF) + +- # check for valid comment length +- if len(self.comment) >= ZIP_MAX_COMMENT: +- if self.debug > 0: +- msg = 'Archive comment is too long; truncating to %d bytes' \ +- % ZIP_MAX_COMMENT +- self.comment = self.comment[:ZIP_MAX_COMMENT] +- + endrec = struct.pack(structEndArchive, stringEndArchive, + 0, 0, centDirCount, centDirCount, +- centDirSize, centDirOffset, len(self.comment)) ++ centDirSize, centDirOffset, len(self._comment)) + self.fp.write(endrec) +- self.fp.write(self.comment) ++ self.fp.write(self._comment) + self.fp.flush() + + if not self._filePassed: +diff -r 3d0686d90f55 Mac/README +--- a/Mac/README ++++ b/Mac/README +@@ -66,7 +66,7 @@ + $ make + $ make install + +-This flag can be used a framework build of python, but also with a classic ++This flag can be used with a framework build of python, but also with a classic + unix build. Either way you will have to build python on Mac OS X 10.4 (or later) + with Xcode 2.1 (or later). You also have to install the 10.4u SDK when + installing Xcode. +@@ -214,8 +214,8 @@ + + Go to the directory "Mac/OSX/BuildScript". There you'll find a script + "build-installer.py" that does all the work. This will download and build +-a number of 3th-party libaries, configures and builds a framework Python, +-installs it, creates the installer pacakge files and then packs this in a ++a number of 3rd-party libaries, configures and builds a framework Python, ++installs it, creates the installer package files and then packs this in a + DMG image. + + The script will build a universal binary, you'll therefore have to run this +@@ -251,8 +251,8 @@ + Uninstalling a framework install, including the binary installer + ================================================================ + +-Uninstalling a framework can be done by manually removing all bits that got installed, +-that's true for both installations from source and installations using the binary installer. ++Uninstalling a framework can be done by manually removing all bits that got installed. ++That's true for both installations from source and installations using the binary installer. + Sadly enough OSX does not have a central uninstaller. + + The main bit of a framework install is the framework itself, installed in +diff -r 3d0686d90f55 Makefile.pre.in +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -161,7 +161,7 @@ + SUBDIRSTOO= Include Lib Misc + + # Files and directories to be distributed +-CONFIGFILES= configure configure.in acconfig.h pyconfig.h.in Makefile.pre.in ++CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in + DISTFILES= README ChangeLog $(CONFIGFILES) + DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy + DIST= $(DISTFILES) $(DISTDIRS) +@@ -917,7 +917,8 @@ + LIBSUBDIRS= tkinter tkinter/test tkinter/test/test_tkinter \ + tkinter/test/test_ttk site-packages test \ + test/capath test/data \ +- test/cjkencodings test/decimaltestdata test/xmltestdata test/subprocessdata \ ++ test/cjkencodings test/decimaltestdata test/xmltestdata \ ++ test/subprocessdata test/sndhdrdata \ + test/tracedmodules test/encoded_modules \ + concurrent concurrent/futures encodings \ + email email/mime email/test email/test/data \ +@@ -1210,7 +1211,7 @@ + $(SHELL) config.status --recheck + $(SHELL) config.status + +-# Rebuild the configure script from configure.in; also rebuild pyconfig.h.in ++# Rebuild the configure script from configure.ac; also rebuild pyconfig.h.in + autoconf: + (cd $(srcdir); autoconf -Wall) + (cd $(srcdir); autoheader -Wall) +diff -r 3d0686d90f55 Misc/ACKS +--- a/Misc/ACKS ++++ b/Misc/ACKS +@@ -145,10 +145,12 @@ + Brett Cannon + Mike Carlton + Terry Carroll ++Damien Cassou + Lorenzo M. Catucci + Donn Cave + Charles Cazabon + Per Cederqvist ++Matej Cepl + Octavian Cerna + Pascal Chambon + John Chandler +@@ -173,6 +175,7 @@ + Andrew Clegg + Brad Clements + Steve Clift ++Hervé Coatanhay + Nick Coghlan + Josh Cogliati + Dave Cole +@@ -306,6 +309,7 @@ + John Fouhy + Martin Franklin + Robin Friedrich ++Bradley Froehle + Ivan Frohne + Jim Fulton + Tadayoshi Funaba +@@ -329,6 +333,7 @@ + Dan Gass + Andrew Gaul + Stephen M. Gava ++Xavier de Gaye + Harry Henry Gebel + Marius Gedminas + Thomas Gellekum +@@ -341,6 +346,7 @@ + Michael Gilfix + Christoph Gohlke + Tim Golden ++Guilherme Gonçalves + Chris Gonnerman + David Goodger + Hans de Graaff +@@ -429,6 +435,7 @@ + Gerhard Häring + Fredrik Håård + Mihai Ibanescu ++Ali Ikinci + Lars Immisch + Bobby Impollonia + Meador Inge +@@ -447,9 +454,11 @@ + Jack Jansen + Bill Janssen + Thomas Jarosch ++Zbyszek JÄ™drzejewski-Szmek + Drew Jenkins + Flemming Kjær Jensen + MunSic Jeong ++Chris Jerdonek + Orjan Johansen + Fredrik Johansson + Gregory K. Johnson +@@ -507,6 +516,7 @@ + Marko Kohtala + Vlad Korolev + Joseph Koshy ++Jerzy Kozera + Maksim Kozyarchuk + Stefan Krah + Bob Kras +@@ -546,11 +556,13 @@ + Robert Lehmann + Petri Lehtinen + Luke Kenneth Casson Leighton ++Tshepang Lekhonkhobe + Marc-Andre Lemburg + John Lenton + Christopher Tur Lesniewski-Laas + Mark Levinson + William Lewis ++Akira Li + Xuanji Li + Robert van Liere + Ross Light +@@ -588,6 +600,7 @@ + Vladimir Marangozov + David Marek + Doug Marien ++Sven Marnach + Alex Martelli + Anthony Martin + Owen Martin +@@ -618,6 +631,7 @@ + Steven Miale + Trent Mick + Stan Mihai ++Stefan Mihaila + Aristotelis Mikropoulos + Damien Miller + Chad Miller +@@ -627,6 +641,7 @@ + Andrii V. Mishkovskyi + Dustin J. Mitchell + Dom Mitchell ++Florian Mladitsch + Doug Moen + The Dragon De Monsyne + Skip Montanaro +@@ -665,6 +680,7 @@ + Tim Northover + Joe Norton + Neal Norwitz ++Mikhail Novikov + Michal Nowikowski + Steffen Daode Nurpmeso + Nigel O'Brian +@@ -695,6 +711,7 @@ + Alexandre Parenteau + Dan Parisien + Harri Pasanen ++Joe Peterson + Randy Pausch + Samuele Pedroni + Marcel van der Peijl +@@ -776,6 +793,7 @@ + Mark Roddy + Kevin Rodgers + Giampaolo Rodola ++Adi Roiban + Mike Romberg + Armin Ronacher + Case Roole +@@ -839,6 +857,7 @@ + Denis Severson + Ian Seyer + Ha Shao ++Mark Shannon + Richard Shapiro + Bruce Sherwood + Alexander Shigin +@@ -849,6 +868,7 @@ + Itamar Shtull-Trauring + Eric Siegerman + Paul Sijben ++Tim Silk + Kirill Simonov + Nathan Paul Simons + Janne Sinkkonen +@@ -879,6 +899,7 @@ + Peter Stoehr + Casper Stoel + Michael Stone ++Serhiy Storchaka + Ken Stox + Dan Stromberg + Daniel Stutzbach +@@ -967,6 +988,7 @@ + Kevin Walzer + Rodrigo Steinmuller Wanderley + Greg Ward ++Zachary Ware + Barry Warsaw + Steve Waterbury + Bob Watson +@@ -988,6 +1010,7 @@ + Gerry Wiener + Frank Wierzbicki + Bryce "Zooko" Wilcox-O'Hearn ++Jakub Wilk + Jason Williams + John Williams + Sue Williams +@@ -1017,6 +1040,7 @@ + Florent Xicluna + Hirokazu Yamamoto + Ka-Ping Yee ++Jason Yeo + Bob Yodlowski + Danny Yoo + George Yoshida +diff -r 3d0686d90f55 Misc/NEWS +--- a/Misc/NEWS ++++ b/Misc/NEWS +@@ -2,6 +2,400 @@ + Python News + +++++++++++ + ++What's New in Python 3.2.4 ++========================== ++ ++*Release date: XX-XX-XXXX* ++ ++Core and Builtins ++----------------- ++ ++- Issue #15020: The program name used to search for Python's path is now ++ "python3" under Unix, not "python". ++ ++- Issue #15033: Fix the exit status bug when modules invoked using -m swith, ++ return the proper failure return value (1). Patch contributed by Jeff Knupp. ++ ++- Issue #12268: File readline, readlines and read() or readall() methods ++ no longer lose data when an underlying read system call is interrupted. ++ IOError is no longer raised due to a read system call returning EINTR ++ from within these methods. ++ ++- Issue #15142: Fix reference leak when deallocating instances of types ++ created using PyType_FromSpec(). ++ ++- Issue #10053: Don't close FDs when FileIO.__init__ fails. Loosely based on ++ the work by Hirokazu Yamamoto. ++ ++- Issue #14775: Fix a potential quadratic dict build-up due to the garbage ++ collector repeatedly trying to untrack dicts. ++ ++- Issue #14494: Fix __future__.py and its documentation to note that ++ absolute imports are the default behavior in 3.0 instead of 2.7. ++ Patch by Sven Marnach. ++ ++- Issue #14761: Fix potential leak on an error case in the import machinery. ++ ++- Issue #14699: Fix calling the classmethod descriptor directly. ++ ++- Issue #14433: Prevent msvcrt crash in interactive prompt when stdin ++ is closed. ++ ++- Issue #11603 (again): Setting __repr__ to __str__ now raises a RuntimeError ++ when repr() or str() is called on such an object. ++ ++- Issue #14658: Fix binding a special method to a builtin implementation of a ++ special method with a different name. ++ ++- Issue #14630: Fix a memory access bug for instances of a subclass of int ++ with value 0. ++ ++- Issue #14612: Fix jumping around with blocks by setting f_lineno. ++ ++- Issue #14607: Fix keyword-only arguments which started with ``__``. ++ ++- Issue #13889: Check and (if necessary) set FPU control word before calling ++ any of the dtoa.c string <-> float conversion functions, on MSVC builds of ++ Python. This fixes issues when embedding Python in a Delphi app. ++ ++- Issue #14474: Save and restore exception state in thread.start_new_thread() ++ while writing error message if the thread leaves a unhandled exception. ++ ++- Issue #13019: Fix potential reference leaks in bytearray.extend(). Patch ++ by Suman Saha. ++ ++- Issue #14378: Fix compiling ast.ImportFrom nodes with a "__future__" string as ++ the module name that was not interned. ++ ++- Issue #14331: Use significantly less stack space when importing modules by ++ allocating path buffers on the heap instead of the stack. ++ ++- Issue #14334: Prevent in a segfault in type.__getattribute__ when it was not ++ passed strings. ++ ++- Issue #1469629: Allow cycles through an object's __dict__ slot to be ++ collected. (For example if ``x.__dict__ is x``). ++ ++- Issue #14172: Fix reference leak when marshalling a buffer-like object ++ (other than a bytes object). ++ ++- 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 #14471: Fix a possible buffer overrun in the winreg module. ++ ++Library ++------- ++ ++- Issue #14990: Correctly fail with SyntaxError on invalid encoding ++ declaration. ++ ++- Issue #15247: FileIO now raises an error when given a file descriptor ++ pointing to a directory. ++ ++- Issue #5346: Preserve permissions of mbox, MMDF and Babyl mailbox ++ files on flush(). ++ ++- Issue #10571: Fix the "--sign" option of distutils' upload command. ++ Patch by Jakub Wilk. ++ ++- Issue #9559: If messages were only added, a new file is no longer ++ created and renamed over the old file when flush() is called on an ++ mbox, MMDF or Babyl mailbox. ++ ++- Issue #14653: email.utils.mktime_tz() no longer relies on system ++ mktime() when timezone offest is supplied. ++ ++- Fix GzipFile's handling of filenames given as bytes objects. ++ ++- Issue #15101: Make pool finalizer avoid joining current thread. ++ ++- Issue #15036: Mailbox no longer throws an error if a flush is done ++ between operations when removing or changing multiple items in mbox, ++ MMDF, or Babyl mailboxes. ++ ++- Issue #10133: Make multiprocessing deallocate buffer if socket read ++ fails. Patch by Hallvard B Furuseth. ++ ++- Issue #13854: Make multiprocessing properly handle non-integer ++ non-string argument to SystemExit. ++ ++- Issue #12157: Make pool.map() empty iterables correctly. Initial ++ patch by mouad. ++ ++- Issue #14992: os.makedirs(path, exist_ok=True) would raise an OSError ++ when the path existed and had the S_ISGID mode bit set when it was ++ not explicitly asked for. This is no longer an exception as mkdir ++ cannot control if the OS sets that bit for it or not. ++ ++- Issue #14962: Update text coloring in IDLE shell window after changing ++ options. Patch by Roger Serwy. ++ ++- Issue #10997: Prevent a duplicate entry in IDLE's "Recent Files" menu. ++ ++- Issue #14443: Tell rpmbuild to use the correct version of Python in ++ bdist_rpm. Initial patch by Ross Lagerwall. ++ ++- Issue #14929: Stop Idle 3.x from closing on Unicode decode errors when ++ grepping. Patch by Roger Serwy. ++ ++- Issue #12510: Attempting to get invalid tooltip no longer closes Idle. ++ Other tooltipss have been corrected or improved and the number of tests ++ has been tripled. Original patch by Roger Serwy. ++ ++- Issue #10365: File open dialog now works instead of crashing even when ++ the parent window is closed before the dialog. Patch by Roger Serwy. ++ ++- Issue #14876: Use user-selected font for highlight configuration. ++ ++- Issue #14920: Fix the help(urllib.parse) failure on locale C on terminals. ++ Have ascii characters in help. ++ ++- Issue #14863: Update the documentation of os.fdopen() to reflect the ++ fact that it's only a thin wrapper around open() anymore. ++ ++- Issue #14036: Add an additional check to validate that port in urlparse does ++ not go in illegal range and returns None. ++ ++- Issue #14875: Use float('inf') instead of float('1e66666') in the json module. ++ ++- Issue #14426: Correct the Date format in Expires attribute of Set-Cookie ++ Header in Cookie.py. ++ ++- Issue #14721: Send the correct 'Content-length: 0' header when the body is an ++ empty string ''. Initial Patch contributed by Arve Knudsen. ++ ++- Issue #14072: Fix parsing of 'tel' URIs in urlparse by making the check for ++ ports stricter. ++ ++- Issue #9374: Generic parsing of query and fragment portions of url for any ++ scheme. Supported both by RFC3986 and RFC2396. ++ ++- Issue #14798: Fix the functions in pyclbr to raise an ImportError ++ when the first part of a dotted name is not a package. Patch by ++ Xavier de Gaye. ++ ++- Issue #14829: Fix bisect and range() indexing with large indices ++ (>= 2 ** 32) under 64-bit Windows. ++ ++- Issue #14777: tkinter may return undecoded UTF-8 bytes as a string when ++ accessing the Tk clipboard. Modify clipboad_get() to first request type ++ UTF8_STRING when no specific type is requested in an X11 windowing ++ environment, falling back to the current default type STRING if that fails. ++ Original patch by Thomas Kluyver. ++ ++- Issue #12541: Be lenient with quotes around Realm field of HTTP Basic ++ Authentation in urllib2. ++ ++- Issue #14662: Prevent shutil failures on OS X when destination does not ++ support chflag operations. Patch by Hynek Schlawack. ++ ++- Issue #14157: Fix time.strptime failing without a year on February 29th. ++ Patch by Hynek Schlawack. ++ ++- Issue #14768: os.path.expanduser('~/a') doesn't works correctly when HOME is '/'. ++ ++- Issue #14741: Fix missing support for Ellipsis ('...') in parser module. ++ ++- Issue #14697: Fix missing support for set displays and set comprehensions in ++ parser module. ++ ++- Issue #14701: Fix missing support for 'raise ... from' in parser module. ++ ++- Issue #13183: Fix pdb skipping frames after hitting a breakpoint and running ++ step. Patch by Xavier de Gaye. ++ ++- Issue #14696: Fix parser module to understand 'nonlocal' declarations. ++ ++- Issue #10941: Fix imaplib.Internaldate2tuple to produce correct result near ++ the DST transition. Patch by Joe Peterson. ++ ++- Issue #9154: Fix parser module to understand function annotations. ++ ++- Issue #14664: It is now possible to use @unittest.skip{If,Unless} on a ++ test class that doesn't inherit from TestCase (i.e. a mixin). ++ ++- Issue #14160: TarFile.extractfile() failed to resolve symbolic links when ++ the links were not located in an archive subdirectory. ++ ++- Issue #14638: pydoc now treats non-string __name__ values as if they ++ were missing, instead of raising an error. ++ ++- Issue #13684: Fix httplib tunnel issue of infinite loops for certain sites ++ which send EOF without trailing \r\n. ++ ++- Issue #14629: Raise SyntaxError in tokenizer.detect_encoding if the ++ first two lines have non-UTF-8 characters without an encoding declaration. ++ ++- Issue #14308: Fix an exception when a "dummy" thread is in the threading ++ module's active list after a fork(). ++ ++- Issue #14538: HTMLParser can now parse correctly start tags that contain ++ a bare '/'. ++ ++- Issue #14452: SysLogHandler no longer inserts a UTF-8 BOM into the message. ++ ++- Issue #13496: Fix potential overflow in bisect.bisect algorithm when applied ++ to a collection of size > sys.maxsize / 2. ++ ++- 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 ++ the comment is set rather than at the time the zipfile is written. ++ ++- Issue #7978: socketserver now restarts the select() call when EINTR is ++ returned. This avoids crashing the server loop when a signal is received. ++ Patch by Jerzy Kozera. ++ ++- Issue #14496: Fix wrong name in idlelib/tabbedpages.py. ++ Patch by Popa Claudiu. ++ ++- Issue #14482: Raise a ValueError, not a NameError, when trying to create ++ a multiprocessing Client or Listener with an AF_UNIX type address under ++ Windows. Patch by Popa Claudiu. ++ ++- Issue #14151: Raise a ValueError, not a NameError, when trying to create ++ a multiprocessing Client or Listener with an AF_PIPE type address under ++ non-Windows platforms. Patch by Popa Claudiu. ++ ++- Issue #13872: socket.detach() now marks the socket closed (as mirrored ++ in the socket repr()). Patch by Matt Joiner. ++ ++- Issue #14406: Fix a race condition when using ``concurrent.futures.wait( ++ return_when=ALL_COMPLETED)``. Patch by Matt Joiner. ++ ++- Issue #14409: IDLE now properly executes commands in the Shell window ++ when it cannot read the normal config files on startup and ++ has to use the built-in default key bindings. ++ There was previously a bug in one of the defaults. ++ ++- Issue #10340: asyncore - properly handle EINVAL in dispatcher constructor on ++ OSX; avoid to call handle_connect in case of a disconnected socket which ++ was not meant to connect. ++ ++- Issue #12757: Fix the skipping of doctests when python is run with -OO so ++ that it works in unittest's verbose mode as well as non-verbose mode. ++ ++- Issue #3573: IDLE hangs when passing invalid command line args ++ (directory(ies) instead of file(s)) (Patch by Guilherme Polo) ++ ++- Issue #13694: asynchronous connect in asyncore.dispatcher does not set addr ++ attribute. ++ ++- Issue #11686: Added missing entries to email package __all__ lists ++ (mostly the new Bytes classes). ++ ++- Issue #10484: Fix the CGIHTTPServer's PATH_INFO handling problem. ++ ++- Issue #11199: Fix the with urllib which hangs on particular ftp urls. ++ ++- Issue #14062: Header objects now correctly respect the 'linesep' setting ++ when processed by BytesParser (which smtplib.SMTP.send_message uses). ++ ++- Issue #14291: Email now defaults to utf-8 for non-ASCII unicode headers ++ instead of raising an error. This fixes a regression relative to 2.7. ++ ++- Issue #5219: Prevent event handler cascade in IDLE. ++ ++- Issue #14184: Increase the default stack size for secondary threads on ++ Mac OS X to avoid interpreter crashes when using threads on 10.7. ++ ++- Issue #10543: Fix unittest test discovery with Jython bytecode files. ++ ++- Issue #14252: Fix subprocess.Popen.terminate() to not raise an error under ++ Windows when the child process has already exited. ++ ++- Issue #14195: An issue that caused weakref.WeakSet instances to incorrectly ++ return True for a WeakSet instance 'a' in both 'a < a' and 'a > a' has been ++ fixed. ++ ++- Issue #14177: marshal.loads() now raises TypeError when given an unicode ++ string. Patch by Guilherme Gonçalves. ++ ++- Issue #14159: Fix the len() of weak containers (WeakSet, WeakKeyDictionary, ++ WeakValueDictionary) to return a better approximation when some objects ++ are dead or dying. Moreover, the implementation is now O(1) rather than ++ O(n). ++ ++- Issue #13125: Silence spurious test_lib2to3 output when in non-verbose mode. ++ Patch by Mikhail Novikov. ++ ++- Issue #13447: Add a test file to host regression tests for bugs in the ++ scripts found in the Tools directory. ++ ++- Issue #8033: sqlite3: Fix 64-bit integer handling in user functions ++ on 32-bit architectures. Initial patch by Philippe Devalkeneer. ++ ++Extension Modules ++----------------- ++ ++- Issue #15000: Support the "unique" x32 architecture in _posixsubprocess.c. ++ ++- Issue #9041: An issue in ctypes.c_longdouble, ctypes.c_double, and ++ ctypes.c_float that caused an incorrect exception to be returned in the ++ case of overflow has been fixed. ++ ++- Issue #14212: The re module didn't retain a reference to buffers it was ++ scanning, resulting in segfaults. ++ ++Tests ++----- ++ ++- Issue #15300: Ensure the temporary test working directories are in the same ++ parent folder when running tests in multiprocess mode from a Python build. ++ Patch by Chris Jerdonek. ++ ++- test_nntplib now tolerates being run from behind NNTP gateways that add ++ "X-Antivirus" headers to articles ++ ++- Issue #15043: test_gdb is now skipped entirely if gdb security settings ++ block loading of the gdb hooks ++ ++- Issue #14026: In test_cmd_line_script, check that sys.argv is populated ++ correctly for the various invocation approaches (Patch by Jason Yeo) ++ ++- Issue #14032: Fix incorrect variable name in test_cmd_line_script debugging ++ message (Patch by Jason Yeo) ++ ++- Issue #14589: Update certificate chain for sha256.tbs-internet.com, fixing ++ a test failure in test_ssl. ++ ++Build ++----- ++ ++- Issue #14472: Update .gitignore. Patch by Matej Cepl. ++ ++- The Windows build now uses OpenSSL 1.0.0j and bzip2 1.0.6. ++ ++- Issue #14557: Fix extensions build on HP-UX. Patch by Adi Roiban. ++ ++- Issue #14437: Fix building the _io module under Cygwin. ++ ++- Issue #14387: Do not include accu.h from Python.h. ++ ++- Issue #14359: Only use O_CLOEXEC in _posixmodule.c if it is defined. ++ Based on patch from Hervé Coatanhay. ++ ++Documentation ++------------- ++ ++- Issue #13557: Clarify effect of giving two different namespaces to exec or ++ execfile(). ++ ++- Issue #8799: Fix and improve the threading.Condition documentation. ++ ++- Issue #14943: Correct a default argument value for winreg.OpenKey ++ and correctly list the argument names in the function's explanation. ++ ++- Issue #14034: added the argparse tutorial. ++ ++Tools/Demos ++----------- ++ ++- Issue #14695: Fix missing support for starred assignments in ++ Tools/parser/unparse.py. ++ ++ + What's New in Python 3.2.3? + =========================== + +@@ -156,9 +550,6 @@ + Library + ------- + +-- Issue #8033: sqlite3: Fix 64-bit integer handling in user functions +- on 32-bit architectures. Initial patch by Philippe Devalkeneer. +- + - HTMLParser is now able to handle slashes in the start tag. + + - Issue #14001: CVE-2012-0845: xmlrpc: Fix an endless loop in +@@ -773,6 +1164,9 @@ + - Issue #12451: xml.dom.pulldom: parse() now opens files in binary mode instead + of the text mode (using the locale encoding) to avoid encoding issues. + ++- Issue #14443: Ensure that .py files are byte-compiled with the correct Python ++ executable within bdist_rpm even on older versions of RPM ++ + Extension Modules + ----------------- + +diff -r 3d0686d90f55 Modules/_bisectmodule.c +--- a/Modules/_bisectmodule.c ++++ b/Modules/_bisectmodule.c +@@ -3,6 +3,7 @@ + Converted to C by Dmitry Vasiliev (dima at hlabs.spb.ru). + */ + ++#define PY_SSIZE_T_CLEAN + #include "Python.h" + + static Py_ssize_t +@@ -21,7 +22,10 @@ + return -1; + } + while (lo < hi) { +- mid = (lo + hi) / 2; ++ /* The (size_t)cast ensures that the addition and subsequent division ++ are performed as unsigned operations, avoiding difficulties from ++ signed overflow. (See issue 13496.) */ ++ mid = ((size_t)lo + hi) / 2; + litem = PySequence_GetItem(list, mid); + if (litem == NULL) + return -1; +@@ -121,7 +125,10 @@ + return -1; + } + while (lo < hi) { +- mid = (lo + hi) / 2; ++ /* The (size_t)cast ensures that the addition and subsequent division ++ are performed as unsigned operations, avoiding difficulties from ++ signed overflow. (See issue 13496.) */ ++ mid = ((size_t)lo + hi) / 2; + litem = PySequence_GetItem(list, mid); + if (litem == NULL) + return -1; +@@ -186,7 +193,7 @@ + if (PyList_Insert(list, index, item) < 0) + return NULL; + } else { +- result = PyObject_CallMethod(list, "insert", "iO", index, item); ++ result = PyObject_CallMethod(list, "insert", "nO", index, item); + if (result == NULL) + return NULL; + Py_DECREF(result); +diff -r 3d0686d90f55 Modules/_ctypes/cfield.c +--- a/Modules/_ctypes/cfield.c ++++ b/Modules/_ctypes/cfield.c +@@ -1002,12 +1002,8 @@ + long double x; + + x = PyFloat_AsDouble(value); +- if (x == -1 && PyErr_Occurred()) { +- PyErr_Format(PyExc_TypeError, +- " float expected instead of %s instance", +- value->ob_type->tp_name); ++ if (x == -1 && PyErr_Occurred()) + return NULL; +- } + memcpy(ptr, &x, sizeof(long double)); + _RET(value); + } +@@ -1026,12 +1022,8 @@ + double x; + + x = PyFloat_AsDouble(value); +- if (x == -1 && PyErr_Occurred()) { +- PyErr_Format(PyExc_TypeError, +- " float expected instead of %s instance", +- value->ob_type->tp_name); ++ if (x == -1 && PyErr_Occurred()) + return NULL; +- } + memcpy(ptr, &x, sizeof(double)); + _RET(value); + } +@@ -1050,12 +1042,8 @@ + double x; + + x = PyFloat_AsDouble(value); +- if (x == -1 && PyErr_Occurred()) { +- PyErr_Format(PyExc_TypeError, +- " float expected instead of %s instance", +- value->ob_type->tp_name); ++ if (x == -1 && PyErr_Occurred()) + return NULL; +- } + #ifdef WORDS_BIGENDIAN + if (_PyFloat_Pack8(x, (unsigned char *)ptr, 1)) + return NULL; +@@ -1082,12 +1070,8 @@ + float x; + + x = (float)PyFloat_AsDouble(value); +- if (x == -1 && PyErr_Occurred()) { +- PyErr_Format(PyExc_TypeError, +- " float expected instead of %s instance", +- value->ob_type->tp_name); ++ if (x == -1 && PyErr_Occurred()) + return NULL; +- } + memcpy(ptr, &x, sizeof(x)); + _RET(value); + } +@@ -1106,12 +1090,8 @@ + float x; + + x = (float)PyFloat_AsDouble(value); +- if (x == -1 && PyErr_Occurred()) { +- PyErr_Format(PyExc_TypeError, +- " float expected instead of %s instance", +- value->ob_type->tp_name); ++ if (x == -1 && PyErr_Occurred()) + return NULL; +- } + #ifdef WORDS_BIGENDIAN + if (_PyFloat_Pack4(x, (unsigned char *)ptr, 1)) + return NULL; +diff -r 3d0686d90f55 Modules/_io/_iomodule.c +--- a/Modules/_io/_iomodule.c ++++ b/Modules/_io/_iomodule.c +@@ -58,7 +58,7 @@ + "\n" + "At the top of the I/O hierarchy is the abstract base class IOBase. It\n" + "defines the basic interface to a stream. Note, however, that there is no\n" +-"seperation between reading and writing to streams; implementations are\n" ++"separation between reading and writing to streams; implementations are\n" + "allowed to throw an IOError if they do not support a given operation.\n" + "\n" + "Extending IOBase is RawIOBase which deals simply with the reading and\n" +diff -r 3d0686d90f55 Modules/_io/_iomodule.h +--- a/Modules/_io/_iomodule.h ++++ b/Modules/_io/_iomodule.h +@@ -57,6 +57,11 @@ + int translated, int universal, PyObject *readnl, + Py_UNICODE *start, Py_UNICODE *end, Py_ssize_t *consumed); + ++/* Return 1 if an EnvironmentError with errno == EINTR is set (and then ++ clears the error indicator), 0 otherwise. ++ Should only be called when PyErr_Occurred() is true. ++*/ ++extern int _PyIO_trap_eintr(void); + + #define DEFAULT_BUFFER_SIZE (8 * 1024) /* bytes */ + +@@ -67,7 +72,7 @@ + PyObject *filename; /* Not used, but part of the IOError object */ + Py_ssize_t written; + } PyBlockingIOErrorObject; +-PyAPI_DATA(PyObject *) PyExc_BlockingIOError; ++extern PyObject *PyExc_BlockingIOError; + + /* + * Offset type for positioning. +diff -r 3d0686d90f55 Modules/_io/bufferedio.c +--- a/Modules/_io/bufferedio.c ++++ b/Modules/_io/bufferedio.c +@@ -730,8 +730,8 @@ + clears the error indicator), 0 otherwise. + Should only be called when PyErr_Occurred() is true. + */ +-static int +-_trap_eintr(void) ++int ++_PyIO_trap_eintr(void) + { + static PyObject *eintr_int = NULL; + PyObject *typ, *val, *tb; +@@ -1314,7 +1314,7 @@ + */ + do { + res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_readinto, memobj, NULL); +- } while (res == NULL && _trap_eintr()); ++ } while (res == NULL && _PyIO_trap_eintr()); + Py_DECREF(memobj); + if (res == NULL) + return -1; +@@ -1742,7 +1742,7 @@ + errno = 0; + res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_write, memobj, NULL); + errnum = errno; +- } while (res == NULL && _trap_eintr()); ++ } while (res == NULL && _PyIO_trap_eintr()); + Py_DECREF(memobj); + if (res == NULL) + return -1; +diff -r 3d0686d90f55 Modules/_io/fileio.c +--- a/Modules/_io/fileio.c ++++ b/Modules/_io/fileio.c +@@ -166,22 +166,15 @@ + directories, so we need a check. */ + + static int +-dircheck(fileio* self, const char *name) ++dircheck(fileio* self, PyObject *nameobj) + { + #if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR) + struct stat buf; + if (self->fd < 0) + return 0; + if (fstat(self->fd, &buf) == 0 && S_ISDIR(buf.st_mode)) { +- char *msg = strerror(EISDIR); +- PyObject *exc; +- if (internal_close(self)) +- return -1; +- +- exc = PyObject_CallFunction(PyExc_IOError, "(iss)", +- EISDIR, msg, name); +- PyErr_SetObject(PyExc_IOError, exc); +- Py_XDECREF(exc); ++ errno = EISDIR; ++ PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, nameobj); + return -1; + } + #endif +@@ -224,12 +217,17 @@ + int flags = 0; + int fd = -1; + int closefd = 1; ++ int fd_is_own = 0; + + assert(PyFileIO_Check(oself)); + if (self->fd >= 0) { +- /* Have to close the existing file first. */ +- if (internal_close(self) < 0) +- return -1; ++ if (self->closefd) { ++ /* Have to close the existing file first. */ ++ if (internal_close(self) < 0) ++ return -1; ++ } ++ else ++ self->fd = -1; + } + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|si:fileio", +@@ -358,6 +356,7 @@ + #endif + self->fd = open(name, flags, 0666); + Py_END_ALLOW_THREADS ++ fd_is_own = 1; + if (self->fd < 0) { + #ifdef MS_WINDOWS + if (widename != NULL) +@@ -367,9 +366,9 @@ + PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); + goto error; + } +- if (dircheck(self, name) < 0) +- goto error; + } ++ if (dircheck(self, nameobj) < 0) ++ goto error; + + #if defined(MS_WINDOWS) || defined(__CYGWIN__) + /* don't translate newlines (\r\n <=> \n) */ +@@ -384,13 +383,8 @@ + end of file (otherwise, it might be done only on the + first write()). */ + PyObject *pos = portable_lseek(self->fd, NULL, 2); +- if (pos == NULL) { +- if (closefd) { +- close(self->fd); +- self->fd = -1; +- } ++ if (pos == NULL) + goto error; +- } + Py_DECREF(pos); + } + +@@ -398,6 +392,8 @@ + + error: + ret = -1; ++ if (!fd_is_own) ++ self->fd = -1; + if (self->fd >= 0) + internal_close(self); + +@@ -602,6 +598,13 @@ + if (n == 0) + break; + if (n < 0) { ++ if (errno == EINTR) { ++ if (PyErr_CheckSignals()) { ++ Py_DECREF(result); ++ return NULL; ++ } ++ continue; ++ } + if (total > 0) + break; + if (errno == EAGAIN) { +diff -r 3d0686d90f55 Modules/_io/iobase.c +--- a/Modules/_io/iobase.c ++++ b/Modules/_io/iobase.c +@@ -482,8 +482,14 @@ + + if (has_peek) { + PyObject *readahead = PyObject_CallMethod(self, "peek", "i", 1); +- if (readahead == NULL) ++ if (readahead == NULL) { ++ /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() ++ when EINTR occurs so we needn't do it ourselves. */ ++ if (_PyIO_trap_eintr()) { ++ continue; ++ } + goto fail; ++ } + if (!PyBytes_Check(readahead)) { + PyErr_Format(PyExc_IOError, + "peek() should have returned a bytes object, " +@@ -516,8 +522,14 @@ + } + + b = PyObject_CallMethod(self, "read", "n", nreadahead); +- if (b == NULL) ++ if (b == NULL) { ++ /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() ++ when EINTR occurs so we needn't do it ourselves. */ ++ if (_PyIO_trap_eintr()) { ++ continue; ++ } + goto fail; ++ } + if (!PyBytes_Check(b)) { + PyErr_Format(PyExc_IOError, + "read() should have returned a bytes object, " +@@ -826,6 +838,11 @@ + PyObject *data = PyObject_CallMethod(self, "read", + "i", DEFAULT_BUFFER_SIZE); + if (!data) { ++ /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() ++ when EINTR occurs so we needn't do it ourselves. */ ++ if (_PyIO_trap_eintr()) { ++ continue; ++ } + Py_DECREF(chunks); + return NULL; + } +diff -r 3d0686d90f55 Modules/_io/textio.c +--- a/Modules/_io/textio.c ++++ b/Modules/_io/textio.c +@@ -627,7 +627,7 @@ + "enabled. With this enabled, on input, the lines endings '\\n', '\\r',\n" + "or '\\r\\n' are translated to '\\n' before being returned to the\n" + "caller. Conversely, on output, '\\n' is translated to the system\n" +- "default line seperator, os.linesep. If newline is any other of its\n" ++ "default line separator, os.linesep. If newline is any other of its\n" + "legal values, that newline becomes the newline when the file is read\n" + "and it is returned untranslated. On output, '\\n' is converted to the\n" + "newline.\n" +@@ -1541,8 +1541,14 @@ + /* Keep reading chunks until we have n characters to return */ + while (remaining > 0) { + res = textiowrapper_read_chunk(self); +- if (res < 0) ++ if (res < 0) { ++ /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() ++ when EINTR occurs so we needn't do it ourselves. */ ++ if (_PyIO_trap_eintr()) { ++ continue; ++ } + goto fail; ++ } + if (res == 0) /* EOF */ + break; + if (chunks == NULL) { +@@ -1701,8 +1707,14 @@ + while (!self->decoded_chars || + !PyUnicode_GET_SIZE(self->decoded_chars)) { + res = textiowrapper_read_chunk(self); +- if (res < 0) ++ if (res < 0) { ++ /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() ++ when EINTR occurs so we needn't do it ourselves. */ ++ if (_PyIO_trap_eintr()) { ++ continue; ++ } + goto error; ++ } + if (res == 0) + break; + } +diff -r 3d0686d90f55 Modules/_json.c +--- a/Modules/_json.c ++++ b/Modules/_json.c +@@ -634,7 +634,7 @@ + + /* read key */ + if (str[idx] != '"') { +- raise_errmsg("Expecting property name", pystr, idx); ++ raise_errmsg("Expecting property name enclosed in double quotes", pystr, idx); + goto bail; + } + key = scanstring_unicode(pystr, idx + 1, strict, &next_idx); +@@ -655,7 +655,7 @@ + /* skip whitespace between key and : delimiter, read :, skip whitespace */ + while (idx <= end_idx && IS_WHITESPACE(str[idx])) idx++; + if (idx > end_idx || str[idx] != ':') { +- raise_errmsg("Expecting : delimiter", pystr, idx); ++ raise_errmsg("Expecting ':' delimiter", pystr, idx); + goto bail; + } + idx++; +@@ -695,7 +695,7 @@ + break; + } + else if (str[idx] != ',') { +- raise_errmsg("Expecting , delimiter", pystr, idx); ++ raise_errmsg("Expecting ',' delimiter", pystr, idx); + goto bail; + } + idx++; +@@ -777,7 +777,7 @@ + break; + } + else if (str[idx] != ',') { +- raise_errmsg("Expecting , delimiter", pystr, idx); ++ raise_errmsg("Expecting ',' delimiter", pystr, idx); + goto bail; + } + idx++; +diff -r 3d0686d90f55 Modules/_multiprocessing/socket_connection.c +--- a/Modules/_multiprocessing/socket_connection.c ++++ b/Modules/_multiprocessing/socket_connection.c +@@ -117,7 +117,7 @@ + conn_recv_string(ConnectionObject *conn, char *buffer, + size_t buflength, char **newbuffer, size_t maxlength) + { +- int res; ++ Py_ssize_t res; + UINT32 ulength; + + *newbuffer = NULL; +@@ -132,20 +132,23 @@ + if (ulength > maxlength) + return MP_BAD_MESSAGE_LENGTH; + +- if (ulength <= buflength) { +- Py_BEGIN_ALLOW_THREADS +- res = _conn_recvall(conn->handle, buffer, (size_t)ulength); +- Py_END_ALLOW_THREADS +- return res < 0 ? res : ulength; +- } else { +- *newbuffer = PyMem_Malloc((size_t)ulength); +- if (*newbuffer == NULL) ++ if (ulength > buflength) { ++ *newbuffer = buffer = PyMem_Malloc((size_t)ulength); ++ if (buffer == NULL) + return MP_MEMORY_ERROR; +- Py_BEGIN_ALLOW_THREADS +- res = _conn_recvall(conn->handle, *newbuffer, (size_t)ulength); +- Py_END_ALLOW_THREADS +- return res < 0 ? (Py_ssize_t)res : (Py_ssize_t)ulength; + } ++ ++ Py_BEGIN_ALLOW_THREADS ++ res = _conn_recvall(conn->handle, buffer, (size_t)ulength); ++ Py_END_ALLOW_THREADS ++ ++ if (res >= 0) { ++ res = (Py_ssize_t)ulength; ++ } else if (*newbuffer != NULL) { ++ PyMem_Free(*newbuffer); ++ *newbuffer = NULL; ++ } ++ return res; + } + + /* +diff -r 3d0686d90f55 Modules/_multiprocessing/win32_functions.c +--- a/Modules/_multiprocessing/win32_functions.c ++++ b/Modules/_multiprocessing/win32_functions.c +@@ -244,6 +244,7 @@ + Py_INCREF(&Win32Type); + + WIN32_CONSTANT(F_DWORD, ERROR_ALREADY_EXISTS); ++ WIN32_CONSTANT(F_DWORD, ERROR_NO_DATA); + WIN32_CONSTANT(F_DWORD, ERROR_PIPE_BUSY); + WIN32_CONSTANT(F_DWORD, ERROR_PIPE_CONNECTED); + WIN32_CONSTANT(F_DWORD, ERROR_SEM_TIMEOUT); +diff -r 3d0686d90f55 Modules/_posixsubprocess.c +--- a/Modules/_posixsubprocess.c ++++ b/Modules/_posixsubprocess.c +@@ -175,8 +175,15 @@ + * chooses to break compatibility with all existing binaries. Highly Unlikely. + */ + struct linux_dirent { ++#if defined(__x86_64__) && defined(__ILP32__) ++ /* Support the wacky x32 ABI (fake 32-bit userspace speaking to x86_64 ++ * kernel interfaces) - https://sites.google.com/site/x32abi/ */ ++ unsigned long long d_ino; ++ unsigned long long d_off; ++#else + unsigned long d_ino; /* Inode number */ + unsigned long d_off; /* Offset to next linux_dirent */ ++#endif + unsigned short d_reclen; /* Length of this linux_dirent */ + char d_name[256]; /* Filename (null-terminated) */ + }; +@@ -202,7 +209,18 @@ + int fd_dir_fd; + if (start_fd >= end_fd) + return; +- fd_dir_fd = open(FD_DIR, O_RDONLY | O_CLOEXEC, 0); ++#ifdef O_CLOEXEC ++ fd_dir_fd = open(FD_DIR, O_RDONLY | O_CLOEXEC, 0); ++#else ++ fd_dir_fd = open(FD_DIR, O_RDONLY, 0); ++#ifdef FD_CLOEXEC ++ { ++ int old = fcntl(fd_dir_fd, F_GETFD); ++ if (old != -1) ++ fcntl(fd_dir_fd, F_SETFD, old | FD_CLOEXEC); ++ } ++#endif ++#endif + if (fd_dir_fd == -1) { + /* No way to get a list of open fds. */ + _close_fds_by_brute_force(start_fd, end_fd, py_fds_to_keep); +diff -r 3d0686d90f55 Modules/_sre.c +--- a/Modules/_sre.c ++++ b/Modules/_sre.c +@@ -1664,7 +1664,7 @@ + } + + static void* +-getstring(PyObject* string, Py_ssize_t* p_length, int* p_charsize) ++getstring(PyObject* string, Py_ssize_t* p_length, int* p_charsize, Py_buffer *view) + { + /* given a python object, return a data pointer, a length (in + characters), and a character size. return NULL if the object +@@ -1674,7 +1674,6 @@ + Py_ssize_t size, bytes; + int charsize; + void* ptr; +- Py_buffer view; + + /* Unicode objects do not support the buffer API. So, get the data + directly instead. */ +@@ -1686,26 +1685,21 @@ + } + + /* get pointer to string buffer */ +- view.len = -1; ++ view->len = -1; + buffer = Py_TYPE(string)->tp_as_buffer; + if (!buffer || !buffer->bf_getbuffer || +- (*buffer->bf_getbuffer)(string, &view, PyBUF_SIMPLE) < 0) { ++ (*buffer->bf_getbuffer)(string, view, PyBUF_SIMPLE) < 0) { + PyErr_SetString(PyExc_TypeError, "expected string or buffer"); + return NULL; + } + + /* determine buffer size */ +- bytes = view.len; +- ptr = view.buf; +- +- /* Release the buffer immediately --- possibly dangerous +- but doing something else would require some re-factoring +- */ +- PyBuffer_Release(&view); ++ bytes = view->len; ++ ptr = view->buf; + + if (bytes < 0) { + PyErr_SetString(PyExc_TypeError, "buffer has negative size"); +- return NULL; ++ goto err; + } + + /* determine character size */ +@@ -1719,7 +1713,7 @@ + #endif + else { + PyErr_SetString(PyExc_TypeError, "buffer size mismatch"); +- return NULL; ++ goto err; + } + + *p_length = size; +@@ -1728,8 +1722,13 @@ + if (ptr == NULL) { + PyErr_SetString(PyExc_ValueError, + "Buffer is NULL"); ++ goto err; + } + return ptr; ++ err: ++ PyBuffer_Release(view); ++ view->buf = NULL; ++ return NULL; + } + + LOCAL(PyObject*) +@@ -1747,20 +1746,21 @@ + state->lastmark = -1; + state->lastindex = -1; + +- ptr = getstring(string, &length, &charsize); ++ state->buffer.buf = NULL; ++ ptr = getstring(string, &length, &charsize, &state->buffer); + if (!ptr) +- return NULL; +- +- if (charsize == 1 && pattern->charsize > 1) { +- PyErr_SetString(PyExc_TypeError, ++ goto err; ++ ++ if (charsize == 1 && pattern->charsize > 1) { ++ PyErr_SetString(PyExc_TypeError, + "can't use a string pattern on a bytes-like object"); +- return NULL; +- } +- if (charsize > 1 && pattern->charsize == 1) { +- PyErr_SetString(PyExc_TypeError, ++ goto err; ++ } ++ if (charsize > 1 && pattern->charsize == 1) { ++ PyErr_SetString(PyExc_TypeError, + "can't use a bytes pattern on a string-like object"); +- return NULL; +- } ++ goto err; ++ } + + /* adjust boundaries */ + if (start < 0) +@@ -1797,11 +1797,17 @@ + state->lower = sre_lower; + + return string; ++ err: ++ if (state->buffer.buf) ++ PyBuffer_Release(&state->buffer); ++ return NULL; + } + + LOCAL(void) + state_fini(SRE_STATE* state) + { ++ if (state->buffer.buf) ++ PyBuffer_Release(&state->buffer); + Py_XDECREF(state->string); + data_stack_dealloc(state); + } +@@ -1863,6 +1869,8 @@ + { + if (self->weakreflist != NULL) + PyObject_ClearWeakRefs((PyObject *) self); ++ if (self->view.buf) ++ PyBuffer_Release(&self->view); + Py_XDECREF(self->pattern); + Py_XDECREF(self->groupindex); + Py_XDECREF(self->indexgroup); +@@ -2297,6 +2305,7 @@ + Py_ssize_t i, b, e; + int bint; + int filter_is_callable; ++ Py_buffer view; + + if (PyCallable_Check(ptemplate)) { + /* sub/subn takes either a function or a template */ +@@ -2306,7 +2315,8 @@ + } else { + /* if not callable, check if it's a literal string */ + int literal; +- ptr = getstring(ptemplate, &n, &bint); ++ view.buf = NULL; ++ ptr = getstring(ptemplate, &n, &bint, &view); + b = bint; + if (ptr) { + if (b == 1) { +@@ -2320,6 +2330,8 @@ + PyErr_Clear(); + literal = 0; + } ++ if (view.buf) ++ PyBuffer_Release(&view); + if (literal) { + filter = ptemplate; + Py_INCREF(filter); +@@ -2661,6 +2673,7 @@ + Py_ssize_t groups = 0; + PyObject* groupindex = NULL; + PyObject* indexgroup = NULL; ++ + if (!PyArg_ParseTuple(args, "OiO!|nOO", &pattern, &flags, + &PyList_Type, &code, &groups, + &groupindex, &indexgroup)) +@@ -2675,6 +2688,7 @@ + self->pattern = NULL; + self->groupindex = NULL; + self->indexgroup = NULL; ++ self->view.buf = NULL; + + self->codesize = n; + +@@ -2694,15 +2708,15 @@ + return NULL; + } + +- if (pattern == Py_None) +- self->charsize = -1; +- else { +- Py_ssize_t p_length; +- if (!getstring(pattern, &p_length, &self->charsize)) { +- Py_DECREF(self); +- return NULL; +- } +- } ++ if (pattern == Py_None) ++ self->charsize = -1; ++ else { ++ Py_ssize_t p_length; ++ if (!getstring(pattern, &p_length, &self->charsize, &self->view)) { ++ Py_DECREF(self); ++ return NULL; ++ } ++ } + + Py_INCREF(pattern); + self->pattern = pattern; +diff -r 3d0686d90f55 Modules/_threadmodule.c +--- a/Modules/_threadmodule.c ++++ b/Modules/_threadmodule.c +@@ -994,14 +994,17 @@ + PyErr_Clear(); + else { + PyObject *file; ++ PyObject *exc, *value, *tb; + PySys_WriteStderr( + "Unhandled exception in thread started by "); ++ PyErr_Fetch(&exc, &value, &tb); + file = PySys_GetObject("stderr"); + if (file != NULL && file != Py_None) + PyFile_WriteObject(boot->func, file, 0); + else + PyObject_Print(boot->func, stderr, 0); + PySys_WriteStderr("\n"); ++ PyErr_Restore(exc, value, tb); + PyErr_PrintEx(0); + } + } +diff -r 3d0686d90f55 Modules/gcmodule.c +--- a/Modules/gcmodule.c ++++ b/Modules/gcmodule.c +@@ -116,6 +116,46 @@ + http://mail.python.org/pipermail/python-dev/2008-June/080579.html + */ + ++/* ++ NOTE: about untracking of mutable objects. ++ ++ Certain types of container cannot participate in a reference cycle, and ++ so do not need to be tracked by the garbage collector. Untracking these ++ objects reduces the cost of garbage collections. However, determining ++ which objects may be untracked is not free, and the costs must be ++ weighed against the benefits for garbage collection. ++ ++ There are two possible strategies for when to untrack a container: ++ ++ i) When the container is created. ++ ii) When the container is examined by the garbage collector. ++ ++ Tuples containing only immutable objects (integers, strings etc, and ++ recursively, tuples of immutable objects) do not need to be tracked. ++ The interpreter creates a large number of tuples, many of which will ++ not survive until garbage collection. It is therefore not worthwhile ++ to untrack eligible tuples at creation time. ++ ++ Instead, all tuples except the empty tuple are tracked when created. ++ During garbage collection it is determined whether any surviving tuples ++ can be untracked. A tuple can be untracked if all of its contents are ++ already not tracked. Tuples are examined for untracking in all garbage ++ collection cycles. It may take more than one cycle to untrack a tuple. ++ ++ Dictionaries containing only immutable objects also do not need to be ++ tracked. Dictionaries are untracked when created. If a tracked item is ++ inserted into a dictionary (either as a key or value), the dictionary ++ becomes tracked. During a full garbage collection (all generations), ++ the collector will untrack any dictionaries whose contents are not ++ tracked. ++ ++ The module provides the python function is_tracked(obj), which returns ++ the CURRENT tracking status of the object. Subsequent garbage ++ collections may change the tracking status of the object. ++ ++ Untracking of certain containers was introduced in issue #4688, and ++ the algorithm was refined in response to issue #14775. ++*/ + + /* set for debugging information */ + #define DEBUG_STATS (1<<0) /* print collection statistics */ +@@ -437,9 +477,6 @@ + if (PyTuple_CheckExact(op)) { + _PyTuple_MaybeUntrack(op); + } +- else if (PyDict_CheckExact(op)) { +- _PyDict_MaybeUntrack(op); +- } + } + else { + /* This *may* be unreachable. To make progress, +@@ -457,6 +494,20 @@ + } + } + ++/* Try to untrack all currently tracked dictionaries */ ++static void ++untrack_dicts(PyGC_Head *head) ++{ ++ PyGC_Head *next, *gc = head->gc.gc_next; ++ while (gc != head) { ++ PyObject *op = FROM_GC(gc); ++ next = gc->gc.gc_next; ++ if (PyDict_CheckExact(op)) ++ _PyDict_MaybeUntrack(op); ++ gc = next; ++ } ++} ++ + /* Return true if object has a finalization method. */ + static int + has_finalizer(PyObject *op) +@@ -857,6 +908,9 @@ + gc_list_merge(young, old); + } + else { ++ /* We only untrack dicts in full collections, to avoid quadratic ++ dict build-up. See issue #14775. */ ++ untrack_dicts(young); + long_lived_pending = 0; + long_lived_total = gc_list_size(young); + } +diff -r 3d0686d90f55 Modules/main.c +--- a/Modules/main.c ++++ b/Modules/main.c +@@ -673,7 +673,7 @@ + sts = run_command(command, &cf); + free(command); + } else if (module) { +- sts = RunModule(module, 1); ++ sts = (RunModule(module, 1) != 0); + } + else { + +diff -r 3d0686d90f55 Modules/mathmodule.c +--- a/Modules/mathmodule.c ++++ b/Modules/mathmodule.c +@@ -694,13 +694,13 @@ + return NULL; + } + if (Py_IS_INFINITY(r) && Py_IS_FINITE(x)) { +- if (can_overflow) +- PyErr_SetString(PyExc_OverflowError, +- "math range error"); /* overflow */ +- else +- PyErr_SetString(PyExc_ValueError, +- "math domain error"); /* singularity */ +- return NULL; ++ if (can_overflow) ++ PyErr_SetString(PyExc_OverflowError, ++ "math range error"); /* overflow */ ++ else ++ PyErr_SetString(PyExc_ValueError, ++ "math domain error"); /* singularity */ ++ return NULL; + } + if (Py_IS_FINITE(r) && errno && is_error(r)) + /* this branch unnecessary on most platforms */ +diff -r 3d0686d90f55 Modules/parsermodule.c +--- a/Modules/parsermodule.c ++++ b/Modules/parsermodule.c +@@ -938,6 +938,7 @@ + #define validate_doublestar(ch) validate_terminal(ch, DOUBLESTAR, "**") + #define validate_dot(ch) validate_terminal(ch, DOT, ".") + #define validate_at(ch) validate_terminal(ch, AT, "@") ++#define validate_rarrow(ch) validate_terminal(ch, RARROW, "->") + #define validate_name(ch, str) validate_terminal(ch, NAME, str) + + #define VALIDATER(n) static int validate_##n(node *tree) +@@ -953,7 +954,8 @@ + VALIDATER(return_stmt); VALIDATER(raise_stmt); + VALIDATER(import_stmt); VALIDATER(import_stmt); + VALIDATER(import_name); VALIDATER(yield_stmt); +-VALIDATER(global_stmt); VALIDATER(assert_stmt); ++VALIDATER(global_stmt); VALIDATER(nonlocal_stmt); ++VALIDATER(assert_stmt); + VALIDATER(compound_stmt); VALIDATER(test_or_star_expr); + VALIDATER(while); VALIDATER(for); + VALIDATER(try); VALIDATER(except_clause); +@@ -1226,68 +1228,68 @@ + return 0; + } + +-/* '*' vfpdef (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef ++/* '*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef + * ..or tfpdef in place of vfpdef. vfpdef: NAME; tfpdef: NAME [':' test] + */ + static int + validate_varargslist_trailer(node *tree, int start) + { + int nch = NCH(tree); +- int res = 0, i; +- int sym; ++ int res = 0; + + if (nch <= start) { + err_string("expected variable argument trailer for varargslist"); + return 0; + } +- sym = TYPE(CHILD(tree, start)); +- if (sym == STAR) { ++ if (TYPE(CHILD(tree, start)) == STAR) { + /* +- * '*' vfpdef (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef ++ * '*' [vfpdef] + */ +- if (nch-start == 2) +- res = validate_vfpdef(CHILD(tree, start+1)); +- else if (nch-start == 5 && TYPE(CHILD(tree, start+2)) == COMMA) +- res = (validate_vfpdef(CHILD(tree, start+1)) +- && validate_comma(CHILD(tree, start+2)) +- && validate_doublestar(CHILD(tree, start+3)) +- && validate_vfpdef(CHILD(tree, start+4))); ++ res = validate_star(CHILD(tree, start++)); ++ if (res && start < nch && (TYPE(CHILD(tree, start)) == vfpdef || ++ TYPE(CHILD(tree, start)) == tfpdef)) ++ res = validate_vfpdef(CHILD(tree, start++)); ++ /* ++ * (',' vfpdef ['=' test])* ++ */ ++ while (res && start + 1 < nch && ( ++ TYPE(CHILD(tree, start + 1)) == vfpdef || ++ TYPE(CHILD(tree, start + 1)) == tfpdef)) { ++ res = (validate_comma(CHILD(tree, start++)) ++ && validate_vfpdef(CHILD(tree, start++))); ++ if (res && start + 1 < nch && TYPE(CHILD(tree, start)) == EQUAL) ++ res = (validate_equal(CHILD(tree, start++)) ++ && validate_test(CHILD(tree, start++))); ++ } ++ /* ++ * [',' '**' vfpdef] ++ */ ++ if (res && start + 2 < nch && TYPE(CHILD(tree, start+1)) == DOUBLESTAR) ++ res = (validate_comma(CHILD(tree, start++)) ++ && validate_doublestar(CHILD(tree, start++)) ++ && validate_vfpdef(CHILD(tree, start++))); ++ } ++ else if (TYPE(CHILD(tree, start)) == DOUBLESTAR) { ++ /* ++ * '**' vfpdef ++ */ ++ if (start + 1 < nch) ++ res = (validate_doublestar(CHILD(tree, start++)) ++ && validate_vfpdef(CHILD(tree, start++))); + else { +- /* skip over vfpdef (',' vfpdef ['=' test])* */ +- i = start + 1; +- if (TYPE(CHILD(tree, i)) == vfpdef || +- TYPE(CHILD(tree, i)) == tfpdef) { /* skip over vfpdef or tfpdef */ +- i += 1; +- } +- while (res && i+1 < nch) { /* validate (',' vfpdef ['=' test])* */ +- res = validate_comma(CHILD(tree, i)); +- if (TYPE(CHILD(tree, i+1)) == DOUBLESTAR) +- break; +- res = res && validate_vfpdef(CHILD(tree, i+1)); +- if (res && i+2 < nch && TYPE(CHILD(tree, i+2)) == EQUAL) { +- res = res && (i+3 < nch) +- && validate_test(CHILD(tree, i+3)); +- i += 4; +- } +- else { +- i += 2; +- } +- } +- /* [',' '**' vfpdef] */ +- if (res && i+1 < nch && TYPE(CHILD(tree, i+1)) == DOUBLESTAR) { +- res = validate_vfpdef(CHILD(tree, i+2)); +- } ++ res = 0; ++ err_string("expected vfpdef after ** in varargslist trailer"); + } + } +- else if (sym == DOUBLESTAR) { +- /* +- * '**' NAME +- */ +- if (nch-start == 2) +- res = validate_vfpdef(CHILD(tree, start+1)); ++ else { ++ res = 0; ++ err_string("expected * or ** in varargslist trailer"); + } +- if (!res) +- err_string("illegal variable argument trailer for varargslist"); ++ ++ if (res && start != nch) { ++ res = 0; ++ err_string("unexpected extra children in varargslist trailer"); ++ } + return res; + } + +@@ -1476,6 +1478,7 @@ + || (ntype == flow_stmt) + || (ntype == import_stmt) + || (ntype == global_stmt) ++ || (ntype == nonlocal_stmt) + || (ntype == assert_stmt)) + res = validate_node(CHILD(tree, 0)); + else { +@@ -1605,31 +1608,30 @@ + } + + ++/* ++ * raise_stmt: ++ * ++ * 'raise' [test ['from' test]] ++ */ + static int + validate_raise_stmt(node *tree) + { + int nch = NCH(tree); + int res = (validate_ntype(tree, raise_stmt) +- && ((nch == 1) || (nch == 2) || (nch == 4) || (nch == 6))); ++ && ((nch == 1) || (nch == 2) || (nch == 4))); ++ ++ if (!res && !PyErr_Occurred()) ++ (void) validate_numnodes(tree, 2, "raise"); + + if (res) { + res = validate_name(CHILD(tree, 0), "raise"); + if (res && (nch >= 2)) + res = validate_test(CHILD(tree, 1)); +- if (res && nch > 2) { +- res = (validate_comma(CHILD(tree, 2)) ++ if (res && (nch == 4)) { ++ res = (validate_name(CHILD(tree, 2), "from") + && validate_test(CHILD(tree, 3))); +- if (res && (nch > 4)) +- res = (validate_comma(CHILD(tree, 4)) +- && validate_test(CHILD(tree, 5))); + } + } +- else +- (void) validate_numnodes(tree, 2, "raise"); +- if (res && (nch == 4)) +- res = (validate_comma(CHILD(tree, 2)) +- && validate_test(CHILD(tree, 3))); +- + return (res); + } + +@@ -1833,8 +1835,10 @@ + } + + +- +- ++/* global_stmt: ++ * ++ * 'global' NAME (',' NAME)* ++ */ + static int + validate_global_stmt(node *tree) + { +@@ -1856,6 +1860,30 @@ + return (res); + } + ++/* nonlocal_stmt: ++ * ++ * 'nonlocal' NAME (',' NAME)* ++ */ ++static int ++validate_nonlocal_stmt(node *tree) ++{ ++ int j; ++ int nch = NCH(tree); ++ int res = (validate_ntype(tree, nonlocal_stmt) ++ && is_even(nch) && (nch >= 2)); ++ ++ if (!res && !PyErr_Occurred()) ++ err_string("illegal nonlocal statement"); ++ ++ if (res) ++ res = (validate_name(CHILD(tree, 0), "nonlocal") ++ && validate_ntype(CHILD(tree, 1), NAME)); ++ for (j = 2; res && (j < nch); j += 2) ++ res = (validate_comma(CHILD(tree, j)) ++ && validate_ntype(CHILD(tree, j + 1), NAME)); ++ ++ return res; ++} + + /* assert_stmt: + * +@@ -2361,17 +2389,13 @@ + break; + case NAME: + case NUMBER: ++ case ELLIPSIS: + res = (nch == 1); + break; + case STRING: + for (pos = 1; res && (pos < nch); ++pos) + res = validate_ntype(CHILD(tree, pos), STRING); + break; +- case DOT: +- res = (nch == 3 && +- validate_ntype(CHILD(tree, 1), DOT) && +- validate_ntype(CHILD(tree, 2), DOT)); +- break; + default: + res = 0; + break; +@@ -2495,23 +2519,36 @@ + return ok; + } + +-/* funcdef: +- * +- * -5 -4 -3 -2 -1 +- * 'def' NAME parameters ':' suite +- */ ++/* funcdef: 'def' NAME parameters ['->' test] ':' suite */ ++ + static int + validate_funcdef(node *tree) + { + int nch = NCH(tree); +- int ok = (validate_ntype(tree, funcdef) +- && (nch == 5) +- && validate_name(RCHILD(tree, -5), "def") +- && validate_ntype(RCHILD(tree, -4), NAME) +- && validate_colon(RCHILD(tree, -2)) +- && validate_parameters(RCHILD(tree, -3)) +- && validate_suite(RCHILD(tree, -1))); +- return ok; ++ int res = validate_ntype(tree, funcdef); ++ if (res) { ++ if (nch == 5) { ++ res = (validate_name(CHILD(tree, 0), "def") ++ && validate_ntype(CHILD(tree, 1), NAME) ++ && validate_parameters(CHILD(tree, 2)) ++ && validate_colon(CHILD(tree, 3)) ++ && validate_suite(CHILD(tree, 4))); ++ } ++ else if (nch == 7) { ++ res = (validate_name(CHILD(tree, 0), "def") ++ && validate_ntype(CHILD(tree, 1), NAME) ++ && validate_parameters(CHILD(tree, 2)) ++ && validate_rarrow(CHILD(tree, 3)) ++ && validate_test(CHILD(tree, 4)) ++ && validate_colon(CHILD(tree, 5)) ++ && validate_suite(CHILD(tree, 6))); ++ } ++ else { ++ res = 0; ++ err_string("illegal number of children for funcdef"); ++ } ++ } ++ return res; + } + + +@@ -2824,34 +2861,92 @@ + validate_expr_or_star_expr, "exprlist")); + } + +- ++/* ++ * dictorsetmaker: ++ * ++ * (test ':' test (comp_for | (',' test ':' test)* [','])) | ++ * (test (comp_for | (',' test)* [','])) ++ */ + static int + validate_dictorsetmaker(node *tree) + { + int nch = NCH(tree); +- int res = (validate_ntype(tree, dictorsetmaker) +- && (nch >= 3) +- && validate_test(CHILD(tree, 0)) +- && validate_colon(CHILD(tree, 1)) +- && validate_test(CHILD(tree, 2))); +- +- if (res && ((nch % 4) == 0)) +- res = validate_comma(CHILD(tree, --nch)); +- else if (res) +- res = ((nch % 4) == 3); +- +- if (res && (nch > 3)) { +- int pos = 3; +- /* ( ',' test ':' test )* */ +- while (res && (pos < nch)) { +- res = (validate_comma(CHILD(tree, pos)) +- && validate_test(CHILD(tree, pos + 1)) +- && validate_colon(CHILD(tree, pos + 2)) +- && validate_test(CHILD(tree, pos + 3))); +- pos += 4; ++ int res; ++ int i = 0; ++ ++ res = validate_ntype(tree, dictorsetmaker); ++ if (!res) ++ return 0; ++ ++ if (nch - i < 1) { ++ (void) validate_numnodes(tree, 1, "dictorsetmaker"); ++ return 0; ++ } ++ ++ res = validate_test(CHILD(tree, i++)); ++ if (!res) ++ return 0; ++ ++ if (nch - i >= 2 && TYPE(CHILD(tree, i)) == COLON) { ++ /* Dictionary display or dictionary comprehension. */ ++ res = (validate_colon(CHILD(tree, i++)) ++ && validate_test(CHILD(tree, i++))); ++ if (!res) ++ return 0; ++ ++ if (nch - i >= 1 && TYPE(CHILD(tree, i)) == comp_for) { ++ /* Dictionary comprehension. */ ++ res = validate_comp_for(CHILD(tree, i++)); ++ if (!res) ++ return 0; ++ } ++ else { ++ /* Dictionary display. */ ++ while (nch - i >= 4) { ++ res = (validate_comma(CHILD(tree, i++)) ++ && validate_test(CHILD(tree, i++)) ++ && validate_colon(CHILD(tree, i++)) ++ && validate_test(CHILD(tree, i++))); ++ if (!res) ++ return 0; ++ } ++ if (nch - i == 1) { ++ res = validate_comma(CHILD(tree, i++)); ++ if (!res) ++ return 0; ++ } + } + } +- return (res); ++ else { ++ /* Set display or set comprehension. */ ++ if (nch - i >= 1 && TYPE(CHILD(tree, i)) == comp_for) { ++ /* Set comprehension. */ ++ res = validate_comp_for(CHILD(tree, i++)); ++ if (!res) ++ return 0; ++ } ++ else { ++ /* Set display. */ ++ while (nch - i >= 2) { ++ res = (validate_comma(CHILD(tree, i++)) ++ && validate_test(CHILD(tree, i++))); ++ if (!res) ++ return 0; ++ } ++ if (nch - i == 1) { ++ res = validate_comma(CHILD(tree, i++)); ++ if (!res) ++ return 0; ++ } ++ } ++ } ++ ++ if (nch - i > 0) { ++ err_string("Illegal trailing nodes for dictorsetmaker."); ++ return 0; ++ } ++ ++ return 1; + } + + +@@ -2907,8 +3002,8 @@ + break; + case small_stmt: + /* +- * expr_stmt | del_stmt | pass_stmt | flow_stmt +- * | import_stmt | global_stmt | assert_stmt ++ * expr_stmt | del_stmt | pass_stmt | flow_stmt | ++ * import_stmt | global_stmt | nonlocal_stmt | assert_stmt + */ + res = validate_small_stmt(tree); + break; +@@ -2975,6 +3070,9 @@ + case global_stmt: + res = validate_global_stmt(tree); + break; ++ case nonlocal_stmt: ++ res = validate_nonlocal_stmt(tree); ++ break; + case assert_stmt: + res = validate_assert_stmt(tree); + break; +diff -r 3d0686d90f55 Modules/python.c +--- a/Modules/python.c ++++ b/Modules/python.c +@@ -22,9 +22,9 @@ + int + main(int argc, char **argv) + { +- wchar_t **argv_copy = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*argc); ++ wchar_t **argv_copy = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*(argc+1)); + /* We need a second copies, as Python might modify the first one. */ +- wchar_t **argv_copy2 = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*argc); ++ wchar_t **argv_copy2 = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*(argc+1)); + int i, res; + char *oldloc; + /* 754 requires that FP exceptions run in "no stop" mode by default, +@@ -58,6 +58,8 @@ + } + argv_copy2[i] = argv_copy[i]; + } ++ argv_copy2[argc] = argv_copy[argc] = NULL; ++ + setlocale(LC_ALL, oldloc); + free(oldloc); + res = Py_Main(argc, argv_copy); +diff -r 3d0686d90f55 Modules/socketmodule.c +--- a/Modules/socketmodule.c ++++ b/Modules/socketmodule.c +@@ -1347,7 +1347,7 @@ + "getsockaddrarg: port must be 0-65535."); + return 0; + } +- if (flowinfo < 0 || flowinfo > 0xfffff) { ++ if (flowinfo > 0xfffff) { + PyErr_SetString( + PyExc_OverflowError, + "getsockaddrarg: flowinfo must be 0-1048575."); +@@ -4129,7 +4129,7 @@ + if (!PyArg_ParseTuple(sa, "si|II", + &hostp, &port, &flowinfo, &scope_id)) + return NULL; +- if (flowinfo < 0 || flowinfo > 0xfffff) { ++ if (flowinfo > 0xfffff) { + PyErr_SetString(PyExc_OverflowError, + "getsockaddrarg: flowinfo must be 0-1048575."); + return NULL; +diff -r 3d0686d90f55 Modules/sre.h +--- a/Modules/sre.h ++++ b/Modules/sre.h +@@ -31,6 +31,7 @@ + int flags; /* flags used when compiling pattern source */ + PyObject *weakreflist; /* List of weak references */ + int charsize; /* pattern charsize (or -1) */ ++ Py_buffer view; + /* pattern code */ + Py_ssize_t codesize; + SRE_CODE code[1]; +@@ -80,6 +81,7 @@ + char* data_stack; + size_t data_stack_size; + size_t data_stack_base; ++ Py_buffer buffer; + /* current repeat context */ + SRE_REPEAT *repeat; + /* hooks */ +diff -r 3d0686d90f55 Modules/timemodule.c +--- a/Modules/timemodule.c ++++ b/Modules/timemodule.c +@@ -504,7 +504,7 @@ + fmt = PyBytes_AS_STRING(format); + #endif + +-#if defined(MS_WINDOWS) ++#if defined(MS_WINDOWS) && !defined(HAVE_WCSFTIME) + /* check that the format string contains only valid directives */ + for(outbuf = strchr(fmt, '%'); + outbuf != NULL; +@@ -516,7 +516,8 @@ + !strchr("aAbBcdHIjmMpSUwWxXyYzZ%", outbuf[1])) + { + PyErr_SetString(PyExc_ValueError, "Invalid format string"); +- return 0; ++ Py_DECREF(format); ++ return NULL; + } + } + #endif +diff -r 3d0686d90f55 Objects/accu.c +--- a/Objects/accu.c ++++ b/Objects/accu.c +@@ -1,6 +1,7 @@ + /* Accumulator struct implementation */ + + #include "Python.h" ++#include "accu.h" + + static PyObject * + join_list_unicode(PyObject *lst) +diff -r 3d0686d90f55 Objects/bytearrayobject.c +--- a/Objects/bytearrayobject.c ++++ b/Objects/bytearrayobject.c +@@ -2234,8 +2234,10 @@ + } + + bytearray_obj = PyByteArray_FromStringAndSize(NULL, buf_size); +- if (bytearray_obj == NULL) ++ if (bytearray_obj == NULL) { ++ Py_DECREF(it); + return NULL; ++ } + buf = PyByteArray_AS_STRING(bytearray_obj); + + while ((item = PyIter_Next(it)) != NULL) { +@@ -2268,8 +2270,10 @@ + return NULL; + } + +- if (bytearray_setslice(self, Py_SIZE(self), Py_SIZE(self), bytearray_obj) == -1) ++ if (bytearray_setslice(self, Py_SIZE(self), Py_SIZE(self), bytearray_obj) == -1) { ++ Py_DECREF(bytearray_obj); + return NULL; ++ } + Py_DECREF(bytearray_obj); + + Py_RETURN_NONE; +diff -r 3d0686d90f55 Objects/bytesobject.c +--- a/Objects/bytesobject.c ++++ b/Objects/bytesobject.c +@@ -875,7 +875,9 @@ + register unsigned char *p; + register Py_hash_t x; + ++#ifdef Py_DEBUG + assert(_Py_HashSecret_Initialized); ++#endif + if (a->ob_shash != -1) + return a->ob_shash; + len = Py_SIZE(a); +diff -r 3d0686d90f55 Objects/descrobject.c +--- a/Objects/descrobject.c ++++ b/Objects/descrobject.c +@@ -256,14 +256,52 @@ + classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args, + PyObject *kwds) + { +- PyObject *func, *result; ++ Py_ssize_t argc; ++ PyObject *self, *func, *result; + +- func = PyCFunction_New(descr->d_method, (PyObject *)PyDescr_TYPE(descr)); ++ /* Make sure that the first argument is acceptable as 'self' */ ++ assert(PyTuple_Check(args)); ++ argc = PyTuple_GET_SIZE(args); ++ if (argc < 1) { ++ PyErr_Format(PyExc_TypeError, ++ "descriptor '%V' of '%.100s' " ++ "object needs an argument", ++ descr_name((PyDescrObject *)descr), "?", ++ PyDescr_TYPE(descr)->tp_name); ++ return NULL; ++ } ++ self = PyTuple_GET_ITEM(args, 0); ++ if (!PyType_Check(self)) { ++ PyErr_Format(PyExc_TypeError, ++ "descriptor '%V' requires a type " ++ "but received a '%.100s'", ++ descr_name((PyDescrObject *)descr), "?", ++ PyDescr_TYPE(descr)->tp_name, ++ self->ob_type->tp_name); ++ return NULL; ++ } ++ if (!PyType_IsSubtype((PyTypeObject *)self, PyDescr_TYPE(descr))) { ++ PyErr_Format(PyExc_TypeError, ++ "descriptor '%V' " ++ "requires a subtype of '%.100s' " ++ "but received '%.100s", ++ descr_name((PyDescrObject *)descr), "?", ++ PyDescr_TYPE(descr)->tp_name, ++ self->ob_type->tp_name); ++ return NULL; ++ } ++ ++ func = PyCFunction_New(descr->d_method, self); + if (func == NULL) + return NULL; +- ++ args = PyTuple_GetSlice(args, 1, argc); ++ if (args == NULL) { ++ Py_DECREF(func); ++ return NULL; ++ } + result = PyEval_CallObjectWithKeywords(func, args, kwds); + Py_DECREF(func); ++ Py_DECREF(args); + return result; + } + +diff -r 3d0686d90f55 Objects/dictobject.c +--- a/Objects/dictobject.c ++++ b/Objects/dictobject.c +@@ -510,27 +510,16 @@ + _PyObject_GC_UNTRACK(op); + } + +- + /* +-Internal routine to insert a new item into the table. +-Used both by the internal resize routine and by the public insert routine. +-Eats a reference to key and one to value. +-Returns -1 if an error occurred, or 0 on success. ++Internal routine to insert a new item into the table when you have entry object. ++Used by insertdict. + */ + static int +-insertdict(register PyDictObject *mp, PyObject *key, Py_hash_t hash, PyObject *value) ++insertdict_by_entry(register PyDictObject *mp, PyObject *key, Py_hash_t hash, ++ PyDictEntry *ep, PyObject *value) + { + PyObject *old_value; +- register PyDictEntry *ep; +- typedef PyDictEntry *(*lookupfunc)(PyDictObject *, PyObject *, Py_hash_t); + +- assert(mp->ma_lookup != NULL); +- ep = mp->ma_lookup(mp, key, hash); +- if (ep == NULL) { +- Py_DECREF(key); +- Py_DECREF(value); +- return -1; +- } + MAINTAIN_TRACKING(mp, key, value); + if (ep->me_value != NULL) { + old_value = ep->me_value; +@@ -553,6 +542,28 @@ + return 0; + } + ++ ++/* ++Internal routine to insert a new item into the table. ++Used both by the internal resize routine and by the public insert routine. ++Eats a reference to key and one to value. ++Returns -1 if an error occurred, or 0 on success. ++*/ ++static int ++insertdict(register PyDictObject *mp, PyObject *key, Py_hash_t hash, PyObject *value) ++{ ++ register PyDictEntry *ep; ++ ++ assert(mp->ma_lookup != NULL); ++ ep = mp->ma_lookup(mp, key, hash); ++ if (ep == NULL) { ++ Py_DECREF(key); ++ Py_DECREF(value); ++ return -1; ++ } ++ return insertdict_by_entry(mp, key, hash, ep, value); ++} ++ + /* + Internal routine used by dictresize() to insert an item which is + known to be absent from the dict. This routine also assumes that +@@ -776,39 +787,26 @@ + return ep->me_value; + } + +-/* CAUTION: PyDict_SetItem() must guarantee that it won't resize the +- * dictionary if it's merely replacing the value for an existing key. +- * This means that it's safe to loop over a dictionary with PyDict_Next() +- * and occasionally replace a value -- but you can't insert new keys or +- * remove them. +- */ +-int +-PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value) ++static int ++dict_set_item_by_hash_or_entry(register PyObject *op, PyObject *key, ++ Py_hash_t hash, PyDictEntry *ep, PyObject *value) + { + register PyDictObject *mp; +- register Py_hash_t hash; + register Py_ssize_t n_used; + +- if (!PyDict_Check(op)) { +- PyErr_BadInternalCall(); +- return -1; +- } +- assert(key); +- assert(value); + mp = (PyDictObject *)op; +- if (!PyUnicode_CheckExact(key) || +- (hash = ((PyUnicodeObject *) key)->hash) == -1) +- { +- hash = PyObject_Hash(key); +- if (hash == -1) +- return -1; +- } + assert(mp->ma_fill <= mp->ma_mask); /* at least one empty slot */ + n_used = mp->ma_used; + Py_INCREF(value); + Py_INCREF(key); +- if (insertdict(mp, key, hash, value) != 0) +- return -1; ++ if (ep == NULL) { ++ if (insertdict(mp, key, hash, value) != 0) ++ return -1; ++ } ++ else { ++ if (insertdict_by_entry(mp, key, hash, ep, value) != 0) ++ return -1; ++ } + /* If we added a key, we can safely resize. Otherwise just return! + * If fill >= 2/3 size, adjust size. Normally, this doubles or + * quaduples the size, but it's also possible for the dict to shrink +@@ -828,6 +826,36 @@ + return dictresize(mp, (mp->ma_used > 50000 ? 2 : 4) * mp->ma_used); + } + ++/* CAUTION: PyDict_SetItem() must guarantee that it won't resize the ++ * dictionary if it's merely replacing the value for an existing key. ++ * This means that it's safe to loop over a dictionary with PyDict_Next() ++ * and occasionally replace a value -- but you can't insert new keys or ++ * remove them. ++ */ ++int ++PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value) ++{ ++ register Py_hash_t hash; ++ ++ if (!PyDict_Check(op)) { ++ PyErr_BadInternalCall(); ++ return -1; ++ } ++ assert(key); ++ assert(value); ++ if (PyUnicode_CheckExact(key)) { ++ hash = ((PyUnicodeObject *) key)->hash; ++ if (hash == -1) ++ hash = PyObject_Hash(key); ++ } ++ else { ++ hash = PyObject_Hash(key); ++ if (hash == -1) ++ return -1; ++ } ++ return dict_set_item_by_hash_or_entry(op, key, hash, NULL, value); ++} ++ + int + PyDict_DelItem(PyObject *op, PyObject *key) + { +@@ -1797,9 +1825,9 @@ + return NULL; + val = ep->me_value; + if (val == NULL) { +- val = failobj; +- if (PyDict_SetItem((PyObject*)mp, key, failobj)) +- val = NULL; ++ if (dict_set_item_by_hash_or_entry((PyObject*)mp, key, hash, ep, ++ failobj) == 0) ++ val = failobj; + } + Py_XINCREF(val); + return val; +diff -r 3d0686d90f55 Objects/frameobject.c +--- a/Objects/frameobject.c ++++ b/Objects/frameobject.c +@@ -199,6 +199,7 @@ + case SETUP_LOOP: + case SETUP_EXCEPT: + case SETUP_FINALLY: ++ case SETUP_WITH: + blockstack[blockstack_top++] = addr; + in_finally[blockstack_top-1] = 0; + break; +@@ -206,7 +207,7 @@ + case POP_BLOCK: + assert(blockstack_top > 0); + setup_op = code[blockstack[blockstack_top-1]]; +- if (setup_op == SETUP_FINALLY) { ++ if (setup_op == SETUP_FINALLY || setup_op == SETUP_WITH) { + in_finally[blockstack_top-1] = 1; + } + else { +@@ -221,7 +222,7 @@ + * be seeing such an END_FINALLY.) */ + if (blockstack_top > 0) { + setup_op = code[blockstack[blockstack_top-1]]; +- if (setup_op == SETUP_FINALLY) { ++ if (setup_op == SETUP_FINALLY || setup_op == SETUP_WITH) { + blockstack_top--; + } + } +@@ -283,6 +284,7 @@ + case SETUP_LOOP: + case SETUP_EXCEPT: + case SETUP_FINALLY: ++ case SETUP_WITH: + delta_iblock++; + break; + +diff -r 3d0686d90f55 Objects/genobject.c +--- a/Objects/genobject.c ++++ b/Objects/genobject.c +@@ -129,7 +129,7 @@ + } + + PyDoc_STRVAR(close_doc, +-"close(arg) -> raise GeneratorExit inside generator."); ++"close() -> raise GeneratorExit inside generator."); + + static PyObject * + gen_close(PyGenObject *gen, PyObject *args) +diff -r 3d0686d90f55 Objects/listobject.c +--- a/Objects/listobject.c ++++ b/Objects/listobject.c +@@ -1,6 +1,7 @@ + /* List object implementation */ + + #include "Python.h" ++#include "accu.h" + + #ifdef STDC_HEADERS + #include +diff -r 3d0686d90f55 Objects/longobject.c +--- a/Objects/longobject.c ++++ b/Objects/longobject.c +@@ -156,9 +156,7 @@ + if (i < 0) + i = -(i); + if (i < 2) { +- sdigit ival = src->ob_digit[0]; +- if (Py_SIZE(src) < 0) +- ival = -ival; ++ sdigit ival = MEDIUM_VALUE(src); + CHECK_SMALL_INT(ival); + } + result = _PyLong_New(i); +diff -r 3d0686d90f55 Objects/rangeobject.c +--- a/Objects/rangeobject.c ++++ b/Objects/rangeobject.c +@@ -307,7 +307,7 @@ + static PyObject * + range_item(rangeobject *r, Py_ssize_t i) + { +- PyObject *res, *arg = PyLong_FromLong(i); ++ PyObject *res, *arg = PyLong_FromSsize_t(i); + if (!arg) { + return NULL; + } +diff -r 3d0686d90f55 Objects/tupleobject.c +--- a/Objects/tupleobject.c ++++ b/Objects/tupleobject.c +@@ -2,6 +2,7 @@ + /* Tuple object implementation */ + + #include "Python.h" ++#include "accu.h" + + /* Speed optimization to avoid frequent malloc/free of small tuples */ + #ifndef PyTuple_MAXSAVESIZE +diff -r 3d0686d90f55 Objects/typeobject.c +--- a/Objects/typeobject.c ++++ b/Objects/typeobject.c +@@ -458,26 +458,23 @@ + for (i = 0; i < PyTuple_GET_SIZE(value); i++) { + ob = PyTuple_GET_ITEM(value, i); + if (!PyType_Check(ob)) { +- PyErr_Format( +- PyExc_TypeError, +- "%s.__bases__ must be tuple of old- or new-style classes, not '%s'", +- type->tp_name, Py_TYPE(ob)->tp_name); +- return -1; ++ PyErr_Format(PyExc_TypeError, ++ "%s.__bases__ must be tuple of old- or " ++ "new-style classes, not '%s'", ++ type->tp_name, Py_TYPE(ob)->tp_name); ++ return -1; + } +- if (PyType_Check(ob)) { +- if (PyType_IsSubtype((PyTypeObject*)ob, type)) { +- PyErr_SetString(PyExc_TypeError, +- "a __bases__ item causes an inheritance cycle"); +- return -1; +- } ++ if (PyType_IsSubtype((PyTypeObject*)ob, type)) { ++ PyErr_SetString(PyExc_TypeError, ++ "a __bases__ item causes an inheritance cycle"); ++ return -1; + } + } + + new_base = best_base(value); + +- if (!new_base) { ++ if (!new_base) + return -1; +- } + + if (!compatible_for_assignment(type->tp_base, new_base, "__bases__")) + return -1; +@@ -830,8 +827,13 @@ + assert(base); + } + +- /* There's no need to clear the instance dict (if any); +- the collector will call its tp_clear handler. */ ++ /* Clear the instance dict (if any), to break cycles involving only ++ __dict__ slots (as in the case 'self.__dict__ is self'). */ ++ if (type->tp_dictoffset != base->tp_dictoffset) { ++ PyObject **dictptr = _PyObject_GetDictPtr(self); ++ if (dictptr && *dictptr) ++ Py_CLEAR(*dictptr); ++ } + + if (baseclear) + return baseclear(self); +@@ -2358,33 +2360,39 @@ + return NULL; + res->ht_name = PyUnicode_FromString(spec->name); + if (!res->ht_name) +- goto fail; ++ goto fail; + res->ht_type.tp_name = _PyUnicode_AsString(res->ht_name); + if (!res->ht_type.tp_name) +- goto fail; ++ goto fail; + + res->ht_type.tp_basicsize = spec->basicsize; + res->ht_type.tp_itemsize = spec->itemsize; + res->ht_type.tp_flags = spec->flags | Py_TPFLAGS_HEAPTYPE; + + for (slot = spec->slots; slot->slot; slot++) { +- if (slot->slot >= sizeof(slotoffsets)/sizeof(slotoffsets[0])) { +- PyErr_SetString(PyExc_RuntimeError, "invalid slot offset"); +- goto fail; +- } +- *(void**)(res_start + slotoffsets[slot->slot]) = slot->pfunc; ++ if (slot->slot >= sizeof(slotoffsets)/sizeof(slotoffsets[0])) { ++ PyErr_SetString(PyExc_RuntimeError, "invalid slot offset"); ++ goto fail; ++ } ++ *(void**)(res_start + slotoffsets[slot->slot]) = slot->pfunc; + + /* need to make a copy of the docstring slot, which usually + points to a static string literal */ + if (slot->slot == Py_tp_doc) { +- ssize_t len = strlen(slot->pfunc)+1; ++ size_t len = strlen(slot->pfunc)+1; + char *tp_doc = PyObject_MALLOC(len); + if (tp_doc == NULL) +- goto fail; ++ goto fail; + memcpy(tp_doc, slot->pfunc, len); + res->ht_type.tp_doc = tp_doc; + } + } ++ if (res->ht_type.tp_dealloc == NULL) { ++ /* It's a heap type, so needs the heap types' dealloc. ++ subtype_dealloc will call the base type's tp_dealloc, if ++ necessary. */ ++ res->ht_type.tp_dealloc = subtype_dealloc; ++ } + + if (PyType_Ready(&res->ht_type) < 0) + goto fail; +@@ -2457,6 +2465,13 @@ + PyObject *meta_attribute, *attribute; + descrgetfunc meta_get; + ++ if (!PyUnicode_Check(name)) { ++ PyErr_Format(PyExc_TypeError, ++ "attribute name must be string, not '%.200s'", ++ name->ob_type->tp_name); ++ return NULL; ++ } ++ + /* Initialize this type (we'll assume the metatype is initialized) */ + if (type->tp_dict == NULL) { + if (PyType_Ready(type) < 0) +@@ -2919,7 +2934,7 @@ + unaryfunc f; + + f = Py_TYPE(self)->tp_repr; +- if (f == NULL || f == object_str) ++ if (f == NULL) + f = object_repr; + return f(self); + } +@@ -3518,6 +3533,7 @@ + + for (; meth->ml_name != NULL; meth++) { + PyObject *descr; ++ int err; + if (PyDict_GetItemString(dict, meth->ml_name) && + !(meth->ml_flags & METH_COEXIST)) + continue; +@@ -3541,9 +3557,10 @@ + } + if (descr == NULL) + return -1; +- if (PyDict_SetItemString(dict, meth->ml_name, descr) < 0) ++ err = PyDict_SetItemString(dict, meth->ml_name, descr); ++ Py_DECREF(descr); ++ if (err < 0) + return -1; +- Py_DECREF(descr); + } + return 0; + } +@@ -5748,7 +5765,8 @@ + } + continue; + } +- if (Py_TYPE(descr) == &PyWrapperDescr_Type) { ++ if (Py_TYPE(descr) == &PyWrapperDescr_Type && ++ ((PyWrapperDescrObject *)descr)->d_base->name_strobj == p->name_strobj) { + void **tptr = resolve_slotdups(type, p->name_strobj); + if (tptr == NULL || tptr == ptr) + generic = p->function; +diff -r 3d0686d90f55 Objects/unicodeobject.c +--- a/Objects/unicodeobject.c ++++ b/Objects/unicodeobject.c +@@ -7673,7 +7673,9 @@ + Py_UNICODE *p; + Py_hash_t x; + ++#ifdef Py_DEBUG + assert(_Py_HashSecret_Initialized); ++#endif + if (self->hash != -1) + return self->hash; + len = Py_SIZE(self); +@@ -9208,10 +9210,6 @@ + } + + static PyMethodDef unicode_methods[] = { +- +- /* Order is according to common usage: often used methods should +- appear first, since lookup is done sequentially. */ +- + {"encode", (PyCFunction) unicode_encode, METH_VARARGS | METH_KEYWORDS, encode__doc__}, + {"replace", (PyCFunction) unicode_replace, METH_VARARGS, replace__doc__}, + {"split", (PyCFunction) unicode_split, METH_VARARGS, split__doc__}, +diff -r 3d0686d90f55 PC/VC6/bz2.dsp +--- a/PC/VC6/bz2.dsp ++++ b/PC/VC6/bz2.dsp +@@ -44,7 +44,7 @@ + # 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.5" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /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" +@@ -54,7 +54,7 @@ + # 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.5\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./bz2.pyd" ++# 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" +@@ -72,7 +72,7 @@ + # 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.5" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /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" +@@ -82,7 +82,7 @@ + # 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.5\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt" /nodefaultlib:"libc" /out:"./bz2_d.pyd" /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 +diff -r 3d0686d90f55 PC/VC6/pythoncore.dsp +--- a/PC/VC6/pythoncore.dsp ++++ b/PC/VC6/pythoncore.dsp +@@ -655,6 +655,10 @@ + # 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 +diff -r 3d0686d90f55 PC/VC6/readme.txt +--- a/PC/VC6/readme.txt ++++ b/PC/VC6/readme.txt +@@ -120,14 +120,14 @@ + Download the source from the python.org copy into the dist + directory: + +- svn export http://svn.python.org/projects/external/bzip2-1.0.5 ++ svn export http://svn.python.org/projects/external/bzip2-1.0.6 + + And requires building bz2 first. + +- cd dist\bzip2-1.0.5 ++ cd dist\bzip2-1.0.6 + nmake -f makefile.msc + +- All of this managed to build bzip2-1.0.5\libbz2.lib, which the Python ++ All of this managed to build bzip2-1.0.6\libbz2.lib, which the Python + project links in. + + +@@ -153,10 +153,9 @@ + + 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.0a ++ dist/openssl-1.0.0j + +- You can (theoretically) use any version of OpenSSL you like - the +- build process will automatically select the latest version. ++ You need to use version 1.0.0j of OpenSSL. + + You can install the NASM assembler from + http://www.nasm.us/ +diff -r 3d0686d90f55 PC/VS7.1/pythoncore.vcproj +--- a/PC/VS7.1/pythoncore.vcproj ++++ b/PC/VS7.1/pythoncore.vcproj +@@ -767,6 +767,9 @@ + RelativePath="..\..\Python\pythonrun.c"> + + ++ ++ + + + + + + + + + + + + + + + ++ ++ + +diff -r 3d0686d90f55 PC/VS8.0/select.vcproj +--- a/PC/VS8.0/select.vcproj ++++ b/PC/VS8.0/select.vcproj +@@ -54,7 +54,7 @@ + /> + +@@ -116,7 +116,7 @@ + /> + +@@ -178,7 +178,7 @@ + /> + +@@ -241,7 +241,7 @@ + /> + +@@ -303,7 +303,7 @@ + /> + +@@ -366,7 +366,7 @@ + /> + + +@@ -492,7 +492,7 @@ + /> + sizeof(long), and sizeof(PY_LONG_LONG) >= sizeof(off_t). + On Win64 the second condition is not true, but if fpos_t replaces off_t + then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64 +diff -r 3d0686d90f55 PC/python3.mak +--- a/PC/python3.mak ++++ b/PC/python3.mak +@@ -1,4 +1,4 @@ +-$(OutDir)python32.dll: python3.def $(OutDir)python32stub.lib ++$(OutDir)python3.dll: python3.def $(OutDir)python32stub.lib + cl /LD /Fe$(OutDir)python3.dll python3dll.c python3.def $(OutDir)python32stub.lib + + $(OutDir)python32stub.lib: python32stub.def +@@ -7,4 +7,4 @@ + clean: + del $(OutDir)python3.dll $(OutDir)python3.lib $(OutDir)python32stub.lib $(OutDir)python3.exp $(OutDir)python32stub.exp + +-rebuild: clean $(OutDir)python32.dll ++rebuild: clean $(OutDir)python3.dll +diff -r 3d0686d90f55 PC/winreg.c +--- a/PC/winreg.c ++++ b/PC/winreg.c +@@ -1110,7 +1110,7 @@ + * nul. RegEnumKeyEx requires a 257 character buffer to + * retrieve such a key name. */ + wchar_t tmpbuf[257]; +- DWORD len = sizeof(tmpbuf); /* includes NULL terminator */ ++ DWORD len = sizeof(tmpbuf)/sizeof(wchar_t); /* includes NULL terminator */ + + if (!PyArg_ParseTuple(args, "Oi:EnumKey", &obKey, &index)) + return NULL; +diff -r 3d0686d90f55 PCbuild/build_ssl.py +--- a/PCbuild/build_ssl.py ++++ b/PCbuild/build_ssl.py +@@ -63,37 +63,13 @@ + 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 os.error: +- 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 ++# Fetch SSL directory from VC properties ++def get_ssl_dir(): ++ propfile = (os.path.join(os.path.dirname(__file__), 'pyproject.vsprops')) ++ with open(propfile) as f: ++ m = re.search('openssl-([^"]+)"', f.read()) ++ return "..\..\openssl-"+m.group(1) ++ + + def create_makefile64(makefile, m32): + """Create and fix makefile for 64bit +@@ -202,7 +178,7 @@ + print("No Perl installation was found. Existing Makefiles are used.") + sys.stdout.flush() + # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. +- ssl_dir = find_best_ssl_dir(("..\\..",)) ++ ssl_dir = get_ssl_dir() + if ssl_dir is None: + sys.exit(1) + +diff -r 3d0686d90f55 PCbuild/bz2.vcproj +--- a/PCbuild/bz2.vcproj ++++ b/PCbuild/bz2.vcproj +@@ -532,7 +532,7 @@ + + + + + + + + + + + +@@ -116,7 +116,7 @@ + /> + +@@ -178,7 +178,7 @@ + /> + +@@ -241,7 +241,7 @@ + /> + +@@ -303,7 +303,7 @@ + /> + +@@ -366,7 +366,7 @@ + /> + + +@@ -492,7 +492,7 @@ + /> + + +@@ -119,7 +119,7 @@ + /> + +@@ -182,7 +182,7 @@ + /> + +@@ -245,7 +245,7 @@ + /> + + +@@ -372,7 +372,7 @@ + /> + c_arena); +-#if 0 +- result = Tuple(args, Store, LINENO(n), n->n_col_offset, c->c_arena); +- if (!set_context(c, result, Store, n)) +- return NULL; +- return result; +-#endif + } + + /* returns -1 if failed to handle keyword only arguments +@@ -859,7 +853,7 @@ + "non-default argument follows default argument"); + return NULL; + } +- arg = compiler_arg(c, ch); ++ arg = ast_for_arg(c, ch); + if (!arg) + return NULL; + asdl_seq_SET(posargs, k++, arg); +diff -r 3d0686d90f55 Python/bltinmodule.c +--- a/Python/bltinmodule.c ++++ b/Python/bltinmodule.c +@@ -158,10 +158,8 @@ + cls = PyEval_CallObjectWithKeywords(meta, margs, mkw); + Py_DECREF(margs); + } +- if (cls != NULL && PyCell_Check(cell)) { +- Py_INCREF(cls); +- PyCell_SET(cell, cls); +- } ++ if (cls != NULL && PyCell_Check(cell)) ++ PyCell_Set(cell, cls); + Py_DECREF(cell); + } + Py_DECREF(ns); +diff -r 3d0686d90f55 Python/compile.c +--- a/Python/compile.c ++++ b/Python/compile.c +@@ -1319,7 +1319,11 @@ + arg_ty arg = asdl_seq_GET(kwonlyargs, i); + expr_ty default_ = asdl_seq_GET(kw_defaults, i); + if (default_) { +- ADDOP_O(c, LOAD_CONST, arg->arg, consts); ++ PyObject *mangled = _Py_Mangle(c->u->u_private, arg->arg); ++ if (!mangled) ++ return -1; ++ ADDOP_O(c, LOAD_CONST, mangled, consts); ++ Py_DECREF(mangled); + if (!compiler_visit_expr(c, default_)) { + return -1; + } +diff -r 3d0686d90f55 Python/future.c +--- a/Python/future.c ++++ b/Python/future.c +@@ -60,13 +60,6 @@ + { + int i, found_docstring = 0, done = 0, prev_line = 0; + +- static PyObject *future; +- if (!future) { +- future = PyUnicode_InternFromString("__future__"); +- if (!future) +- return 0; +- } +- + if (!(mod->kind == Module_kind || mod->kind == Interactive_kind)) + return 1; + +@@ -93,7 +86,9 @@ + */ + + if (s->kind == ImportFrom_kind) { +- if (s->v.ImportFrom.module == future) { ++ identifier modname = s->v.ImportFrom.module; ++ if (modname && ++ !PyUnicode_CompareWithASCIIString(modname, "__future__")) { + if (done) { + PyErr_SetString(PyExc_SyntaxError, + ERR_LATE_FUTURE); +diff -r 3d0686d90f55 Python/getargs.c +--- a/Python/getargs.c ++++ b/Python/getargs.c +@@ -1633,6 +1633,7 @@ + case 'z': /* string or None */ + case 'y': /* bytes */ + case 'u': /* unicode string */ ++ case 'Z': /* unicode string or None */ + case 'w': /* buffer, read-write */ + { + (void) va_arg(*p_va, char **); +diff -r 3d0686d90f55 Python/import.c +--- a/Python/import.c ++++ b/Python/import.c +@@ -1291,9 +1291,9 @@ + { + struct stat st; + FILE *fpc; +- char buf[MAXPATHLEN+1]; ++ char *buf; + char *cpathname; +- PyCodeObject *co; ++ PyCodeObject *co = NULL; + PyObject *m; + + if (fstat(fileno(fp), &st) != 0) { +@@ -1310,6 +1310,10 @@ + */ + st.st_mtime &= 0xFFFFFFFF; + } ++ buf = PyMem_MALLOC(MAXPATHLEN+1); ++ if (buf == NULL) { ++ return PyErr_NoMemory(); ++ } + cpathname = make_compiled_pathname( + pathname, buf, (size_t)MAXPATHLEN + 1, !Py_OptimizeFlag); + if (cpathname != NULL && +@@ -1317,9 +1321,9 @@ + co = read_compiled_module(cpathname, fpc); + fclose(fpc); + if (co == NULL) +- return NULL; ++ goto error_exit; + if (update_compiled_module(co, pathname) < 0) +- return NULL; ++ goto error_exit; + if (Py_VerboseFlag) + PySys_WriteStderr("import %s # precompiled from %s\n", + name, cpathname); +@@ -1328,7 +1332,7 @@ + else { + co = parse_source_module(pathname, fp); + if (co == NULL) +- return NULL; ++ goto error_exit; + if (Py_VerboseFlag) + PySys_WriteStderr("import %s # from %s\n", + name, pathname); +@@ -1342,7 +1346,13 @@ + name, (PyObject *)co, pathname, cpathname); + Py_DECREF(co); + ++ PyMem_FREE(buf); + return m; ++ ++error_exit: ++ Py_XDECREF(co); ++ PyMem_FREE(buf); ++ return NULL; + } + + /* Get source file -> unicode or None +@@ -1351,7 +1361,7 @@ + static PyObject * + get_sourcefile(char *file) + { +- char py[MAXPATHLEN + 1]; ++ char *py = NULL; + Py_ssize_t len; + PyObject *u; + struct stat statbuf; +@@ -1366,6 +1376,10 @@ + return PyUnicode_DecodeFSDefault(file); + } + ++ py = PyMem_MALLOC(MAXPATHLEN+1); ++ if (py == NULL) { ++ return PyErr_NoMemory(); ++ } + /* Start by trying to turn PEP 3147 path into source path. If that + * fails, just chop off the trailing character, i.e. legacy pyc path + * to py. +@@ -1382,6 +1396,7 @@ + else { + u = PyUnicode_DecodeFSDefault(file); + } ++ PyMem_FREE(py); + return u; + } + +@@ -1401,7 +1416,7 @@ + PyObject *file = NULL; + PyObject *path = NULL; + int err; +- char buf[MAXPATHLEN+1]; ++ char *buf = NULL; + FILE *fp = NULL; + struct filedescr *fdp; + +@@ -1423,8 +1438,13 @@ + err = PyDict_SetItemString(d, "__path__", path); + if (err != 0) + goto error; ++ buf = PyMem_MALLOC(MAXPATHLEN+1); ++ if (buf == NULL) { ++ PyErr_NoMemory(); ++ goto error; ++ } + buf[0] = '\0'; +- fdp = find_module(name, "__init__", path, buf, sizeof(buf), &fp, NULL); ++ fdp = find_module(name, "__init__", path, buf, MAXPATHLEN+1, &fp, NULL); + if (fdp == NULL) { + if (PyErr_ExceptionMatches(PyExc_ImportError)) { + PyErr_Clear(); +@@ -1442,6 +1462,8 @@ + error: + m = NULL; + cleanup: ++ if (buf) ++ PyMem_FREE(buf); + Py_XDECREF(path); + Py_XDECREF(file); + return m; +@@ -1571,7 +1593,7 @@ + static struct filedescr fd_frozen = {"", "", PY_FROZEN}; + static struct filedescr fd_builtin = {"", "", C_BUILTIN}; + static struct filedescr fd_package = {"", "", PKG_DIRECTORY}; +- char name[MAXPATHLEN+1]; ++ char *name; + #if defined(PYOS_OS2) + size_t saved_len; + size_t saved_namelen; +@@ -1585,6 +1607,11 @@ + "module name is too long"); + return NULL; + } ++ name = PyMem_MALLOC(MAXPATHLEN+1); ++ if (name == NULL) { ++ PyErr_NoMemory(); ++ return NULL; ++ } + strcpy(name, subname); + + /* sys.meta_path import hook */ +@@ -1596,7 +1623,7 @@ + PyErr_SetString(PyExc_RuntimeError, + "sys.meta_path must be a list of " + "import hooks"); +- return NULL; ++ goto error_exit; + } + Py_INCREF(meta_path); /* zap guard */ + npath = PyList_Size(meta_path); +@@ -1609,12 +1636,13 @@ + path : Py_None); + if (loader == NULL) { + Py_DECREF(meta_path); +- return NULL; /* true error */ ++ goto error_exit; /* true error */ + } + if (loader != Py_None) { + /* a loader was found */ + *p_loader = loader; + Py_DECREF(meta_path); ++ PyMem_FREE(name); + return &importhookdescr; + } + Py_DECREF(loader); +@@ -1624,18 +1652,21 @@ + + if (find_frozen(fullname) != NULL) { + strcpy(buf, fullname); ++ PyMem_FREE(name); + return &fd_frozen; + } + + if (path == NULL) { + if (is_builtin(name)) { + strcpy(buf, name); ++ PyMem_FREE(name); + return &fd_builtin; + } + #ifdef MS_COREDLL + fp = PyWin_FindRegisteredModule(name, &fdp, buf, buflen); + if (fp != NULL) { + *p_fp = fp; ++ PyMem_FREE(name); + return fdp; + } + #endif +@@ -1645,7 +1676,7 @@ + if (path == NULL || !PyList_Check(path)) { + PyErr_SetString(PyExc_RuntimeError, + "sys.path must be a list of directory names"); +- return NULL; ++ goto error_exit; + } + + path_hooks = PySys_GetObject("path_hooks"); +@@ -1653,14 +1684,14 @@ + PyErr_SetString(PyExc_RuntimeError, + "sys.path_hooks must be a list of " + "import hooks"); +- return NULL; ++ goto error_exit; + } + path_importer_cache = PySys_GetObject("path_importer_cache"); + if (path_importer_cache == NULL || + !PyDict_Check(path_importer_cache)) { + PyErr_SetString(PyExc_RuntimeError, + "sys.path_importer_cache must be a dict"); +- return NULL; ++ goto error_exit; + } + + npath = PyList_Size(path); +@@ -1671,11 +1702,11 @@ + const char *base; + Py_ssize_t size; + if (!v) +- return NULL; ++ goto error_exit; + if (PyUnicode_Check(v)) { + v = PyUnicode_EncodeFSDefault(v); + if (v == NULL) +- return NULL; ++ goto error_exit; + } + else if (!PyBytes_Check(v)) + continue; +@@ -1703,7 +1734,7 @@ + importer = get_path_importer(path_importer_cache, + path_hooks, origv); + if (importer == NULL) { +- return NULL; ++ goto error_exit; + } + /* Note: importer is a borrowed reference */ + if (importer != Py_None) { +@@ -1712,10 +1743,11 @@ + "find_module", + "s", fullname); + if (loader == NULL) +- return NULL; /* error */ ++ goto error_exit; /* error */ + if (loader != Py_None) { + /* a loader was found */ + *p_loader = loader; ++ PyMem_FREE(name); + return &importhookdescr; + } + Py_DECREF(loader); +@@ -1740,19 +1772,20 @@ + S_ISDIR(statbuf.st_mode) && /* it's a directory */ + case_ok(buf, len, namelen, name)) { /* case matches */ + if (find_init_module(buf)) { /* and has __init__.py */ ++ PyMem_FREE(name); + return &fd_package; + } + else { + int err; + PyObject *unicode = PyUnicode_DecodeFSDefault(buf); + if (unicode == NULL) +- return NULL; ++ goto error_exit; + err = PyErr_WarnFormat(PyExc_ImportWarning, 1, + "Not importing directory '%U': missing __init__.py", + unicode); + Py_DECREF(unicode); + if (err) +- return NULL; ++ goto error_exit; + } + } + #endif +@@ -1833,10 +1866,15 @@ + if (fp == NULL) { + PyErr_Format(PyExc_ImportError, + "No module named %.200s", name); +- return NULL; ++ goto error_exit; + } + *p_fp = fp; ++ PyMem_FREE(name); + return fdp; ++ ++error_exit: ++ PyMem_FREE(name); ++ return NULL; + } + + /* case_ok(char* buf, Py_ssize_t len, Py_ssize_t namelen, char* name) +@@ -2416,7 +2454,7 @@ + import_module_level(char *name, PyObject *globals, PyObject *locals, + PyObject *fromlist, int level) + { +- char buf[MAXPATHLEN+1]; ++ char *buf; + Py_ssize_t buflen = 0; + PyObject *parent, *head, *next, *tail; + +@@ -2430,14 +2468,18 @@ + return NULL; + } + ++ buf = PyMem_MALLOC(MAXPATHLEN+1); ++ if (buf == NULL) { ++ return PyErr_NoMemory(); ++ } + parent = get_parent(globals, buf, &buflen, level); + if (parent == NULL) +- return NULL; ++ goto error_exit; + + head = load_next(parent, level < 0 ? Py_None : parent, &name, buf, + &buflen); + if (head == NULL) +- return NULL; ++ goto error_exit; + + tail = head; + Py_INCREF(tail); +@@ -2446,7 +2488,7 @@ + Py_DECREF(tail); + if (next == NULL) { + Py_DECREF(head); +- return NULL; ++ goto error_exit; + } + tail = next; + } +@@ -2458,7 +2500,7 @@ + Py_DECREF(head); + PyErr_SetString(PyExc_ValueError, + "Empty module name"); +- return NULL; ++ goto error_exit; + } + + if (fromlist != NULL) { +@@ -2468,16 +2510,22 @@ + + if (fromlist == NULL) { + Py_DECREF(tail); ++ PyMem_FREE(buf); + return head; + } + + Py_DECREF(head); + if (!ensure_fromlist(tail, fromlist, buf, buflen, 0)) { + Py_DECREF(tail); +- return NULL; ++ goto error_exit; + } + ++ PyMem_FREE(buf); + return tail; ++ ++error_exit: ++ PyMem_FREE(buf); ++ return NULL; + } + + PyObject * +@@ -2880,7 +2928,7 @@ + } + else { + PyObject *path, *loader = NULL; +- char buf[MAXPATHLEN+1]; ++ char *buf; + struct filedescr *fdp; + FILE *fp = NULL; + +@@ -2895,11 +2943,16 @@ + } + } + ++ buf = PyMem_MALLOC(MAXPATHLEN+1); ++ if (buf == NULL) { ++ return PyErr_NoMemory(); ++ } + buf[0] = '\0'; + fdp = find_module(fullname, subname, path, buf, MAXPATHLEN+1, + &fp, &loader); + Py_XDECREF(path); + if (fdp == NULL) { ++ PyMem_FREE(buf); + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + return NULL; + PyErr_Clear(); +@@ -2914,6 +2967,7 @@ + Py_XDECREF(m); + m = NULL; + } ++ PyMem_FREE(buf); + } + + return m; +@@ -2931,7 +2985,7 @@ + PyObject *modules = PyImport_GetModuleDict(); + PyObject *path = NULL, *loader = NULL, *existing_m = NULL; + char *name, *subname; +- char buf[MAXPATHLEN+1]; ++ char *buf; + struct filedescr *fdp; + FILE *fp = NULL; + PyObject *newm; +@@ -2991,6 +3045,11 @@ + if (path == NULL) + PyErr_Clear(); + } ++ buf = PyMem_MALLOC(MAXPATHLEN+1); ++ if (buf == NULL) { ++ Py_XDECREF(path); ++ return PyErr_NoMemory(); ++ } + buf[0] = '\0'; + fdp = find_module(name, subname, path, buf, MAXPATHLEN+1, &fp, &loader); + Py_XDECREF(path); +@@ -2998,6 +3057,7 @@ + if (fdp == NULL) { + Py_XDECREF(loader); + imp_modules_reloading_clear(); ++ PyMem_FREE(buf); + return NULL; + } + +@@ -3015,6 +3075,7 @@ + PyDict_SetItemString(modules, name, m); + } + imp_modules_reloading_clear(); ++ PyMem_FREE(buf); + return newm; + } + +@@ -3168,26 +3229,32 @@ + PyObject *fob, *ret; + PyObject *pathobj; + struct filedescr *fdp; +- char pathname[MAXPATHLEN+1]; ++ char *pathname; + FILE *fp = NULL; + int fd = -1; + char *found_encoding = NULL; + char *encoding = NULL; + ++ pathname = PyMem_MALLOC(MAXPATHLEN+1); ++ if (pathname == NULL) { ++ return PyErr_NoMemory(); ++ } + pathname[0] = '\0'; + if (path == Py_None) + path = NULL; + fdp = find_module(NULL, name, path, pathname, MAXPATHLEN+1, &fp, NULL); + if (fdp == NULL) +- return NULL; ++ goto error_exit; + if (fp != NULL) { + fd = fileno(fp); + if (fd != -1) + fd = dup(fd); + fclose(fp); + fp = NULL; +- if (fd == -1) +- return PyErr_SetFromErrno(PyExc_OSError); ++ if (fd == -1) { ++ PyErr_SetFromErrno(PyExc_OSError); ++ goto error_exit; ++ } + } + if (fd != -1) { + if (strchr(fdp->mode, 'b') == NULL) { +@@ -3197,7 +3264,7 @@ + lseek(fd, 0, 0); /* Reset position */ + if (found_encoding == NULL && PyErr_Occurred()) { + close(fd); +- return NULL; ++ goto error_exit; + } + encoding = (found_encoding != NULL) ? found_encoding : + (char*)PyUnicode_GetDefaultEncoding(); +@@ -3207,7 +3274,7 @@ + if (fob == NULL) { + close(fd); + PyMem_FREE(found_encoding); +- return NULL; ++ goto error_exit; + } + } + else { +@@ -3218,8 +3285,12 @@ + ret = Py_BuildValue("NN(ssi)", + fob, pathobj, fdp->suffix, fdp->mode, fdp->type); + PyMem_FREE(found_encoding); +- ++ PyMem_FREE(pathname); + return ret; ++ ++error_exit: ++ PyMem_FREE(pathname); ++ return NULL; + } + + static PyObject * +@@ -3509,7 +3580,7 @@ + { + static char *kwlist[] = {"path", "debug_override", NULL}; + +- char buf[MAXPATHLEN+1]; ++ char *buf; + PyObject *pathbytes; + char *cpathname; + PyObject *debug_override = NULL; +@@ -3526,6 +3597,10 @@ + return NULL; + } + ++ buf = PyMem_MALLOC(MAXPATHLEN+1); ++ if (buf == NULL) { ++ return PyErr_NoMemory(); ++ } + cpathname = make_compiled_pathname( + PyBytes_AS_STRING(pathbytes), + buf, MAXPATHLEN+1, debug); +@@ -3533,9 +3608,14 @@ + + if (cpathname == NULL) { + PyErr_Format(PyExc_SystemError, "path buffer too short"); ++ PyMem_FREE(buf); + return NULL; + } +- return PyUnicode_DecodeFSDefault(buf); ++ { ++ PyObject *ret = PyUnicode_DecodeFSDefault(buf); ++ PyMem_FREE(buf); ++ return ret; ++ } + } + + PyDoc_STRVAR(doc_cache_from_source, +@@ -3556,7 +3636,7 @@ + + PyObject *pathname_obj; + char *pathname; +- char buf[MAXPATHLEN+1]; ++ char *buf; + + if (!PyArg_ParseTupleAndKeywords( + args, kws, "O&", kwlist, +@@ -3564,14 +3644,23 @@ + return NULL; + + pathname = PyBytes_AS_STRING(pathname_obj); ++ buf = PyMem_MALLOC(MAXPATHLEN+1); ++ if (buf == NULL) { ++ return PyErr_NoMemory(); ++ } + if (make_source_pathname(pathname, buf) == NULL) { + PyErr_Format(PyExc_ValueError, "Not a PEP 3147 pyc path: %s", + pathname); + Py_DECREF(pathname_obj); ++ PyMem_FREE(buf); + return NULL; + } + Py_DECREF(pathname_obj); +- return PyUnicode_FromString(buf); ++ { ++ PyObject *ret = PyUnicode_FromString(buf); ++ PyMem_FREE(buf); ++ return ret; ++ } + } + + PyDoc_STRVAR(doc_source_from_cache, +diff -r 3d0686d90f55 Python/marshal.c +--- a/Python/marshal.c ++++ b/Python/marshal.c +@@ -411,11 +411,12 @@ + else if (PyObject_CheckBuffer(v)) { + /* Write unknown buffer-style objects as a string */ + char *s; +- PyBufferProcs *pb = v->ob_type->tp_as_buffer; + Py_buffer view; +- if ((*pb->bf_getbuffer)(v, &view, PyBUF_SIMPLE) != 0) { ++ if (PyObject_GetBuffer(v, &view, PyBUF_SIMPLE) != 0) { + w_byte(TYPE_UNKNOWN, p); ++ p->depth--; + p->error = WFERR_UNMARSHALLABLE; ++ return; + } + w_byte(TYPE_STRING, p); + n = view.len; +@@ -427,8 +428,7 @@ + } + w_long((long)n, p); + w_string(s, (int)n, p); +- if (pb->bf_releasebuffer != NULL) +- (*pb->bf_releasebuffer)(v, &view); ++ PyBuffer_Release(&view); + } + else { + w_byte(TYPE_UNKNOWN, p); +@@ -1383,7 +1383,7 @@ + char *s; + Py_ssize_t n; + PyObject* result; +- if (!PyArg_ParseTuple(args, "s*:loads", &p)) ++ if (!PyArg_ParseTuple(args, "y*:loads", &p)) + return NULL; + s = p.buf; + n = p.len; +@@ -1400,10 +1400,10 @@ + } + + PyDoc_STRVAR(loads_doc, +-"loads(string)\n\ ++"loads(bytes)\n\ + \n\ +-Convert the string to a value. If no valid value is found, raise\n\ +-EOFError, ValueError or TypeError. Extra characters in the string are\n\ ++Convert the bytes object to a value. If no valid value is found, raise\n\ ++EOFError, ValueError or TypeError. Extra characters in the input are\n\ + ignored."); + + static PyMethodDef marshal_methods[] = { +diff -r 3d0686d90f55 Python/pystate.c +--- a/Python/pystate.c ++++ b/Python/pystate.c +@@ -22,6 +22,9 @@ + #endif + #endif + ++#ifdef __cplusplus ++extern "C" { ++#endif + + #ifdef WITH_THREAD + #include "pythread.h" +@@ -30,10 +33,6 @@ + #define HEAD_LOCK() PyThread_acquire_lock(head_mutex, WAIT_LOCK) + #define HEAD_UNLOCK() PyThread_release_lock(head_mutex) + +-#ifdef __cplusplus +-extern "C" { +-#endif +- + /* The single PyInterpreterState used by this process' + GILState implementation + */ +@@ -727,10 +726,10 @@ + PyEval_SaveThread(); + } + ++#endif /* WITH_THREAD */ ++ + #ifdef __cplusplus + } + #endif + +-#endif /* WITH_THREAD */ + +- +diff -r 3d0686d90f55 Python/pythonrun.c +--- a/Python/pythonrun.c ++++ b/Python/pythonrun.c +@@ -696,7 +696,11 @@ + PyInterpreterState_Delete(interp); + } + ++#ifdef MS_WINDOWS + static wchar_t *progname = L"python"; ++#else ++static wchar_t *progname = L"python3"; ++#endif + + void + Py_SetProgramName(wchar_t *pn) +@@ -1335,56 +1339,67 @@ + return PyArg_ParseTuple(err, "O(ziiz)", message, filename, + lineno, offset, text); + ++ *message = NULL; ++ + /* new style errors. `err' is an instance */ +- +- if (! (v = PyObject_GetAttrString(err, "msg"))) +- goto finally; +- *message = v; +- +- if (!(v = PyObject_GetAttrString(err, "filename"))) +- goto finally; +- if (v == Py_None) +- *filename = NULL; +- else if (! (*filename = _PyUnicode_AsString(v))) ++ *message = PyObject_GetAttrString(err, "msg"); ++ if (!*message) + goto finally; + +- Py_DECREF(v); +- if (!(v = PyObject_GetAttrString(err, "lineno"))) ++ v = PyObject_GetAttrString(err, "filename"); ++ if (!v) ++ goto finally; ++ if (v == Py_None) { ++ Py_DECREF(v); ++ *filename = NULL; ++ } ++ else { ++ *filename = _PyUnicode_AsString(v); ++ Py_DECREF(v); ++ if (!*filename) ++ goto finally; ++ } ++ ++ v = PyObject_GetAttrString(err, "lineno"); ++ if (!v) + goto finally; + hold = PyLong_AsLong(v); + Py_DECREF(v); +- v = NULL; + if (hold < 0 && PyErr_Occurred()) + goto finally; + *lineno = (int)hold; + +- if (!(v = PyObject_GetAttrString(err, "offset"))) ++ v = PyObject_GetAttrString(err, "offset"); ++ if (!v) + goto finally; + if (v == Py_None) { + *offset = -1; + Py_DECREF(v); +- v = NULL; + } else { + hold = PyLong_AsLong(v); + Py_DECREF(v); +- v = NULL; + if (hold < 0 && PyErr_Occurred()) + goto finally; + *offset = (int)hold; + } + +- if (!(v = PyObject_GetAttrString(err, "text"))) ++ v = PyObject_GetAttrString(err, "text"); ++ if (!v) + goto finally; +- if (v == Py_None) ++ if (v == Py_None) { ++ Py_DECREF(v); + *text = NULL; +- else if (!PyUnicode_Check(v) || +- !(*text = _PyUnicode_AsString(v))) +- goto finally; +- Py_DECREF(v); ++ } ++ else { ++ *text = _PyUnicode_AsString(v); ++ Py_DECREF(v); ++ if (!*text) ++ goto finally; ++ } + return 1; + + finally: +- Py_XDECREF(v); ++ Py_XDECREF(*message); + return 0; + } + +diff -r 3d0686d90f55 Python/thread_pthread.h +--- a/Python/thread_pthread.h ++++ b/Python/thread_pthread.h +@@ -19,14 +19,18 @@ + #define THREAD_STACK_SIZE 0 /* use default stack size */ + #endif + +-#if (defined(__APPLE__) || defined(__FreeBSD__)) && defined(THREAD_STACK_SIZE) && THREAD_STACK_SIZE == 0 +- /* The default stack size for new threads on OSX is small enough that +- * we'll get hard crashes instead of 'maximum recursion depth exceeded' +- * exceptions. +- * +- * The default stack size below is the minimal stack size where a +- * simple recursive function doesn't cause a hard crash. +- */ ++/* The default stack size for new threads on OSX and BSD is small enough that ++ * we'll get hard crashes instead of 'maximum recursion depth exceeded' ++ * exceptions. ++ * ++ * The default stack sizes below are the empirically determined minimal stack ++ * sizes where a simple recursive function doesn't cause a hard crash. ++ */ ++#if defined(__APPLE__) && defined(THREAD_STACK_SIZE) && THREAD_STACK_SIZE == 0 ++#undef THREAD_STACK_SIZE ++#define THREAD_STACK_SIZE 0x500000 ++#endif ++#if defined(__FreeBSD__) && defined(THREAD_STACK_SIZE) && THREAD_STACK_SIZE == 0 + #undef THREAD_STACK_SIZE + #define THREAD_STACK_SIZE 0x400000 + #endif +diff -r 3d0686d90f55 Tools/buildbot/build-amd64.bat +--- a/Tools/buildbot/build-amd64.bat ++++ b/Tools/buildbot/build-amd64.bat +@@ -1,4 +1,5 @@ + @rem Used by the buildbot "compile" step. ++set HOST_PYTHON="%CD%\PCbuild\amd64\python_d.exe" + cmd /c Tools\buildbot\external-amd64.bat + call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64 + cmd /c Tools\buildbot\clean-amd64.bat +diff -r 3d0686d90f55 Tools/buildbot/clean.bat +--- a/Tools/buildbot/clean.bat ++++ b/Tools/buildbot/clean.bat +@@ -1,7 +1,5 @@ + @rem Used by the buildbot "clean" step. + call "%VS90COMNTOOLS%vsvars32.bat" +-@echo Deleting .pyc/.pyo files ... +-del /s Lib\*.pyc Lib\*.pyo + @echo Deleting test leftovers ... + rmdir /s /q build + cd PCbuild +diff -r 3d0686d90f55 Tools/buildbot/external-common.bat +--- a/Tools/buildbot/external-common.bat ++++ b/Tools/buildbot/external-common.bat +@@ -4,7 +4,7 @@ + cd .. + @rem XXX: If you need to force the buildbots to start from a fresh environment, uncomment + @rem the following, check it in, then check it out, comment it out, then check it back in. +-@rem if exist bzip2-1.0.5 rd /s/q bzip2-1.0.5 ++@rem if exist bzip2-1.0.6 rd /s/q bzip2-1.0.6 + @rem if exist tcltk rd /s/q tcltk + @rem if exist tcltk64 rd /s/q tcltk64 + @rem if exist tcl8.4.12 rd /s/q tcl8.4.12 +@@ -14,20 +14,17 @@ + @rem if exist tk8.4.16 rd /s/q tk8.4.16 + @rem if exist tk-8.4.18.1 rd /s/q tk-8.4.18.1 + @rem if exist db-4.4.20 rd /s/q db-4.4.20 +-@rem if exist openssl-1.0.0a rd /s/q openssl-1.0.0a ++@rem if exist openssl-1.0.0j rd /s/q openssl-1.0.0j + @rem if exist sqlite-3.7.4 rd /s/q sqlite-3.7.4 + + @rem bzip +-if not exist bzip2-1.0.5 ( +- rd /s/q bzip2-1.0.3 +- svn export http://svn.python.org/projects/external/bzip2-1.0.5 ++if not exist bzip2-1.0.6 ( ++ rd /s/q bzip2-1.0.5 ++ svn export http://svn.python.org/projects/external/bzip2-1.0.6 + ) + +-@rem Sleepycat db +-if not exist db-4.4.20 svn export http://svn.python.org/projects/external/db-4.4.20-vs9 db-4.4.20 +- + @rem OpenSSL +-if not exist openssl-1.0.0a svn export http://svn.python.org/projects/external/openssl-1.0.0a ++if not exist openssl-1.0.0j svn export http://svn.python.org/projects/external/openssl-1.0.0j + + @rem tcl/tk + if not exist tcl-8.5.9.0 ( +diff -r 3d0686d90f55 Tools/buildbot/test-amd64.bat +--- a/Tools/buildbot/test-amd64.bat ++++ b/Tools/buildbot/test-amd64.bat +@@ -1,3 +1,3 @@ + @rem Used by the buildbot "test" step. + cd PCbuild +-call rt.bat -q -d -x64 -uall -rw ++call rt.bat -d -q -x64 -uall -rwW -n %1 %2 %3 %4 %5 %6 %7 %8 %9 +diff -r 3d0686d90f55 Tools/buildbot/test.bat +--- a/Tools/buildbot/test.bat ++++ b/Tools/buildbot/test.bat +@@ -1,4 +1,3 @@ + @rem Used by the buildbot "test" step. + cd PCbuild +-call rt.bat -d -q -uall -rwW -n +- ++call rt.bat -d -q -uall -rwW -n %1 %2 %3 %4 %5 %6 %7 %8 %9 +diff -r 3d0686d90f55 Tools/msi/msi.py +--- a/Tools/msi/msi.py ++++ b/Tools/msi/msi.py +@@ -1021,6 +1021,7 @@ + lib.add_file("check_soundcard.vbs") + lib.add_file("empty.vbs") + lib.add_file("Sine-1000Hz-300ms.aif") ++ lib.add_file("mime.types") + lib.glob("*.uue") + lib.glob("*.pem") + lib.glob("*.pck") +diff -r 3d0686d90f55 Tools/parser/test_unparse.py +--- a/Tools/parser/test_unparse.py ++++ b/Tools/parser/test_unparse.py +@@ -209,6 +209,13 @@ + def test_try_except_finally(self): + self.check_roundtrip(try_except_finally) + ++ def test_starred_assignment(self): ++ self.check_roundtrip("a, *b, c = seq") ++ self.check_roundtrip("a, (*b, c) = seq") ++ self.check_roundtrip("a, *b[0], c = seq") ++ self.check_roundtrip("a, *(b, c) = seq") ++ ++ + class DirectoryTestCase(ASTTestCase): + """Test roundtrip behaviour on all files in Lib and Lib/test.""" + +diff -r 3d0686d90f55 Tools/parser/unparse.py +--- a/Tools/parser/unparse.py ++++ b/Tools/parser/unparse.py +@@ -472,6 +472,10 @@ + self.dispatch(t.slice) + self.write("]") + ++ def _Starred(self, t): ++ self.write("*") ++ self.dispatch(t.value) ++ + # slice + def _Ellipsis(self, t): + self.write("...") +diff -r 3d0686d90f55 Tools/scripts/abitype.py +--- a/Tools/scripts/abitype.py ++++ b/Tools/scripts/abitype.py +@@ -3,34 +3,6 @@ + # Usage: abitype.py < old_code > new_code + import re, sys + +-############ Simplistic C scanner ################################## +-tokenizer = re.compile( +- r"(?P#.*\n)" +- r"|(?P/\*.*?\*/)" +- r"|(?P[a-zA-Z_][a-zA-Z0-9_]*)" +- r"|(?P[ \t\n]+)" +- r"|(?P.)", +- re.MULTILINE) +- +-tokens = [] +-source = sys.stdin.read() +-pos = 0 +-while pos != len(source): +- m = tokenizer.match(source, pos) +- tokens.append([m.lastgroup, m.group()]) +- pos += len(tokens[-1][1]) +- if tokens[-1][0] == 'preproc': +- # continuation lines are considered +- # only in preprocess statements +- while tokens[-1][1].endswith('\\\n'): +- nl = source.find('\n', pos) +- if nl == -1: +- line = source[pos:] +- else: +- line = source[pos:nl+1] +- tokens[-1][1] += line +- pos += len(line) +- + ###### Replacement of PyTypeObject static instances ############## + + # classify each token, giving it a one-letter code: +@@ -79,7 +51,7 @@ + while tokens[pos][0] in ('ws', 'comment'): + pos += 1 + if tokens[pos][1] != 'PyVarObject_HEAD_INIT': +- raise Exception, '%s has no PyVarObject_HEAD_INIT' % name ++ raise Exception('%s has no PyVarObject_HEAD_INIT' % name) + while tokens[pos][1] != ')': + pos += 1 + pos += 1 +@@ -183,18 +155,48 @@ + return '\n'.join(res) + + +-# Main loop: replace all static PyTypeObjects until +-# there are none left. +-while 1: +- c = classify() +- m = re.search('(SW)?TWIW?=W?{.*?};', c) +- if not m: +- break +- start = m.start() +- end = m.end() +- name, fields = get_fields(start, m) +- tokens[start:end] = [('',make_slots(name, fields))] ++if __name__ == '__main__': + +-# Output result to stdout +-for t, v in tokens: +- sys.stdout.write(v) ++ ############ Simplistic C scanner ################################## ++ tokenizer = re.compile( ++ r"(?P#.*\n)" ++ r"|(?P/\*.*?\*/)" ++ r"|(?P[a-zA-Z_][a-zA-Z0-9_]*)" ++ r"|(?P[ \t\n]+)" ++ r"|(?P.)", ++ re.MULTILINE) ++ ++ tokens = [] ++ source = sys.stdin.read() ++ pos = 0 ++ while pos != len(source): ++ m = tokenizer.match(source, pos) ++ tokens.append([m.lastgroup, m.group()]) ++ pos += len(tokens[-1][1]) ++ if tokens[-1][0] == 'preproc': ++ # continuation lines are considered ++ # only in preprocess statements ++ while tokens[-1][1].endswith('\\\n'): ++ nl = source.find('\n', pos) ++ if nl == -1: ++ line = source[pos:] ++ else: ++ line = source[pos:nl+1] ++ tokens[-1][1] += line ++ pos += len(line) ++ ++ # Main loop: replace all static PyTypeObjects until ++ # there are none left. ++ while 1: ++ c = classify() ++ m = re.search('(SW)?TWIW?=W?{.*?};', c) ++ if not m: ++ break ++ start = m.start() ++ end = m.end() ++ name, fields = get_fields(start, m) ++ tokens[start:end] = [('',make_slots(name, fields))] ++ ++ # Output result to stdout ++ for t, v in tokens: ++ sys.stdout.write(v) +diff -r 3d0686d90f55 Tools/scripts/find_recursionlimit.py +--- a/Tools/scripts/find_recursionlimit.py ++++ b/Tools/scripts/find_recursionlimit.py +@@ -106,14 +106,16 @@ + else: + print("Yikes!") + +-limit = 1000 +-while 1: +- check_limit(limit, "test_recurse") +- check_limit(limit, "test_add") +- check_limit(limit, "test_repr") +- check_limit(limit, "test_init") +- check_limit(limit, "test_getattr") +- check_limit(limit, "test_getitem") +- check_limit(limit, "test_cpickle") +- print("Limit of %d is fine" % limit) +- limit = limit + 100 ++if __name__ == '__main__': ++ ++ limit = 1000 ++ while 1: ++ check_limit(limit, "test_recurse") ++ check_limit(limit, "test_add") ++ check_limit(limit, "test_repr") ++ check_limit(limit, "test_init") ++ check_limit(limit, "test_getattr") ++ check_limit(limit, "test_getitem") ++ check_limit(limit, "test_cpickle") ++ print("Limit of %d is fine" % limit) ++ limit = limit + 100 +diff -r 3d0686d90f55 Tools/scripts/findnocoding.py +--- a/Tools/scripts/findnocoding.py ++++ b/Tools/scripts/findnocoding.py +@@ -76,29 +76,31 @@ + -c: recognize Python source files trying to compile them + -d: debug output""" % sys.argv[0] + +-try: +- opts, args = getopt.getopt(sys.argv[1:], 'cd') +-except getopt.error as msg: +- print(msg, file=sys.stderr) +- print(usage, file=sys.stderr) +- sys.exit(1) ++if __name__ == '__main__': + +-is_python = pysource.looks_like_python +-debug = False ++ try: ++ opts, args = getopt.getopt(sys.argv[1:], 'cd') ++ except getopt.error as msg: ++ print(msg, file=sys.stderr) ++ print(usage, file=sys.stderr) ++ sys.exit(1) + +-for o, a in opts: +- if o == '-c': +- is_python = pysource.can_be_compiled +- elif o == '-d': +- debug = True ++ is_python = pysource.looks_like_python ++ debug = False + +-if not args: +- print(usage, file=sys.stderr) +- sys.exit(1) ++ for o, a in opts: ++ if o == '-c': ++ is_python = pysource.can_be_compiled ++ elif o == '-d': ++ debug = True + +-for fullpath in pysource.walk_python_files(args, is_python): +- if debug: +- print("Testing for coding: %s" % fullpath) +- result = needs_declaration(fullpath) +- if result: +- print(fullpath) ++ if not args: ++ print(usage, file=sys.stderr) ++ sys.exit(1) ++ ++ for fullpath in pysource.walk_python_files(args, is_python): ++ if debug: ++ print("Testing for coding: %s" % fullpath) ++ result = needs_declaration(fullpath) ++ if result: ++ print(fullpath) +diff -r 3d0686d90f55 Tools/scripts/fixcid.py +--- a/Tools/scripts/fixcid.py ++++ b/Tools/scripts/fixcid.py +@@ -292,7 +292,7 @@ + if not words: continue + if len(words) == 3 and words[0] == 'struct': + words[:2] = [words[0] + ' ' + words[1]] +- elif len(words) <> 2: ++ elif len(words) != 2: + err(substfile + '%s:%r: warning: bad line: %r' % (substfile, lineno, line)) + continue + if Reverse: +diff -r 3d0686d90f55 Tools/scripts/gprof2html.py +--- a/Tools/scripts/gprof2html.py ++++ b/Tools/scripts/gprof2html.py +@@ -19,17 +19,19 @@ + + """ + +-def add_escapes(input): +- for line in input: +- yield cgi.escape(line) ++def add_escapes(filename): ++ with open(filename) as fp: ++ for line in fp: ++ yield cgi.escape(line) ++ + + def main(): + filename = "gprof.out" + if sys.argv[1:]: + filename = sys.argv[1] + outputfilename = filename + ".html" +- input = add_escapes(file(filename)) +- output = file(outputfilename, "w") ++ input = add_escapes(filename) ++ output = open(outputfilename, "w") + output.write(header % filename) + for line in input: + output.write(line) +diff -r 3d0686d90f55 Tools/scripts/md5sum.py +--- a/Tools/scripts/md5sum.py ++++ b/Tools/scripts/md5sum.py +@@ -20,7 +20,7 @@ + import sys + import os + import getopt +-import md5 ++from hashlib import md5 + + def sum(*files): + sts = 0 +diff -r 3d0686d90f55 Tools/scripts/parseentities.py +--- a/Tools/scripts/parseentities.py ++++ b/Tools/scripts/parseentities.py +@@ -13,7 +13,6 @@ + + """ + import re,sys +-import TextTools + + entityRE = re.compile('') + +@@ -45,7 +44,7 @@ + charcode = repr(charcode) + else: + charcode = repr(charcode) +- comment = TextTools.collapse(comment) ++ comment = ' '.join(comment.split()) + f.write(" '%s':\t%s, \t# %s\n" % (name,charcode,comment)) + f.write('\n}\n') + +diff -r 3d0686d90f55 Tools/scripts/pdeps.py +--- a/Tools/scripts/pdeps.py ++++ b/Tools/scripts/pdeps.py +@@ -76,10 +76,9 @@ + nextline = fp.readline() + if not nextline: break + line = line[:-1] + nextline +- if m_import.match(line) >= 0: +- (a, b), (a1, b1) = m_import.regs[:2] +- elif m_from.match(line) >= 0: +- (a, b), (a1, b1) = m_from.regs[:2] ++ m_found = m_import.match(line) or m_from.match(line) ++ if m_found: ++ (a, b), (a1, b1) = m_found.regs[:2] + else: continue + words = line[a1:b1].split(',') + # print '#', line, words +@@ -87,6 +86,7 @@ + word = word.strip() + if word not in list: + list.append(word) ++ fp.close() + + + # Compute closure (this is in fact totally general) +@@ -123,7 +123,7 @@ + def inverse(table): + inv = {} + for key in table.keys(): +- if not inv.has_key(key): ++ if key not in inv: + inv[key] = [] + for item in table[key]: + store(inv, item, key) +diff -r 3d0686d90f55 configure.ac +--- /dev/null ++++ b/configure.ac +@@ -0,0 +1,4355 @@ ++dnl *********************************************** ++dnl * Please run autoreconf to test your changes! * ++dnl *********************************************** ++ ++# Set VERSION so we only need to edit in one place (i.e., here) ++m4_define(PYTHON_VERSION, 3.2) ++ ++dnl Some m4 magic to ensure that the configure script is generated ++dnl by the correct autoconf version. ++m4_define([version_required], ++[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]), [$1]), 0, ++ [], ++ [m4_fatal([Autoconf version $1 is required for Python], 63)]) ++]) ++AC_PREREQ(2.65) ++ ++AC_REVISION($Revision$) ++AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/) ++AC_CONFIG_SRCDIR([Include/object.h]) ++AC_CONFIG_HEADER(pyconfig.h) ++ ++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. ++ ++dnl Last slash shouldn't be stripped if prefix=/ ++if test "$prefix" != "/"; then ++ prefix=`echo "$prefix" | sed -e 's/\/$//g'` ++fi ++ ++dnl This is for stuff that absolutely must end up in pyconfig.h. ++dnl Please use pyport.h instead, if possible. ++AH_TOP([ ++#ifndef Py_PYCONFIG_H ++#define Py_PYCONFIG_H ++]) ++AH_BOTTOM([ ++/* Define the macros needed if on a UnixWare 7.x system. */ ++#if defined(__USLC__) && defined(__SCO_VERSION__) ++#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ ++#endif ++ ++#endif /*Py_PYCONFIG_H*/ ++]) ++ ++# We don't use PACKAGE_ variables, and they cause conflicts ++# with other autoconf-based packages that include Python.h ++grep -v 'define PACKAGE_' confdefs.h.new ++rm confdefs.h ++mv confdefs.h.new confdefs.h ++ ++AC_SUBST(VERSION) ++VERSION=PYTHON_VERSION ++ ++# Version number of Python's own shared library file. ++AC_SUBST(SOVERSION) ++SOVERSION=1.0 ++ ++# The later defininition of _XOPEN_SOURCE disables certain features ++# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone). ++AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features]) ++ ++# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables ++# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable ++# them. ++AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features]) ++ ++# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables ++# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable ++# them. ++AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features]) ++ ++# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables ++# u_int on Irix 5.3. Defining _BSD_TYPES brings it back. ++AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int]) ++ ++# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables ++# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable ++# them. ++AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features]) ++ ++ ++define_xopen_source=yes ++ ++# Arguments passed to configure. ++AC_SUBST(CONFIG_ARGS) ++CONFIG_ARGS="$ac_configure_args" ++ ++AC_MSG_CHECKING([for --enable-universalsdk]) ++AC_ARG_ENABLE(universalsdk, ++ AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]), ++[ ++ case $enableval in ++ yes) ++ enableval=/Developer/SDKs/MacOSX10.4u.sdk ++ if test ! -d "${enableval}" ++ then ++ enableval=/ ++ fi ++ ;; ++ esac ++ case $enableval in ++ no) ++ UNIVERSALSDK= ++ enable_universalsdk= ++ ;; ++ *) ++ UNIVERSALSDK=$enableval ++ if test ! -d "${UNIVERSALSDK}" ++ then ++ AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}]) ++ fi ++ ;; ++ esac ++ ++],[ ++ UNIVERSALSDK= ++ enable_universalsdk= ++]) ++if test -n "${UNIVERSALSDK}" ++then ++ AC_MSG_RESULT(${UNIVERSALSDK}) ++else ++ AC_MSG_RESULT(no) ++fi ++AC_SUBST(UNIVERSALSDK) ++ ++AC_SUBST(ARCH_RUN_32BIT) ++ ++UNIVERSAL_ARCHS="32-bit" ++AC_SUBST(LIPO_32BIT_FLAGS) ++AC_MSG_CHECKING(for --with-universal-archs) ++AC_ARG_WITH(universal-archs, ++ AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]), ++[ ++ AC_MSG_RESULT($withval) ++ UNIVERSAL_ARCHS="$withval" ++], ++[ ++ AC_MSG_RESULT(32-bit) ++]) ++ ++ ++ ++AC_ARG_WITH(framework-name, ++ AS_HELP_STRING([--with-framework-name=FRAMEWORK], ++ [specify an alternate name of the framework built with --enable-framework]), ++[ ++ PYTHONFRAMEWORK=${withval} ++ PYTHONFRAMEWORKDIR=${withval}.framework ++ PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'` ++ ],[ ++ PYTHONFRAMEWORK=Python ++ PYTHONFRAMEWORKDIR=Python.framework ++ PYTHONFRAMEWORKIDENTIFIER=org.python.python ++]) ++dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output ++AC_ARG_ENABLE(framework, ++ AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]), ++[ ++ case $enableval in ++ yes) ++ enableval=/Library/Frameworks ++ esac ++ case $enableval in ++ no) ++ PYTHONFRAMEWORK= ++ PYTHONFRAMEWORKDIR=no-framework ++ PYTHONFRAMEWORKPREFIX= ++ PYTHONFRAMEWORKINSTALLDIR= ++ FRAMEWORKINSTALLFIRST= ++ FRAMEWORKINSTALLLAST= ++ FRAMEWORKALTINSTALLFIRST= ++ FRAMEWORKALTINSTALLLAST= ++ if test "x${prefix}" = "xNONE"; then ++ FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" ++ else ++ FRAMEWORKUNIXTOOLSPREFIX="${prefix}" ++ fi ++ enable_framework= ++ ;; ++ *) ++ PYTHONFRAMEWORKPREFIX="${enableval}" ++ PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR ++ FRAMEWORKINSTALLFIRST="frameworkinstallstructure" ++ FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure " ++ FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools" ++ FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools" ++ FRAMEWORKINSTALLAPPSPREFIX="/Applications" ++ ++ if test "x${prefix}" = "xNONE" ; then ++ FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" ++ ++ else ++ FRAMEWORKUNIXTOOLSPREFIX="${prefix}" ++ fi ++ ++ case "${enableval}" in ++ /System*) ++ FRAMEWORKINSTALLAPPSPREFIX="/Applications" ++ if test "${prefix}" = "NONE" ; then ++ # See below ++ FRAMEWORKUNIXTOOLSPREFIX="/usr" ++ fi ++ ;; ++ ++ /Library*) ++ FRAMEWORKINSTALLAPPSPREFIX="/Applications" ++ ;; ++ ++ */Library/Frameworks) ++ MDIR="`dirname "${enableval}"`" ++ MDIR="`dirname "${MDIR}"`" ++ FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications" ++ ++ if test "${prefix}" = "NONE"; then ++ # User hasn't specified the ++ # --prefix option, but wants to install ++ # the framework in a non-default location, ++ # ensure that the compatibility links get ++ # installed relative to that prefix as well ++ # instead of in /usr/local. ++ FRAMEWORKUNIXTOOLSPREFIX="${MDIR}" ++ fi ++ ;; ++ ++ *) ++ FRAMEWORKINSTALLAPPSPREFIX="/Applications" ++ ;; ++ esac ++ ++ prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION ++ ++ # Add files for Mac specific code to the list of output ++ # files: ++ AC_CONFIG_FILES(Mac/Makefile) ++ AC_CONFIG_FILES(Mac/PythonLauncher/Makefile) ++ AC_CONFIG_FILES(Mac/Resources/framework/Info.plist) ++ AC_CONFIG_FILES(Mac/Resources/app/Info.plist) ++ esac ++ ],[ ++ PYTHONFRAMEWORK= ++ PYTHONFRAMEWORKDIR=no-framework ++ PYTHONFRAMEWORKPREFIX= ++ PYTHONFRAMEWORKINSTALLDIR= ++ FRAMEWORKINSTALLFIRST= ++ FRAMEWORKINSTALLLAST= ++ FRAMEWORKALTINSTALLFIRST= ++ FRAMEWORKALTINSTALLLAST= ++ if test "x${prefix}" = "xNONE" ; then ++ FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" ++ else ++ FRAMEWORKUNIXTOOLSPREFIX="${prefix}" ++ fi ++ enable_framework= ++ ++]) ++AC_SUBST(PYTHONFRAMEWORK) ++AC_SUBST(PYTHONFRAMEWORKIDENTIFIER) ++AC_SUBST(PYTHONFRAMEWORKDIR) ++AC_SUBST(PYTHONFRAMEWORKPREFIX) ++AC_SUBST(PYTHONFRAMEWORKINSTALLDIR) ++AC_SUBST(FRAMEWORKINSTALLFIRST) ++AC_SUBST(FRAMEWORKINSTALLLAST) ++AC_SUBST(FRAMEWORKALTINSTALLFIRST) ++AC_SUBST(FRAMEWORKALTINSTALLLAST) ++AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX) ++AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX) ++ ++##AC_ARG_WITH(dyld, ++## AS_HELP_STRING([--with-dyld], ++## [Use (OpenStep|Rhapsody) dynamic linker])) ++## ++# Set name for machine-dependent library files ++AC_SUBST(MACHDEP) ++AC_MSG_CHECKING(MACHDEP) ++if test -z "$MACHDEP" ++then ++ ac_sys_system=`uname -s` ++ if test "$ac_sys_system" = "AIX" \ ++ -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then ++ ac_sys_release=`uname -v` ++ 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 ++ linux*) MACHDEP="linux2";; ++ cygwin*) MACHDEP="cygwin";; ++ darwin*) MACHDEP="darwin";; ++ irix646) MACHDEP="irix6";; ++ '') MACHDEP="unknown";; ++ esac ++fi ++ ++# Some systems cannot stand _XOPEN_SOURCE being defined at all; they ++# disable features if it is defined, without any means to access these ++# features as extensions. For these systems, we skip the definition of ++# _XOPEN_SOURCE. Before adding a system to the list to gain access to ++# some feature, make sure there is no alternative way to access this ++# feature. Also, when using wildcards, make sure you have verified the ++# need for not defining _XOPEN_SOURCE on all systems matching the ++# wildcard, and that the wildcard does not include future systems ++# (which may remove their limitations). ++dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output ++case $ac_sys_system/$ac_sys_release in ++ # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, ++ # even though select is a POSIX function. Reported by J. Ribbens. ++ # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. ++ # In addition, Stefan Krah confirms that issue #1244610 exists through ++ # OpenBSD 4.6, but is fixed in 4.7. ++ OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@) ++ define_xopen_source=no ++ # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is ++ # also defined. This can be overridden by defining _BSD_SOURCE ++ # As this has a different meaning on Linux, only define it on OpenBSD ++ AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features]) ++ ;; ++ OpenBSD/*) ++ # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is ++ # also defined. This can be overridden by defining _BSD_SOURCE ++ # As this has a different meaning on Linux, only define it on OpenBSD ++ AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features]) ++ ;; ++ # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of ++ # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by ++ # Marc Recht ++ NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@) ++ define_xopen_source=no;; ++ # From the perspective of Solaris, _XOPEN_SOURCE is not so much a ++ # request to enable features supported by the standard as a request ++ # to disable features not supported by the standard. The best way ++ # for Python to use Solaris is simply to leave _XOPEN_SOURCE out ++ # entirely and define __EXTENSIONS__ instead. ++ SunOS/*) ++ define_xopen_source=no;; ++ # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE, ++ # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice. ++ # Reconfirmed for 7.1.4 by Martin v. Loewis. ++ OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@) ++ define_xopen_source=no;; ++ # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE, ++ # but used in struct sockaddr.sa_family. Reported by Tim Rice. ++ SCO_SV/3.2) ++ define_xopen_source=no;; ++ # On FreeBSD 4, the math functions C89 does not cover are never defined ++ # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them. ++ FreeBSD/4.*) ++ define_xopen_source=no;; ++ # On MacOS X 10.2, a bug in ncurses.h means that it craps out if ++ # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which ++ # identifies itself as Darwin/7.* ++ # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE ++ # disables platform specific features beyond repair. ++ # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE ++ # has no effect, don't bother defining them ++ Darwin/@<:@6789@:>@.*) ++ define_xopen_source=no;; ++ Darwin/1@<:@0-9@:>@.*) ++ define_xopen_source=no;; ++ # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but ++ # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined ++ # or has another value. By not (re)defining it, the defaults come in place. ++ AIX/4) ++ define_xopen_source=no;; ++ AIX/5) ++ if test `uname -r` -eq 1; then ++ define_xopen_source=no ++ fi ++ ;; ++ # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from ++ # defining NI_NUMERICHOST. ++ QNX/6.3.2) ++ define_xopen_source=no ++ ;; ++ ++esac ++ ++if test $define_xopen_source = yes ++then ++ AC_DEFINE(_XOPEN_SOURCE, 600, ++ Define to the level of X/Open that your system supports) ++ ++ # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires ++ # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else ++ # several APIs are not declared. Since this is also needed in some ++ # cases for HP-UX, we define it globally. ++ AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, ++ Define to activate Unix95-and-earlier features) ++ ++ AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001) ++ ++fi ++ ++# ++# SGI compilers allow the specification of the both the ABI and the ++# ISA on the command line. Depending on the values of these switches, ++# different and often incompatable code will be generated. ++# ++# The SGI_ABI variable can be used to modify the CC and LDFLAGS and ++# thus supply support for various ABI/ISA combinations. The MACHDEP ++# variable is also adjusted. ++# ++AC_SUBST(SGI_ABI) ++if test ! -z "$SGI_ABI" ++then ++ CC="cc $SGI_ABI" ++ LDFLAGS="$SGI_ABI $LDFLAGS" ++ MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'` ++fi ++AC_MSG_RESULT($MACHDEP) ++ ++# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET, ++# it may influence the way we can build extensions, so distutils ++# needs to check it ++AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET) ++AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET) ++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 ++# for debug/optimization stuff. BASECFLAGS is for flags that are required ++# just to get things to compile and link. Users are free to override OPT ++# when running configure or make. The build should not break if they do. ++# BASECFLAGS should generally not be messed with, however. ++ ++# XXX shouldn't some/most/all of this code be merged with the stuff later ++# on that fiddles with OPT and BASECFLAGS? ++AC_MSG_CHECKING(for --without-gcc) ++AC_ARG_WITH(gcc, ++ AS_HELP_STRING([--without-gcc], [never use gcc]), ++[ ++ case $withval in ++ no) CC=${CC:-cc} ++ without_gcc=yes;; ++ yes) CC=gcc ++ without_gcc=no;; ++ *) CC=$withval ++ without_gcc=$withval;; ++ esac], [ ++ case $ac_sys_system in ++ AIX*) CC=${CC:-xlc_r} ++ without_gcc=;; ++ *) without_gcc=no;; ++ esac]) ++AC_MSG_RESULT($without_gcc) ++ ++# If the user switches compilers, we can't believe the cache ++if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC" ++then ++ AC_MSG_ERROR([cached CC is different -- throw away $cache_file ++(it is also a good idea to do 'make clean' before compiling)]) ++fi ++ ++# Don't let AC_PROG_CC set the default CFLAGS. It normally sets -g -O2 ++# when the compiler supports them, but we don't always want -O2, and ++# we set -g later. ++if test -z "$CFLAGS"; then ++ CFLAGS= ++fi ++AC_PROG_CC ++ ++AC_SUBST(CXX) ++AC_SUBST(MAINCC) ++AC_MSG_CHECKING(for --with-cxx-main=) ++AC_ARG_WITH(cxx_main, ++ AS_HELP_STRING([--with-cxx-main=], ++ [compile main() and link python executable with C++ compiler]), ++[ ++ ++ case $withval in ++ no) with_cxx_main=no ++ MAINCC='$(CC)';; ++ yes) with_cxx_main=yes ++ MAINCC='$(CXX)';; ++ *) with_cxx_main=yes ++ MAINCC=$withval ++ if test -z "$CXX" ++ then ++ CXX=$withval ++ fi;; ++ esac], [ ++ with_cxx_main=no ++ MAINCC='$(CC)' ++]) ++AC_MSG_RESULT($with_cxx_main) ++ ++preset_cxx="$CXX" ++if test -z "$CXX" ++then ++ case "$CC" in ++ gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;; ++ cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;; ++ esac ++ if test "$CXX" = "notfound" ++ then ++ CXX="" ++ fi ++fi ++if test -z "$CXX" ++then ++ AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound) ++ if test "$CXX" = "notfound" ++ then ++ CXX="" ++ fi ++fi ++if test "$preset_cxx" != "$CXX" ++then ++ AC_MSG_WARN([ ++ ++ By default, distutils will build C++ extension modules with "$CXX". ++ If this is not intended, then set CXX on the configure command line. ++ ]) ++fi ++ ++ ++AC_MSG_CHECKING([for -Wl,--no-as-needed]) ++save_LDFLAGS="$LDFLAGS" ++LDFLAGS="$LDFLAGS -Wl,--no-as-needed" ++AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], ++ [NO_AS_NEEDED="-Wl,--no-as-needed" ++ AC_MSG_RESULT([yes])], ++ [NO_AS_NEEDED="" ++ AC_MSG_RESULT([no])]) ++LDFLAGS="$save_LDFLAGS" ++AC_SUBST(NO_AS_NEEDED) ++ ++ ++# checks for UNIX variants that set C preprocessor variables ++AC_USE_SYSTEM_EXTENSIONS ++ ++# Check for unsupported systems ++case $ac_sys_system/$ac_sys_release in ++atheos*|Linux*/1*) ++ echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported. ++ echo See README for details. ++ exit 1;; ++esac ++ ++AC_EXEEXT ++AC_MSG_CHECKING(for --with-suffix) ++AC_ARG_WITH(suffix, ++ AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]), ++[ ++ case $withval in ++ no) EXEEXT=;; ++ yes) EXEEXT=.exe;; ++ *) EXEEXT=$withval;; ++ esac]) ++AC_MSG_RESULT($EXEEXT) ++ ++# Test whether we're running on a non-case-sensitive system, in which ++# case we give a warning if no ext is given ++AC_SUBST(BUILDEXEEXT) ++AC_MSG_CHECKING(for case-insensitive build directory) ++if test ! -d CaseSensitiveTestDir; then ++mkdir CaseSensitiveTestDir ++fi ++ ++if test -d casesensitivetestdir ++then ++ AC_MSG_RESULT(yes) ++ BUILDEXEEXT=.exe ++else ++ AC_MSG_RESULT(no) ++ BUILDEXEEXT=$EXEEXT ++fi ++rmdir CaseSensitiveTestDir ++ ++case $MACHDEP in ++bsdos*) ++ case $CC in ++ gcc) CC="$CC -D_HAVE_BSDI";; ++ esac;; ++esac ++ ++case $ac_sys_system in ++hp*|HP*) ++ case $CC in ++ cc|*/cc) CC="$CC -Ae";; ++ esac;; ++esac ++ ++ ++AC_SUBST(LIBRARY) ++AC_MSG_CHECKING(LIBRARY) ++if test -z "$LIBRARY" ++then ++ LIBRARY='libpython$(VERSION)$(ABIFLAGS).a' ++fi ++AC_MSG_RESULT($LIBRARY) ++ ++# LDLIBRARY is the name of the library to link against (as opposed to the ++# name of the library into which to insert object files). BLDLIBRARY is also ++# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY ++# is blank as the main program is not linked directly against LDLIBRARY. ++# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On ++# systems without shared libraries, LDLIBRARY is the same as LIBRARY ++# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library, ++# DLLLIBRARY is the shared (i.e., DLL) library. ++# ++# RUNSHARED is used to run shared python without installed libraries ++# ++# INSTSONAME is the name of the shared library that will be use to install ++# on the system - some systems like version suffix, others don't ++# ++# LDVERSION is the shared library version number, normally the Python version ++# with the ABI build flags appended. ++AC_SUBST(LDLIBRARY) ++AC_SUBST(DLLLIBRARY) ++AC_SUBST(BLDLIBRARY) ++AC_SUBST(PY3LIBRARY) ++AC_SUBST(LDLIBRARYDIR) ++AC_SUBST(INSTSONAME) ++AC_SUBST(RUNSHARED) ++AC_SUBST(LDVERSION) ++LDLIBRARY="$LIBRARY" ++BLDLIBRARY='$(LDLIBRARY)' ++INSTSONAME='$(LDLIBRARY)' ++DLLLIBRARY='' ++LDLIBRARYDIR='' ++RUNSHARED='' ++LDVERSION="$VERSION" ++ ++# LINKCC is the command that links the python executable -- default is $(CC). ++# If CXX is set, and if it is needed to link a main function that was ++# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable: ++# python might then depend on the C++ runtime ++# This is altered for AIX in order to build the export list before ++# linking. ++AC_SUBST(LINKCC) ++AC_MSG_CHECKING(LINKCC) ++if test -z "$LINKCC" ++then ++ LINKCC='$(PURIFY) $(MAINCC)' ++ case $ac_sys_system in ++ AIX*) ++ exp_extra="\"\"" ++ if test $ac_sys_release -ge 5 -o \ ++ $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then ++ exp_extra="." ++ fi ++ LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";; ++ QNX*) ++ # qcc must be used because the other compilers do not ++ # support -N. ++ LINKCC=qcc;; ++ esac ++fi ++AC_MSG_RESULT($LINKCC) ++ ++# GNULD is set to "yes" if the GNU linker is used. If this goes wrong ++# make sure we default having it set to "no": this is used by ++# distutils.unixccompiler to know if it should add --enable-new-dtags ++# to linker command lines, and failing to detect GNU ld simply results ++# in the same bahaviour as before. ++AC_SUBST(GNULD) ++AC_MSG_CHECKING(for GNU ld) ++ac_prog=ld ++if test "$GCC" = yes; then ++ ac_prog=`$CC -print-prog-name=ld` ++fi ++case `"$ac_prog" -V 2>&1 < /dev/null` in ++ *GNU*) ++ GNULD=yes;; ++ *) ++ GNULD=no;; ++esac ++AC_MSG_RESULT($GNULD) ++ ++AC_C_INLINE ++if test "$ac_cv_c_inline" != no ; then ++ AC_DEFINE(USE_INLINE, 1, [Define to use the C99 inline keyword.]) ++ AC_SUBST(USE_INLINE) ++fi ++ ++ ++AC_MSG_CHECKING(for --enable-shared) ++AC_ARG_ENABLE(shared, ++ AS_HELP_STRING([--enable-shared], [disable/enable building shared python library])) ++ ++if test -z "$enable_shared" ++then ++ case $ac_sys_system in ++ CYGWIN*) ++ enable_shared="yes";; ++ *) ++ enable_shared="no";; ++ esac ++fi ++AC_MSG_RESULT($enable_shared) ++ ++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 ++ ++AC_MSG_CHECKING(LDLIBRARY) ++ ++# MacOSX framework builds need more magic. LDLIBRARY is the dynamic ++# library that we build, but we do not want to link against it (we ++# will find it with a -framework option). For this reason there is an ++# extra variable BLDLIBRARY against which Python and the extension ++# modules are linked, BLDLIBRARY. This is normally the same as ++# LDLIBRARY, but empty for MacOSX framework builds. ++if test "$enable_framework" ++then ++ LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' ++ RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH" ++ BLDLIBRARY='' ++else ++ BLDLIBRARY='$(LDLIBRARY)' ++fi ++ ++# Other platforms follow ++if test $enable_shared = "yes"; then ++ AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.]) ++ case $ac_sys_system in ++ CYGWIN*) ++ LDLIBRARY='libpython$(LDVERSION).dll.a' ++ DLLLIBRARY='libpython$(LDVERSION).dll' ++ ;; ++ SunOS*) ++ LDLIBRARY='libpython$(LDVERSION).so' ++ BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)' ++ RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} ++ INSTSONAME="$LDLIBRARY".$SOVERSION ++ if test "$with_pydebug" != yes ++ then ++ PY3LIBRARY=libpython3.so ++ fi ++ ;; ++ Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*) ++ LDLIBRARY='libpython$(LDVERSION).so' ++ BLDLIBRARY='-L. -lpython$(LDVERSION)' ++ RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} ++ case $ac_sys_system in ++ FreeBSD*) ++ SOVERSION=`echo $SOVERSION|cut -d "." -f 1` ++ ;; ++ esac ++ INSTSONAME="$LDLIBRARY".$SOVERSION ++ if test "$with_pydebug" != yes ++ then ++ PY3LIBRARY=libpython3.so ++ fi ++ ;; ++ hp*|HP*) ++ case `uname -m` in ++ ia64) ++ LDLIBRARY='libpython$(LDVERSION).so' ++ ;; ++ *) ++ LDLIBRARY='libpython$(LDVERSION).sl' ++ ;; ++ esac ++ BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)' ++ RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH} ++ ;; ++ OSF*) ++ LDLIBRARY='libpython$(LDVERSION).so' ++ BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(LDVERSION)' ++ RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} ++ ;; ++ Darwin*) ++ LDLIBRARY='libpython$(LDVERSION).dylib' ++ BLDLIBRARY='-L. -lpython$(LDVERSION)' ++ RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}' ++ ;; ++ AIX*) ++ LDLIBRARY='libpython$(LDVERSION).so' ++ RUNSHARED=LIBPATH=`pwd`:${LIBPATH} ++ ;; ++ ++ esac ++else # shared is disabled ++ case $ac_sys_system in ++ CYGWIN*) ++ BLDLIBRARY='$(LIBRARY)' ++ LDLIBRARY='libpython$(LDVERSION).dll.a' ++ ;; ++ esac ++fi ++ ++AC_MSG_RESULT($LDLIBRARY) ++ ++AC_PROG_RANLIB ++AC_SUBST(AR) ++AC_CHECK_PROGS(AR, ar aal, ar) ++ ++# tweak ARFLAGS only if the user didn't set it on the command line ++AC_SUBST(ARFLAGS) ++if test -z "$ARFLAGS" ++then ++ ARFLAGS="rc" ++fi ++ ++AC_SUBST(SVNVERSION) ++AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found) ++if test $SVNVERSION = found ++then ++ SVNVERSION="svnversion \$(srcdir)" ++else ++ SVNVERSION="echo Unversioned directory" ++fi ++ ++AC_SUBST(HGVERSION) ++AC_SUBST(HGTAG) ++AC_SUBST(HGBRANCH) ++ ++if test -e $srcdir/.hg/dirstate ++then ++AC_CHECK_PROG(HAS_HG, hg, found, not-found) ++else ++HAS_HG=no-repository ++fi ++if test $HAS_HG = found ++then ++ HGVERSION="hg id -i \$(srcdir)" ++ HGTAG="hg id -t \$(srcdir)" ++ HGBRANCH="hg id -b \$(srcdir)" ++else ++ HGVERSION="" ++ HGTAG="" ++ HGBRANCH="" ++fi ++ ++AC_SUBST(DISABLE_ASDLGEN) ++DISABLE_ASDLGEN="" ++AC_CHECK_PROG(HAS_PYTHON, python, found, not-found) ++if test $HAS_HG != found -o $HAS_PYTHON != found ++then ++ DISABLE_ASDLGEN="@echo hg: $HAS_HG, python: $HAS_PYTHON! cannot run \$(srcdir)/Parser/asdl_c.py #" ++fi ++ ++ ++case $MACHDEP in ++bsdos*|hp*|HP*) ++ # install -d does not work on BSDI or HP-UX ++ if test -z "$INSTALL" ++ then ++ INSTALL="${srcdir}/install-sh -c" ++ fi ++esac ++AC_PROG_INSTALL ++ ++# Not every filesystem supports hard links ++AC_SUBST(LN) ++if test -z "$LN" ; then ++ case $ac_sys_system in ++ CYGWIN*) LN="ln -s";; ++ *) LN=ln;; ++ esac ++fi ++ ++# For calculating the .so ABI tag. ++AC_SUBST(ABIFLAGS) ++ABIFLAGS="" ++ ++# Check for --with-pydebug ++AC_MSG_CHECKING(for --with-pydebug) ++AC_ARG_WITH(pydebug, ++ AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]), ++[ ++if test "$withval" != no ++then ++ AC_DEFINE(Py_DEBUG, 1, ++ [Define if you want to build an interpreter with many run-time checks.]) ++ AC_MSG_RESULT(yes); ++ Py_DEBUG='true' ++ ABIFLAGS="${ABIFLAGS}d" ++else AC_MSG_RESULT(no); Py_DEBUG='false' ++fi], ++[AC_MSG_RESULT(no)]) ++ ++# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be ++# merged with this chunk of code? ++ ++# Optimizer/debugger flags ++# ------------------------ ++# (The following bit of code is complicated enough - please keep things ++# indented properly. Just pretend you're editing Python code. ;-) ++ ++# There are two parallel sets of case statements below, one that checks to ++# see if OPT was set and one that does BASECFLAGS setting based upon ++# compiler and platform. BASECFLAGS tweaks need to be made even if the ++# user set OPT. ++ ++# tweak OPT based on compiler and platform, only if the user didn't set ++# it on the command line ++AC_SUBST(OPT) ++if test "${OPT-unset}" = "unset" ++then ++ case $GCC in ++ yes) ++ if test "$CC" != 'g++' ; then ++ STRICT_PROTO="-Wstrict-prototypes" ++ fi ++ # For gcc 4.x we need to use -fwrapv so lets check if its supported ++ if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then ++ WRAP="-fwrapv" ++ fi ++ ++ # Clang also needs -fwrapv ++ case $CC in ++ *clang*) WRAP="-fwrapv" ++ ;; ++ esac ++ ++ case $ac_cv_prog_cc_g in ++ yes) ++ if test "$Py_DEBUG" = 'true' ; then ++ # Optimization messes up debuggers, so turn it off for ++ # debug builds. ++ OPT="-g -O0 -Wall $STRICT_PROTO" ++ else ++ OPT="-g $WRAP -O3 -Wall $STRICT_PROTO" ++ fi ++ ;; ++ *) ++ OPT="-O3 -Wall $STRICT_PROTO" ++ ;; ++ esac ++ case $ac_sys_system in ++ SCO_SV*) OPT="$OPT -m486 -DSCO5" ++ ;; ++ esac ++ ;; ++ ++ *) ++ OPT="-O" ++ ;; ++ esac ++fi ++ ++AC_SUBST(BASECFLAGS) ++ ++# The -arch flags for universal builds on OSX ++UNIVERSAL_ARCH_FLAGS= ++AC_SUBST(UNIVERSAL_ARCH_FLAGS) ++ ++# tweak BASECFLAGS based on compiler and platform ++case $GCC in ++yes) ++ # Python doesn't violate C99 aliasing rules, but older versions of ++ # GCC produce warnings for legal Python code. Enable ++ # -fno-strict-aliasing on versions of GCC that support but produce ++ # warnings. See Issue3326 ++ AC_MSG_CHECKING(whether $CC accepts and needs -fno-strict-aliasing) ++ ac_save_cc="$CC" ++ CC="$CC -fno-strict-aliasing" ++ save_CFLAGS="$CFLAGS" ++ AC_CACHE_VAL(ac_cv_no_strict_aliasing, ++ AC_COMPILE_IFELSE( ++ [ ++ AC_LANG_PROGRAM([[]], [[]]) ++ ],[ ++ CC="$ac_save_cc -fstrict-aliasing" ++ CFLAGS="$CFLAGS -Werror -Wstrict-aliasing" ++ AC_COMPILE_IFELSE( ++ [ ++ AC_LANG_PROGRAM([[void f(int **x) {}]], ++ [[double *x; f((int **) &x);]]) ++ ],[ ++ ac_cv_no_strict_aliasing=no ++ ],[ ++ ac_cv_no_strict_aliasing=yes ++ ]) ++ ],[ ++ ac_cv_no_strict_aliasing=no ++ ])) ++ CFLAGS="$save_CFLAGS" ++ CC="$ac_save_cc" ++ AC_MSG_RESULT($ac_cv_no_strict_aliasing) ++ if test $ac_cv_no_strict_aliasing = yes ++ then ++ BASECFLAGS="$BASECFLAGS -fno-strict-aliasing" ++ fi ++ ++ # 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 ++ alpha*) ++ BASECFLAGS="$BASECFLAGS -mieee" ++ ;; ++ esac ++ ++ case $ac_sys_system in ++ SCO_SV*) ++ BASECFLAGS="$BASECFLAGS -m486 -DSCO5" ++ ;; ++ # is there any other compiler on Darwin besides gcc? ++ Darwin*) ++ # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd ++ # used to be here, but non-Apple gcc doesn't accept them. ++ if test "${CC}" = gcc ++ then ++ AC_MSG_CHECKING(which compiler should be used) ++ case "${UNIVERSALSDK}" in ++ */MacOSX10.4u.sdk) ++ # Build using 10.4 SDK, force usage of gcc when the ++ # compiler is gcc, otherwise the user will get very ++ # confusing error messages when building on OSX 10.6 ++ CC=gcc-4.0 ++ CPP=cpp-4.0 ++ ;; ++ esac ++ AC_MSG_RESULT($CC) ++ fi ++ ++ ++ if test "${enable_universalsdk}"; then ++ UNIVERSAL_ARCH_FLAGS="" ++ if test "$UNIVERSAL_ARCHS" = "32-bit" ; then ++ UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386" ++ ARCH_RUN_32BIT="" ++ LIPO_32BIT_FLAGS="" ++ elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then ++ UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64" ++ LIPO_32BIT_FLAGS="" ++ ARCH_RUN_32BIT="true" ++ ++ elif test "$UNIVERSAL_ARCHS" = "all" ; then ++ UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64" ++ LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" ++ ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc" ++ ++ elif test "$UNIVERSAL_ARCHS" = "intel" ; then ++ UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64" ++ LIPO_32BIT_FLAGS="-extract i386" ++ ARCH_RUN_32BIT="/usr/bin/arch -i386" ++ ++ elif test "$UNIVERSAL_ARCHS" = "3-way" ; then ++ UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64" ++ LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" ++ ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc" ++ ++ else ++ AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way]) ++ ++ fi ++ ++ ++ CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}" ++ if test "${UNIVERSALSDK}" != "/" ++ then ++ CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}" ++ LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}" ++ CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}" ++ fi ++ fi ++ ++ # Calculate the right deployment target for this build. ++ # ++ cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'` ++ if test ${cur_target} '>' 10.2; then ++ cur_target=10.3 ++ if test ${enable_universalsdk}; then ++ if test "${UNIVERSAL_ARCHS}" = "all"; then ++ # Ensure that the default platform for a ++ # 4-way universal build is OSX 10.5, ++ # that's the first OS release where ++ # 4-way builds make sense. ++ cur_target='10.5' ++ ++ elif test "${UNIVERSAL_ARCHS}" = "3-way"; then ++ cur_target='10.5' ++ ++ elif test "${UNIVERSAL_ARCHS}" = "intel"; then ++ cur_target='10.5' ++ ++ elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then ++ cur_target='10.5' ++ fi ++ else ++ if test `/usr/bin/arch` = "i386"; then ++ # On Intel macs default to a deployment ++ # target of 10.4, that's the first OSX ++ # release with Intel support. ++ cur_target="10.4" ++ fi ++ fi ++ fi ++ CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} ++ ++ # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the ++ # environment with a value that is the same as what we'll use ++ # in the Makefile to ensure that we'll get the same compiler ++ # environment during configure and build time. ++ MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET" ++ export MACOSX_DEPLOYMENT_TARGET ++ EXPORT_MACOSX_DEPLOYMENT_TARGET='' ++ ++ ;; ++ OSF*) ++ BASECFLAGS="$BASECFLAGS -mieee" ++ ;; ++ esac ++ ;; ++ ++*) ++ case $ac_sys_system in ++ OpenUNIX*|UnixWare*) ++ BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca " ++ ;; ++ OSF*) ++ BASECFLAGS="$BASECFLAGS -ieee -std" ++ ;; ++ SCO_SV*) ++ BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5" ++ ;; ++ esac ++ ;; ++esac ++ ++if test "$Py_DEBUG" = 'true'; then ++ : ++else ++ OPT="-DNDEBUG $OPT" ++fi ++ ++if test "$ac_arch_flags" ++then ++ BASECFLAGS="$BASECFLAGS $ac_arch_flags" ++fi ++ ++# Check whether GCC supports PyArg_ParseTuple format ++if test "$GCC" = "yes" ++then ++ AC_MSG_CHECKING(whether gcc supports ParseTuple __format__) ++ save_CFLAGS=$CFLAGS ++ CFLAGS="$CFLAGS -Werror" ++ AC_COMPILE_IFELSE([ ++ AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]]) ++ ],[ ++ AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, ++ [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))]) ++ AC_MSG_RESULT(yes) ++ ],[ ++ AC_MSG_RESULT(no) ++ ]) ++ CFLAGS=$save_CFLAGS ++fi ++ ++# On some compilers, pthreads are available without further options ++# (e.g. MacOS X). On some of these systems, the compiler will not ++# complain if unaccepted options are passed (e.g. gcc on Mac OS X). ++# So we have to see first whether pthreads are available without ++# options before we can check whether -Kpthread improves anything. ++AC_MSG_CHECKING(whether pthreads are available without options) ++AC_CACHE_VAL(ac_cv_pthread_is_default, ++[AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++ ++void* routine(void* p){return NULL;} ++ ++int main(){ ++ pthread_t p; ++ if(pthread_create(&p,NULL,routine,NULL)!=0) ++ return 1; ++ (void)pthread_detach(p); ++ return 0; ++} ++]])],[ ++ ac_cv_pthread_is_default=yes ++ ac_cv_kthread=no ++ ac_cv_pthread=no ++],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no]) ++]) ++AC_MSG_RESULT($ac_cv_pthread_is_default) ++ ++ ++if test $ac_cv_pthread_is_default = yes ++then ++ ac_cv_kpthread=no ++else ++# -Kpthread, if available, provides the right #defines ++# and linker options to make pthread_create available ++# Some compilers won't report that they do not support -Kpthread, ++# so we need to run a program to see whether it really made the ++# function available. ++AC_MSG_CHECKING(whether $CC accepts -Kpthread) ++AC_CACHE_VAL(ac_cv_kpthread, ++[ac_save_cc="$CC" ++CC="$CC -Kpthread" ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++ ++void* routine(void* p){return NULL;} ++ ++int main(){ ++ pthread_t p; ++ if(pthread_create(&p,NULL,routine,NULL)!=0) ++ return 1; ++ (void)pthread_detach(p); ++ return 0; ++} ++]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no]) ++CC="$ac_save_cc"]) ++AC_MSG_RESULT($ac_cv_kpthread) ++fi ++ ++if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no ++then ++# -Kthread, if available, provides the right #defines ++# and linker options to make pthread_create available ++# Some compilers won't report that they do not support -Kthread, ++# so we need to run a program to see whether it really made the ++# function available. ++AC_MSG_CHECKING(whether $CC accepts -Kthread) ++AC_CACHE_VAL(ac_cv_kthread, ++[ac_save_cc="$CC" ++CC="$CC -Kthread" ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++ ++void* routine(void* p){return NULL;} ++ ++int main(){ ++ pthread_t p; ++ if(pthread_create(&p,NULL,routine,NULL)!=0) ++ return 1; ++ (void)pthread_detach(p); ++ return 0; ++} ++]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no]) ++CC="$ac_save_cc"]) ++AC_MSG_RESULT($ac_cv_kthread) ++fi ++ ++if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no ++then ++# -pthread, if available, provides the right #defines ++# and linker options to make pthread_create available ++# Some compilers won't report that they do not support -pthread, ++# 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_save_cc="$CC" ++CC="$CC -pthread" ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++ ++void* routine(void* p){return NULL;} ++ ++int main(){ ++ pthread_t p; ++ if(pthread_create(&p,NULL,routine,NULL)!=0) ++ return 1; ++ (void)pthread_detach(p); ++ return 0; ++} ++]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no]) ++CC="$ac_save_cc"]) ++AC_MSG_RESULT($ac_cv_pthread) ++fi ++ ++# If we have set a CC compiler flag for thread support then ++# check if it works for CXX, too. ++ac_cv_cxx_thread=no ++if test ! -z "$CXX" ++then ++AC_MSG_CHECKING(whether $CXX also accepts flags for thread support) ++ac_save_cxx="$CXX" ++ ++if test "$ac_cv_kpthread" = "yes" ++then ++ CXX="$CXX -Kpthread" ++ ac_cv_cxx_thread=yes ++elif test "$ac_cv_kthread" = "yes" ++then ++ CXX="$CXX -Kthread" ++ ac_cv_cxx_thread=yes ++elif test "$ac_cv_pthread" = "yes" ++then ++ CXX="$CXX -pthread" ++ ac_cv_cxx_thread=yes ++fi ++ ++if test $ac_cv_cxx_thread = yes ++then ++ echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext ++ $CXX -c conftest.$ac_ext 2>&5 ++ if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \ ++ && test -s conftest$ac_exeext && ./conftest$ac_exeext ++ then ++ ac_cv_cxx_thread=yes ++ else ++ ac_cv_cxx_thread=no ++ fi ++ rm -fr conftest* ++fi ++AC_MSG_RESULT($ac_cv_cxx_thread) ++fi ++CXX="$ac_save_cxx" ++ ++dnl # check for ANSI or K&R ("traditional") preprocessor ++dnl AC_MSG_CHECKING(for C preprocessor type) ++dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++dnl #define spam(name, doc) {#name, &name, #name "() -- " doc} ++dnl int foo; ++dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something"); ++dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional]) ++dnl AC_MSG_RESULT($cpp_type) ++ ++# checks for header files ++AC_HEADER_STDC ++AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ ++fcntl.h grp.h \ ++ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ ++shadow.h signal.h stdint.h stropts.h termios.h thread.h \ ++unistd.h utime.h \ ++sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \ ++sys/lock.h sys/mkdev.h sys/modem.h \ ++sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \ ++sys/syscall.h sys/termio.h sys/time.h \ ++sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ ++sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ ++bluetooth/bluetooth.h linux/tipc.h spawn.h util.h) ++AC_HEADER_DIRENT ++AC_HEADER_MAJOR ++ ++# On Solaris, term.h requires curses.h ++AC_CHECK_HEADERS(term.h,,,[ ++#ifdef HAVE_CURSES_H ++#include ++#endif ++]) ++ ++# On Linux, netlink.h requires asm/types.h ++AC_CHECK_HEADERS(linux/netlink.h,,,[ ++#ifdef HAVE_ASM_TYPES_H ++#include ++#endif ++#ifdef HAVE_SYS_SOCKET_H ++#include ++#endif ++]) ++ ++# checks for typedefs ++was_it_defined=no ++AC_MSG_CHECKING(for clock_t in time.h) ++AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [ ++ AC_DEFINE(clock_t, long, [Define to 'long' if doesn't define.]) ++]) ++AC_MSG_RESULT($was_it_defined) ++ ++# Check whether using makedev requires defining _OSF_SOURCE ++AC_MSG_CHECKING(for makedev) ++AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ++#if defined(MAJOR_IN_MKDEV) ++#include ++#elif defined(MAJOR_IN_SYSMACROS) ++#include ++#else ++#include ++#endif ++]], [[ ++ makedev(0, 0) ]]) ++],[ac_cv_has_makedev=yes],[ac_cv_has_makedev=no]) ++if test "$ac_cv_has_makedev" = "no"; then ++ # we didn't link, try if _OSF_SOURCE will allow us to link ++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ++#define _OSF_SOURCE 1 ++#include ++ ]], ++ [[ makedev(0, 0) ]])], ++ [ac_cv_has_makedev=yes], ++ [ac_cv_has_makedev=no]) ++ if test "$ac_cv_has_makedev" = "yes"; then ++ AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.]) ++ fi ++fi ++AC_MSG_RESULT($ac_cv_has_makedev) ++if test "$ac_cv_has_makedev" = "yes"; then ++ AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.]) ++fi ++ ++# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in ++# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are ++# defined, but the compiler does not support pragma redefine_extname, ++# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit ++# structures (such as rlimit64) without declaring them. As a ++# work-around, disable LFS on such configurations ++ ++use_lfs=yes ++AC_MSG_CHECKING(Solaris LFS bug) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++#define _LARGEFILE_SOURCE 1 ++#define _FILE_OFFSET_BITS 64 ++#include ++]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes]) ++AC_MSG_RESULT($sol_lfs_bug) ++if test "$sol_lfs_bug" = "yes"; then ++ use_lfs=no ++fi ++ ++if test "$use_lfs" = "yes"; then ++# Two defines needed to enable largefile support on various platforms ++# These may affect some typedefs ++case $ac_sys_system/$ac_sys_release in ++AIX*) ++ AC_DEFINE(_LARGE_FILES, 1, ++ [This must be defined on AIX systems to enable large file support.]) ++ ;; ++esac ++AC_DEFINE(_LARGEFILE_SOURCE, 1, ++[This must be defined on some systems to enable large file support.]) ++AC_DEFINE(_FILE_OFFSET_BITS, 64, ++[This must be set to 64 on some systems to enable large file support.]) ++fi ++ ++# Add some code to confdefs.h so that the test for off_t works on SCO ++cat >> confdefs.h <<\EOF ++#if defined(SCO_DS) ++#undef _OFF_T ++#endif ++EOF ++ ++# Type availability checks ++AC_TYPE_MODE_T ++AC_TYPE_OFF_T ++AC_TYPE_PID_T ++AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void]) ++AC_TYPE_SIZE_T ++AC_TYPE_UID_T ++AC_TYPE_UINT32_T ++AC_TYPE_UINT64_T ++AC_TYPE_INT32_T ++AC_TYPE_INT64_T ++AC_CHECK_TYPE(ssize_t, ++ AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,) ++ ++# Sizes of various common basic types ++# ANSI C requires sizeof(char) == 1, so no need to check it ++AC_CHECK_SIZEOF(int, 4) ++AC_CHECK_SIZEOF(long, 4) ++AC_CHECK_SIZEOF(void *, 4) ++AC_CHECK_SIZEOF(short, 2) ++AC_CHECK_SIZEOF(float, 4) ++AC_CHECK_SIZEOF(double, 8) ++AC_CHECK_SIZEOF(fpos_t, 4) ++AC_CHECK_SIZEOF(size_t, 4) ++AC_CHECK_SIZEOF(pid_t, 4) ++ ++AC_MSG_CHECKING(for long long support) ++have_long_long=no ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[ ++ AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.]) ++ have_long_long=yes ++],[]) ++AC_MSG_RESULT($have_long_long) ++if test "$have_long_long" = yes ; then ++AC_CHECK_SIZEOF(long long, 8) ++fi ++ ++AC_MSG_CHECKING(for long double support) ++have_long_double=no ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[ ++ AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.]) ++ have_long_double=yes ++],[]) ++AC_MSG_RESULT($have_long_double) ++if test "$have_long_double" = yes ; then ++AC_CHECK_SIZEOF(long double, 16) ++fi ++ ++ ++AC_MSG_CHECKING(for _Bool support) ++have_c99_bool=no ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[ ++ AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.]) ++ have_c99_bool=yes ++],[]) ++AC_MSG_RESULT($have_c99_bool) ++if test "$have_c99_bool" = yes ; then ++AC_CHECK_SIZEOF(_Bool, 1) ++fi ++ ++AC_CHECK_TYPES(uintptr_t, ++ [AC_CHECK_SIZEOF(uintptr_t, 4)], ++ [], [#ifdef HAVE_STDINT_H ++ #include ++ #endif ++ #ifdef HAVE_INTTYPES_H ++ #include ++ #endif]) ++ ++AC_CHECK_SIZEOF(off_t, [], [ ++#ifdef HAVE_SYS_TYPES_H ++#include ++#endif ++]) ++ ++AC_MSG_CHECKING(whether to enable large file support) ++if test "$have_long_long" = yes ++then ++if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \ ++ "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then ++ AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, ++ [Defined to enable large file support when an off_t is bigger than a long ++ and long long is available and at least as big as an off_t. You may need ++ to add some flags for configuration and compilation to enable this mode. ++ (For Solaris and Linux, the necessary defines are already defined.)]) ++ AC_MSG_RESULT(yes) ++else ++ AC_MSG_RESULT(no) ++fi ++else ++ AC_MSG_RESULT(no) ++fi ++ ++AC_CHECK_SIZEOF(time_t, [], [ ++#ifdef HAVE_SYS_TYPES_H ++#include ++#endif ++#ifdef HAVE_TIME_H ++#include ++#endif ++]) ++ ++# if have pthread_t then define SIZEOF_PTHREAD_T ++ac_save_cc="$CC" ++if test "$ac_cv_kpthread" = "yes" ++then CC="$CC -Kpthread" ++elif test "$ac_cv_kthread" = "yes" ++then CC="$CC -Kthread" ++elif test "$ac_cv_pthread" = "yes" ++then CC="$CC -pthread" ++fi ++ ++AC_MSG_CHECKING(for pthread_t) ++have_pthread_t=no ++AC_COMPILE_IFELSE([ ++ AC_LANG_PROGRAM([[#include ]], [[pthread_t x; x = *(pthread_t*)0;]]) ++],[have_pthread_t=yes],[]) ++AC_MSG_RESULT($have_pthread_t) ++if test "$have_pthread_t" = yes ; then ++ AC_CHECK_SIZEOF(pthread_t, [], [ ++#ifdef HAVE_PTHREAD_H ++#include ++#endif ++ ]) ++fi ++CC="$ac_save_cc" ++ ++AC_SUBST(OTHER_LIBTOOL_OPT) ++case $ac_sys_system/$ac_sys_release in ++ Darwin/@<:@01567@:>@\..*) ++ OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000" ++ ;; ++ Darwin/*) ++ OTHER_LIBTOOL_OPT="" ++ ;; ++esac ++ ++ ++ARCH_RUN_32BIT="" ++AC_SUBST(LIBTOOL_CRUFT) ++case $ac_sys_system/$ac_sys_release in ++ Darwin/@<:@01567@:>@\..*) ++ LIBTOOL_CRUFT="-framework System -lcc_dynamic" ++ if test "${enable_universalsdk}"; then ++ : ++ else ++ LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`" ++ fi ++ LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' ++ LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; ++ Darwin/*) ++ gcc_version=`gcc -dumpversion` ++ if test ${gcc_version} '<' 4.0 ++ then ++ LIBTOOL_CRUFT="-lcc_dynamic" ++ else ++ LIBTOOL_CRUFT="" ++ fi ++ AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++ #include ++ int main(int argc, char*argv[]) ++ { ++ if (sizeof(long) == 4) { ++ return 0; ++ } else { ++ return 1; ++ } ++ } ++ ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes]) ++ ++ if test "${ac_osx_32bit}" = "yes"; then ++ case `/usr/bin/arch` in ++ i386) ++ MACOSX_DEFAULT_ARCH="i386" ++ ;; ++ ppc) ++ MACOSX_DEFAULT_ARCH="ppc" ++ ;; ++ *) ++ AC_MSG_ERROR([Unexpected output of 'arch' on OSX]) ++ ;; ++ esac ++ else ++ case `/usr/bin/arch` in ++ i386) ++ MACOSX_DEFAULT_ARCH="x86_64" ++ ;; ++ ppc) ++ MACOSX_DEFAULT_ARCH="ppc64" ++ ;; ++ *) ++ AC_MSG_ERROR([Unexpected output of 'arch' on OSX]) ++ ;; ++ esac ++ ++ #ARCH_RUN_32BIT="true" ++ fi ++ ++ LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}" ++ LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' ++ LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; ++esac ++ ++AC_MSG_CHECKING(for --enable-framework) ++if test "$enable_framework" ++then ++ BASECFLAGS="$BASECFLAGS -fno-common -dynamic" ++ # -F. is needed to allow linking to the framework while ++ # in the build location. ++ AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, ++ [Define if you want to produce an OpenStep/Rhapsody framework ++ (shared library plus accessory files).]) ++ AC_MSG_RESULT(yes) ++ if test $enable_shared = "yes" ++ then ++ AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead]) ++ fi ++else ++ AC_MSG_RESULT(no) ++fi ++ ++AC_MSG_CHECKING(for dyld) ++case $ac_sys_system/$ac_sys_release in ++ Darwin/*) ++ AC_DEFINE(WITH_DYLD, 1, ++ [Define if you want to use the new-style (Openstep, Rhapsody, MacOS) ++ dynamic linker (dyld) instead of the old-style (NextStep) dynamic ++ linker (rld). Dyld is necessary to support frameworks.]) ++ AC_MSG_RESULT(always on for Darwin) ++ ;; ++ *) ++ AC_MSG_RESULT(no) ++ ;; ++esac ++ ++# Set info about shared libraries. ++AC_SUBST(SO) ++AC_SUBST(LDSHARED) ++AC_SUBST(LDCXXSHARED) ++AC_SUBST(BLDSHARED) ++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 ++# Python, as opposed to building Python itself as a shared library.) ++AC_MSG_CHECKING(LDSHARED) ++if test -z "$LDSHARED" ++then ++ case $ac_sys_system/$ac_sys_release in ++ AIX*) ++ BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp" ++ LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp" ++ ;; ++ IRIX/5*) LDSHARED="ld -shared";; ++ IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";; ++ SunOS/5*) ++ if test "$GCC" = "yes" ; then ++ LDSHARED='$(CC) -shared' ++ LDCXXSHARED='$(CXX) -shared' ++ else ++ LDSHARED='$(CC) -G' ++ LDCXXSHARED='$(CXX) -G' ++ fi ;; ++ hp*|HP*) ++ if test "$GCC" = "yes" ; then ++ LDSHARED='$(CC) -shared' ++ LDCXXSHARED='$(CXX) -shared' ++ else ++ LDSHARED='ld -b' ++ fi ;; ++ OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";; ++ Darwin/1.3*) ++ LDSHARED='$(CC) -bundle' ++ LDCXXSHARED='$(CXX) -bundle' ++ if test "$enable_framework" ; then ++ # Link against the framework. All externals should be defined. ++ BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' ++ LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' ++ LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' ++ else ++ # No framework. Ignore undefined symbols, assuming they come from Python ++ LDSHARED="$LDSHARED -undefined suppress" ++ LDCXXSHARED="$LDCXXSHARED -undefined suppress" ++ fi ;; ++ Darwin/1.4*|Darwin/5.*|Darwin/6.*) ++ LDSHARED='$(CC) -bundle' ++ LDCXXSHARED='$(CXX) -bundle' ++ if test "$enable_framework" ; then ++ # Link against the framework. All externals should be defined. ++ BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' ++ LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' ++ LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' ++ else ++ # No framework, use the Python app as bundle-loader ++ BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' ++ LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' ++ LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' ++ fi ;; ++ Darwin/*) ++ # Use -undefined dynamic_lookup whenever possible (10.3 and later). ++ # This allows an extension to be used in any Python ++ ++ if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2 ++ then ++ if test "${enable_universalsdk}"; then ++ LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}" ++ fi ++ LDSHARED='$(CC) -bundle -undefined dynamic_lookup' ++ LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup' ++ BLDSHARED="$LDSHARED" ++ else ++ LDSHARED='$(CC) -bundle' ++ LDCXXSHARED='$(CXX) -bundle' ++ if test "$enable_framework" ; then ++ # Link against the framework. All externals should be defined. ++ BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' ++ LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' ++ LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' ++ else ++ # No framework, use the Python app as bundle-loader ++ BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' ++ LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' ++ LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' ++ fi ++ fi ++ ;; ++ Linux*|GNU*|QNX*) ++ LDSHARED='$(CC) -shared' ++ LDCXXSHARED='$(CXX) -shared';; ++ BSD/OS*/4*) ++ LDSHARED="gcc -shared" ++ LDCXXSHARED="g++ -shared";; ++ FreeBSD*) ++ if [[ "`$CC -dM -E - &1 | grep export-dynamic >/dev/null ++ then ++ LINKFORSHARED="-Xlinker --export-dynamic" ++ fi;; ++ esac;; ++ CYGWIN*) ++ if test $enable_shared = "no" ++ then ++ LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)' ++ fi;; ++ QNX*) ++ # -Wl,-E causes the symbols to be added to the dynamic ++ # symbol table so that they can be found when a module ++ # is loaded. -N 2048K causes the stack size to be set ++ # to 2048 kilobytes so that the stack doesn't overflow ++ # when running test_compile.py. ++ LINKFORSHARED='-Wl,-E -N 2048K';; ++ esac ++fi ++AC_MSG_RESULT($LINKFORSHARED) ++ ++ ++AC_SUBST(CFLAGSFORSHARED) ++AC_MSG_CHECKING(CFLAGSFORSHARED) ++if test ! "$LIBRARY" = "$LDLIBRARY" ++then ++ case $ac_sys_system in ++ CYGWIN*) ++ # Cygwin needs CCSHARED when building extension DLLs ++ # but not when building the interpreter DLL. ++ CFLAGSFORSHARED='';; ++ *) ++ CFLAGSFORSHARED='$(CCSHARED)' ++ esac ++fi ++AC_MSG_RESULT($CFLAGSFORSHARED) ++ ++# SHLIBS are libraries (except -lc and -lm) to link to the python shared ++# library (with --enable-shared). ++# For platforms on which shared libraries are not allowed to have unresolved ++# symbols, this must be set to $(LIBS) (expanded by make). We do this even ++# if it is not required, since it creates a dependency of the shared library ++# to LIBS. This, in turn, means that applications linking the shared libpython ++# don't need to link LIBS explicitly. The default should be only changed ++# on systems where this approach causes problems. ++AC_SUBST(SHLIBS) ++AC_MSG_CHECKING(SHLIBS) ++case "$ac_sys_system" in ++ *) ++ SHLIBS='$(LIBS)';; ++esac ++AC_MSG_RESULT($SHLIBS) ++ ++ ++# checks for libraries ++AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV ++AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX ++ ++# only check for sem_init if thread support is requested ++if test "$with_threads" = "yes" -o -z "$with_threads"; then ++ AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris ++ # posix4 on Solaris 2.6 ++ # pthread (first!) on Linux ++fi ++ ++# check if we need libintl for locale functions ++AC_CHECK_LIB(intl, textdomain, ++ [AC_DEFINE(WITH_LIBINTL, 1, ++ [Define to 1 if libintl is needed for locale functions.]) ++ LIBS="-lintl $LIBS"]) ++ ++# checks for system dependent C++ extensions support ++case "$ac_sys_system" in ++ AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support) ++ AC_LINK_IFELSE([ ++ AC_LANG_PROGRAM([[#include ]], ++ [[loadAndInit("", 0, "")]]) ++ ],[ ++ AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1, ++ [Define for AIX if your compiler is a genuine IBM xlC/xlC_r ++ and you want support for AIX C++ shared extension modules.]) ++ AC_MSG_RESULT(yes) ++ ],[ ++ AC_MSG_RESULT(no) ++ ]);; ++ *) ;; ++esac ++ ++# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl. ++AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4 ++AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets ++ ++AC_MSG_CHECKING(for --with-libs) ++AC_ARG_WITH(libs, ++ AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]), ++[ ++AC_MSG_RESULT($withval) ++LIBS="$withval $LIBS" ++], ++[AC_MSG_RESULT(no)]) ++ ++AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) ++ ++# Check for use of the system expat library ++AC_MSG_CHECKING(for --with-system-expat) ++AC_ARG_WITH(system_expat, ++ AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]), ++ [], ++ [with_system_expat="no"]) ++ ++AC_MSG_RESULT($with_system_expat) ++ ++# Check for use of the system libffi library ++AC_MSG_CHECKING(for --with-system-ffi) ++AC_ARG_WITH(system_ffi, ++ AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]), ++ [], ++ [with_system_ffi="no"]) ++ ++if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then ++ LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`" ++else ++ LIBFFI_INCLUDEDIR="" ++fi ++AC_SUBST(LIBFFI_INCLUDEDIR) ++ ++AC_MSG_RESULT($with_system_ffi) ++ ++# Check for support for loadable sqlite extensions ++AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions) ++AC_ARG_ENABLE(loadable-sqlite-extensions, ++ AS_HELP_STRING([--enable-loadable-sqlite-extensions], [support loadable extensions in _sqlite module]), ++ [], ++ [enable_loadable_sqlite_extensions="no"]) ++ ++AC_MSG_RESULT($enable_loadable_sqlite_extensions) ++ ++# Check for --with-dbmliborder ++AC_MSG_CHECKING(for --with-dbmliborder) ++AC_ARG_WITH(dbmliborder, ++ AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [order to check db backends for dbm. Valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]), ++[ ++if test x$with_dbmliborder = xyes ++then ++AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...]) ++else ++ for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do ++ if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb ++ then ++ AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...]) ++ fi ++ done ++fi]) ++AC_MSG_RESULT($with_dbmliborder) ++ ++# Determine if signalmodule should be used. ++AC_SUBST(USE_SIGNAL_MODULE) ++AC_SUBST(SIGNAL_OBJS) ++AC_MSG_CHECKING(for --with-signal-module) ++AC_ARG_WITH(signal-module, ++ AS_HELP_STRING([--with-signal-module], [disable/enable signal module])) ++ ++if test -z "$with_signal_module" ++then with_signal_module="yes" ++fi ++AC_MSG_RESULT($with_signal_module) ++ ++if test "${with_signal_module}" = "yes"; then ++ USE_SIGNAL_MODULE="" ++ SIGNAL_OBJS="" ++else ++ USE_SIGNAL_MODULE="#" ++ SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o" ++fi ++ ++# This is used to generate Setup.config ++AC_SUBST(USE_THREAD_MODULE) ++USE_THREAD_MODULE="" ++ ++AC_MSG_CHECKING(for --with-dec-threads) ++AC_SUBST(LDLAST) ++AC_ARG_WITH(dec-threads, ++ AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]), ++[ ++AC_MSG_RESULT($withval) ++LDLAST=-threads ++if test "${with_thread+set}" != set; then ++ with_thread="$withval"; ++fi], ++[AC_MSG_RESULT(no)]) ++ ++# Templates for things AC_DEFINEd more than once. ++# For a single AC_DEFINE, no template is needed. ++AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package]) ++AH_TEMPLATE(_REENTRANT, ++ [Define to force use of thread-safe errno, h_errno, and other functions]) ++AH_TEMPLATE(WITH_THREAD, ++ [Define if you want to compile in rudimentary thread support]) ++ ++AC_MSG_CHECKING(for --with-threads) ++dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output ++AC_ARG_WITH(threads, ++ AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support])) ++ ++# --with-thread is deprecated, but check for it anyway ++dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output ++AC_ARG_WITH(thread, ++ AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]), ++ [with_threads=$with_thread]) ++ ++if test -z "$with_threads" ++then with_threads="yes" ++fi ++AC_MSG_RESULT($with_threads) ++ ++AC_SUBST(THREADOBJ) ++if test "$with_threads" = "no" ++then ++ USE_THREAD_MODULE="#" ++elif test "$ac_cv_pthread_is_default" = yes ++then ++ AC_DEFINE(WITH_THREAD) ++ # Defining _REENTRANT on system with POSIX threads should not hurt. ++ AC_DEFINE(_REENTRANT) ++ posix_threads=yes ++ THREADOBJ="Python/thread.o" ++elif test "$ac_cv_kpthread" = "yes" ++then ++ CC="$CC -Kpthread" ++ if test "$ac_cv_cxx_thread" = "yes"; then ++ CXX="$CXX -Kpthread" ++ fi ++ AC_DEFINE(WITH_THREAD) ++ posix_threads=yes ++ THREADOBJ="Python/thread.o" ++elif test "$ac_cv_kthread" = "yes" ++then ++ CC="$CC -Kthread" ++ if test "$ac_cv_cxx_thread" = "yes"; then ++ CXX="$CXX -Kthread" ++ fi ++ AC_DEFINE(WITH_THREAD) ++ posix_threads=yes ++ THREADOBJ="Python/thread.o" ++elif test "$ac_cv_pthread" = "yes" ++then ++ CC="$CC -pthread" ++ if test "$ac_cv_cxx_thread" = "yes"; then ++ CXX="$CXX -pthread" ++ fi ++ AC_DEFINE(WITH_THREAD) ++ posix_threads=yes ++ THREADOBJ="Python/thread.o" ++else ++ if test ! -z "$with_threads" -a -d "$with_threads" ++ then LDFLAGS="$LDFLAGS -L$with_threads" ++ fi ++ if test ! -z "$withval" -a -d "$withval" ++ then LDFLAGS="$LDFLAGS -L$withval" ++ fi ++ ++ # According to the POSIX spec, a pthreads implementation must ++ # define _POSIX_THREADS in unistd.h. Some apparently don't ++ # (e.g. gnu pth with pthread emulation) ++ AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h) ++ AC_EGREP_CPP(yes, ++ [ ++#include ++#ifdef _POSIX_THREADS ++yes ++#endif ++ ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no) ++ AC_MSG_RESULT($unistd_defines_pthreads) ++ ++ AC_DEFINE(_REENTRANT) ++ AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD) ++ AC_DEFINE(C_THREADS) ++ AC_DEFINE(HURD_C_THREADS, 1, ++ [Define if you are using Mach cthreads directly under /include]) ++ LIBS="$LIBS -lthreads" ++ THREADOBJ="Python/thread.o"],[ ++ AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD) ++ AC_DEFINE(C_THREADS) ++ AC_DEFINE(MACH_C_THREADS, 1, ++ [Define if you are using Mach cthreads under mach /]) ++ THREADOBJ="Python/thread.o"],[ ++ # Just looking for pthread_create in libpthread is not enough: ++ # on HP/UX, pthread.h renames pthread_create to a different symbol name. ++ # So we really have to include pthread.h, and then link. ++ _libs=$LIBS ++ LIBS="$LIBS -lpthread" ++ AC_MSG_CHECKING([for pthread_create in -lpthread]) ++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ++ ++void * start_routine (void *arg) { exit (0); }]], [[ ++pthread_create (NULL, NULL, start_routine, NULL)]])],[ ++ AC_MSG_RESULT(yes) ++ AC_DEFINE(WITH_THREAD) ++ posix_threads=yes ++ THREADOBJ="Python/thread.o"],[ ++ LIBS=$_libs ++ AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD) ++ posix_threads=yes ++ THREADOBJ="Python/thread.o"],[ ++ AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD) ++ posix_threads=yes ++ LIBS="$LIBS -lpthreads" ++ THREADOBJ="Python/thread.o"], [ ++ AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD) ++ posix_threads=yes ++ LIBS="$LIBS -lc_r" ++ THREADOBJ="Python/thread.o"], [ ++ AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD) ++ posix_threads=yes ++ LIBS="$LIBS -lpthread" ++ THREADOBJ="Python/thread.o"], [ ++ AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD) ++ posix_threads=yes ++ LIBS="$LIBS -lcma" ++ THREADOBJ="Python/thread.o"],[ ++ USE_THREAD_MODULE="#"]) ++ ])])])])])])]) ++ ++ AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) ++ LIBS="$LIBS -lmpc" ++ THREADOBJ="Python/thread.o" ++ USE_THREAD_MODULE=""]) ++ ++ if test "$posix_threads" != "yes"; then ++ AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD) ++ LIBS="$LIBS -lthread" ++ THREADOBJ="Python/thread.o" ++ USE_THREAD_MODULE=""]) ++ fi ++ ++ if test "$USE_THREAD_MODULE" != "#" ++ then ++ # If the above checks didn't disable threads, (at least) OSF1 ++ # needs this '-threads' argument during linking. ++ case $ac_sys_system in ++ OSF1) LDLAST=-threads;; ++ esac ++ fi ++fi ++ ++if test "$posix_threads" = "yes"; then ++ if test "$unistd_defines_pthreads" = "no"; then ++ AC_DEFINE(_POSIX_THREADS, 1, ++ [Define if you have POSIX threads, ++ and your system does not define that.]) ++ fi ++ ++ # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8. ++ case $ac_sys_system/$ac_sys_release in ++ SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1, ++ [Defined for Solaris 2.6 bug in pthread header.]) ++ ;; ++ SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1, ++ [Define if the Posix semaphores do not work on your system]) ++ ;; ++ AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1, ++ [Define if the Posix semaphores do not work on your system]) ++ ;; ++ esac ++ ++ AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported) ++ AC_CACHE_VAL(ac_cv_pthread_system_supported, ++ [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include ++ void *foo(void *parm) { ++ return NULL; ++ } ++ main() { ++ pthread_attr_t attr; ++ pthread_t id; ++ if (pthread_attr_init(&attr)) exit(-1); ++ if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1); ++ if (pthread_create(&id, &attr, foo, NULL)) exit(-1); ++ exit(0); ++ }]])], ++ [ac_cv_pthread_system_supported=yes], ++ [ac_cv_pthread_system_supported=no], ++ [ac_cv_pthread_system_supported=no]) ++ ]) ++ AC_MSG_RESULT($ac_cv_pthread_system_supported) ++ if test "$ac_cv_pthread_system_supported" = "yes"; then ++ AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.]) ++ fi ++ AC_CHECK_FUNCS(pthread_sigmask, ++ [case $ac_sys_system in ++ CYGWIN*) ++ AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1, ++ [Define if pthread_sigmask() does not work on your system.]) ++ ;; ++ esac]) ++fi ++ ++ ++# Check for enable-ipv6 ++AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified]) ++AC_MSG_CHECKING([if --enable-ipv6 is specified]) ++AC_ARG_ENABLE(ipv6, ++[ --enable-ipv6 Enable ipv6 (with ipv4) support ++ --disable-ipv6 Disable ipv6 support], ++[ case "$enableval" in ++ no) ++ AC_MSG_RESULT(no) ++ ipv6=no ++ ;; ++ *) AC_MSG_RESULT(yes) ++ AC_DEFINE(ENABLE_IPV6) ++ ipv6=yes ++ ;; ++ esac ], ++ ++[ ++dnl the check does not work on cross compilation case... ++ AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 available check */ ++#include ++#include ++main() ++{ ++ if (socket(AF_INET6, SOCK_STREAM, 0) < 0) ++ exit(1); ++ else ++ exit(0); ++} ++]])],[ ++ AC_MSG_RESULT(yes) ++ ipv6=yes ++],[ ++ AC_MSG_RESULT(no) ++ ipv6=no ++],[ ++ AC_MSG_RESULT(no) ++ ipv6=no ++]) ++ ++if test "$ipv6" = "yes"; then ++ AC_MSG_CHECKING(if RFC2553 API is available) ++ AC_COMPILE_IFELSE([ ++ AC_LANG_PROGRAM([[#include ++#include ]], ++ [[struct sockaddr_in6 x; ++ x.sin6_scope_id;]]) ++ ],[ ++ AC_MSG_RESULT(yes) ++ ipv6=yes ++ ],[ ++ AC_MSG_RESULT(no, IPv6 disabled) ++ ipv6=no ++ ]) ++fi ++ ++if test "$ipv6" = "yes"; then ++ AC_DEFINE(ENABLE_IPV6) ++fi ++]) ++ ++ipv6type=unknown ++ipv6lib=none ++ipv6trylibc=no ++ ++if test "$ipv6" = "yes"; then ++ AC_MSG_CHECKING([ipv6 stack type]) ++ for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta; ++ do ++ case $i in ++ inria) ++ dnl http://www.kame.net/ ++ AC_EGREP_CPP(yes, [ ++#include ++#ifdef IPV6_INRIA_VERSION ++yes ++#endif], ++ [ipv6type=$i]) ++ ;; ++ kame) ++ dnl http://www.kame.net/ ++ AC_EGREP_CPP(yes, [ ++#include ++#ifdef __KAME__ ++yes ++#endif], ++ [ipv6type=$i; ++ ipv6lib=inet6 ++ ipv6libdir=/usr/local/v6/lib ++ ipv6trylibc=yes]) ++ ;; ++ linux-glibc) ++ dnl http://www.v6.linux.or.jp/ ++ AC_EGREP_CPP(yes, [ ++#include ++#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)) ++yes ++#endif], ++ [ipv6type=$i; ++ ipv6trylibc=yes]) ++ ;; ++ linux-inet6) ++ dnl http://www.v6.linux.or.jp/ ++ if test -d /usr/inet6; then ++ ipv6type=$i ++ ipv6lib=inet6 ++ ipv6libdir=/usr/inet6/lib ++ BASECFLAGS="-I/usr/inet6/include $BASECFLAGS" ++ fi ++ ;; ++ solaris) ++ if test -f /etc/netconfig; then ++ if $GREP -q tcp6 /etc/netconfig; then ++ ipv6type=$i ++ ipv6trylibc=yes ++ fi ++ fi ++ ;; ++ toshiba) ++ AC_EGREP_CPP(yes, [ ++#include ++#ifdef _TOSHIBA_INET6 ++yes ++#endif], ++ [ipv6type=$i; ++ ipv6lib=inet6; ++ ipv6libdir=/usr/local/v6/lib]) ++ ;; ++ v6d) ++ AC_EGREP_CPP(yes, [ ++#include ++#ifdef __V6D__ ++yes ++#endif], ++ [ipv6type=$i; ++ ipv6lib=v6; ++ ipv6libdir=/usr/local/v6/lib; ++ BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"]) ++ ;; ++ zeta) ++ AC_EGREP_CPP(yes, [ ++#include ++#ifdef _ZETA_MINAMI_INET6 ++yes ++#endif], ++ [ipv6type=$i; ++ ipv6lib=inet6; ++ ipv6libdir=/usr/local/v6/lib]) ++ ;; ++ esac ++ if test "$ipv6type" != "unknown"; then ++ break ++ fi ++ done ++ AC_MSG_RESULT($ipv6type) ++fi ++ ++if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then ++ if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then ++ LIBS="-L$ipv6libdir -l$ipv6lib $LIBS" ++ echo "using lib$ipv6lib" ++ else ++ if test $ipv6trylibc = "yes"; then ++ echo "using libc" ++ else ++ echo 'Fatal: no $ipv6lib library found. cannot continue.' ++ echo "You need to fetch lib$ipv6lib.a from appropriate" ++ echo 'ipv6 kit and compile beforehand.' ++ exit 1 ++ fi ++ fi ++fi ++ ++AC_MSG_CHECKING(for OSX 10.5 SDK or later) ++AC_COMPILE_IFELSE([ ++ AC_LANG_PROGRAM([[#include ]], [[FSIORefNum fRef = 0]]) ++],[ ++ AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.]) ++ AC_MSG_RESULT(yes) ++],[ ++ AC_MSG_RESULT(no) ++]) ++ ++# Check for --with-doc-strings ++AC_MSG_CHECKING(for --with-doc-strings) ++AC_ARG_WITH(doc-strings, ++ AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings])) ++ ++if test -z "$with_doc_strings" ++then with_doc_strings="yes" ++fi ++if test "$with_doc_strings" != "no" ++then ++ AC_DEFINE(WITH_DOC_STRINGS, 1, ++ [Define if you want documentation strings in extension modules]) ++fi ++AC_MSG_RESULT($with_doc_strings) ++ ++# Check if eval loop should use timestamp counter profiling ++AC_MSG_CHECKING(for --with-tsc) ++AC_ARG_WITH(tsc, ++ AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[ ++if test "$withval" != no ++then ++ AC_DEFINE(WITH_TSC, 1, ++ [Define to profile with the Pentium timestamp counter]) ++ AC_MSG_RESULT(yes) ++else AC_MSG_RESULT(no) ++fi], ++[AC_MSG_RESULT(no)]) ++ ++# Check for Python-specific malloc support ++AC_MSG_CHECKING(for --with-pymalloc) ++AC_ARG_WITH(pymalloc, ++ AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs])) ++ ++if test -z "$with_pymalloc" ++then ++ with_pymalloc="yes" ++ ABIFLAGS="${ABIFLAGS}m" ++fi ++if test "$with_pymalloc" != "no" ++then ++ AC_DEFINE(WITH_PYMALLOC, 1, ++ [Define if you want to compile in Python-specific mallocs]) ++fi ++AC_MSG_RESULT($with_pymalloc) ++ ++# Check for Valgrind support ++AC_MSG_CHECKING([for --with-valgrind]) ++AC_ARG_WITH([valgrind], ++ AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),, ++ with_valgrind=no) ++AC_MSG_RESULT([$with_valgrind]) ++if test "$with_valgrind" != no; then ++ AC_CHECK_HEADER([valgrind/valgrind.h], ++ [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])], ++ [AC_MSG_ERROR([Valgrind support requested but headers not available])] ++ ) ++ OPT="-DDYNAMIC_ANNOTATIONS_ENABLED=1 $OPT" ++fi ++ ++# -I${DLINCLDIR} is added to the compile rule for importdl.o ++AC_SUBST(DLINCLDIR) ++DLINCLDIR=. ++ ++# the dlopen() function means we might want to use dynload_shlib.o. some ++# platforms, such as AIX, have dlopen(), but don't want to use it. ++AC_CHECK_FUNCS(dlopen) ++ ++# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic ++# loading of modules. ++AC_SUBST(DYNLOADFILE) ++AC_MSG_CHECKING(DYNLOADFILE) ++if test -z "$DYNLOADFILE" ++then ++ case $ac_sys_system/$ac_sys_release in ++ AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c ++ if test "$ac_cv_func_dlopen" = yes ++ then DYNLOADFILE="dynload_shlib.o" ++ else DYNLOADFILE="dynload_aix.o" ++ fi ++ ;; ++ hp*|HP*) DYNLOADFILE="dynload_hpux.o";; ++ # Use dynload_next.c only on 10.2 and below, which don't have native dlopen() ++ Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";; ++ *) ++ # use dynload_shlib.c and dlopen() if we have it; otherwise stub ++ # out any dynamic loading ++ if test "$ac_cv_func_dlopen" = yes ++ then DYNLOADFILE="dynload_shlib.o" ++ else DYNLOADFILE="dynload_stub.o" ++ fi ++ ;; ++ esac ++fi ++AC_MSG_RESULT($DYNLOADFILE) ++if test "$DYNLOADFILE" != "dynload_stub.o" ++then ++ AC_DEFINE(HAVE_DYNAMIC_LOADING, 1, ++ [Defined when any dynamic module loading is enabled.]) ++fi ++ ++# MACHDEP_OBJS can be set to platform-specific object files needed by Python ++ ++AC_SUBST(MACHDEP_OBJS) ++AC_MSG_CHECKING(MACHDEP_OBJS) ++if test -z "$MACHDEP_OBJS" ++then ++ MACHDEP_OBJS=$extra_machdep_objs ++else ++ MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs" ++fi ++AC_MSG_RESULT(MACHDEP_OBJS) ++ ++# checks for library functions ++AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \ ++ clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \ ++ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ ++ getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \ ++ initgroups kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \ ++ mremap nice pathconf pause plock poll pthread_init \ ++ putenv readlink realpath \ ++ select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \ ++ setgid \ ++ setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setuid setvbuf \ ++ sigaction siginterrupt sigrelse snprintf strftime strlcpy \ ++ sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ ++ truncate uname unsetenv utimes waitpid wait3 wait4 \ ++ wcscoll wcsftime wcsxfrm _getpty) ++ ++AC_CHECK_DECL(dirfd, ++ AC_DEFINE(HAVE_DIRFD, 1, ++ Define if you have the 'dirfd' function or macro.), , ++ [#include ++ #include ]) ++ ++# For some functions, having a definition is not sufficient, since ++# we want to take their address. ++AC_MSG_CHECKING(for chroot) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=chroot]])], ++ [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no) ++]) ++AC_MSG_CHECKING(for link) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=link]])], ++ [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no) ++]) ++AC_MSG_CHECKING(for symlink) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=symlink]])], ++ [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no) ++]) ++AC_MSG_CHECKING(for fchdir) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=fchdir]])], ++ [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no) ++]) ++AC_MSG_CHECKING(for fsync) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=fsync]])], ++ [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no) ++]) ++AC_MSG_CHECKING(for fdatasync) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=fdatasync]])], ++ [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no) ++]) ++AC_MSG_CHECKING(for epoll) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=epoll_create]])], ++ [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no) ++]) ++AC_MSG_CHECKING(for kqueue) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++#include ++#include ++ ]], [[int x=kqueue()]])], ++ [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no) ++]) ++# On some systems (eg. FreeBSD 5), we would find a definition of the ++# functions ctermid_r, setgroups in the library, but no prototype ++# (e.g. because we use _XOPEN_SOURCE). See whether we can take their ++# address to avoid compiler warnings and potential miscompilations ++# because of the missing prototypes. ++ ++AC_MSG_CHECKING(for ctermid_r) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++#include ++]], [[void* p = ctermid_r]])], ++ [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no) ++]) ++ ++AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl], ++ [AC_COMPILE_IFELSE( ++ [AC_LANG_PROGRAM( ++ [#include ], ++ [void* p = flock] ++ )], ++ [ac_cv_flock_decl=yes], ++ [ac_cv_flock_decl=no] ++ ) ++]) ++if test "x${ac_cv_flock_decl}" = xyes; then ++ AC_CHECK_FUNCS(flock,, ++ AC_CHECK_LIB(bsd,flock, ++ [AC_DEFINE(HAVE_FLOCK) ++ AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.) ++ ]) ++ ) ++fi ++ ++AC_MSG_CHECKING(for getpagesize) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++#include ++]], [[void* p = getpagesize]])], ++ [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no) ++]) ++ ++AC_MSG_CHECKING(for broken unsetenv) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++#include ++]], [[int res = unsetenv("DUMMY")]])], ++ [AC_MSG_RESULT(no)], ++ [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.) ++ AC_MSG_RESULT(yes) ++]) ++ ++dnl check for true ++AC_CHECK_PROGS(TRUE, true, /bin/true) ++ ++dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv ++dnl On others, they are in the C library, so we to take no action ++AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE], ++ AC_CHECK_LIB(resolv, inet_aton) ++) ++ ++# On Tru64, chflags seems to be present, but calling it will ++# exit Python ++AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++#include ++int main(int argc, char*argv[]) ++{ ++ if(chflags(argv[0], 0) != 0) ++ return 1; ++ return 0; ++} ++]])], ++[ac_cv_have_chflags=yes], ++[ac_cv_have_chflags=no], ++[ac_cv_have_chflags=cross]) ++]) ++if test "$ac_cv_have_chflags" = cross ; then ++ AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"]) ++fi ++if test "$ac_cv_have_chflags" = yes ; then ++ AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.]) ++fi ++ ++AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++#include ++int main(int argc, char*argv[]) ++{ ++ if(lchflags(argv[0], 0) != 0) ++ return 1; ++ return 0; ++} ++]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross]) ++]) ++if test "$ac_cv_have_lchflags" = cross ; then ++ AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"]) ++fi ++if test "$ac_cv_have_lchflags" = yes ; then ++ AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.]) ++fi ++ ++dnl Check if system zlib has *Copy() functions ++dnl ++dnl On MacOSX the linker will search for dylibs on the entire linker path ++dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first ++dnl to revert to a more traditional unix behaviour and make it possible to ++dnl override the system libz with a local static library of libz. Temporarily ++dnl add that flag to our CFLAGS as well to ensure that we check the version ++dnl of libz that will be used by setup.py. ++dnl The -L/usr/local/lib is needed as wel to get the same compilation ++dnl environment as setup.py (and leaving it out can cause configure to use the ++dnl wrong version of the library) ++case $ac_sys_system/$ac_sys_release in ++Darwin/*) ++ _CUR_CFLAGS="${CFLAGS}" ++ _CUR_LDFLAGS="${LDFLAGS}" ++ CFLAGS="${CFLAGS} -Wl,-search_paths_first" ++ LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib" ++ ;; ++esac ++ ++AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy])) ++ ++case $ac_sys_system/$ac_sys_release in ++Darwin/*) ++ CFLAGS="${_CUR_CFLAGS}" ++ LDFLAGS="${_CUR_LDFLAGS}" ++ ;; ++esac ++ ++AC_MSG_CHECKING(for hstrerror) ++AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ++#include ++]], [[void* p = hstrerror; hstrerror(0)]])], ++ [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no) ++]) ++ ++AC_MSG_CHECKING(for inet_aton) ++AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ++#include ++#include ++#include ++#include ++]], [[void* p = inet_aton;inet_aton(0,0)]])], ++ [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no) ++]) ++ ++AC_MSG_CHECKING(for inet_pton) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++#include ++#include ++#include ++#include ++]], [[void* p = inet_pton]])], ++ [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no) ++]) ++ ++# On some systems, setgroups is in unistd.h, on others, in grp.h ++AC_MSG_CHECKING(for setgroups) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++#include ++#ifdef HAVE_GRP_H ++#include ++#endif ++]], [[void* p = setgroups]])], ++ [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no) ++]) ++ ++# check for openpty and forkpty ++ ++AC_CHECK_FUNCS(openpty,, ++ AC_CHECK_LIB(util,openpty, ++ [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"], ++ AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"]) ++ ) ++) ++AC_CHECK_FUNCS(forkpty,, ++ AC_CHECK_LIB(util,forkpty, ++ [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"], ++ AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"]) ++ ) ++) ++ ++# Stuff for expat. ++AC_CHECK_FUNCS(memmove) ++ ++# check for long file support functions ++AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs) ++ ++AC_REPLACE_FUNCS(dup2 getcwd strdup) ++AC_CHECK_FUNCS(getpgrp, ++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[getpgrp(0);]])], ++ [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])], ++ []) ++) ++AC_CHECK_FUNCS(setpgrp, ++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[setpgrp(0,0);]])], ++ [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])], ++ []) ++) ++AC_CHECK_FUNCS(gettimeofday, ++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], ++ [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])], ++ [], ++ [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1, ++ [Define if gettimeofday() does not have second (timezone) argument ++ This is the case on Motorola V4 (R40V4.2)]) ++ ]) ++) ++ ++AC_MSG_CHECKING(for major, minor, and makedev) ++AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ++#if defined(MAJOR_IN_MKDEV) ++#include ++#elif defined(MAJOR_IN_SYSMACROS) ++#include ++#else ++#include ++#endif ++]], [[ ++ makedev(major(0),minor(0)); ++]])],[ ++ AC_DEFINE(HAVE_DEVICE_MACROS, 1, ++ [Define to 1 if you have the device macros.]) ++ AC_MSG_RESULT(yes) ++],[ ++ AC_MSG_RESULT(no) ++]) ++ ++# On OSF/1 V5.1, getaddrinfo is available, but a define ++# for [no]getaddrinfo in netdb.h. ++AC_MSG_CHECKING(for getaddrinfo) ++AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ++#include ++#include ++#include ++#include ++]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])], ++[have_getaddrinfo=yes], ++[have_getaddrinfo=no]) ++AC_MSG_RESULT($have_getaddrinfo) ++if test $have_getaddrinfo = yes ++then ++ AC_MSG_CHECKING(getaddrinfo bug) ++ AC_CACHE_VAL(ac_cv_buggy_getaddrinfo, ++ AC_RUN_IFELSE([AC_LANG_SOURCE([[[ ++#include ++#include ++#include ++#include ++#include ++ ++int main() ++{ ++ int passive, gaierr, inet4 = 0, inet6 = 0; ++ struct addrinfo hints, *ai, *aitop; ++ char straddr[INET6_ADDRSTRLEN], strport[16]; ++ ++ for (passive = 0; passive <= 1; passive++) { ++ memset(&hints, 0, sizeof(hints)); ++ hints.ai_family = AF_UNSPEC; ++ hints.ai_flags = passive ? AI_PASSIVE : 0; ++ hints.ai_socktype = SOCK_STREAM; ++ hints.ai_protocol = IPPROTO_TCP; ++ if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) { ++ (void)gai_strerror(gaierr); ++ goto bad; ++ } ++ for (ai = aitop; ai; ai = ai->ai_next) { ++ if (ai->ai_addr == NULL || ++ ai->ai_addrlen == 0 || ++ getnameinfo(ai->ai_addr, ai->ai_addrlen, ++ straddr, sizeof(straddr), strport, sizeof(strport), ++ NI_NUMERICHOST|NI_NUMERICSERV) != 0) { ++ goto bad; ++ } ++ switch (ai->ai_family) { ++ case AF_INET: ++ if (strcmp(strport, "54321") != 0) { ++ goto bad; ++ } ++ if (passive) { ++ if (strcmp(straddr, "0.0.0.0") != 0) { ++ goto bad; ++ } ++ } else { ++ if (strcmp(straddr, "127.0.0.1") != 0) { ++ goto bad; ++ } ++ } ++ inet4++; ++ break; ++ case AF_INET6: ++ if (strcmp(strport, "54321") != 0) { ++ goto bad; ++ } ++ if (passive) { ++ if (strcmp(straddr, "::") != 0) { ++ goto bad; ++ } ++ } else { ++ if (strcmp(straddr, "::1") != 0) { ++ goto bad; ++ } ++ } ++ inet6++; ++ break; ++ case AF_UNSPEC: ++ goto bad; ++ break; ++ default: ++ /* another family support? */ ++ break; ++ } ++ } ++ } ++ ++ if (!(inet4 == 0 || inet4 == 2)) ++ goto bad; ++ if (!(inet6 == 0 || inet6 == 2)) ++ goto bad; ++ ++ if (aitop) ++ freeaddrinfo(aitop); ++ return 0; ++ ++ bad: ++ if (aitop) ++ freeaddrinfo(aitop); ++ return 1; ++} ++]]])], ++[ac_cv_buggy_getaddrinfo=no], ++[ac_cv_buggy_getaddrinfo=yes], ++[ac_cv_buggy_getaddrinfo=yes])) ++fi ++ ++AC_MSG_RESULT($ac_cv_buggy_getaddrinfo) ++ ++if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes ++then ++ if test $ipv6 = yes ++ then ++ echo 'Fatal: You must get working getaddrinfo() function.' ++ echo ' or you can specify "--disable-ipv6"'. ++ exit 1 ++ fi ++else ++ AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.]) ++fi ++ ++AC_CHECK_FUNCS(getnameinfo) ++ ++# checks for structures ++AC_HEADER_TIME ++AC_STRUCT_TM ++AC_STRUCT_TIMEZONE ++AC_CHECK_MEMBERS([struct stat.st_rdev]) ++AC_CHECK_MEMBERS([struct stat.st_blksize]) ++AC_CHECK_MEMBERS([struct stat.st_flags]) ++AC_CHECK_MEMBERS([struct stat.st_gen]) ++AC_CHECK_MEMBERS([struct stat.st_birthtime]) ++AC_STRUCT_ST_BLOCKS ++ ++AC_MSG_CHECKING(for time.h that defines altzone) ++AC_CACHE_VAL(ac_cv_header_time_altzone,[ ++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[return altzone;]])], ++ [ac_cv_header_time_altzone=yes], ++ [ac_cv_header_time_altzone=no]) ++ ]) ++AC_MSG_RESULT($ac_cv_header_time_altzone) ++if test $ac_cv_header_time_altzone = yes; then ++ AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.]) ++fi ++ ++was_it_defined=no ++AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++#include ++#include ++#include ++]], [[;]])],[ ++ AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1, ++ [Define if you can safely include both and ++ (which you can't on SCO ODT 3.0).]) ++ was_it_defined=yes ++],[]) ++AC_MSG_RESULT($was_it_defined) ++ ++AC_MSG_CHECKING(for addrinfo) ++AC_CACHE_VAL(ac_cv_struct_addrinfo, ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct addrinfo a]])], ++ [ac_cv_struct_addrinfo=yes], ++ [ac_cv_struct_addrinfo=no])) ++AC_MSG_RESULT($ac_cv_struct_addrinfo) ++if test $ac_cv_struct_addrinfo = yes; then ++ AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)]) ++fi ++ ++AC_MSG_CHECKING(for sockaddr_storage) ++AC_CACHE_VAL(ac_cv_struct_sockaddr_storage, ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++# include ++# include ]], [[struct sockaddr_storage s]])], ++ [ac_cv_struct_sockaddr_storage=yes], ++ [ac_cv_struct_sockaddr_storage=no])) ++AC_MSG_RESULT($ac_cv_struct_sockaddr_storage) ++if test $ac_cv_struct_sockaddr_storage = yes; then ++ AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)]) ++fi ++ ++# checks for compiler characteristics ++ ++AC_C_CHAR_UNSIGNED ++AC_C_CONST ++ ++works=no ++AC_MSG_CHECKING(for working volatile) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])], ++ [works=yes], ++ [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])] ++) ++AC_MSG_RESULT($works) ++ ++works=no ++AC_MSG_CHECKING(for working signed char) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])], ++ [works=yes], ++ [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])] ++) ++AC_MSG_RESULT($works) ++ ++have_prototypes=no ++AC_MSG_CHECKING(for prototypes) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])], ++ [AC_DEFINE(HAVE_PROTOTYPES, 1, ++ [Define if your compiler supports function prototype]) ++ have_prototypes=yes], ++ [] ++) ++AC_MSG_RESULT($have_prototypes) ++ ++works=no ++AC_MSG_CHECKING(for variable length prototypes and stdarg.h) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++#include ++int foo(int x, ...) { ++ va_list va; ++ va_start(va, x); ++ va_arg(va, int); ++ va_arg(va, char *); ++ va_arg(va, double); ++ return 0; ++} ++]], [[return foo(10, "", 3.14);]])],[ ++ AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1, ++ [Define if your compiler supports variable length function prototypes ++ (e.g. void fprintf(FILE *, char *, ...);) *and* ]) ++ works=yes ++],[]) ++AC_MSG_RESULT($works) ++ ++# check for socketpair ++AC_MSG_CHECKING(for socketpair) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++#include ++#include ++]], [[void *x=socketpair]])], ++ [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.]) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no)] ++) ++ ++# check if sockaddr has sa_len member ++AC_MSG_CHECKING(if sockaddr has sa_len member) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ++#include ]], [[struct sockaddr x; ++x.sa_len = 0;]])], ++ [AC_MSG_RESULT(yes) ++ AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])], ++ [AC_MSG_RESULT(no)] ++) ++ ++va_list_is_array=no ++AC_MSG_CHECKING(whether va_list is an array) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++#ifdef HAVE_STDARG_PROTOTYPES ++#include ++#else ++#include ++#endif ++]], [[va_list list1, list2; list1 = list2;]])],[],[ ++ AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind]) ++ va_list_is_array=yes ++]) ++AC_MSG_RESULT($va_list_is_array) ++ ++# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-( ++AH_TEMPLATE(HAVE_GETHOSTBYNAME_R, ++ [Define this if you have some version of gethostbyname_r()]) ++ ++AC_CHECK_FUNC(gethostbyname_r, [ ++ AC_DEFINE(HAVE_GETHOSTBYNAME_R) ++ AC_MSG_CHECKING([gethostbyname_r with 6 args]) ++ OLD_CFLAGS=$CFLAGS ++ CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS" ++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++# include ++ ]], [[ ++ char *name; ++ struct hostent *he, *res; ++ char buffer[2048]; ++ int buflen = 2048; ++ int h_errnop; ++ ++ (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop) ++ ]])],[ ++ AC_DEFINE(HAVE_GETHOSTBYNAME_R) ++ AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1, ++ [Define this if you have the 6-arg version of gethostbyname_r().]) ++ AC_MSG_RESULT(yes) ++ ],[ ++ AC_MSG_RESULT(no) ++ AC_MSG_CHECKING([gethostbyname_r with 5 args]) ++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++# include ++ ]], [[ ++ char *name; ++ struct hostent *he; ++ char buffer[2048]; ++ int buflen = 2048; ++ int h_errnop; ++ ++ (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop) ++ ]])], ++ [ ++ AC_DEFINE(HAVE_GETHOSTBYNAME_R) ++ AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1, ++ [Define this if you have the 5-arg version of gethostbyname_r().]) ++ AC_MSG_RESULT(yes) ++ ], [ ++ AC_MSG_RESULT(no) ++ AC_MSG_CHECKING([gethostbyname_r with 3 args]) ++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++# include ++ ]], [[ ++ char *name; ++ struct hostent *he; ++ struct hostent_data data; ++ ++ (void) gethostbyname_r(name, he, &data); ++ ]])], ++ [ ++ AC_DEFINE(HAVE_GETHOSTBYNAME_R) ++ AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1, ++ [Define this if you have the 3-arg version of gethostbyname_r().]) ++ AC_MSG_RESULT(yes) ++ ], [ ++ AC_MSG_RESULT(no) ++ ]) ++ ]) ++ ]) ++ CFLAGS=$OLD_CFLAGS ++], [ ++ AC_CHECK_FUNCS(gethostbyname) ++]) ++AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG) ++AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG) ++AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG) ++AC_SUBST(HAVE_GETHOSTBYNAME_R) ++AC_SUBST(HAVE_GETHOSTBYNAME) ++ ++# checks for system services ++# (none yet) ++ ++# Linux requires this for correct f.p. operations ++AC_CHECK_FUNC(__fpu_control, ++ [], ++ [AC_CHECK_LIB(ieee, __fpu_control) ++]) ++ ++# Check for --with-fpectl ++AC_MSG_CHECKING(for --with-fpectl) ++AC_ARG_WITH(fpectl, ++ AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]), ++[ ++if test "$withval" != no ++then ++ AC_DEFINE(WANT_SIGFPE_HANDLER, 1, ++ [Define if you want SIGFPE handled (see Include/pyfpe.h).]) ++ AC_MSG_RESULT(yes) ++else AC_MSG_RESULT(no) ++fi], ++[AC_MSG_RESULT(no)]) ++ ++# check for --with-libm=... ++AC_SUBST(LIBM) ++case $ac_sys_system in ++Darwin) ;; ++*) LIBM=-lm ++esac ++AC_MSG_CHECKING(for --with-libm=STRING) ++AC_ARG_WITH(libm, ++ AS_HELP_STRING([--with-libm=STRING], [math library]), ++[ ++if test "$withval" = no ++then LIBM= ++ AC_MSG_RESULT(force LIBM empty) ++elif test "$withval" != yes ++then LIBM=$withval ++ AC_MSG_RESULT(set LIBM="$withval") ++else AC_MSG_ERROR([proper usage is --with-libm=STRING]) ++fi], ++[AC_MSG_RESULT(default LIBM="$LIBM")]) ++ ++# check for --with-libc=... ++AC_SUBST(LIBC) ++AC_MSG_CHECKING(for --with-libc=STRING) ++AC_ARG_WITH(libc, ++ AS_HELP_STRING([--with-libc=STRING], [C library]), ++[ ++if test "$withval" = no ++then LIBC= ++ AC_MSG_RESULT(force LIBC empty) ++elif test "$withval" != yes ++then LIBC=$withval ++ AC_MSG_RESULT(set LIBC="$withval") ++else AC_MSG_ERROR([proper usage is --with-libc=STRING]) ++fi], ++[AC_MSG_RESULT(default LIBC="$LIBC")]) ++ ++# ************************************************** ++# * Check for various properties of floating point * ++# ************************************************** ++ ++AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64) ++AC_CACHE_VAL(ac_cv_little_endian_double, [ ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++int main() { ++ double x = 9006104071832581.0; ++ if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0) ++ return 0; ++ else ++ return 1; ++} ++]])], ++[ac_cv_little_endian_double=yes], ++[ac_cv_little_endian_double=no], ++[ac_cv_little_endian_double=no])]) ++AC_MSG_RESULT($ac_cv_little_endian_double) ++if test "$ac_cv_little_endian_double" = yes ++then ++ AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1, ++ [Define if C doubles are 64-bit IEEE 754 binary format, stored ++ with the least significant byte first]) ++fi ++ ++AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64) ++AC_CACHE_VAL(ac_cv_big_endian_double, [ ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++int main() { ++ double x = 9006104071832581.0; ++ if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0) ++ return 0; ++ else ++ return 1; ++} ++]])], ++[ac_cv_big_endian_double=yes], ++[ac_cv_big_endian_double=no], ++[ac_cv_big_endian_double=no])]) ++AC_MSG_RESULT($ac_cv_big_endian_double) ++if test "$ac_cv_big_endian_double" = yes ++then ++ AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1, ++ [Define if C doubles are 64-bit IEEE 754 binary format, stored ++ with the most significant byte first]) ++fi ++ ++# Some ARM platforms use a mixed-endian representation for doubles. ++# While Python doesn't currently have full support for these platforms ++# (see e.g., issue 1762561), we can at least make sure that float <-> string ++# conversions work. ++AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64) ++AC_CACHE_VAL(ac_cv_mixed_endian_double, [ ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++int main() { ++ double x = 9006104071832581.0; ++ if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0) ++ return 0; ++ else ++ return 1; ++} ++]])], ++[ac_cv_mixed_endian_double=yes], ++[ac_cv_mixed_endian_double=no], ++[ac_cv_mixed_endian_double=no])]) ++AC_MSG_RESULT($ac_cv_mixed_endian_double) ++if test "$ac_cv_mixed_endian_double" = yes ++then ++ AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1, ++ [Define if C doubles are 64-bit IEEE 754 binary format, stored ++ in ARM mixed-endian order (byte order 45670123)]) ++fi ++ ++# The short float repr introduced in Python 3.1 requires the ++# correctly-rounded string <-> double conversion functions from ++# Python/dtoa.c, which in turn require that the FPU uses 53-bit ++# rounding; this is a problem on x86, where the x87 FPU has a default ++# rounding precision of 64 bits. For gcc/x86, we can fix this by ++# using inline assembler to get and set the x87 FPU control word. ++ ++# This inline assembler syntax may also work for suncc and icc, ++# so we try it on all platforms. ++ ++AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ ++ unsigned short cw; ++ __asm__ __volatile__ ("fnstcw %0" : "=m" (cw)); ++ __asm__ __volatile__ ("fldcw %0" : : "m" (cw)); ++]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no]) ++AC_MSG_RESULT($have_gcc_asm_for_x87) ++if test "$have_gcc_asm_for_x87" = yes ++then ++ AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1, ++ [Define if we can use gcc inline assembler to get and set x87 control word]) ++fi ++ ++# Detect whether system arithmetic is subject to x87-style double ++# rounding issues. The result of this test has little meaning on non ++# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding ++# mode is round-to-nearest and double rounding issues are present, and ++# 0 otherwise. See http://bugs.python.org/issue2937 for more info. ++AC_MSG_CHECKING(for x87-style double rounding) ++# $BASECFLAGS may affect the result ++ac_save_cc="$CC" ++CC="$CC $BASECFLAGS" ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++#include ++int main() { ++ volatile double x, y, z; ++ /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */ ++ x = 0.99999999999999989; /* 1-2**-53 */ ++ y = 1./x; ++ if (y != 1.) ++ exit(0); ++ /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */ ++ x = 1e16; ++ y = 2.99999; ++ z = x + y; ++ if (z != 1e16+4.) ++ exit(0); ++ /* both tests show evidence of double rounding */ ++ exit(1); ++} ++]])], ++[ac_cv_x87_double_rounding=no], ++[ac_cv_x87_double_rounding=yes], ++[ac_cv_x87_double_rounding=no]) ++CC="$ac_save_cc" ++AC_MSG_RESULT($ac_cv_x87_double_rounding) ++if test "$ac_cv_x87_double_rounding" = yes ++then ++ AC_DEFINE(X87_DOUBLE_ROUNDING, 1, ++ [Define if arithmetic is subject to x87-style double rounding issue]) ++fi ++ ++# ************************************ ++# * Check for mathematical functions * ++# ************************************ ++ ++LIBS_SAVE=$LIBS ++LIBS="$LIBS $LIBM" ++ ++AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma]) ++AC_CHECK_FUNCS([hypot lgamma log1p round tgamma]) ++AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include ]]) ++ ++# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of ++# -0. on some architectures. ++AC_MSG_CHECKING(whether tanh preserves the sign of zero) ++AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [ ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++#include ++int main() { ++ /* return 0 if either negative zeros don't exist ++ on this platform or if negative zeros exist ++ and tanh(-0.) == -0. */ ++ if (atan2(0., -1.) == atan2(-0., -1.) || ++ atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0); ++ else exit(1); ++} ++]])], ++[ac_cv_tanh_preserves_zero_sign=yes], ++[ac_cv_tanh_preserves_zero_sign=no], ++[ac_cv_tanh_preserves_zero_sign=no])]) ++AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign) ++if test "$ac_cv_tanh_preserves_zero_sign" = yes ++then ++ AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1, ++ [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros]) ++fi ++ ++if test "$ac_cv_func_log1p" = yes ++then ++ # On some versions of AIX, log1p(-0.) returns 0. instead of ++ # -0. See issue #9920. ++ AC_MSG_CHECKING(whether log1p drops the sign of negative zero) ++ AC_CACHE_VAL(ac_cv_log1p_drops_zero_sign, [ ++ AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++ #include ++ #include ++ int main() { ++ /* Fail if the signs of log1p(-0.) and -0. can be ++ distinguished. */ ++ if (atan2(log1p(-0.), -1.) == atan2(-0., -1.)) ++ return 0; ++ else ++ return 1; ++ } ++ ]])], ++ [ac_cv_log1p_drops_zero_sign=no], ++ [ac_cv_log1p_drops_zero_sign=yes], ++ [ac_cv_log1p_drops_zero_sign=no])]) ++ AC_MSG_RESULT($ac_cv_log1p_drops_zero_sign) ++fi ++if test "$ac_cv_log1p_drops_zero_sign" = yes ++then ++ AC_DEFINE(LOG1P_DROPS_ZERO_SIGN, 1, ++ [Define if log1p(-0.) is 0. rather than -0.]) ++fi ++ ++LIBS=$LIBS_SAVE ++ ++# For multiprocessing module, check that sem_open ++# actually works. For FreeBSD versions <= 7.2, ++# the kernel module that provides POSIX semaphores ++# isn't loaded by default, so an attempt to call ++# sem_open results in a 'Signal 12' error. ++AC_MSG_CHECKING(whether POSIX semaphores are enabled) ++AC_CACHE_VAL(ac_cv_posix_semaphores_enabled, ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++#include ++#include ++#include ++#include ++ ++int main(void) { ++ sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0); ++ if (a == SEM_FAILED) { ++ perror("sem_open"); ++ return 1; ++ } ++ sem_close(a); ++ sem_unlink("/autoconf"); ++ return 0; ++} ++]])], ++[ac_cv_posix_semaphores_enabled=yes], ++[ac_cv_posix_semaphores_enabled=no], ++[ac_cv_posix_semaphores_enabled=yes]) ++) ++AC_MSG_RESULT($ac_cv_posix_semaphores_enabled) ++if test $ac_cv_posix_semaphores_enabled = no ++then ++ AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1, ++ [Define if POSIX semaphores aren't enabled on your system]) ++fi ++ ++# Multiprocessing check for broken sem_getvalue ++AC_MSG_CHECKING(for broken sem_getvalue) ++AC_CACHE_VAL(ac_cv_broken_sem_getvalue, ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++#include ++#include ++#include ++#include ++ ++int main(void){ ++ sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0); ++ int count; ++ int res; ++ if(a==SEM_FAILED){ ++ perror("sem_open"); ++ return 1; ++ ++ } ++ res = sem_getvalue(a, &count); ++ sem_close(a); ++ sem_unlink("/autocftw"); ++ return res==-1 ? 1 : 0; ++} ++]])], ++[ac_cv_broken_sem_getvalue=no], ++[ac_cv_broken_sem_getvalue=yes], ++[ac_cv_broken_sem_getvalue=yes]) ++) ++AC_MSG_RESULT($ac_cv_broken_sem_getvalue) ++if test $ac_cv_broken_sem_getvalue = yes ++then ++ AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1, ++ [define to 1 if your sem_getvalue is broken.]) ++fi ++ ++# determine what size digit to use for Python's longs ++AC_MSG_CHECKING([digit size for Python's longs]) ++AC_ARG_ENABLE(big-digits, ++AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]), ++[case $enable_big_digits in ++yes) ++ enable_big_digits=30 ;; ++no) ++ enable_big_digits=15 ;; ++[15|30]) ++ ;; ++*) ++ AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;; ++esac ++AC_MSG_RESULT($enable_big_digits) ++AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits]) ++], ++[AC_MSG_RESULT(no value specified)]) ++ ++# check for wchar.h ++AC_CHECK_HEADER(wchar.h, [ ++ AC_DEFINE(HAVE_WCHAR_H, 1, ++ [Define if the compiler provides a wchar.h header file.]) ++ wchar_h="yes" ++], ++wchar_h="no" ++) ++ ++# determine wchar_t size ++if test "$wchar_h" = yes ++then ++ AC_CHECK_SIZEOF(wchar_t, 4, [#include ]) ++fi ++ ++AC_MSG_CHECKING(for UCS-4 tcl) ++have_ucs4_tcl=no ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++#include ++#if TCL_UTF_MAX != 6 ++# error "NOT UCS4_TCL" ++#endif]], [[]])],[ ++ AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6]) ++ have_ucs4_tcl=yes ++],[]) ++AC_MSG_RESULT($have_ucs4_tcl) ++ ++# check whether wchar_t is signed or not ++if test "$wchar_h" = yes ++then ++ # check whether wchar_t is signed or not ++ AC_MSG_CHECKING(whether wchar_t is signed) ++ AC_CACHE_VAL(ac_cv_wchar_t_signed, [ ++ AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++ #include ++ int main() ++ { ++ /* Success: exit code 0 */ ++ exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1); ++ } ++ ]])], ++ [ac_cv_wchar_t_signed=yes], ++ [ac_cv_wchar_t_signed=no], ++ [ac_cv_wchar_t_signed=yes])]) ++ AC_MSG_RESULT($ac_cv_wchar_t_signed) ++fi ++ ++AC_MSG_CHECKING(what type to use for str) ++AC_ARG_WITH(wide-unicode, ++ AS_HELP_STRING([--with-wide-unicode], [Use 4-byte Unicode characters (default is 2 bytes)]), ++[ ++if test "$withval" != no ++then unicode_size="4" ++else unicode_size="2" ++fi ++], ++[ ++case "$have_ucs4_tcl" in ++ yes) unicode_size="4";; ++ *) unicode_size="2" ;; ++esac ++]) ++ ++AH_TEMPLATE(Py_UNICODE_SIZE, ++ [Define as the size of the unicode type.]) ++case "$unicode_size" in ++ 4) ++ AC_DEFINE(Py_UNICODE_SIZE, 4) ++ ABIFLAGS="${ABIFLAGS}u" ++ ;; ++ *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;; ++esac ++ ++AH_TEMPLATE(PY_UNICODE_TYPE, ++ [Define as the integral type used for Unicode representation.]) ++ ++# wchar_t is only usable if it maps to an unsigned type ++if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \ ++ -a "$ac_cv_wchar_t_signed" = "no" ++then ++ PY_UNICODE_TYPE="wchar_t" ++ AC_DEFINE(HAVE_USABLE_WCHAR_T, 1, ++ [Define if you have a useable wchar_t type defined in wchar.h; useable ++ means wchar_t must be an unsigned type with at least 16 bits. (see ++ Include/unicodeobject.h).]) ++ AC_DEFINE(PY_UNICODE_TYPE,wchar_t) ++elif test "$ac_cv_sizeof_short" = "$unicode_size" ++then ++ PY_UNICODE_TYPE="unsigned short" ++ AC_DEFINE(PY_UNICODE_TYPE,unsigned short) ++elif test "$ac_cv_sizeof_long" = "$unicode_size" ++then ++ PY_UNICODE_TYPE="unsigned long" ++ AC_DEFINE(PY_UNICODE_TYPE,unsigned long) ++else ++ PY_UNICODE_TYPE="no type found" ++fi ++AC_MSG_RESULT($PY_UNICODE_TYPE) ++ ++# check for endianness ++AC_C_BIGENDIAN ++ ++# ABI version string for Python extension modules. This appears between the ++# periods in shared library file names, e.g. foo..so. It is calculated ++# from the following attributes which affect the ABI of this Python build (in ++# this order): ++# ++# * The Python implementation (always 'cpython-' for us) ++# * The major and minor version numbers ++# * --with-pydebug (adds a 'd') ++# * --with-pymalloc (adds a 'm') ++# * --with-wide-unicode (adds a 'u') ++# ++# Thus for example, Python 3.2 built with wide unicode, pydebug, and pymalloc, ++# would get a shared library ABI version tag of 'cpython-32dmu' and shared ++# libraries would be named 'foo.cpython-32dmu.so'. ++AC_SUBST(SOABI) ++AC_MSG_CHECKING(ABIFLAGS) ++AC_MSG_RESULT($ABIFLAGS) ++AC_MSG_CHECKING(SOABI) ++SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS} ++AC_MSG_RESULT($SOABI) ++ ++AC_MSG_CHECKING(LDVERSION) ++LDVERSION='$(VERSION)$(ABIFLAGS)' ++AC_MSG_RESULT($LDVERSION) ++ ++# SO is the extension of shared libraries `(including the dot!) ++# -- usually .so, .sl on HP-UX, .dll on Cygwin ++AC_MSG_CHECKING(SO) ++if test -z "$SO" ++then ++ case $ac_sys_system in ++ hp*|HP*) ++ case `uname -m` in ++ ia64) SO=.so;; ++ *) SO=.sl;; ++ esac ++ ;; ++ CYGWIN*) SO=.dll;; ++ Linux*|GNU*) ++ SO=.${SOABI}.so;; ++ *) SO=.so;; ++ esac ++else ++ # this might also be a termcap variable, see #610332 ++ echo ++ echo '=====================================================================' ++ echo '+ +' ++ echo '+ WARNING: You have set SO in your environment. +' ++ echo '+ Do you really mean to change the extension for shared libraries? +' ++ echo '+ Continuing in 10 seconds to let you to ponder. +' ++ echo '+ +' ++ echo '=====================================================================' ++ sleep 10 ++fi ++AC_MSG_RESULT($SO) ++ ++# 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) ++AC_CACHE_VAL(ac_cv_rshift_extends_sign, [ ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++int main() ++{ ++ exit(((-1)>>3 == -1) ? 0 : 1); ++} ++]])], ++[ac_cv_rshift_extends_sign=yes], ++[ac_cv_rshift_extends_sign=no], ++[ac_cv_rshift_extends_sign=yes])]) ++AC_MSG_RESULT($ac_cv_rshift_extends_sign) ++if test "$ac_cv_rshift_extends_sign" = no ++then ++ AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1, ++ [Define if i>>j for signed int i does not extend the sign bit ++ when i < 0]) ++fi ++ ++# check for getc_unlocked and related locking functions ++AC_MSG_CHECKING(for getc_unlocked() and friends) ++AC_CACHE_VAL(ac_cv_have_getc_unlocked, [ ++AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ ++ FILE *f = fopen("/dev/null", "r"); ++ flockfile(f); ++ getc_unlocked(f); ++ funlockfile(f); ++]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])]) ++AC_MSG_RESULT($ac_cv_have_getc_unlocked) ++if test "$ac_cv_have_getc_unlocked" = yes ++then ++ AC_DEFINE(HAVE_GETC_UNLOCKED, 1, ++ [Define this if you have flockfile(), getc_unlocked(), and funlockfile()]) ++fi ++ ++# check where readline lives ++# save the value of LIBS so we don't actually link Python with readline ++LIBS_no_readline=$LIBS ++ ++# On some systems we need to link readline to a termcap compatible ++# library. NOTE: Keep the precedence of listed libraries synchronised ++# with setup.py. ++py_cv_lib_readline=no ++AC_MSG_CHECKING([how to link readline libs]) ++for py_libtermcap in "" ncursesw ncurses curses termcap; do ++ if test -z "$py_libtermcap"; then ++ READLINE_LIBS="-lreadline" ++ else ++ READLINE_LIBS="-lreadline -l$py_libtermcap" ++ fi ++ LIBS="$READLINE_LIBS $LIBS_no_readline" ++ AC_LINK_IFELSE( ++ [AC_LANG_CALL([],[readline])], ++ [py_cv_lib_readline=yes]) ++ if test $py_cv_lib_readline = yes; then ++ break ++ fi ++done ++# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts ++#AC_SUBST([READLINE_LIBS]) ++if test $py_cv_lib_readline = no; then ++ AC_MSG_RESULT([none]) ++else ++ AC_MSG_RESULT([$READLINE_LIBS]) ++ AC_DEFINE(HAVE_LIBREADLINE, 1, ++ [Define if you have the readline library (-lreadline).]) ++fi ++ ++# check for readline 2.1 ++AC_CHECK_LIB(readline, rl_callback_handler_install, ++ AC_DEFINE(HAVE_RL_CALLBACK, 1, ++ [Define if you have readline 2.1]), ,$READLINE_LIBS) ++ ++# check for readline 2.2 ++AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include ]])], ++ [have_readline=yes], ++ [have_readline=no] ++) ++if test $have_readline = yes ++then ++ AC_EGREP_HEADER([extern int rl_completion_append_character;], ++ [readline/readline.h], ++ AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1, ++ [Define if you have readline 2.2]), ) ++ AC_EGREP_HEADER([extern int rl_completion_suppress_append;], ++ [readline/readline.h], ++ AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1, ++ [Define if you have rl_completion_suppress_append]), ) ++fi ++ ++# check for readline 4.0 ++AC_CHECK_LIB(readline, rl_pre_input_hook, ++ AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1, ++ [Define if you have readline 4.0]), ,$READLINE_LIBS) ++ ++# also in 4.0 ++AC_CHECK_LIB(readline, rl_completion_display_matches_hook, ++ AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1, ++ [Define if you have readline 4.0]), ,$READLINE_LIBS) ++ ++# check for readline 4.2 ++AC_CHECK_LIB(readline, rl_completion_matches, ++ AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1, ++ [Define if you have readline 4.2]), ,$READLINE_LIBS) ++ ++# also in readline 4.2 ++AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include ]])], ++ [have_readline=yes], ++ [have_readline=no] ++) ++if test $have_readline = yes ++then ++ AC_EGREP_HEADER([extern int rl_catch_signals;], ++ [readline/readline.h], ++ AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1, ++ [Define if you can turn off readline's signal handling.]), ) ++fi ++ ++# End of readline checks: restore LIBS ++LIBS=$LIBS_no_readline ++ ++AC_MSG_CHECKING(for broken nice()) ++AC_CACHE_VAL(ac_cv_broken_nice, [ ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++int main() ++{ ++ int val1 = nice(1); ++ if (val1 != -1 && val1 == nice(2)) ++ exit(0); ++ exit(1); ++} ++]])], ++[ac_cv_broken_nice=yes], ++[ac_cv_broken_nice=no], ++[ac_cv_broken_nice=no])]) ++AC_MSG_RESULT($ac_cv_broken_nice) ++if test "$ac_cv_broken_nice" = yes ++then ++ AC_DEFINE(HAVE_BROKEN_NICE, 1, ++ [Define if nice() returns success/failure instead of the new priority.]) ++fi ++ ++AC_MSG_CHECKING(for broken poll()) ++AC_CACHE_VAL(ac_cv_broken_poll, ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++ ++int main() ++{ ++ struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 }; ++ int poll_test; ++ ++ close (42); ++ ++ poll_test = poll(&poll_struct, 1, 0); ++ if (poll_test < 0) ++ return 0; ++ else if (poll_test == 0 && poll_struct.revents != POLLNVAL) ++ return 0; ++ else ++ return 1; ++} ++]])], ++[ac_cv_broken_poll=yes], ++[ac_cv_broken_poll=no], ++[ac_cv_broken_poll=no])) ++AC_MSG_RESULT($ac_cv_broken_poll) ++if test "$ac_cv_broken_poll" = yes ++then ++ AC_DEFINE(HAVE_BROKEN_POLL, 1, ++ [Define if poll() sets errno on invalid file descriptors.]) ++fi ++ ++# Before we can test tzset, we need to check if struct tm has a tm_zone ++# (which is not required by ISO C or UNIX spec) and/or if we support ++# tzname[] ++AC_STRUCT_TIMEZONE ++ ++# check tzset(3) exists and works like we expect it to ++AC_MSG_CHECKING(for working tzset()) ++AC_CACHE_VAL(ac_cv_working_tzset, [ ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++#include ++#include ++ ++#if HAVE_TZNAME ++extern char *tzname[]; ++#endif ++ ++int main() ++{ ++ /* Note that we need to ensure that not only does tzset(3) ++ do 'something' with localtime, but it works as documented ++ in the library reference and as expected by the test suite. ++ This includes making sure that tzname is set properly if ++ tm->tm_zone does not exist since it is the alternative way ++ of getting timezone info. ++ ++ Red Hat 6.2 doesn't understand the southern hemisphere ++ after New Year's Day. ++ */ ++ ++ time_t groundhogday = 1044144000; /* GMT-based */ ++ time_t midyear = groundhogday + (365 * 24 * 3600 / 2); ++ ++ putenv("TZ=UTC+0"); ++ tzset(); ++ if (localtime(&groundhogday)->tm_hour != 0) ++ exit(1); ++#if HAVE_TZNAME ++ /* For UTC, tzname[1] is sometimes "", sometimes " " */ ++ if (strcmp(tzname[0], "UTC") || ++ (tzname[1][0] != 0 && tzname[1][0] != ' ')) ++ exit(1); ++#endif ++ ++ putenv("TZ=EST+5EDT,M4.1.0,M10.5.0"); ++ tzset(); ++ if (localtime(&groundhogday)->tm_hour != 19) ++ exit(1); ++#if HAVE_TZNAME ++ if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT")) ++ exit(1); ++#endif ++ ++ putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0"); ++ tzset(); ++ if (localtime(&groundhogday)->tm_hour != 11) ++ exit(1); ++#if HAVE_TZNAME ++ if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT")) ++ exit(1); ++#endif ++ ++#if HAVE_STRUCT_TM_TM_ZONE ++ if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT")) ++ exit(1); ++ if (strcmp(localtime(&midyear)->tm_zone, "AEST")) ++ exit(1); ++#endif ++ ++ exit(0); ++} ++]])], ++[ac_cv_working_tzset=yes], ++[ac_cv_working_tzset=no], ++[ac_cv_working_tzset=no])]) ++AC_MSG_RESULT($ac_cv_working_tzset) ++if test "$ac_cv_working_tzset" = yes ++then ++ AC_DEFINE(HAVE_WORKING_TZSET, 1, ++ [Define if tzset() actually switches the local timezone in a meaningful way.]) ++fi ++ ++# Look for subsecond timestamps in struct stat ++AC_MSG_CHECKING(for tv_nsec in struct stat) ++AC_CACHE_VAL(ac_cv_stat_tv_nsec, ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ ++struct stat st; ++st.st_mtim.tv_nsec = 1; ++]])], ++[ac_cv_stat_tv_nsec=yes], ++[ac_cv_stat_tv_nsec=no])) ++AC_MSG_RESULT($ac_cv_stat_tv_nsec) ++if test "$ac_cv_stat_tv_nsec" = yes ++then ++ AC_DEFINE(HAVE_STAT_TV_NSEC, 1, ++ [Define if you have struct stat.st_mtim.tv_nsec]) ++fi ++ ++# Look for BSD style subsecond timestamps in struct stat ++AC_MSG_CHECKING(for tv_nsec2 in struct stat) ++AC_CACHE_VAL(ac_cv_stat_tv_nsec2, ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ ++struct stat st; ++st.st_mtimespec.tv_nsec = 1; ++]])], ++[ac_cv_stat_tv_nsec2=yes], ++[ac_cv_stat_tv_nsec2=no])) ++AC_MSG_RESULT($ac_cv_stat_tv_nsec2) ++if test "$ac_cv_stat_tv_nsec2" = yes ++then ++ AC_DEFINE(HAVE_STAT_TV_NSEC2, 1, ++ [Define if you have struct stat.st_mtimensec]) ++fi ++ ++# On HP/UX 11.0, mvwdelch is a block with a return statement ++AC_MSG_CHECKING(whether mvwdelch is an expression) ++AC_CACHE_VAL(ac_cv_mvwdelch_is_expression, ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ ++ int rtn; ++ rtn = mvwdelch(0,0,0); ++]])], ++[ac_cv_mvwdelch_is_expression=yes], ++[ac_cv_mvwdelch_is_expression=no])) ++AC_MSG_RESULT($ac_cv_mvwdelch_is_expression) ++ ++if test "$ac_cv_mvwdelch_is_expression" = yes ++then ++ AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1, ++ [Define if mvwdelch in curses.h is an expression.]) ++fi ++ ++AC_MSG_CHECKING(whether WINDOW has _flags) ++AC_CACHE_VAL(ac_cv_window_has_flags, ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ ++ WINDOW *w; ++ w->_flags = 0; ++]])], ++[ac_cv_window_has_flags=yes], ++[ac_cv_window_has_flags=no])) ++AC_MSG_RESULT($ac_cv_window_has_flags) ++ ++ ++if test "$ac_cv_window_has_flags" = yes ++then ++ AC_DEFINE(WINDOW_HAS_FLAGS, 1, ++ [Define if WINDOW in curses.h offers a field _flags.]) ++fi ++ ++AC_MSG_CHECKING(for is_term_resized) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=is_term_resized]])], ++ [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no)] ++) ++ ++AC_MSG_CHECKING(for resize_term) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=resize_term]])], ++ [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no)] ++) ++ ++AC_MSG_CHECKING(for resizeterm) ++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=resizeterm]])], ++ [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.) ++ AC_MSG_RESULT(yes)], ++ [AC_MSG_RESULT(no)] ++) ++ ++AC_MSG_CHECKING(for /dev/ptmx) ++ ++if test -r /dev/ptmx ++then ++ AC_MSG_RESULT(yes) ++ AC_DEFINE(HAVE_DEV_PTMX, 1, ++ [Define if we have /dev/ptmx.]) ++else ++ AC_MSG_RESULT(no) ++fi ++ ++AC_MSG_CHECKING(for /dev/ptc) ++ ++if test -r /dev/ptc ++then ++ AC_MSG_RESULT(yes) ++ AC_DEFINE(HAVE_DEV_PTC, 1, ++ [Define if we have /dev/ptc.]) ++else ++ AC_MSG_RESULT(no) ++fi ++ ++if test "$have_long_long" = yes ++then ++ AC_MSG_CHECKING(for %lld and %llu printf() format support) ++ AC_CACHE_VAL(ac_cv_have_long_long_format, ++ AC_RUN_IFELSE([AC_LANG_SOURCE([[[ ++ #include ++ #include ++ #include ++ ++ #ifdef HAVE_SYS_TYPES_H ++ #include ++ #endif ++ ++ int main() ++ { ++ char buffer[256]; ++ ++ if (sprintf(buffer, "%lld", (long long)123) < 0) ++ return 1; ++ if (strcmp(buffer, "123")) ++ return 1; ++ ++ if (sprintf(buffer, "%lld", (long long)-123) < 0) ++ return 1; ++ if (strcmp(buffer, "-123")) ++ return 1; ++ ++ if (sprintf(buffer, "%llu", (unsigned long long)123) < 0) ++ return 1; ++ if (strcmp(buffer, "123")) ++ return 1; ++ ++ return 0; ++ } ++ ]]])], ++ [ac_cv_have_long_long_format=yes], ++ [ac_cv_have_long_long_format=no], ++ [ac_cv_have_long_long_format=no]) ++ ) ++ AC_MSG_RESULT($ac_cv_have_long_long_format) ++fi ++ ++if test "$ac_cv_have_long_long_format" = yes ++then ++ AC_DEFINE(PY_FORMAT_LONG_LONG, "ll", ++ [Define to printf format modifier for long long type]) ++fi ++ ++if test $ac_sys_system = Darwin ++then ++ LIBS="$LIBS -framework CoreFoundation" ++fi ++ ++AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++#include ++#include ++ ++#ifdef HAVE_SYS_TYPES_H ++#include ++#endif ++ ++#ifdef HAVE_SSIZE_T ++typedef ssize_t Py_ssize_t; ++#elif SIZEOF_VOID_P == SIZEOF_LONG ++typedef long Py_ssize_t; ++#else ++typedef int Py_ssize_t; ++#endif ++ ++int main() ++{ ++ char buffer[256]; ++ ++ if(sprintf(buffer, "%zd", (size_t)123) < 0) ++ return 1; ++ ++ if (strcmp(buffer, "123")) ++ return 1; ++ ++ if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) ++ return 1; ++ ++ if (strcmp(buffer, "-123")) ++ return 1; ++ ++ return 0; ++} ++]])], ++ [ac_cv_have_size_t_format=yes], ++ [ac_cv_have_size_t_format=no], ++ [ac_cv_have_size_t_format="cross -- assuming yes" ++])]) ++if test "$ac_cv_have_size_t_format" != no ; then ++ AC_DEFINE(PY_FORMAT_SIZE_T, "z", ++ [Define to printf format modifier for Py_ssize_t]) ++fi ++ ++AC_CHECK_TYPE(socklen_t,, ++ AC_DEFINE(socklen_t,int, ++ [Define to `int' if does not define.]),[ ++#ifdef HAVE_SYS_TYPES_H ++#include ++#endif ++#ifdef HAVE_SYS_SOCKET_H ++#include ++#endif ++]) ++ ++AC_MSG_CHECKING(for broken mbstowcs) ++AC_CACHE_VAL(ac_cv_broken_mbstowcs, ++AC_RUN_IFELSE([AC_LANG_SOURCE([[ ++#include ++int main() { ++ size_t len = -1; ++ const char *str = "text"; ++ len = mbstowcs(NULL, str, 0); ++ return (len != 4); ++} ++]])], ++[ac_cv_broken_mbstowcs=no], ++[ac_cv_broken_mbstowcs=yes], ++[ac_cv_broken_mbstowcs=no])) ++AC_MSG_RESULT($ac_cv_broken_mbstowcs) ++if test "$ac_cv_broken_mbstowcs" = yes ++then ++ AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1, ++ [Define if mbstowcs(NULL, "text", 0) does not return the number of ++ wide chars that would be converted.]) ++fi ++ ++AC_MSG_CHECKING(whether $CC supports computed gotos) ++AC_CACHE_VAL(ac_cv_computed_gotos, ++AC_RUN_IFELSE([AC_LANG_SOURCE([[[ ++int main(int argc, char **argv) ++{ ++ static void *targets[1] = { &&LABEL1 }; ++ goto LABEL2; ++LABEL1: ++ return 0; ++LABEL2: ++ goto *targets[0]; ++ return 1; ++} ++]]])], ++[ac_cv_computed_gotos=yes], ++[ac_cv_computed_gotos=no], ++[ac_cv_computed_gotos=no])) ++AC_MSG_RESULT($ac_cv_computed_gotos) ++if test "$ac_cv_computed_gotos" = yes ++then ++ AC_DEFINE(HAVE_COMPUTED_GOTOS, 1, ++ [Define if the C compiler supports computed gotos.]) ++fi ++ ++# Check for --with-computed-gotos ++AC_MSG_CHECKING(for --with-computed-gotos) ++AC_ARG_WITH(computed-gotos, ++ AS_HELP_STRING([--with(out)-computed-gotos], ++ [Use computed gotos in evaluation loop (enabled by default on supported compilers)]), ++[ ++if test "$withval" = yes ++then ++ AC_DEFINE(USE_COMPUTED_GOTOS, 1, ++ [Define if you want to use computed gotos in ceval.c.]) ++ AC_MSG_RESULT(yes) ++fi ++if test "$withval" = no ++then ++ AC_DEFINE(USE_COMPUTED_GOTOS, 0, ++ [Define if you want to use computed gotos in ceval.c.]) ++ AC_MSG_RESULT(no) ++fi ++], ++[AC_MSG_RESULT(no value specified)]) ++ ++case $ac_sys_system in ++AIX*) ++ AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;; ++esac ++ ++ ++case $ac_sys_system in ++ OSF*) AC_MSG_ERROR(OSF* systems are deprecated unless somebody volunteers. Check http://bugs.python.org/issue8606) ;; ++esac ++ ++AC_CHECK_FUNC(pipe2, AC_DEFINE(HAVE_PIPE2, 1, [Define if the OS supports pipe2()]), ) ++ ++AC_SUBST(THREADHEADERS) ++ ++for h in `(cd $srcdir;echo Python/thread_*.h)` ++do ++ THREADHEADERS="$THREADHEADERS \$(srcdir)/$h" ++done ++ ++AC_SUBST(SRCDIRS) ++SRCDIRS="Parser Grammar Objects Python Modules Mac" ++AC_MSG_CHECKING(for build directories) ++for dir in $SRCDIRS; do ++ if test ! -d $dir; then ++ mkdir $dir ++ fi ++done ++AC_MSG_RESULT(done) ++ ++# generate output files ++AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc) ++AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) ++AC_OUTPUT ++ ++echo "creating Modules/Setup" ++if test ! -f Modules/Setup ++then ++ cp $srcdir/Modules/Setup.dist Modules/Setup ++fi ++ ++echo "creating Modules/Setup.local" ++if test ! -f Modules/Setup.local ++then ++ echo "# Edit this file for local setup changes" >Modules/Setup.local ++fi ++ ++echo "creating Makefile" ++$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \ ++ -s Modules Modules/Setup.config \ ++ Modules/Setup.local Modules/Setup ++mv config.c Modules +diff -r 3d0686d90f55 configure.in +--- a/configure.in ++++ /dev/null +@@ -1,4355 +0,0 @@ +-dnl *********************************************** +-dnl * Please run autoreconf to test your changes! * +-dnl *********************************************** +- +-# Set VERSION so we only need to edit in one place (i.e., here) +-m4_define(PYTHON_VERSION, 3.2) +- +-dnl Some m4 magic to ensure that the configure script is generated +-dnl by the correct autoconf version. +-m4_define([version_required], +-[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]), [$1]), 0, +- [], +- [m4_fatal([Autoconf version $1 is required for Python], 63)]) +-]) +-AC_PREREQ(2.65) +- +-AC_REVISION($Revision$) +-AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/) +-AC_CONFIG_SRCDIR([Include/object.h]) +-AC_CONFIG_HEADER(pyconfig.h) +- +-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. +- +-dnl Last slash shouldn't be stripped if prefix=/ +-if test "$prefix" != "/"; then +- prefix=`echo "$prefix" | sed -e 's/\/$//g'` +-fi +- +-dnl This is for stuff that absolutely must end up in pyconfig.h. +-dnl Please use pyport.h instead, if possible. +-AH_TOP([ +-#ifndef Py_PYCONFIG_H +-#define Py_PYCONFIG_H +-]) +-AH_BOTTOM([ +-/* Define the macros needed if on a UnixWare 7.x system. */ +-#if defined(__USLC__) && defined(__SCO_VERSION__) +-#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +-#endif +- +-#endif /*Py_PYCONFIG_H*/ +-]) +- +-# We don't use PACKAGE_ variables, and they cause conflicts +-# with other autoconf-based packages that include Python.h +-grep -v 'define PACKAGE_' confdefs.h.new +-rm confdefs.h +-mv confdefs.h.new confdefs.h +- +-AC_SUBST(VERSION) +-VERSION=PYTHON_VERSION +- +-# Version number of Python's own shared library file. +-AC_SUBST(SOVERSION) +-SOVERSION=1.0 +- +-# The later defininition of _XOPEN_SOURCE disables certain features +-# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone). +-AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features]) +- +-# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables +-# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable +-# them. +-AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features]) +- +-# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables +-# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable +-# them. +-AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features]) +- +-# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables +-# u_int on Irix 5.3. Defining _BSD_TYPES brings it back. +-AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int]) +- +-# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables +-# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable +-# them. +-AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features]) +- +- +-define_xopen_source=yes +- +-# Arguments passed to configure. +-AC_SUBST(CONFIG_ARGS) +-CONFIG_ARGS="$ac_configure_args" +- +-AC_MSG_CHECKING([for --enable-universalsdk]) +-AC_ARG_ENABLE(universalsdk, +- AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]), +-[ +- case $enableval in +- yes) +- enableval=/Developer/SDKs/MacOSX10.4u.sdk +- if test ! -d "${enableval}" +- then +- enableval=/ +- fi +- ;; +- esac +- case $enableval in +- no) +- UNIVERSALSDK= +- enable_universalsdk= +- ;; +- *) +- UNIVERSALSDK=$enableval +- if test ! -d "${UNIVERSALSDK}" +- then +- AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}]) +- fi +- ;; +- esac +- +-],[ +- UNIVERSALSDK= +- enable_universalsdk= +-]) +-if test -n "${UNIVERSALSDK}" +-then +- AC_MSG_RESULT(${UNIVERSALSDK}) +-else +- AC_MSG_RESULT(no) +-fi +-AC_SUBST(UNIVERSALSDK) +- +-AC_SUBST(ARCH_RUN_32BIT) +- +-UNIVERSAL_ARCHS="32-bit" +-AC_SUBST(LIPO_32BIT_FLAGS) +-AC_MSG_CHECKING(for --with-universal-archs) +-AC_ARG_WITH(universal-archs, +- AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]), +-[ +- AC_MSG_RESULT($withval) +- UNIVERSAL_ARCHS="$withval" +-], +-[ +- AC_MSG_RESULT(32-bit) +-]) +- +- +- +-AC_ARG_WITH(framework-name, +- AS_HELP_STRING([--with-framework-name=FRAMEWORK], +- [specify an alternate name of the framework built with --enable-framework]), +-[ +- PYTHONFRAMEWORK=${withval} +- PYTHONFRAMEWORKDIR=${withval}.framework +- PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'` +- ],[ +- PYTHONFRAMEWORK=Python +- PYTHONFRAMEWORKDIR=Python.framework +- PYTHONFRAMEWORKIDENTIFIER=org.python.python +-]) +-dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output +-AC_ARG_ENABLE(framework, +- AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]), +-[ +- case $enableval in +- yes) +- enableval=/Library/Frameworks +- esac +- case $enableval in +- no) +- PYTHONFRAMEWORK= +- PYTHONFRAMEWORKDIR=no-framework +- PYTHONFRAMEWORKPREFIX= +- PYTHONFRAMEWORKINSTALLDIR= +- FRAMEWORKINSTALLFIRST= +- FRAMEWORKINSTALLLAST= +- FRAMEWORKALTINSTALLFIRST= +- FRAMEWORKALTINSTALLLAST= +- if test "x${prefix}" = "xNONE"; then +- FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" +- else +- FRAMEWORKUNIXTOOLSPREFIX="${prefix}" +- fi +- enable_framework= +- ;; +- *) +- PYTHONFRAMEWORKPREFIX="${enableval}" +- PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR +- FRAMEWORKINSTALLFIRST="frameworkinstallstructure" +- FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure " +- FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools" +- FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools" +- FRAMEWORKINSTALLAPPSPREFIX="/Applications" +- +- if test "x${prefix}" = "xNONE" ; then +- FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" +- +- else +- FRAMEWORKUNIXTOOLSPREFIX="${prefix}" +- fi +- +- case "${enableval}" in +- /System*) +- FRAMEWORKINSTALLAPPSPREFIX="/Applications" +- if test "${prefix}" = "NONE" ; then +- # See below +- FRAMEWORKUNIXTOOLSPREFIX="/usr" +- fi +- ;; +- +- /Library*) +- FRAMEWORKINSTALLAPPSPREFIX="/Applications" +- ;; +- +- */Library/Frameworks) +- MDIR="`dirname "${enableval}"`" +- MDIR="`dirname "${MDIR}"`" +- FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications" +- +- if test "${prefix}" = "NONE"; then +- # User hasn't specified the +- # --prefix option, but wants to install +- # the framework in a non-default location, +- # ensure that the compatibility links get +- # installed relative to that prefix as well +- # instead of in /usr/local. +- FRAMEWORKUNIXTOOLSPREFIX="${MDIR}" +- fi +- ;; +- +- *) +- FRAMEWORKINSTALLAPPSPREFIX="/Applications" +- ;; +- esac +- +- prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION +- +- # Add files for Mac specific code to the list of output +- # files: +- AC_CONFIG_FILES(Mac/Makefile) +- AC_CONFIG_FILES(Mac/PythonLauncher/Makefile) +- AC_CONFIG_FILES(Mac/Resources/framework/Info.plist) +- AC_CONFIG_FILES(Mac/Resources/app/Info.plist) +- esac +- ],[ +- PYTHONFRAMEWORK= +- PYTHONFRAMEWORKDIR=no-framework +- PYTHONFRAMEWORKPREFIX= +- PYTHONFRAMEWORKINSTALLDIR= +- FRAMEWORKINSTALLFIRST= +- FRAMEWORKINSTALLLAST= +- FRAMEWORKALTINSTALLFIRST= +- FRAMEWORKALTINSTALLLAST= +- if test "x${prefix}" = "xNONE" ; then +- FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}" +- else +- FRAMEWORKUNIXTOOLSPREFIX="${prefix}" +- fi +- enable_framework= +- +-]) +-AC_SUBST(PYTHONFRAMEWORK) +-AC_SUBST(PYTHONFRAMEWORKIDENTIFIER) +-AC_SUBST(PYTHONFRAMEWORKDIR) +-AC_SUBST(PYTHONFRAMEWORKPREFIX) +-AC_SUBST(PYTHONFRAMEWORKINSTALLDIR) +-AC_SUBST(FRAMEWORKINSTALLFIRST) +-AC_SUBST(FRAMEWORKINSTALLLAST) +-AC_SUBST(FRAMEWORKALTINSTALLFIRST) +-AC_SUBST(FRAMEWORKALTINSTALLLAST) +-AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX) +-AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX) +- +-##AC_ARG_WITH(dyld, +-## AS_HELP_STRING([--with-dyld], +-## [Use (OpenStep|Rhapsody) dynamic linker])) +-## +-# Set name for machine-dependent library files +-AC_SUBST(MACHDEP) +-AC_MSG_CHECKING(MACHDEP) +-if test -z "$MACHDEP" +-then +- ac_sys_system=`uname -s` +- if test "$ac_sys_system" = "AIX" \ +- -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then +- ac_sys_release=`uname -v` +- 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 +- linux*) MACHDEP="linux2";; +- cygwin*) MACHDEP="cygwin";; +- darwin*) MACHDEP="darwin";; +- irix646) MACHDEP="irix6";; +- '') MACHDEP="unknown";; +- esac +-fi +- +-# Some systems cannot stand _XOPEN_SOURCE being defined at all; they +-# disable features if it is defined, without any means to access these +-# features as extensions. For these systems, we skip the definition of +-# _XOPEN_SOURCE. Before adding a system to the list to gain access to +-# some feature, make sure there is no alternative way to access this +-# feature. Also, when using wildcards, make sure you have verified the +-# need for not defining _XOPEN_SOURCE on all systems matching the +-# wildcard, and that the wildcard does not include future systems +-# (which may remove their limitations). +-dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output +-case $ac_sys_system/$ac_sys_release in +- # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, +- # even though select is a POSIX function. Reported by J. Ribbens. +- # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. +- # In addition, Stefan Krah confirms that issue #1244610 exists through +- # OpenBSD 4.6, but is fixed in 4.7. +- OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@) +- define_xopen_source=no +- # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is +- # also defined. This can be overridden by defining _BSD_SOURCE +- # As this has a different meaning on Linux, only define it on OpenBSD +- AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features]) +- ;; +- OpenBSD/*) +- # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is +- # also defined. This can be overridden by defining _BSD_SOURCE +- # As this has a different meaning on Linux, only define it on OpenBSD +- AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features]) +- ;; +- # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of +- # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by +- # Marc Recht +- NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@) +- define_xopen_source=no;; +- # From the perspective of Solaris, _XOPEN_SOURCE is not so much a +- # request to enable features supported by the standard as a request +- # to disable features not supported by the standard. The best way +- # for Python to use Solaris is simply to leave _XOPEN_SOURCE out +- # entirely and define __EXTENSIONS__ instead. +- SunOS/*) +- define_xopen_source=no;; +- # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE, +- # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice. +- # Reconfirmed for 7.1.4 by Martin v. Loewis. +- OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@) +- define_xopen_source=no;; +- # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE, +- # but used in struct sockaddr.sa_family. Reported by Tim Rice. +- SCO_SV/3.2) +- define_xopen_source=no;; +- # On FreeBSD 4, the math functions C89 does not cover are never defined +- # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them. +- FreeBSD/4.*) +- define_xopen_source=no;; +- # On MacOS X 10.2, a bug in ncurses.h means that it craps out if +- # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which +- # identifies itself as Darwin/7.* +- # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE +- # disables platform specific features beyond repair. +- # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE +- # has no effect, don't bother defining them +- Darwin/@<:@6789@:>@.*) +- define_xopen_source=no;; +- Darwin/1@<:@0-9@:>@.*) +- define_xopen_source=no;; +- # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but +- # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined +- # or has another value. By not (re)defining it, the defaults come in place. +- AIX/4) +- define_xopen_source=no;; +- AIX/5) +- if test `uname -r` -eq 1; then +- define_xopen_source=no +- fi +- ;; +- # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from +- # defining NI_NUMERICHOST. +- QNX/6.3.2) +- define_xopen_source=no +- ;; +- +-esac +- +-if test $define_xopen_source = yes +-then +- AC_DEFINE(_XOPEN_SOURCE, 600, +- Define to the level of X/Open that your system supports) +- +- # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires +- # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else +- # several APIs are not declared. Since this is also needed in some +- # cases for HP-UX, we define it globally. +- AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, +- Define to activate Unix95-and-earlier features) +- +- AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001) +- +-fi +- +-# +-# SGI compilers allow the specification of the both the ABI and the +-# ISA on the command line. Depending on the values of these switches, +-# different and often incompatable code will be generated. +-# +-# The SGI_ABI variable can be used to modify the CC and LDFLAGS and +-# thus supply support for various ABI/ISA combinations. The MACHDEP +-# variable is also adjusted. +-# +-AC_SUBST(SGI_ABI) +-if test ! -z "$SGI_ABI" +-then +- CC="cc $SGI_ABI" +- LDFLAGS="$SGI_ABI $LDFLAGS" +- MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'` +-fi +-AC_MSG_RESULT($MACHDEP) +- +-# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET, +-# it may influence the way we can build extensions, so distutils +-# needs to check it +-AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET) +-AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET) +-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 +-# for debug/optimization stuff. BASECFLAGS is for flags that are required +-# just to get things to compile and link. Users are free to override OPT +-# when running configure or make. The build should not break if they do. +-# BASECFLAGS should generally not be messed with, however. +- +-# XXX shouldn't some/most/all of this code be merged with the stuff later +-# on that fiddles with OPT and BASECFLAGS? +-AC_MSG_CHECKING(for --without-gcc) +-AC_ARG_WITH(gcc, +- AS_HELP_STRING([--without-gcc], [never use gcc]), +-[ +- case $withval in +- no) CC=${CC:-cc} +- without_gcc=yes;; +- yes) CC=gcc +- without_gcc=no;; +- *) CC=$withval +- without_gcc=$withval;; +- esac], [ +- case $ac_sys_system in +- AIX*) CC=${CC:-xlc_r} +- without_gcc=;; +- *) without_gcc=no;; +- esac]) +-AC_MSG_RESULT($without_gcc) +- +-# If the user switches compilers, we can't believe the cache +-if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC" +-then +- AC_MSG_ERROR([cached CC is different -- throw away $cache_file +-(it is also a good idea to do 'make clean' before compiling)]) +-fi +- +-# Don't let AC_PROG_CC set the default CFLAGS. It normally sets -g -O2 +-# when the compiler supports them, but we don't always want -O2, and +-# we set -g later. +-if test -z "$CFLAGS"; then +- CFLAGS= +-fi +-AC_PROG_CC +- +-AC_SUBST(CXX) +-AC_SUBST(MAINCC) +-AC_MSG_CHECKING(for --with-cxx-main=) +-AC_ARG_WITH(cxx_main, +- AS_HELP_STRING([--with-cxx-main=], +- [compile main() and link python executable with C++ compiler]), +-[ +- +- case $withval in +- no) with_cxx_main=no +- MAINCC='$(CC)';; +- yes) with_cxx_main=yes +- MAINCC='$(CXX)';; +- *) with_cxx_main=yes +- MAINCC=$withval +- if test -z "$CXX" +- then +- CXX=$withval +- fi;; +- esac], [ +- with_cxx_main=no +- MAINCC='$(CC)' +-]) +-AC_MSG_RESULT($with_cxx_main) +- +-preset_cxx="$CXX" +-if test -z "$CXX" +-then +- case "$CC" in +- gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;; +- cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;; +- esac +- if test "$CXX" = "notfound" +- then +- CXX="" +- fi +-fi +-if test -z "$CXX" +-then +- AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound) +- if test "$CXX" = "notfound" +- then +- CXX="" +- fi +-fi +-if test "$preset_cxx" != "$CXX" +-then +- AC_MSG_WARN([ +- +- By default, distutils will build C++ extension modules with "$CXX". +- If this is not intended, then set CXX on the configure command line. +- ]) +-fi +- +- +-AC_MSG_CHECKING([for -Wl,--no-as-needed]) +-save_LDFLAGS="$LDFLAGS" +-LDFLAGS="$LDFLAGS -Wl,--no-as-needed" +-AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], +- [NO_AS_NEEDED="-Wl,--no-as-needed" +- AC_MSG_RESULT([yes])], +- [NO_AS_NEEDED="" +- AC_MSG_RESULT([no])]) +-LDFLAGS="$save_LDFLAGS" +-AC_SUBST(NO_AS_NEEDED) +- +- +-# checks for UNIX variants that set C preprocessor variables +-AC_USE_SYSTEM_EXTENSIONS +- +-# Check for unsupported systems +-case $ac_sys_system/$ac_sys_release in +-atheos*|Linux*/1*) +- echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported. +- echo See README for details. +- exit 1;; +-esac +- +-AC_EXEEXT +-AC_MSG_CHECKING(for --with-suffix) +-AC_ARG_WITH(suffix, +- AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]), +-[ +- case $withval in +- no) EXEEXT=;; +- yes) EXEEXT=.exe;; +- *) EXEEXT=$withval;; +- esac]) +-AC_MSG_RESULT($EXEEXT) +- +-# Test whether we're running on a non-case-sensitive system, in which +-# case we give a warning if no ext is given +-AC_SUBST(BUILDEXEEXT) +-AC_MSG_CHECKING(for case-insensitive build directory) +-if test ! -d CaseSensitiveTestDir; then +-mkdir CaseSensitiveTestDir +-fi +- +-if test -d casesensitivetestdir +-then +- AC_MSG_RESULT(yes) +- BUILDEXEEXT=.exe +-else +- AC_MSG_RESULT(no) +- BUILDEXEEXT=$EXEEXT +-fi +-rmdir CaseSensitiveTestDir +- +-case $MACHDEP in +-bsdos*) +- case $CC in +- gcc) CC="$CC -D_HAVE_BSDI";; +- esac;; +-esac +- +-case $ac_sys_system in +-hp*|HP*) +- case $CC in +- cc|*/cc) CC="$CC -Ae";; +- esac;; +-esac +- +- +-AC_SUBST(LIBRARY) +-AC_MSG_CHECKING(LIBRARY) +-if test -z "$LIBRARY" +-then +- LIBRARY='libpython$(VERSION)$(ABIFLAGS).a' +-fi +-AC_MSG_RESULT($LIBRARY) +- +-# LDLIBRARY is the name of the library to link against (as opposed to the +-# name of the library into which to insert object files). BLDLIBRARY is also +-# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY +-# is blank as the main program is not linked directly against LDLIBRARY. +-# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On +-# systems without shared libraries, LDLIBRARY is the same as LIBRARY +-# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library, +-# DLLLIBRARY is the shared (i.e., DLL) library. +-# +-# RUNSHARED is used to run shared python without installed libraries +-# +-# INSTSONAME is the name of the shared library that will be use to install +-# on the system - some systems like version suffix, others don't +-# +-# LDVERSION is the shared library version number, normally the Python version +-# with the ABI build flags appended. +-AC_SUBST(LDLIBRARY) +-AC_SUBST(DLLLIBRARY) +-AC_SUBST(BLDLIBRARY) +-AC_SUBST(PY3LIBRARY) +-AC_SUBST(LDLIBRARYDIR) +-AC_SUBST(INSTSONAME) +-AC_SUBST(RUNSHARED) +-AC_SUBST(LDVERSION) +-LDLIBRARY="$LIBRARY" +-BLDLIBRARY='$(LDLIBRARY)' +-INSTSONAME='$(LDLIBRARY)' +-DLLLIBRARY='' +-LDLIBRARYDIR='' +-RUNSHARED='' +-LDVERSION="$VERSION" +- +-# LINKCC is the command that links the python executable -- default is $(CC). +-# If CXX is set, and if it is needed to link a main function that was +-# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable: +-# python might then depend on the C++ runtime +-# This is altered for AIX in order to build the export list before +-# linking. +-AC_SUBST(LINKCC) +-AC_MSG_CHECKING(LINKCC) +-if test -z "$LINKCC" +-then +- LINKCC='$(PURIFY) $(MAINCC)' +- case $ac_sys_system in +- AIX*) +- exp_extra="\"\"" +- if test $ac_sys_release -ge 5 -o \ +- $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then +- exp_extra="." +- fi +- LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";; +- QNX*) +- # qcc must be used because the other compilers do not +- # support -N. +- LINKCC=qcc;; +- esac +-fi +-AC_MSG_RESULT($LINKCC) +- +-# GNULD is set to "yes" if the GNU linker is used. If this goes wrong +-# make sure we default having it set to "no": this is used by +-# distutils.unixccompiler to know if it should add --enable-new-dtags +-# to linker command lines, and failing to detect GNU ld simply results +-# in the same bahaviour as before. +-AC_SUBST(GNULD) +-AC_MSG_CHECKING(for GNU ld) +-ac_prog=ld +-if test "$GCC" = yes; then +- ac_prog=`$CC -print-prog-name=ld` +-fi +-case `"$ac_prog" -V 2>&1 < /dev/null` in +- *GNU*) +- GNULD=yes;; +- *) +- GNULD=no;; +-esac +-AC_MSG_RESULT($GNULD) +- +-AC_C_INLINE +-if test "$ac_cv_c_inline" != no ; then +- AC_DEFINE(USE_INLINE, 1, [Define to use the C99 inline keyword.]) +- AC_SUBST(USE_INLINE) +-fi +- +- +-AC_MSG_CHECKING(for --enable-shared) +-AC_ARG_ENABLE(shared, +- AS_HELP_STRING([--enable-shared], [disable/enable building shared python library])) +- +-if test -z "$enable_shared" +-then +- case $ac_sys_system in +- CYGWIN*) +- enable_shared="yes";; +- *) +- enable_shared="no";; +- esac +-fi +-AC_MSG_RESULT($enable_shared) +- +-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 +- +-AC_MSG_CHECKING(LDLIBRARY) +- +-# MacOSX framework builds need more magic. LDLIBRARY is the dynamic +-# library that we build, but we do not want to link against it (we +-# will find it with a -framework option). For this reason there is an +-# extra variable BLDLIBRARY against which Python and the extension +-# modules are linked, BLDLIBRARY. This is normally the same as +-# LDLIBRARY, but empty for MacOSX framework builds. +-if test "$enable_framework" +-then +- LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' +- RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH" +- BLDLIBRARY='' +-else +- BLDLIBRARY='$(LDLIBRARY)' +-fi +- +-# Other platforms follow +-if test $enable_shared = "yes"; then +- AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.]) +- case $ac_sys_system in +- CYGWIN*) +- LDLIBRARY='libpython$(LDVERSION).dll.a' +- DLLLIBRARY='libpython$(LDVERSION).dll' +- ;; +- SunOS*) +- LDLIBRARY='libpython$(LDVERSION).so' +- BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)' +- RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} +- INSTSONAME="$LDLIBRARY".$SOVERSION +- if test "$with_pydebug" != yes +- then +- PY3LIBRARY=libpython3.so +- fi +- ;; +- Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*) +- LDLIBRARY='libpython$(LDVERSION).so' +- BLDLIBRARY='-L. -lpython$(LDVERSION)' +- RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} +- case $ac_sys_system in +- FreeBSD*) +- SOVERSION=`echo $SOVERSION|cut -d "." -f 1` +- ;; +- esac +- INSTSONAME="$LDLIBRARY".$SOVERSION +- if test "$with_pydebug" != yes +- then +- PY3LIBRARY=libpython3.so +- fi +- ;; +- hp*|HP*) +- case `uname -m` in +- ia64) +- LDLIBRARY='libpython$(LDVERSION).so' +- ;; +- *) +- LDLIBRARY='libpython$(LDVERSION).sl' +- ;; +- esac +- BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)' +- RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH} +- ;; +- OSF*) +- LDLIBRARY='libpython$(LDVERSION).so' +- BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(LDVERSION)' +- RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} +- ;; +- Darwin*) +- LDLIBRARY='libpython$(LDVERSION).dylib' +- BLDLIBRARY='-L. -lpython$(LDVERSION)' +- RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}' +- ;; +- AIX*) +- LDLIBRARY='libpython$(LDVERSION).so' +- RUNSHARED=LIBPATH=`pwd`:${LIBPATH} +- ;; +- +- esac +-else # shared is disabled +- case $ac_sys_system in +- CYGWIN*) +- BLDLIBRARY='$(LIBRARY)' +- LDLIBRARY='libpython$(LDVERSION).dll.a' +- ;; +- esac +-fi +- +-AC_MSG_RESULT($LDLIBRARY) +- +-AC_PROG_RANLIB +-AC_SUBST(AR) +-AC_CHECK_PROGS(AR, ar aal, ar) +- +-# tweak ARFLAGS only if the user didn't set it on the command line +-AC_SUBST(ARFLAGS) +-if test -z "$ARFLAGS" +-then +- ARFLAGS="rc" +-fi +- +-AC_SUBST(SVNVERSION) +-AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found) +-if test $SVNVERSION = found +-then +- SVNVERSION="svnversion \$(srcdir)" +-else +- SVNVERSION="echo Unversioned directory" +-fi +- +-AC_SUBST(HGVERSION) +-AC_SUBST(HGTAG) +-AC_SUBST(HGBRANCH) +- +-if test -e $srcdir/.hg/dirstate +-then +-AC_CHECK_PROG(HAS_HG, hg, found, not-found) +-else +-HAS_HG=no-repository +-fi +-if test $HAS_HG = found +-then +- HGVERSION="hg id -i \$(srcdir)" +- HGTAG="hg id -t \$(srcdir)" +- HGBRANCH="hg id -b \$(srcdir)" +-else +- HGVERSION="" +- HGTAG="" +- HGBRANCH="" +-fi +- +-AC_SUBST(DISABLE_ASDLGEN) +-DISABLE_ASDLGEN="" +-AC_CHECK_PROG(HAS_PYTHON, python, found, not-found) +-if test $HAS_HG != found -o $HAS_PYTHON != found +-then +- DISABLE_ASDLGEN="@echo hg: $HAS_HG, python: $HAS_PYTHON! cannot run \$(srcdir)/Parser/asdl_c.py #" +-fi +- +- +-case $MACHDEP in +-bsdos*|hp*|HP*) +- # install -d does not work on BSDI or HP-UX +- if test -z "$INSTALL" +- then +- INSTALL="${srcdir}/install-sh -c" +- fi +-esac +-AC_PROG_INSTALL +- +-# Not every filesystem supports hard links +-AC_SUBST(LN) +-if test -z "$LN" ; then +- case $ac_sys_system in +- CYGWIN*) LN="ln -s";; +- *) LN=ln;; +- esac +-fi +- +-# For calculating the .so ABI tag. +-AC_SUBST(ABIFLAGS) +-ABIFLAGS="" +- +-# Check for --with-pydebug +-AC_MSG_CHECKING(for --with-pydebug) +-AC_ARG_WITH(pydebug, +- AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]), +-[ +-if test "$withval" != no +-then +- AC_DEFINE(Py_DEBUG, 1, +- [Define if you want to build an interpreter with many run-time checks.]) +- AC_MSG_RESULT(yes); +- Py_DEBUG='true' +- ABIFLAGS="${ABIFLAGS}d" +-else AC_MSG_RESULT(no); Py_DEBUG='false' +-fi], +-[AC_MSG_RESULT(no)]) +- +-# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be +-# merged with this chunk of code? +- +-# Optimizer/debugger flags +-# ------------------------ +-# (The following bit of code is complicated enough - please keep things +-# indented properly. Just pretend you're editing Python code. ;-) +- +-# There are two parallel sets of case statements below, one that checks to +-# see if OPT was set and one that does BASECFLAGS setting based upon +-# compiler and platform. BASECFLAGS tweaks need to be made even if the +-# user set OPT. +- +-# tweak OPT based on compiler and platform, only if the user didn't set +-# it on the command line +-AC_SUBST(OPT) +-if test "${OPT-unset}" = "unset" +-then +- case $GCC in +- yes) +- if test "$CC" != 'g++' ; then +- STRICT_PROTO="-Wstrict-prototypes" +- fi +- # For gcc 4.x we need to use -fwrapv so lets check if its supported +- if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then +- WRAP="-fwrapv" +- fi +- +- # Clang also needs -fwrapv +- case $CC in +- *clang*) WRAP="-fwrapv" +- ;; +- esac +- +- case $ac_cv_prog_cc_g in +- yes) +- if test "$Py_DEBUG" = 'true' ; then +- # Optimization messes up debuggers, so turn it off for +- # debug builds. +- OPT="-g -O0 -Wall $STRICT_PROTO" +- else +- OPT="-g $WRAP -O3 -Wall $STRICT_PROTO" +- fi +- ;; +- *) +- OPT="-O3 -Wall $STRICT_PROTO" +- ;; +- esac +- case $ac_sys_system in +- SCO_SV*) OPT="$OPT -m486 -DSCO5" +- ;; +- esac +- ;; +- +- *) +- OPT="-O" +- ;; +- esac +-fi +- +-AC_SUBST(BASECFLAGS) +- +-# The -arch flags for universal builds on OSX +-UNIVERSAL_ARCH_FLAGS= +-AC_SUBST(UNIVERSAL_ARCH_FLAGS) +- +-# tweak BASECFLAGS based on compiler and platform +-case $GCC in +-yes) +- # Python doesn't violate C99 aliasing rules, but older versions of +- # GCC produce warnings for legal Python code. Enable +- # -fno-strict-aliasing on versions of GCC that support but produce +- # warnings. See Issue3326 +- AC_MSG_CHECKING(whether $CC accepts and needs -fno-strict-aliasing) +- ac_save_cc="$CC" +- CC="$CC -fno-strict-aliasing" +- save_CFLAGS="$CFLAGS" +- AC_CACHE_VAL(ac_cv_no_strict_aliasing, +- AC_COMPILE_IFELSE( +- [ +- AC_LANG_PROGRAM([[]], [[]]) +- ],[ +- CC="$ac_save_cc -fstrict-aliasing" +- CFLAGS="$CFLAGS -Werror -Wstrict-aliasing" +- AC_COMPILE_IFELSE( +- [ +- AC_LANG_PROGRAM([[void f(int **x) {}]], +- [[double *x; f((int **) &x);]]) +- ],[ +- ac_cv_no_strict_aliasing=no +- ],[ +- ac_cv_no_strict_aliasing=yes +- ]) +- ],[ +- ac_cv_no_strict_aliasing=no +- ])) +- CFLAGS="$save_CFLAGS" +- CC="$ac_save_cc" +- AC_MSG_RESULT($ac_cv_no_strict_aliasing) +- if test $ac_cv_no_strict_aliasing = yes +- then +- BASECFLAGS="$BASECFLAGS -fno-strict-aliasing" +- fi +- +- # 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 +- alpha*) +- BASECFLAGS="$BASECFLAGS -mieee" +- ;; +- esac +- +- case $ac_sys_system in +- SCO_SV*) +- BASECFLAGS="$BASECFLAGS -m486 -DSCO5" +- ;; +- # is there any other compiler on Darwin besides gcc? +- Darwin*) +- # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd +- # used to be here, but non-Apple gcc doesn't accept them. +- if test "${CC}" = gcc +- then +- AC_MSG_CHECKING(which compiler should be used) +- case "${UNIVERSALSDK}" in +- */MacOSX10.4u.sdk) +- # Build using 10.4 SDK, force usage of gcc when the +- # compiler is gcc, otherwise the user will get very +- # confusing error messages when building on OSX 10.6 +- CC=gcc-4.0 +- CPP=cpp-4.0 +- ;; +- esac +- AC_MSG_RESULT($CC) +- fi +- +- +- if test "${enable_universalsdk}"; then +- UNIVERSAL_ARCH_FLAGS="" +- if test "$UNIVERSAL_ARCHS" = "32-bit" ; then +- UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386" +- ARCH_RUN_32BIT="" +- LIPO_32BIT_FLAGS="" +- elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then +- UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64" +- LIPO_32BIT_FLAGS="" +- ARCH_RUN_32BIT="true" +- +- elif test "$UNIVERSAL_ARCHS" = "all" ; then +- UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64" +- LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" +- ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc" +- +- elif test "$UNIVERSAL_ARCHS" = "intel" ; then +- UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64" +- LIPO_32BIT_FLAGS="-extract i386" +- ARCH_RUN_32BIT="/usr/bin/arch -i386" +- +- elif test "$UNIVERSAL_ARCHS" = "3-way" ; then +- UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64" +- LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386" +- ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc" +- +- else +- AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way]) +- +- fi +- +- +- CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}" +- if test "${UNIVERSALSDK}" != "/" +- then +- CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}" +- LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}" +- CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}" +- fi +- fi +- +- # Calculate the right deployment target for this build. +- # +- cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'` +- if test ${cur_target} '>' 10.2; then +- cur_target=10.3 +- if test ${enable_universalsdk}; then +- if test "${UNIVERSAL_ARCHS}" = "all"; then +- # Ensure that the default platform for a +- # 4-way universal build is OSX 10.5, +- # that's the first OS release where +- # 4-way builds make sense. +- cur_target='10.5' +- +- elif test "${UNIVERSAL_ARCHS}" = "3-way"; then +- cur_target='10.5' +- +- elif test "${UNIVERSAL_ARCHS}" = "intel"; then +- cur_target='10.5' +- +- elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then +- cur_target='10.5' +- fi +- else +- if test `/usr/bin/arch` = "i386"; then +- # On Intel macs default to a deployment +- # target of 10.4, that's the first OSX +- # release with Intel support. +- cur_target="10.4" +- fi +- fi +- fi +- CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} +- +- # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the +- # environment with a value that is the same as what we'll use +- # in the Makefile to ensure that we'll get the same compiler +- # environment during configure and build time. +- MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET" +- export MACOSX_DEPLOYMENT_TARGET +- EXPORT_MACOSX_DEPLOYMENT_TARGET='' +- +- ;; +- OSF*) +- BASECFLAGS="$BASECFLAGS -mieee" +- ;; +- esac +- ;; +- +-*) +- case $ac_sys_system in +- OpenUNIX*|UnixWare*) +- BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca " +- ;; +- OSF*) +- BASECFLAGS="$BASECFLAGS -ieee -std" +- ;; +- SCO_SV*) +- BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5" +- ;; +- esac +- ;; +-esac +- +-if test "$Py_DEBUG" = 'true'; then +- : +-else +- OPT="-DNDEBUG $OPT" +-fi +- +-if test "$ac_arch_flags" +-then +- BASECFLAGS="$BASECFLAGS $ac_arch_flags" +-fi +- +-# Check whether GCC supports PyArg_ParseTuple format +-if test "$GCC" = "yes" +-then +- AC_MSG_CHECKING(whether gcc supports ParseTuple __format__) +- save_CFLAGS=$CFLAGS +- CFLAGS="$CFLAGS -Werror" +- AC_COMPILE_IFELSE([ +- AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]]) +- ],[ +- AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, +- [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))]) +- AC_MSG_RESULT(yes) +- ],[ +- AC_MSG_RESULT(no) +- ]) +- CFLAGS=$save_CFLAGS +-fi +- +-# On some compilers, pthreads are available without further options +-# (e.g. MacOS X). On some of these systems, the compiler will not +-# complain if unaccepted options are passed (e.g. gcc on Mac OS X). +-# So we have to see first whether pthreads are available without +-# options before we can check whether -Kpthread improves anything. +-AC_MSG_CHECKING(whether pthreads are available without options) +-AC_CACHE_VAL(ac_cv_pthread_is_default, +-[AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +- +-void* routine(void* p){return NULL;} +- +-int main(){ +- pthread_t p; +- if(pthread_create(&p,NULL,routine,NULL)!=0) +- return 1; +- (void)pthread_detach(p); +- return 0; +-} +-]])],[ +- ac_cv_pthread_is_default=yes +- ac_cv_kthread=no +- ac_cv_pthread=no +-],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no]) +-]) +-AC_MSG_RESULT($ac_cv_pthread_is_default) +- +- +-if test $ac_cv_pthread_is_default = yes +-then +- ac_cv_kpthread=no +-else +-# -Kpthread, if available, provides the right #defines +-# and linker options to make pthread_create available +-# Some compilers won't report that they do not support -Kpthread, +-# so we need to run a program to see whether it really made the +-# function available. +-AC_MSG_CHECKING(whether $CC accepts -Kpthread) +-AC_CACHE_VAL(ac_cv_kpthread, +-[ac_save_cc="$CC" +-CC="$CC -Kpthread" +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +- +-void* routine(void* p){return NULL;} +- +-int main(){ +- pthread_t p; +- if(pthread_create(&p,NULL,routine,NULL)!=0) +- return 1; +- (void)pthread_detach(p); +- return 0; +-} +-]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no]) +-CC="$ac_save_cc"]) +-AC_MSG_RESULT($ac_cv_kpthread) +-fi +- +-if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no +-then +-# -Kthread, if available, provides the right #defines +-# and linker options to make pthread_create available +-# Some compilers won't report that they do not support -Kthread, +-# so we need to run a program to see whether it really made the +-# function available. +-AC_MSG_CHECKING(whether $CC accepts -Kthread) +-AC_CACHE_VAL(ac_cv_kthread, +-[ac_save_cc="$CC" +-CC="$CC -Kthread" +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +- +-void* routine(void* p){return NULL;} +- +-int main(){ +- pthread_t p; +- if(pthread_create(&p,NULL,routine,NULL)!=0) +- return 1; +- (void)pthread_detach(p); +- return 0; +-} +-]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no]) +-CC="$ac_save_cc"]) +-AC_MSG_RESULT($ac_cv_kthread) +-fi +- +-if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no +-then +-# -pthread, if available, provides the right #defines +-# and linker options to make pthread_create available +-# Some compilers won't report that they do not support -pthread, +-# 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_save_cc="$CC" +-CC="$CC -pthread" +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +- +-void* routine(void* p){return NULL;} +- +-int main(){ +- pthread_t p; +- if(pthread_create(&p,NULL,routine,NULL)!=0) +- return 1; +- (void)pthread_detach(p); +- return 0; +-} +-]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no]) +-CC="$ac_save_cc"]) +-AC_MSG_RESULT($ac_cv_pthread) +-fi +- +-# If we have set a CC compiler flag for thread support then +-# check if it works for CXX, too. +-ac_cv_cxx_thread=no +-if test ! -z "$CXX" +-then +-AC_MSG_CHECKING(whether $CXX also accepts flags for thread support) +-ac_save_cxx="$CXX" +- +-if test "$ac_cv_kpthread" = "yes" +-then +- CXX="$CXX -Kpthread" +- ac_cv_cxx_thread=yes +-elif test "$ac_cv_kthread" = "yes" +-then +- CXX="$CXX -Kthread" +- ac_cv_cxx_thread=yes +-elif test "$ac_cv_pthread" = "yes" +-then +- CXX="$CXX -pthread" +- ac_cv_cxx_thread=yes +-fi +- +-if test $ac_cv_cxx_thread = yes +-then +- echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext +- $CXX -c conftest.$ac_ext 2>&5 +- if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \ +- && test -s conftest$ac_exeext && ./conftest$ac_exeext +- then +- ac_cv_cxx_thread=yes +- else +- ac_cv_cxx_thread=no +- fi +- rm -fr conftest* +-fi +-AC_MSG_RESULT($ac_cv_cxx_thread) +-fi +-CXX="$ac_save_cxx" +- +-dnl # check for ANSI or K&R ("traditional") preprocessor +-dnl AC_MSG_CHECKING(for C preprocessor type) +-dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-dnl #define spam(name, doc) {#name, &name, #name "() -- " doc} +-dnl int foo; +-dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something"); +-dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional]) +-dnl AC_MSG_RESULT($cpp_type) +- +-# checks for header files +-AC_HEADER_STDC +-AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ +-fcntl.h grp.h \ +-ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ +-shadow.h signal.h stdint.h stropts.h termios.h thread.h \ +-unistd.h utime.h \ +-sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \ +-sys/lock.h sys/mkdev.h sys/modem.h \ +-sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \ +-sys/syscall.h sys/termio.h sys/time.h \ +-sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ +-sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ +-bluetooth/bluetooth.h linux/tipc.h spawn.h util.h) +-AC_HEADER_DIRENT +-AC_HEADER_MAJOR +- +-# On Solaris, term.h requires curses.h +-AC_CHECK_HEADERS(term.h,,,[ +-#ifdef HAVE_CURSES_H +-#include +-#endif +-]) +- +-# On Linux, netlink.h requires asm/types.h +-AC_CHECK_HEADERS(linux/netlink.h,,,[ +-#ifdef HAVE_ASM_TYPES_H +-#include +-#endif +-#ifdef HAVE_SYS_SOCKET_H +-#include +-#endif +-]) +- +-# checks for typedefs +-was_it_defined=no +-AC_MSG_CHECKING(for clock_t in time.h) +-AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [ +- AC_DEFINE(clock_t, long, [Define to 'long' if doesn't define.]) +-]) +-AC_MSG_RESULT($was_it_defined) +- +-# Check whether using makedev requires defining _OSF_SOURCE +-AC_MSG_CHECKING(for makedev) +-AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +-#if defined(MAJOR_IN_MKDEV) +-#include +-#elif defined(MAJOR_IN_SYSMACROS) +-#include +-#else +-#include +-#endif +-]], [[ +- makedev(0, 0) ]]) +-],[ac_cv_has_makedev=yes],[ac_cv_has_makedev=no]) +-if test "$ac_cv_has_makedev" = "no"; then +- # we didn't link, try if _OSF_SOURCE will allow us to link +- AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +-#define _OSF_SOURCE 1 +-#include +- ]], +- [[ makedev(0, 0) ]])], +- [ac_cv_has_makedev=yes], +- [ac_cv_has_makedev=no]) +- if test "$ac_cv_has_makedev" = "yes"; then +- AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.]) +- fi +-fi +-AC_MSG_RESULT($ac_cv_has_makedev) +-if test "$ac_cv_has_makedev" = "yes"; then +- AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.]) +-fi +- +-# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in +-# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are +-# defined, but the compiler does not support pragma redefine_extname, +-# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit +-# structures (such as rlimit64) without declaring them. As a +-# work-around, disable LFS on such configurations +- +-use_lfs=yes +-AC_MSG_CHECKING(Solaris LFS bug) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-#define _LARGEFILE_SOURCE 1 +-#define _FILE_OFFSET_BITS 64 +-#include +-]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes]) +-AC_MSG_RESULT($sol_lfs_bug) +-if test "$sol_lfs_bug" = "yes"; then +- use_lfs=no +-fi +- +-if test "$use_lfs" = "yes"; then +-# Two defines needed to enable largefile support on various platforms +-# These may affect some typedefs +-case $ac_sys_system/$ac_sys_release in +-AIX*) +- AC_DEFINE(_LARGE_FILES, 1, +- [This must be defined on AIX systems to enable large file support.]) +- ;; +-esac +-AC_DEFINE(_LARGEFILE_SOURCE, 1, +-[This must be defined on some systems to enable large file support.]) +-AC_DEFINE(_FILE_OFFSET_BITS, 64, +-[This must be set to 64 on some systems to enable large file support.]) +-fi +- +-# Add some code to confdefs.h so that the test for off_t works on SCO +-cat >> confdefs.h <<\EOF +-#if defined(SCO_DS) +-#undef _OFF_T +-#endif +-EOF +- +-# Type availability checks +-AC_TYPE_MODE_T +-AC_TYPE_OFF_T +-AC_TYPE_PID_T +-AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void]) +-AC_TYPE_SIZE_T +-AC_TYPE_UID_T +-AC_TYPE_UINT32_T +-AC_TYPE_UINT64_T +-AC_TYPE_INT32_T +-AC_TYPE_INT64_T +-AC_CHECK_TYPE(ssize_t, +- AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,) +- +-# Sizes of various common basic types +-# ANSI C requires sizeof(char) == 1, so no need to check it +-AC_CHECK_SIZEOF(int, 4) +-AC_CHECK_SIZEOF(long, 4) +-AC_CHECK_SIZEOF(void *, 4) +-AC_CHECK_SIZEOF(short, 2) +-AC_CHECK_SIZEOF(float, 4) +-AC_CHECK_SIZEOF(double, 8) +-AC_CHECK_SIZEOF(fpos_t, 4) +-AC_CHECK_SIZEOF(size_t, 4) +-AC_CHECK_SIZEOF(pid_t, 4) +- +-AC_MSG_CHECKING(for long long support) +-have_long_long=no +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[ +- AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.]) +- have_long_long=yes +-],[]) +-AC_MSG_RESULT($have_long_long) +-if test "$have_long_long" = yes ; then +-AC_CHECK_SIZEOF(long long, 8) +-fi +- +-AC_MSG_CHECKING(for long double support) +-have_long_double=no +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[ +- AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.]) +- have_long_double=yes +-],[]) +-AC_MSG_RESULT($have_long_double) +-if test "$have_long_double" = yes ; then +-AC_CHECK_SIZEOF(long double, 16) +-fi +- +- +-AC_MSG_CHECKING(for _Bool support) +-have_c99_bool=no +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[ +- AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.]) +- have_c99_bool=yes +-],[]) +-AC_MSG_RESULT($have_c99_bool) +-if test "$have_c99_bool" = yes ; then +-AC_CHECK_SIZEOF(_Bool, 1) +-fi +- +-AC_CHECK_TYPES(uintptr_t, +- [AC_CHECK_SIZEOF(uintptr_t, 4)], +- [], [#ifdef HAVE_STDINT_H +- #include +- #endif +- #ifdef HAVE_INTTYPES_H +- #include +- #endif]) +- +-AC_CHECK_SIZEOF(off_t, [], [ +-#ifdef HAVE_SYS_TYPES_H +-#include +-#endif +-]) +- +-AC_MSG_CHECKING(whether to enable large file support) +-if test "$have_long_long" = yes +-then +-if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \ +- "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then +- AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, +- [Defined to enable large file support when an off_t is bigger than a long +- and long long is available and at least as big as an off_t. You may need +- to add some flags for configuration and compilation to enable this mode. +- (For Solaris and Linux, the necessary defines are already defined.)]) +- AC_MSG_RESULT(yes) +-else +- AC_MSG_RESULT(no) +-fi +-else +- AC_MSG_RESULT(no) +-fi +- +-AC_CHECK_SIZEOF(time_t, [], [ +-#ifdef HAVE_SYS_TYPES_H +-#include +-#endif +-#ifdef HAVE_TIME_H +-#include +-#endif +-]) +- +-# if have pthread_t then define SIZEOF_PTHREAD_T +-ac_save_cc="$CC" +-if test "$ac_cv_kpthread" = "yes" +-then CC="$CC -Kpthread" +-elif test "$ac_cv_kthread" = "yes" +-then CC="$CC -Kthread" +-elif test "$ac_cv_pthread" = "yes" +-then CC="$CC -pthread" +-fi +- +-AC_MSG_CHECKING(for pthread_t) +-have_pthread_t=no +-AC_COMPILE_IFELSE([ +- AC_LANG_PROGRAM([[#include ]], [[pthread_t x; x = *(pthread_t*)0;]]) +-],[have_pthread_t=yes],[]) +-AC_MSG_RESULT($have_pthread_t) +-if test "$have_pthread_t" = yes ; then +- AC_CHECK_SIZEOF(pthread_t, [], [ +-#ifdef HAVE_PTHREAD_H +-#include +-#endif +- ]) +-fi +-CC="$ac_save_cc" +- +-AC_SUBST(OTHER_LIBTOOL_OPT) +-case $ac_sys_system/$ac_sys_release in +- Darwin/@<:@01567@:>@\..*) +- OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000" +- ;; +- Darwin/*) +- OTHER_LIBTOOL_OPT="" +- ;; +-esac +- +- +-ARCH_RUN_32BIT="" +-AC_SUBST(LIBTOOL_CRUFT) +-case $ac_sys_system/$ac_sys_release in +- Darwin/@<:@01567@:>@\..*) +- LIBTOOL_CRUFT="-framework System -lcc_dynamic" +- if test "${enable_universalsdk}"; then +- : +- else +- LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`" +- fi +- LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' +- LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; +- Darwin/*) +- gcc_version=`gcc -dumpversion` +- if test ${gcc_version} '<' 4.0 +- then +- LIBTOOL_CRUFT="-lcc_dynamic" +- else +- LIBTOOL_CRUFT="" +- fi +- AC_RUN_IFELSE([AC_LANG_SOURCE([[ +- #include +- int main(int argc, char*argv[]) +- { +- if (sizeof(long) == 4) { +- return 0; +- } else { +- return 1; +- } +- } +- ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes]) +- +- if test "${ac_osx_32bit}" = "yes"; then +- case `/usr/bin/arch` in +- i386) +- MACOSX_DEFAULT_ARCH="i386" +- ;; +- ppc) +- MACOSX_DEFAULT_ARCH="ppc" +- ;; +- *) +- AC_MSG_ERROR([Unexpected output of 'arch' on OSX]) +- ;; +- esac +- else +- case `/usr/bin/arch` in +- i386) +- MACOSX_DEFAULT_ARCH="x86_64" +- ;; +- ppc) +- MACOSX_DEFAULT_ARCH="ppc64" +- ;; +- *) +- AC_MSG_ERROR([Unexpected output of 'arch' on OSX]) +- ;; +- esac +- +- #ARCH_RUN_32BIT="true" +- fi +- +- LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}" +- LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' +- LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; +-esac +- +-AC_MSG_CHECKING(for --enable-framework) +-if test "$enable_framework" +-then +- BASECFLAGS="$BASECFLAGS -fno-common -dynamic" +- # -F. is needed to allow linking to the framework while +- # in the build location. +- AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, +- [Define if you want to produce an OpenStep/Rhapsody framework +- (shared library plus accessory files).]) +- AC_MSG_RESULT(yes) +- if test $enable_shared = "yes" +- then +- AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead]) +- fi +-else +- AC_MSG_RESULT(no) +-fi +- +-AC_MSG_CHECKING(for dyld) +-case $ac_sys_system/$ac_sys_release in +- Darwin/*) +- AC_DEFINE(WITH_DYLD, 1, +- [Define if you want to use the new-style (Openstep, Rhapsody, MacOS) +- dynamic linker (dyld) instead of the old-style (NextStep) dynamic +- linker (rld). Dyld is necessary to support frameworks.]) +- AC_MSG_RESULT(always on for Darwin) +- ;; +- *) +- AC_MSG_RESULT(no) +- ;; +-esac +- +-# Set info about shared libraries. +-AC_SUBST(SO) +-AC_SUBST(LDSHARED) +-AC_SUBST(LDCXXSHARED) +-AC_SUBST(BLDSHARED) +-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 +-# Python, as opposed to building Python itself as a shared library.) +-AC_MSG_CHECKING(LDSHARED) +-if test -z "$LDSHARED" +-then +- case $ac_sys_system/$ac_sys_release in +- AIX*) +- BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp" +- LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp" +- ;; +- IRIX/5*) LDSHARED="ld -shared";; +- IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";; +- SunOS/5*) +- if test "$GCC" = "yes" ; then +- LDSHARED='$(CC) -shared' +- LDCXXSHARED='$(CXX) -shared' +- else +- LDSHARED='$(CC) -G' +- LDCXXSHARED='$(CXX) -G' +- fi ;; +- hp*|HP*) +- if test "$GCC" = "yes" ; then +- LDSHARED='$(CC) -shared' +- LDCXXSHARED='$(CXX) -shared' +- else +- LDSHARED='ld -b' +- fi ;; +- OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";; +- Darwin/1.3*) +- LDSHARED='$(CC) -bundle' +- LDCXXSHARED='$(CXX) -bundle' +- if test "$enable_framework" ; then +- # Link against the framework. All externals should be defined. +- BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' +- LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' +- LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' +- else +- # No framework. Ignore undefined symbols, assuming they come from Python +- LDSHARED="$LDSHARED -undefined suppress" +- LDCXXSHARED="$LDCXXSHARED -undefined suppress" +- fi ;; +- Darwin/1.4*|Darwin/5.*|Darwin/6.*) +- LDSHARED='$(CC) -bundle' +- LDCXXSHARED='$(CXX) -bundle' +- if test "$enable_framework" ; then +- # Link against the framework. All externals should be defined. +- BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' +- LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' +- LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' +- else +- # No framework, use the Python app as bundle-loader +- BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' +- LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' +- LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' +- fi ;; +- Darwin/*) +- # Use -undefined dynamic_lookup whenever possible (10.3 and later). +- # This allows an extension to be used in any Python +- +- if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2 +- then +- if test "${enable_universalsdk}"; then +- LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}" +- fi +- LDSHARED='$(CC) -bundle -undefined dynamic_lookup' +- LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup' +- BLDSHARED="$LDSHARED" +- else +- LDSHARED='$(CC) -bundle' +- LDCXXSHARED='$(CXX) -bundle' +- if test "$enable_framework" ; then +- # Link against the framework. All externals should be defined. +- BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' +- LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' +- LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' +- else +- # No framework, use the Python app as bundle-loader +- BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' +- LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' +- LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' +- fi +- fi +- ;; +- Linux*|GNU*|QNX*) +- LDSHARED='$(CC) -shared' +- LDCXXSHARED='$(CXX) -shared';; +- BSD/OS*/4*) +- LDSHARED="gcc -shared" +- LDCXXSHARED="g++ -shared";; +- FreeBSD*) +- if [[ "`$CC -dM -E - &1 | grep export-dynamic >/dev/null +- then +- LINKFORSHARED="-Xlinker --export-dynamic" +- fi;; +- esac;; +- CYGWIN*) +- if test $enable_shared = "no" +- then +- LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)' +- fi;; +- QNX*) +- # -Wl,-E causes the symbols to be added to the dynamic +- # symbol table so that they can be found when a module +- # is loaded. -N 2048K causes the stack size to be set +- # to 2048 kilobytes so that the stack doesn't overflow +- # when running test_compile.py. +- LINKFORSHARED='-Wl,-E -N 2048K';; +- esac +-fi +-AC_MSG_RESULT($LINKFORSHARED) +- +- +-AC_SUBST(CFLAGSFORSHARED) +-AC_MSG_CHECKING(CFLAGSFORSHARED) +-if test ! "$LIBRARY" = "$LDLIBRARY" +-then +- case $ac_sys_system in +- CYGWIN*) +- # Cygwin needs CCSHARED when building extension DLLs +- # but not when building the interpreter DLL. +- CFLAGSFORSHARED='';; +- *) +- CFLAGSFORSHARED='$(CCSHARED)' +- esac +-fi +-AC_MSG_RESULT($CFLAGSFORSHARED) +- +-# SHLIBS are libraries (except -lc and -lm) to link to the python shared +-# library (with --enable-shared). +-# For platforms on which shared libraries are not allowed to have unresolved +-# symbols, this must be set to $(LIBS) (expanded by make). We do this even +-# if it is not required, since it creates a dependency of the shared library +-# to LIBS. This, in turn, means that applications linking the shared libpython +-# don't need to link LIBS explicitly. The default should be only changed +-# on systems where this approach causes problems. +-AC_SUBST(SHLIBS) +-AC_MSG_CHECKING(SHLIBS) +-case "$ac_sys_system" in +- *) +- SHLIBS='$(LIBS)';; +-esac +-AC_MSG_RESULT($SHLIBS) +- +- +-# checks for libraries +-AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV +-AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX +- +-# only check for sem_init if thread support is requested +-if test "$with_threads" = "yes" -o -z "$with_threads"; then +- AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris +- # posix4 on Solaris 2.6 +- # pthread (first!) on Linux +-fi +- +-# check if we need libintl for locale functions +-AC_CHECK_LIB(intl, textdomain, +- [AC_DEFINE(WITH_LIBINTL, 1, +- [Define to 1 if libintl is needed for locale functions.]) +- LIBS="-lintl $LIBS"]) +- +-# checks for system dependent C++ extensions support +-case "$ac_sys_system" in +- AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support) +- AC_LINK_IFELSE([ +- AC_LANG_PROGRAM([[#include ]], +- [[loadAndInit("", 0, "")]]) +- ],[ +- AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1, +- [Define for AIX if your compiler is a genuine IBM xlC/xlC_r +- and you want support for AIX C++ shared extension modules.]) +- AC_MSG_RESULT(yes) +- ],[ +- AC_MSG_RESULT(no) +- ]);; +- *) ;; +-esac +- +-# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl. +-AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4 +-AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets +- +-AC_MSG_CHECKING(for --with-libs) +-AC_ARG_WITH(libs, +- AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]), +-[ +-AC_MSG_RESULT($withval) +-LIBS="$withval $LIBS" +-], +-[AC_MSG_RESULT(no)]) +- +-AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +- +-# Check for use of the system expat library +-AC_MSG_CHECKING(for --with-system-expat) +-AC_ARG_WITH(system_expat, +- AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]), +- [], +- [with_system_expat="no"]) +- +-AC_MSG_RESULT($with_system_expat) +- +-# Check for use of the system libffi library +-AC_MSG_CHECKING(for --with-system-ffi) +-AC_ARG_WITH(system_ffi, +- AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]), +- [], +- [with_system_ffi="no"]) +- +-if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then +- LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`" +-else +- LIBFFI_INCLUDEDIR="" +-fi +-AC_SUBST(LIBFFI_INCLUDEDIR) +- +-AC_MSG_RESULT($with_system_ffi) +- +-# Check for support for loadable sqlite extensions +-AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions) +-AC_ARG_ENABLE(loadable-sqlite-extensions, +- AS_HELP_STRING([--enable-loadable-sqlite-extensions], [support loadable extensions in _sqlite module]), +- [], +- [enable_loadable_sqlite_extensions="no"]) +- +-AC_MSG_RESULT($enable_loadable_sqlite_extensions) +- +-# Check for --with-dbmliborder +-AC_MSG_CHECKING(for --with-dbmliborder) +-AC_ARG_WITH(dbmliborder, +- AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [order to check db backends for dbm. Valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]), +-[ +-if test x$with_dbmliborder = xyes +-then +-AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...]) +-else +- for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do +- if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb +- then +- AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...]) +- fi +- done +-fi]) +-AC_MSG_RESULT($with_dbmliborder) +- +-# Determine if signalmodule should be used. +-AC_SUBST(USE_SIGNAL_MODULE) +-AC_SUBST(SIGNAL_OBJS) +-AC_MSG_CHECKING(for --with-signal-module) +-AC_ARG_WITH(signal-module, +- AS_HELP_STRING([--with-signal-module], [disable/enable signal module])) +- +-if test -z "$with_signal_module" +-then with_signal_module="yes" +-fi +-AC_MSG_RESULT($with_signal_module) +- +-if test "${with_signal_module}" = "yes"; then +- USE_SIGNAL_MODULE="" +- SIGNAL_OBJS="" +-else +- USE_SIGNAL_MODULE="#" +- SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o" +-fi +- +-# This is used to generate Setup.config +-AC_SUBST(USE_THREAD_MODULE) +-USE_THREAD_MODULE="" +- +-AC_MSG_CHECKING(for --with-dec-threads) +-AC_SUBST(LDLAST) +-AC_ARG_WITH(dec-threads, +- AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]), +-[ +-AC_MSG_RESULT($withval) +-LDLAST=-threads +-if test "${with_thread+set}" != set; then +- with_thread="$withval"; +-fi], +-[AC_MSG_RESULT(no)]) +- +-# Templates for things AC_DEFINEd more than once. +-# For a single AC_DEFINE, no template is needed. +-AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package]) +-AH_TEMPLATE(_REENTRANT, +- [Define to force use of thread-safe errno, h_errno, and other functions]) +-AH_TEMPLATE(WITH_THREAD, +- [Define if you want to compile in rudimentary thread support]) +- +-AC_MSG_CHECKING(for --with-threads) +-dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output +-AC_ARG_WITH(threads, +- AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support])) +- +-# --with-thread is deprecated, but check for it anyway +-dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output +-AC_ARG_WITH(thread, +- AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]), +- [with_threads=$with_thread]) +- +-if test -z "$with_threads" +-then with_threads="yes" +-fi +-AC_MSG_RESULT($with_threads) +- +-AC_SUBST(THREADOBJ) +-if test "$with_threads" = "no" +-then +- USE_THREAD_MODULE="#" +-elif test "$ac_cv_pthread_is_default" = yes +-then +- AC_DEFINE(WITH_THREAD) +- # Defining _REENTRANT on system with POSIX threads should not hurt. +- AC_DEFINE(_REENTRANT) +- posix_threads=yes +- THREADOBJ="Python/thread.o" +-elif test "$ac_cv_kpthread" = "yes" +-then +- CC="$CC -Kpthread" +- if test "$ac_cv_cxx_thread" = "yes"; then +- CXX="$CXX -Kpthread" +- fi +- AC_DEFINE(WITH_THREAD) +- posix_threads=yes +- THREADOBJ="Python/thread.o" +-elif test "$ac_cv_kthread" = "yes" +-then +- CC="$CC -Kthread" +- if test "$ac_cv_cxx_thread" = "yes"; then +- CXX="$CXX -Kthread" +- fi +- AC_DEFINE(WITH_THREAD) +- posix_threads=yes +- THREADOBJ="Python/thread.o" +-elif test "$ac_cv_pthread" = "yes" +-then +- CC="$CC -pthread" +- if test "$ac_cv_cxx_thread" = "yes"; then +- CXX="$CXX -pthread" +- fi +- AC_DEFINE(WITH_THREAD) +- posix_threads=yes +- THREADOBJ="Python/thread.o" +-else +- if test ! -z "$with_threads" -a -d "$with_threads" +- then LDFLAGS="$LDFLAGS -L$with_threads" +- fi +- if test ! -z "$withval" -a -d "$withval" +- then LDFLAGS="$LDFLAGS -L$withval" +- fi +- +- # According to the POSIX spec, a pthreads implementation must +- # define _POSIX_THREADS in unistd.h. Some apparently don't +- # (e.g. gnu pth with pthread emulation) +- AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h) +- AC_EGREP_CPP(yes, +- [ +-#include +-#ifdef _POSIX_THREADS +-yes +-#endif +- ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no) +- AC_MSG_RESULT($unistd_defines_pthreads) +- +- AC_DEFINE(_REENTRANT) +- AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD) +- AC_DEFINE(C_THREADS) +- AC_DEFINE(HURD_C_THREADS, 1, +- [Define if you are using Mach cthreads directly under /include]) +- LIBS="$LIBS -lthreads" +- THREADOBJ="Python/thread.o"],[ +- AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD) +- AC_DEFINE(C_THREADS) +- AC_DEFINE(MACH_C_THREADS, 1, +- [Define if you are using Mach cthreads under mach /]) +- THREADOBJ="Python/thread.o"],[ +- # Just looking for pthread_create in libpthread is not enough: +- # on HP/UX, pthread.h renames pthread_create to a different symbol name. +- # So we really have to include pthread.h, and then link. +- _libs=$LIBS +- LIBS="$LIBS -lpthread" +- AC_MSG_CHECKING([for pthread_create in -lpthread]) +- AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include +- +-void * start_routine (void *arg) { exit (0); }]], [[ +-pthread_create (NULL, NULL, start_routine, NULL)]])],[ +- AC_MSG_RESULT(yes) +- AC_DEFINE(WITH_THREAD) +- posix_threads=yes +- THREADOBJ="Python/thread.o"],[ +- LIBS=$_libs +- AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD) +- posix_threads=yes +- THREADOBJ="Python/thread.o"],[ +- AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD) +- posix_threads=yes +- LIBS="$LIBS -lpthreads" +- THREADOBJ="Python/thread.o"], [ +- AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD) +- posix_threads=yes +- LIBS="$LIBS -lc_r" +- THREADOBJ="Python/thread.o"], [ +- AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD) +- posix_threads=yes +- LIBS="$LIBS -lpthread" +- THREADOBJ="Python/thread.o"], [ +- AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD) +- posix_threads=yes +- LIBS="$LIBS -lcma" +- THREADOBJ="Python/thread.o"],[ +- USE_THREAD_MODULE="#"]) +- ])])])])])])]) +- +- AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) +- LIBS="$LIBS -lmpc" +- THREADOBJ="Python/thread.o" +- USE_THREAD_MODULE=""]) +- +- if test "$posix_threads" != "yes"; then +- AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD) +- LIBS="$LIBS -lthread" +- THREADOBJ="Python/thread.o" +- USE_THREAD_MODULE=""]) +- fi +- +- if test "$USE_THREAD_MODULE" != "#" +- then +- # If the above checks didn't disable threads, (at least) OSF1 +- # needs this '-threads' argument during linking. +- case $ac_sys_system in +- OSF1) LDLAST=-threads;; +- esac +- fi +-fi +- +-if test "$posix_threads" = "yes"; then +- if test "$unistd_defines_pthreads" = "no"; then +- AC_DEFINE(_POSIX_THREADS, 1, +- [Define if you have POSIX threads, +- and your system does not define that.]) +- fi +- +- # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8. +- case $ac_sys_system/$ac_sys_release in +- SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1, +- [Defined for Solaris 2.6 bug in pthread header.]) +- ;; +- SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1, +- [Define if the Posix semaphores do not work on your system]) +- ;; +- AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1, +- [Define if the Posix semaphores do not work on your system]) +- ;; +- esac +- +- AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported) +- AC_CACHE_VAL(ac_cv_pthread_system_supported, +- [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include +- void *foo(void *parm) { +- return NULL; +- } +- main() { +- pthread_attr_t attr; +- pthread_t id; +- if (pthread_attr_init(&attr)) exit(-1); +- if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1); +- if (pthread_create(&id, &attr, foo, NULL)) exit(-1); +- exit(0); +- }]])], +- [ac_cv_pthread_system_supported=yes], +- [ac_cv_pthread_system_supported=no], +- [ac_cv_pthread_system_supported=no]) +- ]) +- AC_MSG_RESULT($ac_cv_pthread_system_supported) +- if test "$ac_cv_pthread_system_supported" = "yes"; then +- AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.]) +- fi +- AC_CHECK_FUNCS(pthread_sigmask, +- [case $ac_sys_system in +- CYGWIN*) +- AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1, +- [Define if pthread_sigmask() does not work on your system.]) +- ;; +- esac]) +-fi +- +- +-# Check for enable-ipv6 +-AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified]) +-AC_MSG_CHECKING([if --enable-ipv6 is specified]) +-AC_ARG_ENABLE(ipv6, +-[ --enable-ipv6 Enable ipv6 (with ipv4) support +- --disable-ipv6 Disable ipv6 support], +-[ case "$enableval" in +- no) +- AC_MSG_RESULT(no) +- ipv6=no +- ;; +- *) AC_MSG_RESULT(yes) +- AC_DEFINE(ENABLE_IPV6) +- ipv6=yes +- ;; +- esac ], +- +-[ +-dnl the check does not work on cross compilation case... +- AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 available check */ +-#include +-#include +-main() +-{ +- if (socket(AF_INET6, SOCK_STREAM, 0) < 0) +- exit(1); +- else +- exit(0); +-} +-]])],[ +- AC_MSG_RESULT(yes) +- ipv6=yes +-],[ +- AC_MSG_RESULT(no) +- ipv6=no +-],[ +- AC_MSG_RESULT(no) +- ipv6=no +-]) +- +-if test "$ipv6" = "yes"; then +- AC_MSG_CHECKING(if RFC2553 API is available) +- AC_COMPILE_IFELSE([ +- AC_LANG_PROGRAM([[#include +-#include ]], +- [[struct sockaddr_in6 x; +- x.sin6_scope_id;]]) +- ],[ +- AC_MSG_RESULT(yes) +- ipv6=yes +- ],[ +- AC_MSG_RESULT(no, IPv6 disabled) +- ipv6=no +- ]) +-fi +- +-if test "$ipv6" = "yes"; then +- AC_DEFINE(ENABLE_IPV6) +-fi +-]) +- +-ipv6type=unknown +-ipv6lib=none +-ipv6trylibc=no +- +-if test "$ipv6" = "yes"; then +- AC_MSG_CHECKING([ipv6 stack type]) +- for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta; +- do +- case $i in +- inria) +- dnl http://www.kame.net/ +- AC_EGREP_CPP(yes, [ +-#include +-#ifdef IPV6_INRIA_VERSION +-yes +-#endif], +- [ipv6type=$i]) +- ;; +- kame) +- dnl http://www.kame.net/ +- AC_EGREP_CPP(yes, [ +-#include +-#ifdef __KAME__ +-yes +-#endif], +- [ipv6type=$i; +- ipv6lib=inet6 +- ipv6libdir=/usr/local/v6/lib +- ipv6trylibc=yes]) +- ;; +- linux-glibc) +- dnl http://www.v6.linux.or.jp/ +- AC_EGREP_CPP(yes, [ +-#include +-#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)) +-yes +-#endif], +- [ipv6type=$i; +- ipv6trylibc=yes]) +- ;; +- linux-inet6) +- dnl http://www.v6.linux.or.jp/ +- if test -d /usr/inet6; then +- ipv6type=$i +- ipv6lib=inet6 +- ipv6libdir=/usr/inet6/lib +- BASECFLAGS="-I/usr/inet6/include $BASECFLAGS" +- fi +- ;; +- solaris) +- if test -f /etc/netconfig; then +- if $GREP -q tcp6 /etc/netconfig; then +- ipv6type=$i +- ipv6trylibc=yes +- fi +- fi +- ;; +- toshiba) +- AC_EGREP_CPP(yes, [ +-#include +-#ifdef _TOSHIBA_INET6 +-yes +-#endif], +- [ipv6type=$i; +- ipv6lib=inet6; +- ipv6libdir=/usr/local/v6/lib]) +- ;; +- v6d) +- AC_EGREP_CPP(yes, [ +-#include +-#ifdef __V6D__ +-yes +-#endif], +- [ipv6type=$i; +- ipv6lib=v6; +- ipv6libdir=/usr/local/v6/lib; +- BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"]) +- ;; +- zeta) +- AC_EGREP_CPP(yes, [ +-#include +-#ifdef _ZETA_MINAMI_INET6 +-yes +-#endif], +- [ipv6type=$i; +- ipv6lib=inet6; +- ipv6libdir=/usr/local/v6/lib]) +- ;; +- esac +- if test "$ipv6type" != "unknown"; then +- break +- fi +- done +- AC_MSG_RESULT($ipv6type) +-fi +- +-if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then +- if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then +- LIBS="-L$ipv6libdir -l$ipv6lib $LIBS" +- echo "using lib$ipv6lib" +- else +- if test $ipv6trylibc = "yes"; then +- echo "using libc" +- else +- echo 'Fatal: no $ipv6lib library found. cannot continue.' +- echo "You need to fetch lib$ipv6lib.a from appropriate" +- echo 'ipv6 kit and compile beforehand.' +- exit 1 +- fi +- fi +-fi +- +-AC_MSG_CHECKING(for OSX 10.5 SDK or later) +-AC_COMPILE_IFELSE([ +- AC_LANG_PROGRAM([[#include ]], [[FSIORefNum fRef = 0]]) +-],[ +- AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.]) +- AC_MSG_RESULT(yes) +-],[ +- AC_MSG_RESULT(no) +-]) +- +-# Check for --with-doc-strings +-AC_MSG_CHECKING(for --with-doc-strings) +-AC_ARG_WITH(doc-strings, +- AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings])) +- +-if test -z "$with_doc_strings" +-then with_doc_strings="yes" +-fi +-if test "$with_doc_strings" != "no" +-then +- AC_DEFINE(WITH_DOC_STRINGS, 1, +- [Define if you want documentation strings in extension modules]) +-fi +-AC_MSG_RESULT($with_doc_strings) +- +-# Check if eval loop should use timestamp counter profiling +-AC_MSG_CHECKING(for --with-tsc) +-AC_ARG_WITH(tsc, +- AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[ +-if test "$withval" != no +-then +- AC_DEFINE(WITH_TSC, 1, +- [Define to profile with the Pentium timestamp counter]) +- AC_MSG_RESULT(yes) +-else AC_MSG_RESULT(no) +-fi], +-[AC_MSG_RESULT(no)]) +- +-# Check for Python-specific malloc support +-AC_MSG_CHECKING(for --with-pymalloc) +-AC_ARG_WITH(pymalloc, +- AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs])) +- +-if test -z "$with_pymalloc" +-then +- with_pymalloc="yes" +- ABIFLAGS="${ABIFLAGS}m" +-fi +-if test "$with_pymalloc" != "no" +-then +- AC_DEFINE(WITH_PYMALLOC, 1, +- [Define if you want to compile in Python-specific mallocs]) +-fi +-AC_MSG_RESULT($with_pymalloc) +- +-# Check for Valgrind support +-AC_MSG_CHECKING([for --with-valgrind]) +-AC_ARG_WITH([valgrind], +- AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),, +- with_valgrind=no) +-AC_MSG_RESULT([$with_valgrind]) +-if test "$with_valgrind" != no; then +- AC_CHECK_HEADER([valgrind/valgrind.h], +- [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])], +- [AC_MSG_ERROR([Valgrind support requested but headers not available])] +- ) +- OPT="-DDYNAMIC_ANNOTATIONS_ENABLED=1 $OPT" +-fi +- +-# -I${DLINCLDIR} is added to the compile rule for importdl.o +-AC_SUBST(DLINCLDIR) +-DLINCLDIR=. +- +-# the dlopen() function means we might want to use dynload_shlib.o. some +-# platforms, such as AIX, have dlopen(), but don't want to use it. +-AC_CHECK_FUNCS(dlopen) +- +-# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic +-# loading of modules. +-AC_SUBST(DYNLOADFILE) +-AC_MSG_CHECKING(DYNLOADFILE) +-if test -z "$DYNLOADFILE" +-then +- case $ac_sys_system/$ac_sys_release in +- AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c +- if test "$ac_cv_func_dlopen" = yes +- then DYNLOADFILE="dynload_shlib.o" +- else DYNLOADFILE="dynload_aix.o" +- fi +- ;; +- hp*|HP*) DYNLOADFILE="dynload_hpux.o";; +- # Use dynload_next.c only on 10.2 and below, which don't have native dlopen() +- Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";; +- *) +- # use dynload_shlib.c and dlopen() if we have it; otherwise stub +- # out any dynamic loading +- if test "$ac_cv_func_dlopen" = yes +- then DYNLOADFILE="dynload_shlib.o" +- else DYNLOADFILE="dynload_stub.o" +- fi +- ;; +- esac +-fi +-AC_MSG_RESULT($DYNLOADFILE) +-if test "$DYNLOADFILE" != "dynload_stub.o" +-then +- AC_DEFINE(HAVE_DYNAMIC_LOADING, 1, +- [Defined when any dynamic module loading is enabled.]) +-fi +- +-# MACHDEP_OBJS can be set to platform-specific object files needed by Python +- +-AC_SUBST(MACHDEP_OBJS) +-AC_MSG_CHECKING(MACHDEP_OBJS) +-if test -z "$MACHDEP_OBJS" +-then +- MACHDEP_OBJS=$extra_machdep_objs +-else +- MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs" +-fi +-AC_MSG_RESULT(MACHDEP_OBJS) +- +-# checks for library functions +-AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \ +- clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \ +- gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ +- getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \ +- initgroups kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \ +- mremap nice pathconf pause plock poll pthread_init \ +- putenv readlink realpath \ +- select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \ +- setgid \ +- setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setuid setvbuf \ +- sigaction siginterrupt sigrelse snprintf strftime strlcpy \ +- sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ +- truncate uname unsetenv utimes waitpid wait3 wait4 \ +- wcscoll wcsftime wcsxfrm _getpty) +- +-AC_CHECK_DECL(dirfd, +- AC_DEFINE(HAVE_DIRFD, 1, +- Define if you have the 'dirfd' function or macro.), , +- [#include +- #include ]) +- +-# For some functions, having a definition is not sufficient, since +-# we want to take their address. +-AC_MSG_CHECKING(for chroot) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=chroot]])], +- [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no) +-]) +-AC_MSG_CHECKING(for link) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=link]])], +- [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no) +-]) +-AC_MSG_CHECKING(for symlink) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=symlink]])], +- [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no) +-]) +-AC_MSG_CHECKING(for fchdir) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=fchdir]])], +- [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no) +-]) +-AC_MSG_CHECKING(for fsync) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=fsync]])], +- [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no) +-]) +-AC_MSG_CHECKING(for fdatasync) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=fdatasync]])], +- [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no) +-]) +-AC_MSG_CHECKING(for epoll) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=epoll_create]])], +- [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no) +-]) +-AC_MSG_CHECKING(for kqueue) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-#include +-#include +- ]], [[int x=kqueue()]])], +- [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no) +-]) +-# On some systems (eg. FreeBSD 5), we would find a definition of the +-# functions ctermid_r, setgroups in the library, but no prototype +-# (e.g. because we use _XOPEN_SOURCE). See whether we can take their +-# address to avoid compiler warnings and potential miscompilations +-# because of the missing prototypes. +- +-AC_MSG_CHECKING(for ctermid_r) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-#include +-]], [[void* p = ctermid_r]])], +- [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no) +-]) +- +-AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl], +- [AC_COMPILE_IFELSE( +- [AC_LANG_PROGRAM( +- [#include ], +- [void* p = flock] +- )], +- [ac_cv_flock_decl=yes], +- [ac_cv_flock_decl=no] +- ) +-]) +-if test "x${ac_cv_flock_decl}" = xyes; then +- AC_CHECK_FUNCS(flock,, +- AC_CHECK_LIB(bsd,flock, +- [AC_DEFINE(HAVE_FLOCK) +- AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.) +- ]) +- ) +-fi +- +-AC_MSG_CHECKING(for getpagesize) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-#include +-]], [[void* p = getpagesize]])], +- [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no) +-]) +- +-AC_MSG_CHECKING(for broken unsetenv) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-#include +-]], [[int res = unsetenv("DUMMY")]])], +- [AC_MSG_RESULT(no)], +- [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.) +- AC_MSG_RESULT(yes) +-]) +- +-dnl check for true +-AC_CHECK_PROGS(TRUE, true, /bin/true) +- +-dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv +-dnl On others, they are in the C library, so we to take no action +-AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE], +- AC_CHECK_LIB(resolv, inet_aton) +-) +- +-# On Tru64, chflags seems to be present, but calling it will +-# exit Python +-AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +-#include +-int main(int argc, char*argv[]) +-{ +- if(chflags(argv[0], 0) != 0) +- return 1; +- return 0; +-} +-]])], +-[ac_cv_have_chflags=yes], +-[ac_cv_have_chflags=no], +-[ac_cv_have_chflags=cross]) +-]) +-if test "$ac_cv_have_chflags" = cross ; then +- AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"]) +-fi +-if test "$ac_cv_have_chflags" = yes ; then +- AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.]) +-fi +- +-AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +-#include +-int main(int argc, char*argv[]) +-{ +- if(lchflags(argv[0], 0) != 0) +- return 1; +- return 0; +-} +-]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross]) +-]) +-if test "$ac_cv_have_lchflags" = cross ; then +- AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"]) +-fi +-if test "$ac_cv_have_lchflags" = yes ; then +- AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.]) +-fi +- +-dnl Check if system zlib has *Copy() functions +-dnl +-dnl On MacOSX the linker will search for dylibs on the entire linker path +-dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first +-dnl to revert to a more traditional unix behaviour and make it possible to +-dnl override the system libz with a local static library of libz. Temporarily +-dnl add that flag to our CFLAGS as well to ensure that we check the version +-dnl of libz that will be used by setup.py. +-dnl The -L/usr/local/lib is needed as wel to get the same compilation +-dnl environment as setup.py (and leaving it out can cause configure to use the +-dnl wrong version of the library) +-case $ac_sys_system/$ac_sys_release in +-Darwin/*) +- _CUR_CFLAGS="${CFLAGS}" +- _CUR_LDFLAGS="${LDFLAGS}" +- CFLAGS="${CFLAGS} -Wl,-search_paths_first" +- LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib" +- ;; +-esac +- +-AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy])) +- +-case $ac_sys_system/$ac_sys_release in +-Darwin/*) +- CFLAGS="${_CUR_CFLAGS}" +- LDFLAGS="${_CUR_LDFLAGS}" +- ;; +-esac +- +-AC_MSG_CHECKING(for hstrerror) +-AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +-#include +-]], [[void* p = hstrerror; hstrerror(0)]])], +- [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no) +-]) +- +-AC_MSG_CHECKING(for inet_aton) +-AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +-#include +-#include +-#include +-#include +-]], [[void* p = inet_aton;inet_aton(0,0)]])], +- [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no) +-]) +- +-AC_MSG_CHECKING(for inet_pton) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-#include +-#include +-#include +-#include +-]], [[void* p = inet_pton]])], +- [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no) +-]) +- +-# On some systems, setgroups is in unistd.h, on others, in grp.h +-AC_MSG_CHECKING(for setgroups) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-#include +-#ifdef HAVE_GRP_H +-#include +-#endif +-]], [[void* p = setgroups]])], +- [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no) +-]) +- +-# check for openpty and forkpty +- +-AC_CHECK_FUNCS(openpty,, +- AC_CHECK_LIB(util,openpty, +- [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"], +- AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"]) +- ) +-) +-AC_CHECK_FUNCS(forkpty,, +- AC_CHECK_LIB(util,forkpty, +- [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"], +- AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"]) +- ) +-) +- +-# Stuff for expat. +-AC_CHECK_FUNCS(memmove) +- +-# check for long file support functions +-AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs) +- +-AC_REPLACE_FUNCS(dup2 getcwd strdup) +-AC_CHECK_FUNCS(getpgrp, +- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[getpgrp(0);]])], +- [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])], +- []) +-) +-AC_CHECK_FUNCS(setpgrp, +- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[setpgrp(0,0);]])], +- [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])], +- []) +-) +-AC_CHECK_FUNCS(gettimeofday, +- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], +- [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])], +- [], +- [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1, +- [Define if gettimeofday() does not have second (timezone) argument +- This is the case on Motorola V4 (R40V4.2)]) +- ]) +-) +- +-AC_MSG_CHECKING(for major, minor, and makedev) +-AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +-#if defined(MAJOR_IN_MKDEV) +-#include +-#elif defined(MAJOR_IN_SYSMACROS) +-#include +-#else +-#include +-#endif +-]], [[ +- makedev(major(0),minor(0)); +-]])],[ +- AC_DEFINE(HAVE_DEVICE_MACROS, 1, +- [Define to 1 if you have the device macros.]) +- AC_MSG_RESULT(yes) +-],[ +- AC_MSG_RESULT(no) +-]) +- +-# On OSF/1 V5.1, getaddrinfo is available, but a define +-# for [no]getaddrinfo in netdb.h. +-AC_MSG_CHECKING(for getaddrinfo) +-AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +-#include +-#include +-#include +-#include +-]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])], +-[have_getaddrinfo=yes], +-[have_getaddrinfo=no]) +-AC_MSG_RESULT($have_getaddrinfo) +-if test $have_getaddrinfo = yes +-then +- AC_MSG_CHECKING(getaddrinfo bug) +- AC_CACHE_VAL(ac_cv_buggy_getaddrinfo, +- AC_RUN_IFELSE([AC_LANG_SOURCE([[[ +-#include +-#include +-#include +-#include +-#include +- +-int main() +-{ +- int passive, gaierr, inet4 = 0, inet6 = 0; +- struct addrinfo hints, *ai, *aitop; +- char straddr[INET6_ADDRSTRLEN], strport[16]; +- +- for (passive = 0; passive <= 1; passive++) { +- memset(&hints, 0, sizeof(hints)); +- hints.ai_family = AF_UNSPEC; +- hints.ai_flags = passive ? AI_PASSIVE : 0; +- hints.ai_socktype = SOCK_STREAM; +- hints.ai_protocol = IPPROTO_TCP; +- if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) { +- (void)gai_strerror(gaierr); +- goto bad; +- } +- for (ai = aitop; ai; ai = ai->ai_next) { +- if (ai->ai_addr == NULL || +- ai->ai_addrlen == 0 || +- getnameinfo(ai->ai_addr, ai->ai_addrlen, +- straddr, sizeof(straddr), strport, sizeof(strport), +- NI_NUMERICHOST|NI_NUMERICSERV) != 0) { +- goto bad; +- } +- switch (ai->ai_family) { +- case AF_INET: +- if (strcmp(strport, "54321") != 0) { +- goto bad; +- } +- if (passive) { +- if (strcmp(straddr, "0.0.0.0") != 0) { +- goto bad; +- } +- } else { +- if (strcmp(straddr, "127.0.0.1") != 0) { +- goto bad; +- } +- } +- inet4++; +- break; +- case AF_INET6: +- if (strcmp(strport, "54321") != 0) { +- goto bad; +- } +- if (passive) { +- if (strcmp(straddr, "::") != 0) { +- goto bad; +- } +- } else { +- if (strcmp(straddr, "::1") != 0) { +- goto bad; +- } +- } +- inet6++; +- break; +- case AF_UNSPEC: +- goto bad; +- break; +- default: +- /* another family support? */ +- break; +- } +- } +- } +- +- if (!(inet4 == 0 || inet4 == 2)) +- goto bad; +- if (!(inet6 == 0 || inet6 == 2)) +- goto bad; +- +- if (aitop) +- freeaddrinfo(aitop); +- return 0; +- +- bad: +- if (aitop) +- freeaddrinfo(aitop); +- return 1; +-} +-]]])], +-[ac_cv_buggy_getaddrinfo=no], +-[ac_cv_buggy_getaddrinfo=yes], +-[ac_cv_buggy_getaddrinfo=yes])) +-fi +- +-AC_MSG_RESULT($ac_cv_buggy_getaddrinfo) +- +-if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes +-then +- if test $ipv6 = yes +- then +- echo 'Fatal: You must get working getaddrinfo() function.' +- echo ' or you can specify "--disable-ipv6"'. +- exit 1 +- fi +-else +- AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.]) +-fi +- +-AC_CHECK_FUNCS(getnameinfo) +- +-# checks for structures +-AC_HEADER_TIME +-AC_STRUCT_TM +-AC_STRUCT_TIMEZONE +-AC_CHECK_MEMBERS([struct stat.st_rdev]) +-AC_CHECK_MEMBERS([struct stat.st_blksize]) +-AC_CHECK_MEMBERS([struct stat.st_flags]) +-AC_CHECK_MEMBERS([struct stat.st_gen]) +-AC_CHECK_MEMBERS([struct stat.st_birthtime]) +-AC_STRUCT_ST_BLOCKS +- +-AC_MSG_CHECKING(for time.h that defines altzone) +-AC_CACHE_VAL(ac_cv_header_time_altzone,[ +- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[return altzone;]])], +- [ac_cv_header_time_altzone=yes], +- [ac_cv_header_time_altzone=no]) +- ]) +-AC_MSG_RESULT($ac_cv_header_time_altzone) +-if test $ac_cv_header_time_altzone = yes; then +- AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.]) +-fi +- +-was_it_defined=no +-AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-#include +-#include +-#include +-]], [[;]])],[ +- AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1, +- [Define if you can safely include both and +- (which you can't on SCO ODT 3.0).]) +- was_it_defined=yes +-],[]) +-AC_MSG_RESULT($was_it_defined) +- +-AC_MSG_CHECKING(for addrinfo) +-AC_CACHE_VAL(ac_cv_struct_addrinfo, +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct addrinfo a]])], +- [ac_cv_struct_addrinfo=yes], +- [ac_cv_struct_addrinfo=no])) +-AC_MSG_RESULT($ac_cv_struct_addrinfo) +-if test $ac_cv_struct_addrinfo = yes; then +- AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)]) +-fi +- +-AC_MSG_CHECKING(for sockaddr_storage) +-AC_CACHE_VAL(ac_cv_struct_sockaddr_storage, +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-# include +-# include ]], [[struct sockaddr_storage s]])], +- [ac_cv_struct_sockaddr_storage=yes], +- [ac_cv_struct_sockaddr_storage=no])) +-AC_MSG_RESULT($ac_cv_struct_sockaddr_storage) +-if test $ac_cv_struct_sockaddr_storage = yes; then +- AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)]) +-fi +- +-# checks for compiler characteristics +- +-AC_C_CHAR_UNSIGNED +-AC_C_CONST +- +-works=no +-AC_MSG_CHECKING(for working volatile) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])], +- [works=yes], +- [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])] +-) +-AC_MSG_RESULT($works) +- +-works=no +-AC_MSG_CHECKING(for working signed char) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])], +- [works=yes], +- [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])] +-) +-AC_MSG_RESULT($works) +- +-have_prototypes=no +-AC_MSG_CHECKING(for prototypes) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])], +- [AC_DEFINE(HAVE_PROTOTYPES, 1, +- [Define if your compiler supports function prototype]) +- have_prototypes=yes], +- [] +-) +-AC_MSG_RESULT($have_prototypes) +- +-works=no +-AC_MSG_CHECKING(for variable length prototypes and stdarg.h) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-#include +-int foo(int x, ...) { +- va_list va; +- va_start(va, x); +- va_arg(va, int); +- va_arg(va, char *); +- va_arg(va, double); +- return 0; +-} +-]], [[return foo(10, "", 3.14);]])],[ +- AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1, +- [Define if your compiler supports variable length function prototypes +- (e.g. void fprintf(FILE *, char *, ...);) *and* ]) +- works=yes +-],[]) +-AC_MSG_RESULT($works) +- +-# check for socketpair +-AC_MSG_CHECKING(for socketpair) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-#include +-#include +-]], [[void *x=socketpair]])], +- [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.]) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no)] +-) +- +-# check if sockaddr has sa_len member +-AC_MSG_CHECKING(if sockaddr has sa_len member) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include +-#include ]], [[struct sockaddr x; +-x.sa_len = 0;]])], +- [AC_MSG_RESULT(yes) +- AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])], +- [AC_MSG_RESULT(no)] +-) +- +-va_list_is_array=no +-AC_MSG_CHECKING(whether va_list is an array) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-#ifdef HAVE_STDARG_PROTOTYPES +-#include +-#else +-#include +-#endif +-]], [[va_list list1, list2; list1 = list2;]])],[],[ +- AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind]) +- va_list_is_array=yes +-]) +-AC_MSG_RESULT($va_list_is_array) +- +-# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-( +-AH_TEMPLATE(HAVE_GETHOSTBYNAME_R, +- [Define this if you have some version of gethostbyname_r()]) +- +-AC_CHECK_FUNC(gethostbyname_r, [ +- AC_DEFINE(HAVE_GETHOSTBYNAME_R) +- AC_MSG_CHECKING([gethostbyname_r with 6 args]) +- OLD_CFLAGS=$CFLAGS +- CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS" +- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-# include +- ]], [[ +- char *name; +- struct hostent *he, *res; +- char buffer[2048]; +- int buflen = 2048; +- int h_errnop; +- +- (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop) +- ]])],[ +- AC_DEFINE(HAVE_GETHOSTBYNAME_R) +- AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1, +- [Define this if you have the 6-arg version of gethostbyname_r().]) +- AC_MSG_RESULT(yes) +- ],[ +- AC_MSG_RESULT(no) +- AC_MSG_CHECKING([gethostbyname_r with 5 args]) +- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-# include +- ]], [[ +- char *name; +- struct hostent *he; +- char buffer[2048]; +- int buflen = 2048; +- int h_errnop; +- +- (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop) +- ]])], +- [ +- AC_DEFINE(HAVE_GETHOSTBYNAME_R) +- AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1, +- [Define this if you have the 5-arg version of gethostbyname_r().]) +- AC_MSG_RESULT(yes) +- ], [ +- AC_MSG_RESULT(no) +- AC_MSG_CHECKING([gethostbyname_r with 3 args]) +- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-# include +- ]], [[ +- char *name; +- struct hostent *he; +- struct hostent_data data; +- +- (void) gethostbyname_r(name, he, &data); +- ]])], +- [ +- AC_DEFINE(HAVE_GETHOSTBYNAME_R) +- AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1, +- [Define this if you have the 3-arg version of gethostbyname_r().]) +- AC_MSG_RESULT(yes) +- ], [ +- AC_MSG_RESULT(no) +- ]) +- ]) +- ]) +- CFLAGS=$OLD_CFLAGS +-], [ +- AC_CHECK_FUNCS(gethostbyname) +-]) +-AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG) +-AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG) +-AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG) +-AC_SUBST(HAVE_GETHOSTBYNAME_R) +-AC_SUBST(HAVE_GETHOSTBYNAME) +- +-# checks for system services +-# (none yet) +- +-# Linux requires this for correct f.p. operations +-AC_CHECK_FUNC(__fpu_control, +- [], +- [AC_CHECK_LIB(ieee, __fpu_control) +-]) +- +-# Check for --with-fpectl +-AC_MSG_CHECKING(for --with-fpectl) +-AC_ARG_WITH(fpectl, +- AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]), +-[ +-if test "$withval" != no +-then +- AC_DEFINE(WANT_SIGFPE_HANDLER, 1, +- [Define if you want SIGFPE handled (see Include/pyfpe.h).]) +- AC_MSG_RESULT(yes) +-else AC_MSG_RESULT(no) +-fi], +-[AC_MSG_RESULT(no)]) +- +-# check for --with-libm=... +-AC_SUBST(LIBM) +-case $ac_sys_system in +-Darwin) ;; +-*) LIBM=-lm +-esac +-AC_MSG_CHECKING(for --with-libm=STRING) +-AC_ARG_WITH(libm, +- AS_HELP_STRING([--with-libm=STRING], [math library]), +-[ +-if test "$withval" = no +-then LIBM= +- AC_MSG_RESULT(force LIBM empty) +-elif test "$withval" != yes +-then LIBM=$withval +- AC_MSG_RESULT(set LIBM="$withval") +-else AC_MSG_ERROR([proper usage is --with-libm=STRING]) +-fi], +-[AC_MSG_RESULT(default LIBM="$LIBM")]) +- +-# check for --with-libc=... +-AC_SUBST(LIBC) +-AC_MSG_CHECKING(for --with-libc=STRING) +-AC_ARG_WITH(libc, +- AS_HELP_STRING([--with-libc=STRING], [C library]), +-[ +-if test "$withval" = no +-then LIBC= +- AC_MSG_RESULT(force LIBC empty) +-elif test "$withval" != yes +-then LIBC=$withval +- AC_MSG_RESULT(set LIBC="$withval") +-else AC_MSG_ERROR([proper usage is --with-libc=STRING]) +-fi], +-[AC_MSG_RESULT(default LIBC="$LIBC")]) +- +-# ************************************************** +-# * Check for various properties of floating point * +-# ************************************************** +- +-AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64) +-AC_CACHE_VAL(ac_cv_little_endian_double, [ +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +-int main() { +- double x = 9006104071832581.0; +- if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0) +- return 0; +- else +- return 1; +-} +-]])], +-[ac_cv_little_endian_double=yes], +-[ac_cv_little_endian_double=no], +-[ac_cv_little_endian_double=no])]) +-AC_MSG_RESULT($ac_cv_little_endian_double) +-if test "$ac_cv_little_endian_double" = yes +-then +- AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1, +- [Define if C doubles are 64-bit IEEE 754 binary format, stored +- with the least significant byte first]) +-fi +- +-AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64) +-AC_CACHE_VAL(ac_cv_big_endian_double, [ +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +-int main() { +- double x = 9006104071832581.0; +- if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0) +- return 0; +- else +- return 1; +-} +-]])], +-[ac_cv_big_endian_double=yes], +-[ac_cv_big_endian_double=no], +-[ac_cv_big_endian_double=no])]) +-AC_MSG_RESULT($ac_cv_big_endian_double) +-if test "$ac_cv_big_endian_double" = yes +-then +- AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1, +- [Define if C doubles are 64-bit IEEE 754 binary format, stored +- with the most significant byte first]) +-fi +- +-# Some ARM platforms use a mixed-endian representation for doubles. +-# While Python doesn't currently have full support for these platforms +-# (see e.g., issue 1762561), we can at least make sure that float <-> string +-# conversions work. +-AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64) +-AC_CACHE_VAL(ac_cv_mixed_endian_double, [ +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +-int main() { +- double x = 9006104071832581.0; +- if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0) +- return 0; +- else +- return 1; +-} +-]])], +-[ac_cv_mixed_endian_double=yes], +-[ac_cv_mixed_endian_double=no], +-[ac_cv_mixed_endian_double=no])]) +-AC_MSG_RESULT($ac_cv_mixed_endian_double) +-if test "$ac_cv_mixed_endian_double" = yes +-then +- AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1, +- [Define if C doubles are 64-bit IEEE 754 binary format, stored +- in ARM mixed-endian order (byte order 45670123)]) +-fi +- +-# The short float repr introduced in Python 3.1 requires the +-# correctly-rounded string <-> double conversion functions from +-# Python/dtoa.c, which in turn require that the FPU uses 53-bit +-# rounding; this is a problem on x86, where the x87 FPU has a default +-# rounding precision of 64 bits. For gcc/x86, we can fix this by +-# using inline assembler to get and set the x87 FPU control word. +- +-# This inline assembler syntax may also work for suncc and icc, +-# so we try it on all platforms. +- +-AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ +- unsigned short cw; +- __asm__ __volatile__ ("fnstcw %0" : "=m" (cw)); +- __asm__ __volatile__ ("fldcw %0" : : "m" (cw)); +-]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no]) +-AC_MSG_RESULT($have_gcc_asm_for_x87) +-if test "$have_gcc_asm_for_x87" = yes +-then +- AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1, +- [Define if we can use gcc inline assembler to get and set x87 control word]) +-fi +- +-# Detect whether system arithmetic is subject to x87-style double +-# rounding issues. The result of this test has little meaning on non +-# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding +-# mode is round-to-nearest and double rounding issues are present, and +-# 0 otherwise. See http://bugs.python.org/issue2937 for more info. +-AC_MSG_CHECKING(for x87-style double rounding) +-# $BASECFLAGS may affect the result +-ac_save_cc="$CC" +-CC="$CC $BASECFLAGS" +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +-#include +-int main() { +- volatile double x, y, z; +- /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */ +- x = 0.99999999999999989; /* 1-2**-53 */ +- y = 1./x; +- if (y != 1.) +- exit(0); +- /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */ +- x = 1e16; +- y = 2.99999; +- z = x + y; +- if (z != 1e16+4.) +- exit(0); +- /* both tests show evidence of double rounding */ +- exit(1); +-} +-]])], +-[ac_cv_x87_double_rounding=no], +-[ac_cv_x87_double_rounding=yes], +-[ac_cv_x87_double_rounding=no]) +-CC="$ac_save_cc" +-AC_MSG_RESULT($ac_cv_x87_double_rounding) +-if test "$ac_cv_x87_double_rounding" = yes +-then +- AC_DEFINE(X87_DOUBLE_ROUNDING, 1, +- [Define if arithmetic is subject to x87-style double rounding issue]) +-fi +- +-# ************************************ +-# * Check for mathematical functions * +-# ************************************ +- +-LIBS_SAVE=$LIBS +-LIBS="$LIBS $LIBM" +- +-AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma]) +-AC_CHECK_FUNCS([hypot lgamma log1p round tgamma]) +-AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include ]]) +- +-# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of +-# -0. on some architectures. +-AC_MSG_CHECKING(whether tanh preserves the sign of zero) +-AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [ +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +-#include +-int main() { +- /* return 0 if either negative zeros don't exist +- on this platform or if negative zeros exist +- and tanh(-0.) == -0. */ +- if (atan2(0., -1.) == atan2(-0., -1.) || +- atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0); +- else exit(1); +-} +-]])], +-[ac_cv_tanh_preserves_zero_sign=yes], +-[ac_cv_tanh_preserves_zero_sign=no], +-[ac_cv_tanh_preserves_zero_sign=no])]) +-AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign) +-if test "$ac_cv_tanh_preserves_zero_sign" = yes +-then +- AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1, +- [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros]) +-fi +- +-if test "$ac_cv_func_log1p" = yes +-then +- # On some versions of AIX, log1p(-0.) returns 0. instead of +- # -0. See issue #9920. +- AC_MSG_CHECKING(whether log1p drops the sign of negative zero) +- AC_CACHE_VAL(ac_cv_log1p_drops_zero_sign, [ +- AC_RUN_IFELSE([AC_LANG_SOURCE([[ +- #include +- #include +- int main() { +- /* Fail if the signs of log1p(-0.) and -0. can be +- distinguished. */ +- if (atan2(log1p(-0.), -1.) == atan2(-0., -1.)) +- return 0; +- else +- return 1; +- } +- ]])], +- [ac_cv_log1p_drops_zero_sign=no], +- [ac_cv_log1p_drops_zero_sign=yes], +- [ac_cv_log1p_drops_zero_sign=no])]) +- AC_MSG_RESULT($ac_cv_log1p_drops_zero_sign) +-fi +-if test "$ac_cv_log1p_drops_zero_sign" = yes +-then +- AC_DEFINE(LOG1P_DROPS_ZERO_SIGN, 1, +- [Define if log1p(-0.) is 0. rather than -0.]) +-fi +- +-LIBS=$LIBS_SAVE +- +-# For multiprocessing module, check that sem_open +-# actually works. For FreeBSD versions <= 7.2, +-# the kernel module that provides POSIX semaphores +-# isn't loaded by default, so an attempt to call +-# sem_open results in a 'Signal 12' error. +-AC_MSG_CHECKING(whether POSIX semaphores are enabled) +-AC_CACHE_VAL(ac_cv_posix_semaphores_enabled, +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +-#include +-#include +-#include +-#include +- +-int main(void) { +- sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0); +- if (a == SEM_FAILED) { +- perror("sem_open"); +- return 1; +- } +- sem_close(a); +- sem_unlink("/autoconf"); +- return 0; +-} +-]])], +-[ac_cv_posix_semaphores_enabled=yes], +-[ac_cv_posix_semaphores_enabled=no], +-[ac_cv_posix_semaphores_enabled=yes]) +-) +-AC_MSG_RESULT($ac_cv_posix_semaphores_enabled) +-if test $ac_cv_posix_semaphores_enabled = no +-then +- AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1, +- [Define if POSIX semaphores aren't enabled on your system]) +-fi +- +-# Multiprocessing check for broken sem_getvalue +-AC_MSG_CHECKING(for broken sem_getvalue) +-AC_CACHE_VAL(ac_cv_broken_sem_getvalue, +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +-#include +-#include +-#include +-#include +- +-int main(void){ +- sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0); +- int count; +- int res; +- if(a==SEM_FAILED){ +- perror("sem_open"); +- return 1; +- +- } +- res = sem_getvalue(a, &count); +- sem_close(a); +- sem_unlink("/autocftw"); +- return res==-1 ? 1 : 0; +-} +-]])], +-[ac_cv_broken_sem_getvalue=no], +-[ac_cv_broken_sem_getvalue=yes], +-[ac_cv_broken_sem_getvalue=yes]) +-) +-AC_MSG_RESULT($ac_cv_broken_sem_getvalue) +-if test $ac_cv_broken_sem_getvalue = yes +-then +- AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1, +- [define to 1 if your sem_getvalue is broken.]) +-fi +- +-# determine what size digit to use for Python's longs +-AC_MSG_CHECKING([digit size for Python's longs]) +-AC_ARG_ENABLE(big-digits, +-AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]), +-[case $enable_big_digits in +-yes) +- enable_big_digits=30 ;; +-no) +- enable_big_digits=15 ;; +-[15|30]) +- ;; +-*) +- AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;; +-esac +-AC_MSG_RESULT($enable_big_digits) +-AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits]) +-], +-[AC_MSG_RESULT(no value specified)]) +- +-# check for wchar.h +-AC_CHECK_HEADER(wchar.h, [ +- AC_DEFINE(HAVE_WCHAR_H, 1, +- [Define if the compiler provides a wchar.h header file.]) +- wchar_h="yes" +-], +-wchar_h="no" +-) +- +-# determine wchar_t size +-if test "$wchar_h" = yes +-then +- AC_CHECK_SIZEOF(wchar_t, 4, [#include ]) +-fi +- +-AC_MSG_CHECKING(for UCS-4 tcl) +-have_ucs4_tcl=no +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +-#include +-#if TCL_UTF_MAX != 6 +-# error "NOT UCS4_TCL" +-#endif]], [[]])],[ +- AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6]) +- have_ucs4_tcl=yes +-],[]) +-AC_MSG_RESULT($have_ucs4_tcl) +- +-# check whether wchar_t is signed or not +-if test "$wchar_h" = yes +-then +- # check whether wchar_t is signed or not +- AC_MSG_CHECKING(whether wchar_t is signed) +- AC_CACHE_VAL(ac_cv_wchar_t_signed, [ +- AC_RUN_IFELSE([AC_LANG_SOURCE([[ +- #include +- int main() +- { +- /* Success: exit code 0 */ +- exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1); +- } +- ]])], +- [ac_cv_wchar_t_signed=yes], +- [ac_cv_wchar_t_signed=no], +- [ac_cv_wchar_t_signed=yes])]) +- AC_MSG_RESULT($ac_cv_wchar_t_signed) +-fi +- +-AC_MSG_CHECKING(what type to use for str) +-AC_ARG_WITH(wide-unicode, +- AS_HELP_STRING([--with-wide-unicode], [Use 4-byte Unicode characters (default is 2 bytes)]), +-[ +-if test "$withval" != no +-then unicode_size="4" +-else unicode_size="2" +-fi +-], +-[ +-case "$have_ucs4_tcl" in +- yes) unicode_size="4";; +- *) unicode_size="2" ;; +-esac +-]) +- +-AH_TEMPLATE(Py_UNICODE_SIZE, +- [Define as the size of the unicode type.]) +-case "$unicode_size" in +- 4) +- AC_DEFINE(Py_UNICODE_SIZE, 4) +- ABIFLAGS="${ABIFLAGS}u" +- ;; +- *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;; +-esac +- +-AH_TEMPLATE(PY_UNICODE_TYPE, +- [Define as the integral type used for Unicode representation.]) +- +-# wchar_t is only usable if it maps to an unsigned type +-if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \ +- -a "$ac_cv_wchar_t_signed" = "no" +-then +- PY_UNICODE_TYPE="wchar_t" +- AC_DEFINE(HAVE_USABLE_WCHAR_T, 1, +- [Define if you have a useable wchar_t type defined in wchar.h; useable +- means wchar_t must be an unsigned type with at least 16 bits. (see +- Include/unicodeobject.h).]) +- AC_DEFINE(PY_UNICODE_TYPE,wchar_t) +-elif test "$ac_cv_sizeof_short" = "$unicode_size" +-then +- PY_UNICODE_TYPE="unsigned short" +- AC_DEFINE(PY_UNICODE_TYPE,unsigned short) +-elif test "$ac_cv_sizeof_long" = "$unicode_size" +-then +- PY_UNICODE_TYPE="unsigned long" +- AC_DEFINE(PY_UNICODE_TYPE,unsigned long) +-else +- PY_UNICODE_TYPE="no type found" +-fi +-AC_MSG_RESULT($PY_UNICODE_TYPE) +- +-# check for endianness +-AC_C_BIGENDIAN +- +-# ABI version string for Python extension modules. This appears between the +-# periods in shared library file names, e.g. foo..so. It is calculated +-# from the following attributes which affect the ABI of this Python build (in +-# this order): +-# +-# * The Python implementation (always 'cpython-' for us) +-# * The major and minor version numbers +-# * --with-pydebug (adds a 'd') +-# * --with-pymalloc (adds a 'm') +-# * --with-wide-unicode (adds a 'u') +-# +-# Thus for example, Python 3.2 built with wide unicode, pydebug, and pymalloc, +-# would get a shared library ABI version tag of 'cpython-32dmu' and shared +-# libraries would be named 'foo.cpython-32dmu.so'. +-AC_SUBST(SOABI) +-AC_MSG_CHECKING(ABIFLAGS) +-AC_MSG_RESULT($ABIFLAGS) +-AC_MSG_CHECKING(SOABI) +-SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS} +-AC_MSG_RESULT($SOABI) +- +-AC_MSG_CHECKING(LDVERSION) +-LDVERSION='$(VERSION)$(ABIFLAGS)' +-AC_MSG_RESULT($LDVERSION) +- +-# SO is the extension of shared libraries `(including the dot!) +-# -- usually .so, .sl on HP-UX, .dll on Cygwin +-AC_MSG_CHECKING(SO) +-if test -z "$SO" +-then +- case $ac_sys_system in +- hp*|HP*) +- case `uname -m` in +- ia64) SO=.so;; +- *) SO=.sl;; +- esac +- ;; +- CYGWIN*) SO=.dll;; +- Linux*|GNU*) +- SO=.${SOABI}.so;; +- *) SO=.so;; +- esac +-else +- # this might also be a termcap variable, see #610332 +- echo +- echo '=====================================================================' +- echo '+ +' +- echo '+ WARNING: You have set SO in your environment. +' +- echo '+ Do you really mean to change the extension for shared libraries? +' +- echo '+ Continuing in 10 seconds to let you to ponder. +' +- echo '+ +' +- echo '=====================================================================' +- sleep 10 +-fi +-AC_MSG_RESULT($SO) +- +-# 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) +-AC_CACHE_VAL(ac_cv_rshift_extends_sign, [ +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-int main() +-{ +- exit(((-1)>>3 == -1) ? 0 : 1); +-} +-]])], +-[ac_cv_rshift_extends_sign=yes], +-[ac_cv_rshift_extends_sign=no], +-[ac_cv_rshift_extends_sign=yes])]) +-AC_MSG_RESULT($ac_cv_rshift_extends_sign) +-if test "$ac_cv_rshift_extends_sign" = no +-then +- AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1, +- [Define if i>>j for signed int i does not extend the sign bit +- when i < 0]) +-fi +- +-# check for getc_unlocked and related locking functions +-AC_MSG_CHECKING(for getc_unlocked() and friends) +-AC_CACHE_VAL(ac_cv_have_getc_unlocked, [ +-AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +- FILE *f = fopen("/dev/null", "r"); +- flockfile(f); +- getc_unlocked(f); +- funlockfile(f); +-]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])]) +-AC_MSG_RESULT($ac_cv_have_getc_unlocked) +-if test "$ac_cv_have_getc_unlocked" = yes +-then +- AC_DEFINE(HAVE_GETC_UNLOCKED, 1, +- [Define this if you have flockfile(), getc_unlocked(), and funlockfile()]) +-fi +- +-# check where readline lives +-# save the value of LIBS so we don't actually link Python with readline +-LIBS_no_readline=$LIBS +- +-# On some systems we need to link readline to a termcap compatible +-# library. NOTE: Keep the precedence of listed libraries synchronised +-# with setup.py. +-py_cv_lib_readline=no +-AC_MSG_CHECKING([how to link readline libs]) +-for py_libtermcap in "" ncursesw ncurses curses termcap; do +- if test -z "$py_libtermcap"; then +- READLINE_LIBS="-lreadline" +- else +- READLINE_LIBS="-lreadline -l$py_libtermcap" +- fi +- LIBS="$READLINE_LIBS $LIBS_no_readline" +- AC_LINK_IFELSE( +- [AC_LANG_CALL([],[readline])], +- [py_cv_lib_readline=yes]) +- if test $py_cv_lib_readline = yes; then +- break +- fi +-done +-# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts +-#AC_SUBST([READLINE_LIBS]) +-if test $py_cv_lib_readline = no; then +- AC_MSG_RESULT([none]) +-else +- AC_MSG_RESULT([$READLINE_LIBS]) +- AC_DEFINE(HAVE_LIBREADLINE, 1, +- [Define if you have the readline library (-lreadline).]) +-fi +- +-# check for readline 2.1 +-AC_CHECK_LIB(readline, rl_callback_handler_install, +- AC_DEFINE(HAVE_RL_CALLBACK, 1, +- [Define if you have readline 2.1]), ,$READLINE_LIBS) +- +-# check for readline 2.2 +-AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include ]])], +- [have_readline=yes], +- [have_readline=no] +-) +-if test $have_readline = yes +-then +- AC_EGREP_HEADER([extern int rl_completion_append_character;], +- [readline/readline.h], +- AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1, +- [Define if you have readline 2.2]), ) +- AC_EGREP_HEADER([extern int rl_completion_suppress_append;], +- [readline/readline.h], +- AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1, +- [Define if you have rl_completion_suppress_append]), ) +-fi +- +-# check for readline 4.0 +-AC_CHECK_LIB(readline, rl_pre_input_hook, +- AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1, +- [Define if you have readline 4.0]), ,$READLINE_LIBS) +- +-# also in 4.0 +-AC_CHECK_LIB(readline, rl_completion_display_matches_hook, +- AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1, +- [Define if you have readline 4.0]), ,$READLINE_LIBS) +- +-# check for readline 4.2 +-AC_CHECK_LIB(readline, rl_completion_matches, +- AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1, +- [Define if you have readline 4.2]), ,$READLINE_LIBS) +- +-# also in readline 4.2 +-AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include ]])], +- [have_readline=yes], +- [have_readline=no] +-) +-if test $have_readline = yes +-then +- AC_EGREP_HEADER([extern int rl_catch_signals;], +- [readline/readline.h], +- AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1, +- [Define if you can turn off readline's signal handling.]), ) +-fi +- +-# End of readline checks: restore LIBS +-LIBS=$LIBS_no_readline +- +-AC_MSG_CHECKING(for broken nice()) +-AC_CACHE_VAL(ac_cv_broken_nice, [ +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-int main() +-{ +- int val1 = nice(1); +- if (val1 != -1 && val1 == nice(2)) +- exit(0); +- exit(1); +-} +-]])], +-[ac_cv_broken_nice=yes], +-[ac_cv_broken_nice=no], +-[ac_cv_broken_nice=no])]) +-AC_MSG_RESULT($ac_cv_broken_nice) +-if test "$ac_cv_broken_nice" = yes +-then +- AC_DEFINE(HAVE_BROKEN_NICE, 1, +- [Define if nice() returns success/failure instead of the new priority.]) +-fi +- +-AC_MSG_CHECKING(for broken poll()) +-AC_CACHE_VAL(ac_cv_broken_poll, +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +- +-int main() +-{ +- struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 }; +- int poll_test; +- +- close (42); +- +- poll_test = poll(&poll_struct, 1, 0); +- if (poll_test < 0) +- return 0; +- else if (poll_test == 0 && poll_struct.revents != POLLNVAL) +- return 0; +- else +- return 1; +-} +-]])], +-[ac_cv_broken_poll=yes], +-[ac_cv_broken_poll=no], +-[ac_cv_broken_poll=no])) +-AC_MSG_RESULT($ac_cv_broken_poll) +-if test "$ac_cv_broken_poll" = yes +-then +- AC_DEFINE(HAVE_BROKEN_POLL, 1, +- [Define if poll() sets errno on invalid file descriptors.]) +-fi +- +-# Before we can test tzset, we need to check if struct tm has a tm_zone +-# (which is not required by ISO C or UNIX spec) and/or if we support +-# tzname[] +-AC_STRUCT_TIMEZONE +- +-# check tzset(3) exists and works like we expect it to +-AC_MSG_CHECKING(for working tzset()) +-AC_CACHE_VAL(ac_cv_working_tzset, [ +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +-#include +-#include +- +-#if HAVE_TZNAME +-extern char *tzname[]; +-#endif +- +-int main() +-{ +- /* Note that we need to ensure that not only does tzset(3) +- do 'something' with localtime, but it works as documented +- in the library reference and as expected by the test suite. +- This includes making sure that tzname is set properly if +- tm->tm_zone does not exist since it is the alternative way +- of getting timezone info. +- +- Red Hat 6.2 doesn't understand the southern hemisphere +- after New Year's Day. +- */ +- +- time_t groundhogday = 1044144000; /* GMT-based */ +- time_t midyear = groundhogday + (365 * 24 * 3600 / 2); +- +- putenv("TZ=UTC+0"); +- tzset(); +- if (localtime(&groundhogday)->tm_hour != 0) +- exit(1); +-#if HAVE_TZNAME +- /* For UTC, tzname[1] is sometimes "", sometimes " " */ +- if (strcmp(tzname[0], "UTC") || +- (tzname[1][0] != 0 && tzname[1][0] != ' ')) +- exit(1); +-#endif +- +- putenv("TZ=EST+5EDT,M4.1.0,M10.5.0"); +- tzset(); +- if (localtime(&groundhogday)->tm_hour != 19) +- exit(1); +-#if HAVE_TZNAME +- if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT")) +- exit(1); +-#endif +- +- putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0"); +- tzset(); +- if (localtime(&groundhogday)->tm_hour != 11) +- exit(1); +-#if HAVE_TZNAME +- if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT")) +- exit(1); +-#endif +- +-#if HAVE_STRUCT_TM_TM_ZONE +- if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT")) +- exit(1); +- if (strcmp(localtime(&midyear)->tm_zone, "AEST")) +- exit(1); +-#endif +- +- exit(0); +-} +-]])], +-[ac_cv_working_tzset=yes], +-[ac_cv_working_tzset=no], +-[ac_cv_working_tzset=no])]) +-AC_MSG_RESULT($ac_cv_working_tzset) +-if test "$ac_cv_working_tzset" = yes +-then +- AC_DEFINE(HAVE_WORKING_TZSET, 1, +- [Define if tzset() actually switches the local timezone in a meaningful way.]) +-fi +- +-# Look for subsecond timestamps in struct stat +-AC_MSG_CHECKING(for tv_nsec in struct stat) +-AC_CACHE_VAL(ac_cv_stat_tv_nsec, +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +-struct stat st; +-st.st_mtim.tv_nsec = 1; +-]])], +-[ac_cv_stat_tv_nsec=yes], +-[ac_cv_stat_tv_nsec=no])) +-AC_MSG_RESULT($ac_cv_stat_tv_nsec) +-if test "$ac_cv_stat_tv_nsec" = yes +-then +- AC_DEFINE(HAVE_STAT_TV_NSEC, 1, +- [Define if you have struct stat.st_mtim.tv_nsec]) +-fi +- +-# Look for BSD style subsecond timestamps in struct stat +-AC_MSG_CHECKING(for tv_nsec2 in struct stat) +-AC_CACHE_VAL(ac_cv_stat_tv_nsec2, +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +-struct stat st; +-st.st_mtimespec.tv_nsec = 1; +-]])], +-[ac_cv_stat_tv_nsec2=yes], +-[ac_cv_stat_tv_nsec2=no])) +-AC_MSG_RESULT($ac_cv_stat_tv_nsec2) +-if test "$ac_cv_stat_tv_nsec2" = yes +-then +- AC_DEFINE(HAVE_STAT_TV_NSEC2, 1, +- [Define if you have struct stat.st_mtimensec]) +-fi +- +-# On HP/UX 11.0, mvwdelch is a block with a return statement +-AC_MSG_CHECKING(whether mvwdelch is an expression) +-AC_CACHE_VAL(ac_cv_mvwdelch_is_expression, +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +- int rtn; +- rtn = mvwdelch(0,0,0); +-]])], +-[ac_cv_mvwdelch_is_expression=yes], +-[ac_cv_mvwdelch_is_expression=no])) +-AC_MSG_RESULT($ac_cv_mvwdelch_is_expression) +- +-if test "$ac_cv_mvwdelch_is_expression" = yes +-then +- AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1, +- [Define if mvwdelch in curses.h is an expression.]) +-fi +- +-AC_MSG_CHECKING(whether WINDOW has _flags) +-AC_CACHE_VAL(ac_cv_window_has_flags, +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +- WINDOW *w; +- w->_flags = 0; +-]])], +-[ac_cv_window_has_flags=yes], +-[ac_cv_window_has_flags=no])) +-AC_MSG_RESULT($ac_cv_window_has_flags) +- +- +-if test "$ac_cv_window_has_flags" = yes +-then +- AC_DEFINE(WINDOW_HAS_FLAGS, 1, +- [Define if WINDOW in curses.h offers a field _flags.]) +-fi +- +-AC_MSG_CHECKING(for is_term_resized) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=is_term_resized]])], +- [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no)] +-) +- +-AC_MSG_CHECKING(for resize_term) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=resize_term]])], +- [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no)] +-) +- +-AC_MSG_CHECKING(for resizeterm) +-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=resizeterm]])], +- [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.) +- AC_MSG_RESULT(yes)], +- [AC_MSG_RESULT(no)] +-) +- +-AC_MSG_CHECKING(for /dev/ptmx) +- +-if test -r /dev/ptmx +-then +- AC_MSG_RESULT(yes) +- AC_DEFINE(HAVE_DEV_PTMX, 1, +- [Define if we have /dev/ptmx.]) +-else +- AC_MSG_RESULT(no) +-fi +- +-AC_MSG_CHECKING(for /dev/ptc) +- +-if test -r /dev/ptc +-then +- AC_MSG_RESULT(yes) +- AC_DEFINE(HAVE_DEV_PTC, 1, +- [Define if we have /dev/ptc.]) +-else +- AC_MSG_RESULT(no) +-fi +- +-if test "$have_long_long" = yes +-then +- AC_MSG_CHECKING(for %lld and %llu printf() format support) +- AC_CACHE_VAL(ac_cv_have_long_long_format, +- AC_RUN_IFELSE([AC_LANG_SOURCE([[[ +- #include +- #include +- #include +- +- #ifdef HAVE_SYS_TYPES_H +- #include +- #endif +- +- int main() +- { +- char buffer[256]; +- +- if (sprintf(buffer, "%lld", (long long)123) < 0) +- return 1; +- if (strcmp(buffer, "123")) +- return 1; +- +- if (sprintf(buffer, "%lld", (long long)-123) < 0) +- return 1; +- if (strcmp(buffer, "-123")) +- return 1; +- +- if (sprintf(buffer, "%llu", (unsigned long long)123) < 0) +- return 1; +- if (strcmp(buffer, "123")) +- return 1; +- +- return 0; +- } +- ]]])], +- [ac_cv_have_long_long_format=yes], +- [ac_cv_have_long_long_format=no], +- [ac_cv_have_long_long_format=no]) +- ) +- AC_MSG_RESULT($ac_cv_have_long_long_format) +-fi +- +-if test "$ac_cv_have_long_long_format" = yes +-then +- AC_DEFINE(PY_FORMAT_LONG_LONG, "ll", +- [Define to printf format modifier for long long type]) +-fi +- +-if test $ac_sys_system = Darwin +-then +- LIBS="$LIBS -framework CoreFoundation" +-fi +- +-AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +-#include +-#include +- +-#ifdef HAVE_SYS_TYPES_H +-#include +-#endif +- +-#ifdef HAVE_SSIZE_T +-typedef ssize_t Py_ssize_t; +-#elif SIZEOF_VOID_P == SIZEOF_LONG +-typedef long Py_ssize_t; +-#else +-typedef int Py_ssize_t; +-#endif +- +-int main() +-{ +- char buffer[256]; +- +- if(sprintf(buffer, "%zd", (size_t)123) < 0) +- return 1; +- +- if (strcmp(buffer, "123")) +- return 1; +- +- if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) +- return 1; +- +- if (strcmp(buffer, "-123")) +- return 1; +- +- return 0; +-} +-]])], +- [ac_cv_have_size_t_format=yes], +- [ac_cv_have_size_t_format=no], +- [ac_cv_have_size_t_format="cross -- assuming yes" +-])]) +-if test "$ac_cv_have_size_t_format" != no ; then +- AC_DEFINE(PY_FORMAT_SIZE_T, "z", +- [Define to printf format modifier for Py_ssize_t]) +-fi +- +-AC_CHECK_TYPE(socklen_t,, +- AC_DEFINE(socklen_t,int, +- [Define to `int' if does not define.]),[ +-#ifdef HAVE_SYS_TYPES_H +-#include +-#endif +-#ifdef HAVE_SYS_SOCKET_H +-#include +-#endif +-]) +- +-AC_MSG_CHECKING(for broken mbstowcs) +-AC_CACHE_VAL(ac_cv_broken_mbstowcs, +-AC_RUN_IFELSE([AC_LANG_SOURCE([[ +-#include +-int main() { +- size_t len = -1; +- const char *str = "text"; +- len = mbstowcs(NULL, str, 0); +- return (len != 4); +-} +-]])], +-[ac_cv_broken_mbstowcs=no], +-[ac_cv_broken_mbstowcs=yes], +-[ac_cv_broken_mbstowcs=no])) +-AC_MSG_RESULT($ac_cv_broken_mbstowcs) +-if test "$ac_cv_broken_mbstowcs" = yes +-then +- AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1, +- [Define if mbstowcs(NULL, "text", 0) does not return the number of +- wide chars that would be converted.]) +-fi +- +-AC_MSG_CHECKING(whether $CC supports computed gotos) +-AC_CACHE_VAL(ac_cv_computed_gotos, +-AC_RUN_IFELSE([AC_LANG_SOURCE([[[ +-int main(int argc, char **argv) +-{ +- static void *targets[1] = { &&LABEL1 }; +- goto LABEL2; +-LABEL1: +- return 0; +-LABEL2: +- goto *targets[0]; +- return 1; +-} +-]]])], +-[ac_cv_computed_gotos=yes], +-[ac_cv_computed_gotos=no], +-[ac_cv_computed_gotos=no])) +-AC_MSG_RESULT($ac_cv_computed_gotos) +-if test "$ac_cv_computed_gotos" = yes +-then +- AC_DEFINE(HAVE_COMPUTED_GOTOS, 1, +- [Define if the C compiler supports computed gotos.]) +-fi +- +-# Check for --with-computed-gotos +-AC_MSG_CHECKING(for --with-computed-gotos) +-AC_ARG_WITH(computed-gotos, +- AS_HELP_STRING([--with(out)-computed-gotos], +- [Use computed gotos in evaluation loop (enabled by default on supported compilers)]), +-[ +-if test "$withval" = yes +-then +- AC_DEFINE(USE_COMPUTED_GOTOS, 1, +- [Define if you want to use computed gotos in ceval.c.]) +- AC_MSG_RESULT(yes) +-fi +-if test "$withval" = no +-then +- AC_DEFINE(USE_COMPUTED_GOTOS, 0, +- [Define if you want to use computed gotos in ceval.c.]) +- AC_MSG_RESULT(no) +-fi +-], +-[AC_MSG_RESULT(no value specified)]) +- +-case $ac_sys_system in +-AIX*) +- AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;; +-esac +- +- +-case $ac_sys_system in +- OSF*) AC_MSG_ERROR(OSF* systems are deprecated unless somebody volunteers. Check http://bugs.python.org/issue8606) ;; +-esac +- +-AC_CHECK_FUNC(pipe2, AC_DEFINE(HAVE_PIPE2, 1, [Define if the OS supports pipe2()]), ) +- +-AC_SUBST(THREADHEADERS) +- +-for h in `(cd $srcdir;echo Python/thread_*.h)` +-do +- THREADHEADERS="$THREADHEADERS \$(srcdir)/$h" +-done +- +-AC_SUBST(SRCDIRS) +-SRCDIRS="Parser Grammar Objects Python Modules Mac" +-AC_MSG_CHECKING(for build directories) +-for dir in $SRCDIRS; do +- if test ! -d $dir; then +- mkdir $dir +- fi +-done +-AC_MSG_RESULT(done) +- +-# generate output files +-AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc) +-AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) +-AC_OUTPUT +- +-echo "creating Modules/Setup" +-if test ! -f Modules/Setup +-then +- cp $srcdir/Modules/Setup.dist Modules/Setup +-fi +- +-echo "creating Modules/Setup.local" +-if test ! -f Modules/Setup.local +-then +- echo "# Edit this file for local setup changes" >Modules/Setup.local +-fi +- +-echo "creating Makefile" +-$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \ +- -s Modules Modules/Setup.config \ +- Modules/Setup.local Modules/Setup +-mv config.c Modules +diff -r 3d0686d90f55 pyconfig.h.in +--- a/pyconfig.h.in ++++ b/pyconfig.h.in +@@ -1,4 +1,4 @@ +-/* pyconfig.h.in. Generated from configure.in by autoheader. */ ++/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + + #ifndef Py_PYCONFIG_H +diff -r 3d0686d90f55 setup.py +--- a/setup.py ++++ b/setup.py +@@ -197,7 +197,7 @@ + + # Python header files + headers = [sysconfig.get_config_h_filename()] +- headers += glob(os.path.join(sysconfig.get_path('platinclude'), "*.h")) ++ headers += glob(os.path.join(sysconfig.get_path('include'), "*.h")) + + for ext in self.extensions[:]: + ext.sources = [ find_module_file(filename, moddirlist) +@@ -467,6 +467,10 @@ + if platform in ['osf1', 'unixware7', 'openunix8']: + lib_dirs += ['/usr/ccs/lib'] + ++ # HP-UX11iv3 keeps files in lib/hpux folders. ++ if platform == 'hp-ux11': ++ lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32'] ++ + if platform == 'darwin': + # This should work on any unixy platform ;-) + # If the user has bothered specifying additional -I and -L flags +@@ -1073,10 +1077,14 @@ + for cand in dbm_order: + if cand == "ndbm": + if find_file("ndbm.h", inc_dirs, []) is not None: +- # Some systems have -lndbm, others don't ++ # Some systems have -lndbm, others have -lgdbm_compat, ++ # others don't have either + if self.compiler.find_library_file(lib_dirs, + 'ndbm'): + ndbm_libs = ['ndbm'] ++ elif self.compiler.find_library_file(lib_dirs, ++ 'gdbm_compat'): ++ ndbm_libs = ['gdbm_compat'] + else: + ndbm_libs = [] + print("building dbm using ndbm") --- python3.2-3.2.3.orig/debian/patches/xdg-gvfs-open.diff +++ python3.2-3.2.3/debian/patches/xdg-gvfs-open.diff @@ -0,0 +1,17 @@ +--- a/Lib/webbrowser.py ++++ b/Lib/webbrowser.py +@@ -441,6 +441,14 @@ + + def register_X_browsers(): + ++ # use xdg-open if around ++ if _iscommand("xdg-open"): ++ register("xdg-open", None, BackgroundBrowser("xdg-open")) ++ ++ # The default GNOME3 browser ++ if "GNOME_DESKTOP_SESSION_ID" in os.environ and _iscommand("gvfs-open"): ++ register("gvfs-open", None, BackgroundBrowser("gvfs-open")) ++ + # The default GNOME browser + if "GNOME_DESKTOP_SESSION_ID" in os.environ and _iscommand("gnome-open"): + register("gnome-open", None, BackgroundBrowser("gnome-open")) --- python3.2-3.2.3.orig/debian/patches/tkinter-import.diff +++ python3.2-3.2.3/debian/patches/tkinter-import.diff @@ -0,0 +1,16 @@ +# DP: suggest installation of python-tk package on failing _tkinter import + +--- a/Lib/tkinter/__init__.py ++++ b/Lib/tkinter/__init__.py +@@ -36,7 +36,10 @@ + if sys.platform == "win32": + # Attempt to configure Tcl/Tk without requiring PATH + from tkinter import _fix +-import _tkinter # If this fails your Python may not be configured for Tk ++try: ++ import _tkinter ++except ImportError as msg: ++ raise ImportError(str(msg) + ', please install the python-tk package') + TclError = _tkinter.TclError + from tkinter.constants import * + --- python3.2-3.2.3.orig/debian/patches/series.in +++ python3.2-3.2.3/debian/patches/series.in @@ -0,0 +1,69 @@ +hg-updates.diff +autoconf-version.diff +deb-setup.diff +deb-locations.diff +site-locations.diff +distutils-install-layout.diff +locale-module.diff +distutils-link.diff +// FIXME update patch +//distutils-sysconfig.diff +test-sundry.diff +tkinter-import.diff +link-opt.diff +// debug-build.diff +webbrowser.diff +linecache.diff +setup-modules.diff +platform-lsbrelease.diff +bdist-wininst-notfound.diff +no-zip-on-sys.path.diff +doc-nodownload.diff +profiled-build.diff +makesetup-bashism.diff +hurd-broken-poll.diff +hurd-disable-nonworking-constants.diff +enable-fpectl.diff +statvfs-f_flag-constants.diff +#if defined (arch_alpha) +plat-linux2_alpha.diff +#elif defined (arch_hppa) +plat-linux2_hppa.diff +#elif defined (arch_mips) || defined(arch_mipsel) +plat-linux2_mips.diff +#elif defined (arch_sparc) || defined (arch_sparc64) +plat-linux2_sparc.diff +#endif +#if defined (BROKEN_UTIMES) +disable-utimes.diff +#endif +#if defined (Ubuntu) +langpack-gettext.diff +#endif +#if defined (arch_os_hurd) +no-large-file-support.diff +hurd-path_max.diff +cthreads.diff +#endif +issue9012a.diff +#ifdef OLD_SPHINX +doc-build.diff +revert-r83234.diff +revert-r83274.diff +#endif +link-system-expat.diff +plat-gnukfreebsd.diff +disable-sem-check.diff +lib-argparse.diff +bsddb-libpath.diff +ncursesw-include.diff +ctypes-arm.diff +lto-link-flags.diff +xdg-gvfs-open.diff +libffi-shared.diff +sqlite-rpath.diff +utf16_error_handling.patch +do-not-italicize-punctuation.patch +bsddb-version.diff +multiarch.diff +sysconfigdata.diff --- python3.2-3.2.3.orig/debian/patches/lib-argparse.diff +++ python3.2-3.2.3/debian/patches/lib-argparse.diff @@ -0,0 +1,23 @@ +# DP: argparse.py: Make the gettext import conditional + +--- a/Lib/argparse.py ++++ b/Lib/argparse.py +@@ -89,7 +89,17 @@ + import sys as _sys + import textwrap as _textwrap + +-from gettext import gettext as _, ngettext ++try: ++ from gettext import gettext as _, ngettext ++except ImportError: ++ def gettext(message): ++ return message ++ _ = gettext ++ def ngettext(msgid1, msgid2, n): ++ if n == 1: ++ return msgid1 ++ else: ++ return msgid2 + + + def _callable(obj): --- python3.2-3.2.3.orig/debian/patches/sysconfigdata.diff +++ python3.2-3.2.3/debian/patches/sysconfigdata.diff @@ -0,0 +1,131 @@ +# DP: backport issue #13150: sysconfig no longer parses the Makefile and config.h +# DP: files when imported, instead doing it at build time. This makes importing +# DP: sysconfig faster and reduces Python startup time by 20%. + +diff -r 724a6e0e35f0 Lib/sysconfig.py +--- a/Lib/sysconfig.py Wed Jul 11 19:19:14 2012 +0200 ++++ b/Lib/sysconfig.py Fri Jul 13 02:20:28 2012 +0200 +@@ -325,9 +325,10 @@ + 'config-{}{}'.format(_PY_VERSION_SHORT, sys.abiflags), + 'Makefile') + +- +-def _init_posix(vars): +- """Initialize the module as appropriate for POSIX systems.""" ++def _generate_posix_vars(): ++ """Generate the Python module containing build-time variables.""" ++ import pprint ++ vars = {} + # load the installed Makefile: + makefile = get_makefile_filename() + try: +@@ -353,6 +354,19 @@ + if _PYTHON_BUILD: + vars['LDSHARED'] = vars['BLDSHARED'] + ++ destfile = '_sysconfigdata.py' ++ with open(destfile, 'w', encoding='utf8') as f: ++ f.write('# system configuration generated and used by' ++ ' the sysconfig module\n') ++ f.write('build_time_vars = ') ++ pprint.pprint(vars, stream=f) ++ ++def _init_posix(vars): ++ """Initialize the module as appropriate for POSIX systems.""" ++ # _sysconfigdata is generated at build time, see _generate_posix_vars() ++ from _sysconfigdata import build_time_vars ++ vars.update(build_time_vars) ++ + def _init_non_posix(vars): + """Initialize the module as appropriate for NT""" + # set basic install directories +@@ -757,6 +771,9 @@ + + def _main(): + """Display all information sysconfig detains.""" ++ if '--generate-posix-vars' in sys.argv: ++ _generate_posix_vars() ++ return + print('Platform: "{0}"'.format(get_platform())) + print('Python version: "{0}"'.format(get_python_version())) + print('Current installation scheme: "{0}"'.format(_get_default_scheme())) +diff -r 724a6e0e35f0 Makefile.pre.in +--- a/Makefile.pre.in Wed Jul 11 19:19:14 2012 +0200 ++++ b/Makefile.pre.in Fri Jul 13 02:20:28 2012 +0200 +@@ -380,6 +380,7 @@ + Objects/unicodectype.o \ + Objects/weakrefobject.o + ++SYSCONFIGDATA=_sysconfigdata.py + + ########################################################################## + # objects that get linked into the Python library +@@ -397,7 +398,7 @@ + + # Default target + all: build_all +-build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Modules/_testembed ++build_all: $(BUILDPYTHON) $(SYSCONFIGDATA) oldsharedmods sharedmods gdbhooks Modules/_testembed + + # Compile a binary with gcc profile guided optimization. + profile-opt: +@@ -430,12 +431,18 @@ + $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) + $(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ Modules/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) + +-platform: $(BUILDPYTHON) ++platform: $(BUILDPYTHON) $(SYSCONFIGDATA) + $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from sysconfig import get_platform ; print(get_platform()+"-"+sys.version[0:3])' >platform + ++# Generate the sysconfig build-time data ++$(SYSCONFIGDATA): $(BUILDPYTHON) ++ $(RUNSHARED) ./$(BUILDPYTHON) -SE -m sysconfig --generate-posix-vars ++ $(RUNSHARED) ./$(BUILDPYTHON) -S -c 'import os,sys ; from distutils.util import get_platform ; d=os.path.join("build", "lib."+get_platform()+"-"+sys.version[0:3]); print(d, end="")' > pybuilddir.txt ++ mkdir -p `cat pybuilddir.txt` ++ cp $(SYSCONFIGDATA) `cat pybuilddir.txt`/. + + # Build the shared modules +-sharedmods: $(BUILDPYTHON) ++sharedmods: $(BUILDPYTHON) $(SYSCONFIGDATA) + @case $$MAKEFLAGS in \ + *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \ + *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \ +@@ -956,7 +963,7 @@ + else true; \ + fi; \ + done +- @for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.egg-info ; \ ++ @for i in $(srcdir)/Lib/*.py $(SYSCONFIGDATA) $(srcdir)/Lib/*.egg-info ; \ + do \ + if test -x $$i; then \ + $(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \ +diff -r 724a6e0e35f0 setup.py +--- a/setup.py Wed Jul 11 19:19:14 2012 +0200 ++++ b/setup.py Fri Jul 13 02:20:28 2012 +0200 +@@ -23,10 +23,6 @@ + # This global variable is used to hold the list of modules to be disabled. + disabled_module_list = [] + +-# File which contains the directory for shared mods (for sys.path fixup +-# when running from the build dir, see Modules/getpath.c) +-_BUILDDIR_COOKIE = "pybuilddir.txt" +- + def add_dir_to_list(dirlist, dir): + """Add the directory 'dir' to the list 'dirlist' (after any relative + directories) if: +@@ -243,12 +239,9 @@ + args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags + self.compiler.set_executables(**args) + +- # Not only do we write the builddir cookie, but we manually install +- # the shared modules directory if it isn't already in sys.path. +- # Otherwise trying to import the extensions after building them +- # will fail. +- with open(_BUILDDIR_COOKIE, "wb") as f: +- f.write(self.build_lib.encode('utf-8', 'surrogateescape')) ++ # We manually install the shared modules directory if it isn't ++ # already in sys.path. Otherwise trying to import the ++ # extensions after building them will fail. + abs_build_lib = os.path.join(os.getcwd(), self.build_lib) + if abs_build_lib not in sys.path: + sys.path.append(abs_build_lib) --- python3.2-3.2.3.orig/debian/patches/deb-setup.diff +++ python3.2-3.2.3/debian/patches/deb-setup.diff @@ -0,0 +1,28 @@ +# DP: Don't include /usr/local/include and /usr/local/lib as gcc search paths + +--- a/setup.py ++++ b/setup.py +@@ -393,11 +393,9 @@ + os.unlink(tmpfile) + + def detect_modules(self): +- # Ensure that /usr/local is always used, but the local build +- # directories (i.e. '.' and 'Include') must be first. See issue +- # 10520. +- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') +- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') ++ # On Debian /usr/local is always used, so we don't include it twice ++ #add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') ++ #add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') + self.add_multiarch_paths() + + # Add paths specified in the environment variables LDFLAGS and +@@ -606,7 +604,7 @@ + os.unlink(tmpfile) + # Issue 7384: If readline is already linked against curses, + # use the same library for the readline and curses modules. +- if 'curses' in readline_termcap_library: ++ if False and 'curses' in readline_termcap_library: + curses_library = readline_termcap_library + elif self.compiler.find_library_file(lib_dirs, 'ncursesw'): + curses_library = 'ncursesw' --- python3.2-3.2.3.orig/debian/patches/locale-module.diff +++ python3.2-3.2.3/debian/patches/locale-module.diff @@ -0,0 +1,17 @@ +# DP: * Lib/locale.py: +# DP: - Don't map 'utf8', 'utf-8' to 'utf', which is not a known encoding +# DP: for glibc. + +--- a/Lib/locale.py ++++ b/Lib/locale.py +@@ -1534,8 +1534,8 @@ + 'uk_ua.iso88595': 'uk_UA.ISO8859-5', + 'uk_ua.koi8u': 'uk_UA.KOI8-U', + 'uk_ua.microsoftcp1251': 'uk_UA.CP1251', +- 'univ': 'en_US.utf', +- 'universal': 'en_US.utf', ++ 'univ': 'en_US.UTF-8', ++ 'universal': 'en_US.UTF-8', + 'universal.utf8@ucs4': 'en_US.UTF-8', + 'ur': 'ur_PK.CP1256', + 'ur_pk': 'ur_PK.CP1256', --- python3.2-3.2.3.orig/debian/patches/hurd-disable-nonworking-constants.diff +++ python3.2-3.2.3/debian/patches/hurd-disable-nonworking-constants.diff @@ -0,0 +1,34 @@ +# DP: Comment out constant exposed on the API which are not implemented on +# DP: GNU/Hurd. They would not work at runtime anyway. + +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -8248,12 +8248,14 @@ + #ifdef O_LARGEFILE + if (ins(d, "O_LARGEFILE", (long)O_LARGEFILE)) return -1; + #endif ++#ifndef __GNU__ + #ifdef O_SHLOCK + if (ins(d, "O_SHLOCK", (long)O_SHLOCK)) return -1; + #endif + #ifdef O_EXLOCK + if (ins(d, "O_EXLOCK", (long)O_EXLOCK)) return -1; + #endif ++#endif + + /* MS Windows */ + #ifdef O_NOINHERIT +--- a/Modules/socketmodule.c ++++ b/Modules/socketmodule.c +@@ -4741,9 +4741,11 @@ + #ifdef SO_OOBINLINE + PyModule_AddIntConstant(m, "SO_OOBINLINE", SO_OOBINLINE); + #endif ++#ifndef __GNU__ + #ifdef SO_REUSEPORT + PyModule_AddIntConstant(m, "SO_REUSEPORT", SO_REUSEPORT); + #endif ++#endif + #ifdef SO_SNDBUF + PyModule_AddIntConstant(m, "SO_SNDBUF", SO_SNDBUF); + #endif --- python3.2-3.2.3.orig/debian/patches/doc-faq.dpatch +++ python3.2-3.2.3/debian/patches/doc-faq.dpatch @@ -0,0 +1,52 @@ +#! /bin/sh -e + +# DP: Mention the FAQ on the documentation index page. + +dir= +if [ $# -eq 3 -a "$2" = '-d' ]; then + pdir="-d $3" + dir="$3/" +elif [ $# -ne 1 ]; then + echo >&2 "usage: `basename $0`: -patch|-unpatch [-d ]" + exit 1 +fi +case "$1" in + -patch) + patch $pdir -f --no-backup-if-mismatch -p0 < $0 + ;; + -unpatch) + patch $pdir -f --no-backup-if-mismatch -R -p0 < $0 + ;; + *) + echo >&2 "usage: `basename $0`: -patch|-unpatch [-d ]" + exit 1 +esac +exit 0 + +--- Doc/html/index.html.in~ 2002-04-01 18:11:27.000000000 +0200 ++++ Doc/html/index.html.in 2003-04-05 13:33:35.000000000 +0200 +@@ -123,6 +123,24 @@ + + + ++ ++ ++   ++ ++ ++ ++   ++ ++ ++ + + +

    --- python3.2-3.2.3.orig/debian/patches/profiled-build.diff +++ python3.2-3.2.3/debian/patches/profiled-build.diff @@ -0,0 +1,29 @@ +# DP: Ignore errors in the profile task. + +Index: b/Makefile.pre.in +=================================================================== +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -411,18 +411,18 @@ + $(MAKE) build_all_use_profile + + build_all_generate_profile: +- $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov" ++ $(MAKE) all PY_CFLAGS="$(PY_CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov" + + run_profile_task: +- ./$(BUILDPYTHON) $(PROFILE_TASK) ++ -./$(BUILDPYTHON) $(PROFILE_TASK) + + build_all_use_profile: +- $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use" ++ $(MAKE) all PY_CFLAGS="$(PY_CFLAGS) -fprofile-use -fprofile-correction" + + coverage: + @echo "Building with support for coverage checking:" + $(MAKE) clean +- $(MAKE) all CFLAGS="$(CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov" ++ $(MAKE) all PY_CFLAGS="$(PY_CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov" + + + # Build the interpreter --- python3.2-3.2.3.orig/debian/patches/ncursesw-include.diff +++ python3.2-3.2.3/debian/patches/ncursesw-include.diff @@ -0,0 +1,74 @@ +--- a/setup.py ++++ b/setup.py +@@ -1168,6 +1168,7 @@ + panel_library = 'panelw' + curses_libs = [curses_library] + exts.append( Extension('_curses', ['_cursesmodule.c'], ++ include_dirs=['/usr/include/ncursesw'], + libraries = curses_libs) ) + elif curses_library == 'curses' and platform != 'darwin': + # OSX has an old Berkeley curses, not good enough for +@@ -1188,6 +1189,7 @@ + if (module_enabled(exts, '_curses') and + self.compiler.find_library_file(lib_dirs, panel_library)): + exts.append( Extension('_curses_panel', ['_curses_panel.c'], ++ include_dirs=['/usr/include/ncursesw'], + libraries = [panel_library] + curses_libs) ) + else: + missing.append('_curses_panel') +Index: b/configure.ac +=================================================================== +--- a/configure.ac ++++ b/configure.ac +@@ -1328,9 +1328,9 @@ + + # checks for header files + AC_HEADER_STDC +-AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ ++AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \ + fcntl.h grp.h \ +-ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ ++ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \ + shadow.h signal.h stdint.h stropts.h termios.h thread.h \ + unistd.h utime.h \ + sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \ +@@ -1343,13 +1343,6 @@ + AC_HEADER_DIRENT + AC_HEADER_MAJOR + +-# On Solaris, term.h requires curses.h +-AC_CHECK_HEADERS(term.h,,,[ +-#ifdef HAVE_CURSES_H +-#include +-#endif +-]) +- + # On Linux, netlink.h requires asm/types.h + AC_CHECK_HEADERS(linux/netlink.h,,,[ + #ifdef HAVE_ASM_TYPES_H +@@ -4053,6 +4046,17 @@ + [Define if you have struct stat.st_mtimensec]) + fi + ++ac_save_cppflags="$CPPFLAGS" ++CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" ++AC_CHECK_HEADERS(curses.h ncurses.h) ++ ++# On Solaris, term.h requires curses.h ++AC_CHECK_HEADERS(term.h,,,[ ++#ifdef HAVE_CURSES_H ++#include ++#endif ++]) ++ + # On HP/UX 11.0, mvwdelch is a block with a return statement + AC_MSG_CHECKING(whether mvwdelch is an expression) + AC_CACHE_VAL(ac_cv_mvwdelch_is_expression, +@@ -4107,6 +4111,7 @@ + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)] + ) ++CPPFLAGS=$ac_save_cppflags + + AC_MSG_CHECKING(for /dev/ptmx) + --- python3.2-3.2.3.orig/debian/patches/plat-gnukfreebsd.diff +++ python3.2-3.2.3/debian/patches/plat-gnukfreebsd.diff @@ -0,0 +1,2480 @@ +# DP: Provide Lib/plat-gnukfreebsd[78]. + +--- /dev/null ++++ b/Lib/plat-gnukfreebsd7/DLFCN.py +@@ -0,0 +1,118 @@ ++# Generated by h2py from /usr/include/dlfcn.h ++_DLFCN_H = 1 ++ ++# Included from features.h ++_FEATURES_H = 1 ++__USE_ANSI = 1 ++__FAVOR_BSD = 1 ++_ISOC99_SOURCE = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 200809 ++_XOPEN_SOURCE = 700 ++_XOPEN_SOURCE_EXTENDED = 1 ++_LARGEFILE64_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++_ATFILE_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++__USE_ISOC99 = 1 ++__USE_ISOC95 = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 2 ++_POSIX_C_SOURCE = 199506 ++_POSIX_C_SOURCE = 200112 ++_POSIX_C_SOURCE = 200809 ++__USE_POSIX_IMPLICITLY = 1 ++__USE_POSIX = 1 ++__USE_POSIX2 = 1 ++__USE_POSIX199309 = 1 ++__USE_POSIX199506 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN2K8 = 1 ++_ATFILE_SOURCE = 1 ++__USE_XOPEN = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_UNIX98 = 1 ++_LARGEFILE_SOURCE = 1 ++__USE_XOPEN2K8 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_FILE_OFFSET64 = 1 ++__USE_MISC = 1 ++__USE_BSD = 1 ++__USE_SVID = 1 ++__USE_ATFILE = 1 ++__USE_GNU = 1 ++__USE_REENTRANT = 1 ++__USE_FORTIFY_LEVEL = 2 ++__USE_FORTIFY_LEVEL = 1 ++__USE_FORTIFY_LEVEL = 0 ++ ++# Included from bits/predefs.h ++__STDC_IEC_559__ = 1 ++__STDC_IEC_559_COMPLEX__ = 1 ++__STDC_ISO_10646__ = 200009 ++__GNU_LIBRARY__ = 6 ++__GLIBC__ = 2 ++__GLIBC_MINOR__ = 11 ++__GLIBC_HAVE_LONG_LONG = 1 ++ ++# Included from sys/cdefs.h ++_SYS_CDEFS_H = 1 ++def __NTH(fct): return fct ++ ++def __NTH(fct): return fct ++ ++def __P(args): return args ++ ++def __PMT(args): return args ++ ++def __STRING(x): return #x ++ ++def __bos(ptr): return __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) ++ ++def __bos0(ptr): return __builtin_object_size (ptr, 0) ++ ++def __warnattr(msg): return __attribute__((__warning__ (msg))) ++ ++__flexarr = [] ++__flexarr = [0] ++__flexarr = [] ++__flexarr = [1] ++def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ++ ++def __attribute__(xyz): return ++ ++def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ++ ++def __attribute_format_arg__(x): return ++ ++ ++# Included from bits/wordsize.h ++__WORDSIZE = 32 ++__LDBL_COMPAT = 1 ++def __LDBL_REDIR_DECL(name): return \ ++ ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_EXTERN_INLINES = 1 ++__USE_EXTERN_INLINES_IN_LIBC = 1 ++ ++# Included from gnu/stubs.h ++ ++# Included from bits/dlfcn.h ++RTLD_LAZY = 0x00001 ++RTLD_NOW = 0x00002 ++RTLD_BINDING_MASK = 0x3 ++RTLD_NOLOAD = 0x00004 ++RTLD_DEEPBIND = 0x00008 ++RTLD_GLOBAL = 0x00100 ++RTLD_LOCAL = 0 ++RTLD_NODELETE = 0x01000 ++LM_ID_BASE = 0 ++LM_ID_NEWLM = -1 +--- /dev/null ++++ b/Lib/plat-gnukfreebsd7/IN.py +@@ -0,0 +1,809 @@ ++# Generated by h2py from /usr/include/netinet/in.h ++_NETINET_IN_H = 1 ++ ++# Included from features.h ++_FEATURES_H = 1 ++__USE_ANSI = 1 ++__FAVOR_BSD = 1 ++_ISOC99_SOURCE = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 200809 ++_XOPEN_SOURCE = 700 ++_XOPEN_SOURCE_EXTENDED = 1 ++_LARGEFILE64_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++_ATFILE_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++__USE_ISOC99 = 1 ++__USE_ISOC95 = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 2 ++_POSIX_C_SOURCE = 199506 ++_POSIX_C_SOURCE = 200112 ++_POSIX_C_SOURCE = 200809 ++__USE_POSIX_IMPLICITLY = 1 ++__USE_POSIX = 1 ++__USE_POSIX2 = 1 ++__USE_POSIX199309 = 1 ++__USE_POSIX199506 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN2K8 = 1 ++_ATFILE_SOURCE = 1 ++__USE_XOPEN = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_UNIX98 = 1 ++_LARGEFILE_SOURCE = 1 ++__USE_XOPEN2K8 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_FILE_OFFSET64 = 1 ++__USE_MISC = 1 ++__USE_BSD = 1 ++__USE_SVID = 1 ++__USE_ATFILE = 1 ++__USE_GNU = 1 ++__USE_REENTRANT = 1 ++__USE_FORTIFY_LEVEL = 2 ++__USE_FORTIFY_LEVEL = 1 ++__USE_FORTIFY_LEVEL = 0 ++ ++# Included from bits/predefs.h ++__STDC_IEC_559__ = 1 ++__STDC_IEC_559_COMPLEX__ = 1 ++__STDC_ISO_10646__ = 200009 ++__GNU_LIBRARY__ = 6 ++__GLIBC__ = 2 ++__GLIBC_MINOR__ = 11 ++__GLIBC_HAVE_LONG_LONG = 1 ++ ++# Included from sys/cdefs.h ++_SYS_CDEFS_H = 1 ++def __NTH(fct): return fct ++ ++def __NTH(fct): return fct ++ ++def __P(args): return args ++ ++def __PMT(args): return args ++ ++def __STRING(x): return #x ++ ++def __bos(ptr): return __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) ++ ++def __bos0(ptr): return __builtin_object_size (ptr, 0) ++ ++def __warnattr(msg): return __attribute__((__warning__ (msg))) ++ ++__flexarr = [] ++__flexarr = [0] ++__flexarr = [] ++__flexarr = [1] ++def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ++ ++def __attribute__(xyz): return ++ ++def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ++ ++def __attribute_format_arg__(x): return ++ ++ ++# Included from bits/wordsize.h ++__WORDSIZE = 32 ++__LDBL_COMPAT = 1 ++def __LDBL_REDIR_DECL(name): return \ ++ ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_EXTERN_INLINES = 1 ++__USE_EXTERN_INLINES_IN_LIBC = 1 ++ ++# Included from gnu/stubs.h ++ ++# Included from stdint.h ++_STDINT_H = 1 ++ ++# Included from bits/wchar.h ++_BITS_WCHAR_H = 1 ++__WCHAR_MAX = (2147483647) ++__WCHAR_MIN = (-__WCHAR_MAX - 1) ++def __INT64_C(c): return c ## L ++ ++def __UINT64_C(c): return c ## UL ++ ++def __INT64_C(c): return c ## LL ++ ++def __UINT64_C(c): return c ## ULL ++ ++INT8_MIN = (-128) ++INT16_MIN = (-32767-1) ++INT32_MIN = (-2147483647-1) ++INT64_MIN = (-__INT64_C(9223372036854775807)-1) ++INT8_MAX = (127) ++INT16_MAX = (32767) ++INT32_MAX = (2147483647) ++INT64_MAX = (__INT64_C(9223372036854775807)) ++UINT8_MAX = (255) ++UINT16_MAX = (65535) ++UINT64_MAX = (__UINT64_C(18446744073709551615)) ++INT_LEAST8_MIN = (-128) ++INT_LEAST16_MIN = (-32767-1) ++INT_LEAST32_MIN = (-2147483647-1) ++INT_LEAST64_MIN = (-__INT64_C(9223372036854775807)-1) ++INT_LEAST8_MAX = (127) ++INT_LEAST16_MAX = (32767) ++INT_LEAST32_MAX = (2147483647) ++INT_LEAST64_MAX = (__INT64_C(9223372036854775807)) ++UINT_LEAST8_MAX = (255) ++UINT_LEAST16_MAX = (65535) ++UINT_LEAST64_MAX = (__UINT64_C(18446744073709551615)) ++INT_FAST8_MIN = (-128) ++INT_FAST16_MIN = (-9223372036854775807-1) ++INT_FAST32_MIN = (-9223372036854775807-1) ++INT_FAST16_MIN = (-2147483647-1) ++INT_FAST32_MIN = (-2147483647-1) ++INT_FAST64_MIN = (-__INT64_C(9223372036854775807)-1) ++INT_FAST8_MAX = (127) ++INT_FAST16_MAX = (9223372036854775807) ++INT_FAST32_MAX = (9223372036854775807) ++INT_FAST16_MAX = (2147483647) ++INT_FAST32_MAX = (2147483647) ++INT_FAST64_MAX = (__INT64_C(9223372036854775807)) ++UINT_FAST8_MAX = (255) ++UINT_FAST64_MAX = (__UINT64_C(18446744073709551615)) ++INTPTR_MIN = (-9223372036854775807-1) ++INTPTR_MAX = (9223372036854775807) ++INTPTR_MIN = (-2147483647-1) ++INTPTR_MAX = (2147483647) ++INTMAX_MIN = (-__INT64_C(9223372036854775807)-1) ++INTMAX_MAX = (__INT64_C(9223372036854775807)) ++UINTMAX_MAX = (__UINT64_C(18446744073709551615)) ++PTRDIFF_MIN = (-9223372036854775807-1) ++PTRDIFF_MAX = (9223372036854775807) ++PTRDIFF_MIN = (-2147483647-1) ++PTRDIFF_MAX = (2147483647) ++SIG_ATOMIC_MIN = (-2147483647-1) ++SIG_ATOMIC_MAX = (2147483647) ++WCHAR_MIN = __WCHAR_MIN ++WCHAR_MAX = __WCHAR_MAX ++def INT8_C(c): return c ++ ++def INT16_C(c): return c ++ ++def INT32_C(c): return c ++ ++def INT64_C(c): return c ## L ++ ++def INT64_C(c): return c ## LL ++ ++def UINT8_C(c): return c ++ ++def UINT16_C(c): return c ++ ++def UINT32_C(c): return c ## U ++ ++def UINT64_C(c): return c ## UL ++ ++def UINT64_C(c): return c ## ULL ++ ++def INTMAX_C(c): return c ## L ++ ++def UINTMAX_C(c): return c ## UL ++ ++def INTMAX_C(c): return c ## LL ++ ++def UINTMAX_C(c): return c ## ULL ++ ++ ++# Included from sys/socket.h ++_SYS_SOCKET_H = 1 ++ ++# Included from sys/uio.h ++_SYS_UIO_H = 1 ++from TYPES import * ++ ++# Included from bits/uio.h ++_BITS_UIO_H = 1 ++from TYPES import * ++UIO_MAXIOV = 1024 ++ ++# Included from bits/sigset.h ++_SIGSET_H_types = 1 ++_SIGSET_H_fns = 1 ++def __sigword(sig): return (((sig) - 1) >> 5) ++ ++def __sigemptyset(set): return \ ++ ++def __sigfillset(set): return \ ++ ++def __sigisemptyset(set): return \ ++ ++ ++# Included from bits/socket.h ++__BITS_SOCKET_H = 1 ++ ++# Included from limits.h ++_LIBC_LIMITS_H_ = 1 ++MB_LEN_MAX = 16 ++_LIMITS_H = 1 ++CHAR_BIT = 8 ++SCHAR_MIN = (-128) ++SCHAR_MAX = 127 ++UCHAR_MAX = 255 ++CHAR_MIN = 0 ++CHAR_MAX = UCHAR_MAX ++CHAR_MIN = SCHAR_MIN ++CHAR_MAX = SCHAR_MAX ++SHRT_MIN = (-32768) ++SHRT_MAX = 32767 ++USHRT_MAX = 65535 ++INT_MAX = 2147483647 ++LONG_MAX = 9223372036854775807 ++LONG_MAX = 2147483647 ++LONG_MIN = (-LONG_MAX - 1) ++ ++# Included from bits/posix1_lim.h ++_BITS_POSIX1_LIM_H = 1 ++_POSIX_AIO_LISTIO_MAX = 2 ++_POSIX_AIO_MAX = 1 ++_POSIX_ARG_MAX = 4096 ++_POSIX_CHILD_MAX = 25 ++_POSIX_CHILD_MAX = 6 ++_POSIX_DELAYTIMER_MAX = 32 ++_POSIX_HOST_NAME_MAX = 255 ++_POSIX_LINK_MAX = 8 ++_POSIX_LOGIN_NAME_MAX = 9 ++_POSIX_MAX_CANON = 255 ++_POSIX_MAX_INPUT = 255 ++_POSIX_MQ_OPEN_MAX = 8 ++_POSIX_MQ_PRIO_MAX = 32 ++_POSIX_NAME_MAX = 14 ++_POSIX_NGROUPS_MAX = 8 ++_POSIX_NGROUPS_MAX = 0 ++_POSIX_OPEN_MAX = 20 ++_POSIX_OPEN_MAX = 16 ++_POSIX_FD_SETSIZE = _POSIX_OPEN_MAX ++_POSIX_PATH_MAX = 256 ++_POSIX_PIPE_BUF = 512 ++_POSIX_RE_DUP_MAX = 255 ++_POSIX_RTSIG_MAX = 8 ++_POSIX_SEM_NSEMS_MAX = 256 ++_POSIX_SEM_VALUE_MAX = 32767 ++_POSIX_SIGQUEUE_MAX = 32 ++_POSIX_SSIZE_MAX = 32767 ++_POSIX_STREAM_MAX = 8 ++_POSIX_SYMLINK_MAX = 255 ++_POSIX_SYMLOOP_MAX = 8 ++_POSIX_TIMER_MAX = 32 ++_POSIX_TTY_NAME_MAX = 9 ++_POSIX_TZNAME_MAX = 6 ++_POSIX_QLIMIT = 1 ++_POSIX_HIWAT = _POSIX_PIPE_BUF ++_POSIX_UIO_MAXIOV = 16 ++_POSIX_CLOCKRES_MIN = 20000000 ++ ++# Included from bits/local_lim.h ++ ++# Included from sys/syslimits.h ++ARG_MAX = 262144 ++CHILD_MAX = 40 ++LINK_MAX = 32767 ++MAX_CANON = 255 ++MAX_INPUT = 255 ++NAME_MAX = 255 ++NGROUPS_MAX = 1023 ++OPEN_MAX = 64 ++PATH_MAX = 1024 ++PIPE_BUF = 512 ++IOV_MAX = 1024 ++_POSIX_THREAD_KEYS_MAX = 128 ++PTHREAD_KEYS_MAX = 1024 ++_POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4 ++PTHREAD_DESTRUCTOR_ITERATIONS = _POSIX_THREAD_DESTRUCTOR_ITERATIONS ++_POSIX_THREAD_THREADS_MAX = 64 ++PTHREAD_THREADS_MAX = 1024 ++AIO_PRIO_DELTA_MAX = 20 ++PTHREAD_STACK_MIN = 16384 ++TIMER_MAX = 256 ++DELAYTIMER_MAX = 2147483647 ++SSIZE_MAX = LONG_MAX ++NGROUPS_MAX = 8 ++ ++# Included from bits/posix2_lim.h ++_BITS_POSIX2_LIM_H = 1 ++_POSIX2_BC_BASE_MAX = 99 ++_POSIX2_BC_DIM_MAX = 2048 ++_POSIX2_BC_SCALE_MAX = 99 ++_POSIX2_BC_STRING_MAX = 1000 ++_POSIX2_COLL_WEIGHTS_MAX = 2 ++_POSIX2_EXPR_NEST_MAX = 32 ++_POSIX2_LINE_MAX = 2048 ++_POSIX2_RE_DUP_MAX = 255 ++_POSIX2_CHARCLASS_NAME_MAX = 14 ++BC_BASE_MAX = _POSIX2_BC_BASE_MAX ++BC_DIM_MAX = _POSIX2_BC_DIM_MAX ++BC_SCALE_MAX = _POSIX2_BC_SCALE_MAX ++BC_STRING_MAX = _POSIX2_BC_STRING_MAX ++COLL_WEIGHTS_MAX = 255 ++EXPR_NEST_MAX = _POSIX2_EXPR_NEST_MAX ++LINE_MAX = _POSIX2_LINE_MAX ++CHARCLASS_NAME_MAX = 2048 ++RE_DUP_MAX = (0x7fff) ++ ++# Included from bits/xopen_lim.h ++_XOPEN_LIM_H = 1 ++ ++# Included from bits/stdio_lim.h ++L_tmpnam = 20 ++TMP_MAX = 238328 ++FILENAME_MAX = 1024 ++L_ctermid = 9 ++L_cuserid = 9 ++FOPEN_MAX = 64 ++IOV_MAX = 1024 ++_XOPEN_IOV_MAX = _POSIX_UIO_MAXIOV ++NL_ARGMAX = _POSIX_ARG_MAX ++NL_LANGMAX = _POSIX2_LINE_MAX ++NL_MSGMAX = INT_MAX ++NL_NMAX = INT_MAX ++NL_SETMAX = INT_MAX ++NL_TEXTMAX = INT_MAX ++NZERO = 20 ++WORD_BIT = 16 ++WORD_BIT = 32 ++WORD_BIT = 64 ++WORD_BIT = 16 ++WORD_BIT = 32 ++WORD_BIT = 64 ++WORD_BIT = 32 ++LONG_BIT = 32 ++LONG_BIT = 64 ++LONG_BIT = 32 ++LONG_BIT = 64 ++LONG_BIT = 64 ++LONG_BIT = 32 ++ ++# Included from bits/types.h ++_BITS_TYPES_H = 1 ++__S32_TYPE = int ++__SWORD_TYPE = int ++__SLONG32_TYPE = int ++ ++# Included from bits/typesizes.h ++_BITS_TYPESIZES_H = 1 ++__PID_T_TYPE = __S32_TYPE ++__CLOCK_T_TYPE = __S32_TYPE ++__SWBLK_T_TYPE = __S32_TYPE ++__CLOCKID_T_TYPE = __S32_TYPE ++__TIMER_T_TYPE = __S32_TYPE ++__SSIZE_T_TYPE = __SWORD_TYPE ++__FD_SETSIZE = 1024 ++PF_UNSPEC = 0 ++PF_LOCAL = 1 ++PF_UNIX = PF_LOCAL ++PF_FILE = PF_LOCAL ++PF_INET = 2 ++PF_IMPLINK = 3 ++PF_PUP = 4 ++PF_CHAOS = 5 ++PF_NS = 6 ++PF_ISO = 7 ++PF_OSI = PF_ISO ++PF_ECMA = 8 ++PF_DATAKIT = 9 ++PF_CCITT = 10 ++PF_SNA = 11 ++PF_DECnet = 12 ++PF_DLI = 13 ++PF_LAT = 14 ++PF_HYLINK = 15 ++PF_APPLETALK = 16 ++PF_ROUTE = 17 ++PF_LINK = 18 ++PF_XTP = 19 ++PF_COIP = 20 ++PF_CNT = 21 ++PF_RTIP = 22 ++PF_IPX = 23 ++PF_SIP = 24 ++PF_PIP = 25 ++PF_ISDN = 26 ++PF_KEY = 27 ++PF_INET6 = 28 ++PF_NATM = 29 ++PF_ATM = 30 ++PF_HDRCMPLT = 31 ++PF_NETGRAPH = 32 ++PF_MAX = 33 ++AF_UNSPEC = PF_UNSPEC ++AF_LOCAL = PF_LOCAL ++AF_UNIX = PF_UNIX ++AF_FILE = PF_FILE ++AF_INET = PF_INET ++AF_IMPLINK = PF_IMPLINK ++AF_PUP = PF_PUP ++AF_CHAOS = PF_CHAOS ++AF_NS = PF_NS ++AF_ISO = PF_ISO ++AF_OSI = PF_OSI ++AF_ECMA = PF_ECMA ++AF_DATAKIT = PF_DATAKIT ++AF_CCITT = PF_CCITT ++AF_SNA = PF_SNA ++AF_DECnet = PF_DECnet ++AF_DLI = PF_DLI ++AF_LAT = PF_LAT ++AF_HYLINK = PF_HYLINK ++AF_APPLETALK = PF_APPLETALK ++AF_ROUTE = PF_ROUTE ++AF_LINK = PF_LINK ++pseudo_AF_XTP = PF_XTP ++AF_COIP = PF_COIP ++AF_CNT = PF_CNT ++pseudo_AF_RTIP = PF_RTIP ++AF_IPX = PF_IPX ++AF_SIP = PF_SIP ++pseudo_AF_PIP = PF_PIP ++AF_ISDN = PF_ISDN ++AF_E164 = AF_ISDN ++pseudo_AF_KEY = PF_KEY ++AF_INET6 = PF_INET6 ++AF_NATM = PF_NATM ++AF_ATM = PF_ATM ++pseudo_AF_HDRCMPLT = PF_HDRCMPLT ++AF_NETGRAPH = PF_NETGRAPH ++AF_MAX = PF_MAX ++SOMAXCONN = 128 ++ ++# Included from bits/sockaddr.h ++_BITS_SOCKADDR_H = 1 ++def __SOCKADDR_COMMON(sa_prefix): return \ ++ ++_HAVE_SA_LEN = 1 ++_SS_SIZE = 128 ++def CMSG_FIRSTHDR(mhdr): return \ ++ ++CMGROUP_MAX = 16 ++SOL_SOCKET = 0xffff ++LOCAL_PEERCRED = 0x001 ++LOCAL_CREDS = 0x002 ++LOCAL_CONNWAIT = 0x004 ++ ++# Included from bits/socket2.h ++def IN_CLASSA(a): return ((((in_addr_t)(a)) & (-2147483648)) == 0) ++ ++IN_CLASSA_NET = (-16777216) ++IN_CLASSA_NSHIFT = 24 ++IN_CLASSA_HOST = ((-1) & ~IN_CLASSA_NET) ++IN_CLASSA_MAX = 128 ++def IN_CLASSB(a): return ((((in_addr_t)(a)) & (-1073741824)) == (-2147483648)) ++ ++IN_CLASSB_NET = (-65536) ++IN_CLASSB_NSHIFT = 16 ++IN_CLASSB_HOST = ((-1) & ~IN_CLASSB_NET) ++IN_CLASSB_MAX = 65536 ++def IN_CLASSC(a): return ((((in_addr_t)(a)) & (-536870912)) == (-1073741824)) ++ ++IN_CLASSC_NET = (-256) ++IN_CLASSC_NSHIFT = 8 ++IN_CLASSC_HOST = ((-1) & ~IN_CLASSC_NET) ++def IN_CLASSD(a): return ((((in_addr_t)(a)) & (-268435456)) == (-536870912)) ++ ++def IN_MULTICAST(a): return IN_CLASSD(a) ++ ++def IN_EXPERIMENTAL(a): return ((((in_addr_t)(a)) & (-536870912)) == (-536870912)) ++ ++def IN_BADCLASS(a): return ((((in_addr_t)(a)) & (-268435456)) == (-268435456)) ++ ++IN_LOOPBACKNET = 127 ++INET_ADDRSTRLEN = 16 ++INET6_ADDRSTRLEN = 46 ++ ++# Included from bits/in.h ++IMPLINK_IP = 155 ++IMPLINK_LOWEXPER = 156 ++IMPLINK_HIGHEXPER = 158 ++IPPROTO_DIVERT = 258 ++SOL_IP = 0 ++IP_OPTIONS = 1 ++IP_HDRINCL = 2 ++IP_TOS = 3 ++IP_TTL = 4 ++IP_RECVOPTS = 5 ++IP_RECVRETOPTS = 6 ++IP_RECVDSTADDR = 7 ++IP_SENDSRCADDR = IP_RECVDSTADDR ++IP_RETOPTS = 8 ++IP_MULTICAST_IF = 9 ++IP_MULTICAST_TTL = 10 ++IP_MULTICAST_LOOP = 11 ++IP_ADD_MEMBERSHIP = 12 ++IP_DROP_MEMBERSHIP = 13 ++IP_MULTICAST_VIF = 14 ++IP_RSVP_ON = 15 ++IP_RSVP_OFF = 16 ++IP_RSVP_VIF_ON = 17 ++IP_RSVP_VIF_OFF = 18 ++IP_PORTRANGE = 19 ++IP_RECVIF = 20 ++IP_IPSEC_POLICY = 21 ++IP_FAITH = 22 ++IP_ONESBCAST = 23 ++IP_NONLOCALOK = 24 ++IP_FW_TABLE_ADD = 40 ++IP_FW_TABLE_DEL = 41 ++IP_FW_TABLE_FLUSH = 42 ++IP_FW_TABLE_GETSIZE = 43 ++IP_FW_TABLE_LIST = 44 ++IP_FW_ADD = 50 ++IP_FW_DEL = 51 ++IP_FW_FLUSH = 52 ++IP_FW_ZERO = 53 ++IP_FW_GET = 54 ++IP_FW_RESETLOG = 55 ++IP_FW_NAT_CFG = 56 ++IP_FW_NAT_DEL = 57 ++IP_FW_NAT_GET_CONFIG = 58 ++IP_FW_NAT_GET_LOG = 59 ++IP_DUMMYNET_CONFIGURE = 60 ++IP_DUMMYNET_DEL = 61 ++IP_DUMMYNET_FLUSH = 62 ++IP_DUMMYNET_GET = 64 ++IP_RECVTTL = 65 ++IP_MINTTL = 66 ++IP_DONTFRAG = 67 ++IP_ADD_SOURCE_MEMBERSHIP = 70 ++IP_DROP_SOURCE_MEMBERSHIP = 71 ++IP_BLOCK_SOURCE = 72 ++IP_UNBLOCK_SOURCE = 73 ++IP_MSFILTER = 74 ++MCAST_JOIN_GROUP = 80 ++MCAST_LEAVE_GROUP = 81 ++MCAST_JOIN_SOURCE_GROUP = 82 ++MCAST_LEAVE_SOURCE_GROUP = 83 ++MCAST_BLOCK_SOURCE = 84 ++MCAST_UNBLOCK_SOURCE = 85 ++IP_DEFAULT_MULTICAST_TTL = 1 ++IP_DEFAULT_MULTICAST_LOOP = 1 ++IP_MIN_MEMBERSHIPS = 31 ++IP_MAX_MEMBERSHIPS = 4095 ++IP_MAX_SOURCE_FILTER = 1024 ++MCAST_UNDEFINED = 0 ++MCAST_INCLUDE = 1 ++MCAST_EXCLUDE = 2 ++IP_PORTRANGE_DEFAULT = 0 ++IP_PORTRANGE_HIGH = 1 ++IP_PORTRANGE_LOW = 2 ++IPCTL_FORWARDING = 1 ++IPCTL_SENDREDIRECTS = 2 ++IPCTL_DEFTTL = 3 ++IPCTL_DEFMTU = 4 ++IPCTL_RTEXPIRE = 5 ++IPCTL_RTMINEXPIRE = 6 ++IPCTL_RTMAXCACHE = 7 ++IPCTL_SOURCEROUTE = 8 ++IPCTL_DIRECTEDBROADCAST = 9 ++IPCTL_INTRQMAXLEN = 10 ++IPCTL_INTRQDROPS = 11 ++IPCTL_STATS = 12 ++IPCTL_ACCEPTSOURCEROUTE = 13 ++IPCTL_FASTFORWARDING = 14 ++IPCTL_KEEPFAITH = 15 ++IPCTL_GIF_TTL = 16 ++IPCTL_MAXID = 17 ++IPV6_SOCKOPT_RESERVED1 = 3 ++IPV6_UNICAST_HOPS = 4 ++IPV6_MULTICAST_IF = 9 ++IPV6_MULTICAST_HOPS = 10 ++IPV6_MULTICAST_LOOP = 11 ++IPV6_JOIN_GROUP = 12 ++IPV6_LEAVE_GROUP = 13 ++IPV6_PORTRANGE = 14 ++ICMP6_FILTER = 18 ++IPV6_CHECKSUM = 26 ++IPV6_V6ONLY = 27 ++IPV6_IPSEC_POLICY = 28 ++IPV6_FAITH = 29 ++IPV6_FW_ADD = 30 ++IPV6_FW_DEL = 31 ++IPV6_FW_FLUSH = 32 ++IPV6_FW_ZERO = 33 ++IPV6_FW_GET = 34 ++IPV6_RTHDRDSTOPTS = 35 ++IPV6_RECVPKTINFO = 36 ++IPV6_RECVHOPLIMIT = 37 ++IPV6_RECVRTHDR = 38 ++IPV6_RECVHOPOPTS = 39 ++IPV6_RECVDSTOPTS = 40 ++IPV6_USE_MIN_MTU = 42 ++IPV6_RECVPATHMTU = 43 ++IPV6_PATHMTU = 44 ++IPV6_PKTINFO = 46 ++IPV6_HOPLIMIT = 47 ++IPV6_NEXTHOP = 48 ++IPV6_HOPOPTS = 49 ++IPV6_DSTOPTS = 50 ++IPV6_RTHDR = 51 ++IPV6_RECVTCLASS = 57 ++IPV6_AUTOFLOWLABEL = 59 ++IPV6_TCLASS = 61 ++IPV6_DONTFRAG = 62 ++IPV6_PREFER_TEMPADDR = 63 ++IPV6_ADD_MEMBERSHIP = IPV6_JOIN_GROUP ++IPV6_DROP_MEMBERSHIP = IPV6_LEAVE_GROUP ++IPV6_RXHOPOPTS = IPV6_HOPOPTS ++IPV6_RXDSTOPTS = IPV6_DSTOPTS ++SOL_IPV6 = 41 ++SOL_ICMPV6 = 58 ++IPV6_DEFAULT_MULTICAST_HOPS = 1 ++IPV6_DEFAULT_MULTICAST_LOOP = 1 ++IPV6_PORTRANGE_DEFAULT = 0 ++IPV6_PORTRANGE_HIGH = 1 ++IPV6_PORTRANGE_LOW = 2 ++IPV6_RTHDR_LOOSE = 0 ++IPV6_RTHDR_STRICT = 1 ++IPV6_RTHDR_TYPE_0 = 0 ++IPV6CTL_FORWARDING = 1 ++IPV6CTL_SENDREDIRECTS = 2 ++IPV6CTL_DEFHLIM = 3 ++IPV6CTL_FORWSRCRT = 5 ++IPV6CTL_STATS = 6 ++IPV6CTL_MRTSTATS = 7 ++IPV6CTL_MRTPROTO = 8 ++IPV6CTL_MAXFRAGPACKETS = 9 ++IPV6CTL_SOURCECHECK = 10 ++IPV6CTL_SOURCECHECK_LOGINT = 11 ++IPV6CTL_ACCEPT_RTADV = 12 ++IPV6CTL_KEEPFAITH = 13 ++IPV6CTL_LOG_INTERVAL = 14 ++IPV6CTL_HDRNESTLIMIT = 15 ++IPV6CTL_DAD_COUNT = 16 ++IPV6CTL_AUTO_FLOWLABEL = 17 ++IPV6CTL_DEFMCASTHLIM = 18 ++IPV6CTL_GIF_HLIM = 19 ++IPV6CTL_KAME_VERSION = 20 ++IPV6CTL_USE_DEPRECATED = 21 ++IPV6CTL_RR_PRUNE = 22 ++IPV6CTL_V6ONLY = 24 ++IPV6CTL_RTEXPIRE = 25 ++IPV6CTL_RTMINEXPIRE = 26 ++IPV6CTL_RTMAXCACHE = 27 ++IPV6CTL_USETEMPADDR = 32 ++IPV6CTL_TEMPPLTIME = 33 ++IPV6CTL_TEMPVLTIME = 34 ++IPV6CTL_AUTO_LINKLOCAL = 35 ++IPV6CTL_RIP6STATS = 36 ++IPV6CTL_PREFER_TEMPADDR = 37 ++IPV6CTL_ADDRCTLPOLICY = 38 ++IPV6CTL_USE_DEFAULTZONE = 39 ++IPV6CTL_MAXFRAGS = 41 ++IPV6CTL_MCAST_PMTU = 44 ++IPV6CTL_STEALTH = 45 ++ICMPV6CTL_ND6_ONLINKNSRFC4861 = 47 ++IPV6CTL_MAXID = 48 ++ ++# Included from endian.h ++_ENDIAN_H = 1 ++__LITTLE_ENDIAN = 1234 ++__BIG_ENDIAN = 4321 ++__PDP_ENDIAN = 3412 ++ ++# Included from bits/endian.h ++__BYTE_ORDER = __LITTLE_ENDIAN ++__FLOAT_WORD_ORDER = __BYTE_ORDER ++LITTLE_ENDIAN = __LITTLE_ENDIAN ++BIG_ENDIAN = __BIG_ENDIAN ++PDP_ENDIAN = __PDP_ENDIAN ++BYTE_ORDER = __BYTE_ORDER ++ ++# Included from bits/byteswap.h ++_BITS_BYTESWAP_H = 1 ++def __bswap_constant_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_constant_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_constant_64(x): return \ ++ ++def __bswap_64(x): return \ ++ ++def htobe16(x): return __bswap_16 (x) ++ ++def htole16(x): return (x) ++ ++def be16toh(x): return __bswap_16 (x) ++ ++def le16toh(x): return (x) ++ ++def htobe32(x): return __bswap_32 (x) ++ ++def htole32(x): return (x) ++ ++def be32toh(x): return __bswap_32 (x) ++ ++def le32toh(x): return (x) ++ ++def htobe64(x): return __bswap_64 (x) ++ ++def htole64(x): return (x) ++ ++def be64toh(x): return __bswap_64 (x) ++ ++def le64toh(x): return (x) ++ ++def htobe16(x): return (x) ++ ++def htole16(x): return __bswap_16 (x) ++ ++def be16toh(x): return (x) ++ ++def le16toh(x): return __bswap_16 (x) ++ ++def htobe32(x): return (x) ++ ++def htole32(x): return __bswap_32 (x) ++ ++def be32toh(x): return (x) ++ ++def le32toh(x): return __bswap_32 (x) ++ ++def htobe64(x): return (x) ++ ++def htole64(x): return __bswap_64 (x) ++ ++def be64toh(x): return (x) ++ ++def le64toh(x): return __bswap_64 (x) ++ ++def ntohl(x): return (x) ++ ++def ntohs(x): return (x) ++ ++def htonl(x): return (x) ++ ++def htons(x): return (x) ++ ++def ntohl(x): return __bswap_32 (x) ++ ++def ntohs(x): return __bswap_16 (x) ++ ++def htonl(x): return __bswap_32 (x) ++ ++def htons(x): return __bswap_16 (x) ++ ++def IN6_IS_ADDR_UNSPECIFIED(a): return \ ++ ++def IN6_IS_ADDR_LOOPBACK(a): return \ ++ ++def IN6_IS_ADDR_LINKLOCAL(a): return \ ++ ++def IN6_IS_ADDR_SITELOCAL(a): return \ ++ ++def IN6_IS_ADDR_V4MAPPED(a): return \ ++ ++def IN6_IS_ADDR_V4COMPAT(a): return \ ++ ++def IN6_IS_ADDR_MC_NODELOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_LINKLOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_SITELOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_ORGLOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_GLOBAL(a): return \ ++ +--- /dev/null ++++ b/Lib/plat-gnukfreebsd7/TYPES.py +@@ -0,0 +1,303 @@ ++# Generated by h2py from /usr/include/sys/types.h ++_SYS_TYPES_H = 1 ++ ++# Included from features.h ++_FEATURES_H = 1 ++__USE_ANSI = 1 ++__FAVOR_BSD = 1 ++_ISOC99_SOURCE = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 200809 ++_XOPEN_SOURCE = 700 ++_XOPEN_SOURCE_EXTENDED = 1 ++_LARGEFILE64_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++_ATFILE_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++__USE_ISOC99 = 1 ++__USE_ISOC95 = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 2 ++_POSIX_C_SOURCE = 199506 ++_POSIX_C_SOURCE = 200112 ++_POSIX_C_SOURCE = 200809 ++__USE_POSIX_IMPLICITLY = 1 ++__USE_POSIX = 1 ++__USE_POSIX2 = 1 ++__USE_POSIX199309 = 1 ++__USE_POSIX199506 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN2K8 = 1 ++_ATFILE_SOURCE = 1 ++__USE_XOPEN = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_UNIX98 = 1 ++_LARGEFILE_SOURCE = 1 ++__USE_XOPEN2K8 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_FILE_OFFSET64 = 1 ++__USE_MISC = 1 ++__USE_BSD = 1 ++__USE_SVID = 1 ++__USE_ATFILE = 1 ++__USE_GNU = 1 ++__USE_REENTRANT = 1 ++__USE_FORTIFY_LEVEL = 2 ++__USE_FORTIFY_LEVEL = 1 ++__USE_FORTIFY_LEVEL = 0 ++ ++# Included from bits/predefs.h ++__STDC_IEC_559__ = 1 ++__STDC_IEC_559_COMPLEX__ = 1 ++__STDC_ISO_10646__ = 200009 ++__GNU_LIBRARY__ = 6 ++__GLIBC__ = 2 ++__GLIBC_MINOR__ = 11 ++__GLIBC_HAVE_LONG_LONG = 1 ++ ++# Included from sys/cdefs.h ++_SYS_CDEFS_H = 1 ++def __NTH(fct): return fct ++ ++def __NTH(fct): return fct ++ ++def __P(args): return args ++ ++def __PMT(args): return args ++ ++def __STRING(x): return #x ++ ++def __bos(ptr): return __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) ++ ++def __bos0(ptr): return __builtin_object_size (ptr, 0) ++ ++def __warnattr(msg): return __attribute__((__warning__ (msg))) ++ ++__flexarr = [] ++__flexarr = [0] ++__flexarr = [] ++__flexarr = [1] ++def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ++ ++def __attribute__(xyz): return ++ ++def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ++ ++def __attribute_format_arg__(x): return ++ ++ ++# Included from bits/wordsize.h ++__WORDSIZE = 32 ++__LDBL_COMPAT = 1 ++def __LDBL_REDIR_DECL(name): return \ ++ ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_EXTERN_INLINES = 1 ++__USE_EXTERN_INLINES_IN_LIBC = 1 ++ ++# Included from gnu/stubs.h ++ ++# Included from bits/types.h ++_BITS_TYPES_H = 1 ++__S32_TYPE = int ++__SWORD_TYPE = int ++__SLONG32_TYPE = int ++ ++# Included from bits/typesizes.h ++_BITS_TYPESIZES_H = 1 ++__PID_T_TYPE = __S32_TYPE ++__CLOCK_T_TYPE = __S32_TYPE ++__SWBLK_T_TYPE = __S32_TYPE ++__CLOCKID_T_TYPE = __S32_TYPE ++__TIMER_T_TYPE = __S32_TYPE ++__SSIZE_T_TYPE = __SWORD_TYPE ++__FD_SETSIZE = 1024 ++ ++# Included from time.h ++_TIME_H = 1 ++ ++# Included from bits/time.h ++_BITS_TIME_H = 1 ++CLOCKS_PER_SEC = 1000000 ++CLK_TCK = 128 ++CLOCK_REALTIME = 0 ++CLOCK_PROCESS_CPUTIME_ID = 2 ++CLOCK_THREAD_CPUTIME_ID = 3 ++CLOCK_MONOTONIC = 4 ++CLOCK_VIRTUAL = 1 ++CLOCK_PROF = 2 ++CLOCK_UPTIME = 5 ++CLOCK_UPTIME_PRECISE = 7 ++CLOCK_UPTIME_FAST = 8 ++CLOCK_REALTIME_PRECISE = 9 ++CLOCK_REALTIME_FAST = 10 ++CLOCK_MONOTONIC_PRECISE = 11 ++CLOCK_MONOTONIC_FAST = 12 ++CLOCK_SECOND = 13 ++TIMER_RELTIME = 0 ++TIMER_ABSTIME = 1 ++_STRUCT_TIMEVAL = 1 ++CLK_TCK = CLOCKS_PER_SEC ++__clock_t_defined = 1 ++__time_t_defined = 1 ++__clockid_t_defined = 1 ++__timer_t_defined = 1 ++__timespec_defined = 1 ++ ++# Included from xlocale.h ++_XLOCALE_H = 1 ++def __isleap(year): return \ ++ ++__BIT_TYPES_DEFINED__ = 1 ++ ++# Included from endian.h ++_ENDIAN_H = 1 ++__LITTLE_ENDIAN = 1234 ++__BIG_ENDIAN = 4321 ++__PDP_ENDIAN = 3412 ++ ++# Included from bits/endian.h ++__BYTE_ORDER = __LITTLE_ENDIAN ++__FLOAT_WORD_ORDER = __BYTE_ORDER ++LITTLE_ENDIAN = __LITTLE_ENDIAN ++BIG_ENDIAN = __BIG_ENDIAN ++PDP_ENDIAN = __PDP_ENDIAN ++BYTE_ORDER = __BYTE_ORDER ++ ++# Included from bits/byteswap.h ++_BITS_BYTESWAP_H = 1 ++def __bswap_constant_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_constant_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_constant_64(x): return \ ++ ++def __bswap_64(x): return \ ++ ++def htobe16(x): return __bswap_16 (x) ++ ++def htole16(x): return (x) ++ ++def be16toh(x): return __bswap_16 (x) ++ ++def le16toh(x): return (x) ++ ++def htobe32(x): return __bswap_32 (x) ++ ++def htole32(x): return (x) ++ ++def be32toh(x): return __bswap_32 (x) ++ ++def le32toh(x): return (x) ++ ++def htobe64(x): return __bswap_64 (x) ++ ++def htole64(x): return (x) ++ ++def be64toh(x): return __bswap_64 (x) ++ ++def le64toh(x): return (x) ++ ++def htobe16(x): return (x) ++ ++def htole16(x): return __bswap_16 (x) ++ ++def be16toh(x): return (x) ++ ++def le16toh(x): return __bswap_16 (x) ++ ++def htobe32(x): return (x) ++ ++def htole32(x): return __bswap_32 (x) ++ ++def be32toh(x): return (x) ++ ++def le32toh(x): return __bswap_32 (x) ++ ++def htobe64(x): return (x) ++ ++def htole64(x): return __bswap_64 (x) ++ ++def be64toh(x): return (x) ++ ++def le64toh(x): return __bswap_64 (x) ++ ++ ++# Included from sys/select.h ++_SYS_SELECT_H = 1 ++ ++# Included from bits/select.h ++def __FD_ZERO(fdsp): return \ ++ ++def __FD_ZERO(set): return \ ++ ++ ++# Included from bits/sigset.h ++_SIGSET_H_types = 1 ++_SIGSET_H_fns = 1 ++def __sigword(sig): return (((sig) - 1) >> 5) ++ ++def __sigemptyset(set): return \ ++ ++def __sigfillset(set): return \ ++ ++def __sigisemptyset(set): return \ ++ ++def __FDELT(d): return ((d) / __NFDBITS) ++ ++FD_SETSIZE = __FD_SETSIZE ++def FD_ZERO(fdsetp): return __FD_ZERO (fdsetp) ++ ++ ++# Included from sys/sysmacros.h ++_SYS_SYSMACROS_H = 1 ++def minor(dev): return ((int)((dev) & (-65281))) ++ ++def gnu_dev_major(dev): return major (dev) ++ ++def gnu_dev_minor(dev): return minor (dev) ++ ++ ++# Included from bits/pthreadtypes.h ++_BITS_PTHREADTYPES_H = 1 ++ ++# Included from bits/sched.h ++SCHED_OTHER = 2 ++SCHED_FIFO = 1 ++SCHED_RR = 3 ++CSIGNAL = 0x000000ff ++CLONE_VM = 0x00000100 ++CLONE_FS = 0x00000200 ++CLONE_FILES = 0x00000400 ++CLONE_SIGHAND = 0x00000800 ++CLONE_PTRACE = 0x00002000 ++CLONE_VFORK = 0x00004000 ++CLONE_SYSVSEM = 0x00040000 ++__defined_schedparam = 1 ++__CPU_SETSIZE = 128 ++def __CPUELT(cpu): return ((cpu) / __NCPUBITS) ++ ++def __CPU_ALLOC_SIZE(count): return \ ++ ++def __CPU_ALLOC(count): return __sched_cpualloc (count) ++ ++def __CPU_FREE(cpuset): return __sched_cpufree (cpuset) ++ +--- /dev/null ++++ b/Lib/plat-gnukfreebsd8/DLFCN.py +@@ -0,0 +1,118 @@ ++# Generated by h2py from /usr/include/dlfcn.h ++_DLFCN_H = 1 ++ ++# Included from features.h ++_FEATURES_H = 1 ++__USE_ANSI = 1 ++__FAVOR_BSD = 1 ++_ISOC99_SOURCE = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 200809 ++_XOPEN_SOURCE = 700 ++_XOPEN_SOURCE_EXTENDED = 1 ++_LARGEFILE64_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++_ATFILE_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++__USE_ISOC99 = 1 ++__USE_ISOC95 = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 2 ++_POSIX_C_SOURCE = 199506 ++_POSIX_C_SOURCE = 200112 ++_POSIX_C_SOURCE = 200809 ++__USE_POSIX_IMPLICITLY = 1 ++__USE_POSIX = 1 ++__USE_POSIX2 = 1 ++__USE_POSIX199309 = 1 ++__USE_POSIX199506 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN2K8 = 1 ++_ATFILE_SOURCE = 1 ++__USE_XOPEN = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_UNIX98 = 1 ++_LARGEFILE_SOURCE = 1 ++__USE_XOPEN2K8 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_FILE_OFFSET64 = 1 ++__USE_MISC = 1 ++__USE_BSD = 1 ++__USE_SVID = 1 ++__USE_ATFILE = 1 ++__USE_GNU = 1 ++__USE_REENTRANT = 1 ++__USE_FORTIFY_LEVEL = 2 ++__USE_FORTIFY_LEVEL = 1 ++__USE_FORTIFY_LEVEL = 0 ++ ++# Included from bits/predefs.h ++__STDC_IEC_559__ = 1 ++__STDC_IEC_559_COMPLEX__ = 1 ++__STDC_ISO_10646__ = 200009 ++__GNU_LIBRARY__ = 6 ++__GLIBC__ = 2 ++__GLIBC_MINOR__ = 11 ++__GLIBC_HAVE_LONG_LONG = 1 ++ ++# Included from sys/cdefs.h ++_SYS_CDEFS_H = 1 ++def __NTH(fct): return fct ++ ++def __NTH(fct): return fct ++ ++def __P(args): return args ++ ++def __PMT(args): return args ++ ++def __STRING(x): return #x ++ ++def __bos(ptr): return __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) ++ ++def __bos0(ptr): return __builtin_object_size (ptr, 0) ++ ++def __warnattr(msg): return __attribute__((__warning__ (msg))) ++ ++__flexarr = [] ++__flexarr = [0] ++__flexarr = [] ++__flexarr = [1] ++def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ++ ++def __attribute__(xyz): return ++ ++def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ++ ++def __attribute_format_arg__(x): return ++ ++ ++# Included from bits/wordsize.h ++__WORDSIZE = 32 ++__LDBL_COMPAT = 1 ++def __LDBL_REDIR_DECL(name): return \ ++ ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_EXTERN_INLINES = 1 ++__USE_EXTERN_INLINES_IN_LIBC = 1 ++ ++# Included from gnu/stubs.h ++ ++# Included from bits/dlfcn.h ++RTLD_LAZY = 0x00001 ++RTLD_NOW = 0x00002 ++RTLD_BINDING_MASK = 0x3 ++RTLD_NOLOAD = 0x00004 ++RTLD_DEEPBIND = 0x00008 ++RTLD_GLOBAL = 0x00100 ++RTLD_LOCAL = 0 ++RTLD_NODELETE = 0x01000 ++LM_ID_BASE = 0 ++LM_ID_NEWLM = -1 +--- /dev/null ++++ b/Lib/plat-gnukfreebsd8/IN.py +@@ -0,0 +1,809 @@ ++# Generated by h2py from /usr/include/netinet/in.h ++_NETINET_IN_H = 1 ++ ++# Included from features.h ++_FEATURES_H = 1 ++__USE_ANSI = 1 ++__FAVOR_BSD = 1 ++_ISOC99_SOURCE = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 200809 ++_XOPEN_SOURCE = 700 ++_XOPEN_SOURCE_EXTENDED = 1 ++_LARGEFILE64_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++_ATFILE_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++__USE_ISOC99 = 1 ++__USE_ISOC95 = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 2 ++_POSIX_C_SOURCE = 199506 ++_POSIX_C_SOURCE = 200112 ++_POSIX_C_SOURCE = 200809 ++__USE_POSIX_IMPLICITLY = 1 ++__USE_POSIX = 1 ++__USE_POSIX2 = 1 ++__USE_POSIX199309 = 1 ++__USE_POSIX199506 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN2K8 = 1 ++_ATFILE_SOURCE = 1 ++__USE_XOPEN = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_UNIX98 = 1 ++_LARGEFILE_SOURCE = 1 ++__USE_XOPEN2K8 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_FILE_OFFSET64 = 1 ++__USE_MISC = 1 ++__USE_BSD = 1 ++__USE_SVID = 1 ++__USE_ATFILE = 1 ++__USE_GNU = 1 ++__USE_REENTRANT = 1 ++__USE_FORTIFY_LEVEL = 2 ++__USE_FORTIFY_LEVEL = 1 ++__USE_FORTIFY_LEVEL = 0 ++ ++# Included from bits/predefs.h ++__STDC_IEC_559__ = 1 ++__STDC_IEC_559_COMPLEX__ = 1 ++__STDC_ISO_10646__ = 200009 ++__GNU_LIBRARY__ = 6 ++__GLIBC__ = 2 ++__GLIBC_MINOR__ = 11 ++__GLIBC_HAVE_LONG_LONG = 1 ++ ++# Included from sys/cdefs.h ++_SYS_CDEFS_H = 1 ++def __NTH(fct): return fct ++ ++def __NTH(fct): return fct ++ ++def __P(args): return args ++ ++def __PMT(args): return args ++ ++def __STRING(x): return #x ++ ++def __bos(ptr): return __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) ++ ++def __bos0(ptr): return __builtin_object_size (ptr, 0) ++ ++def __warnattr(msg): return __attribute__((__warning__ (msg))) ++ ++__flexarr = [] ++__flexarr = [0] ++__flexarr = [] ++__flexarr = [1] ++def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ++ ++def __attribute__(xyz): return ++ ++def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ++ ++def __attribute_format_arg__(x): return ++ ++ ++# Included from bits/wordsize.h ++__WORDSIZE = 32 ++__LDBL_COMPAT = 1 ++def __LDBL_REDIR_DECL(name): return \ ++ ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_EXTERN_INLINES = 1 ++__USE_EXTERN_INLINES_IN_LIBC = 1 ++ ++# Included from gnu/stubs.h ++ ++# Included from stdint.h ++_STDINT_H = 1 ++ ++# Included from bits/wchar.h ++_BITS_WCHAR_H = 1 ++__WCHAR_MAX = (2147483647) ++__WCHAR_MIN = (-__WCHAR_MAX - 1) ++def __INT64_C(c): return c ## L ++ ++def __UINT64_C(c): return c ## UL ++ ++def __INT64_C(c): return c ## LL ++ ++def __UINT64_C(c): return c ## ULL ++ ++INT8_MIN = (-128) ++INT16_MIN = (-32767-1) ++INT32_MIN = (-2147483647-1) ++INT64_MIN = (-__INT64_C(9223372036854775807)-1) ++INT8_MAX = (127) ++INT16_MAX = (32767) ++INT32_MAX = (2147483647) ++INT64_MAX = (__INT64_C(9223372036854775807)) ++UINT8_MAX = (255) ++UINT16_MAX = (65535) ++UINT64_MAX = (__UINT64_C(18446744073709551615)) ++INT_LEAST8_MIN = (-128) ++INT_LEAST16_MIN = (-32767-1) ++INT_LEAST32_MIN = (-2147483647-1) ++INT_LEAST64_MIN = (-__INT64_C(9223372036854775807)-1) ++INT_LEAST8_MAX = (127) ++INT_LEAST16_MAX = (32767) ++INT_LEAST32_MAX = (2147483647) ++INT_LEAST64_MAX = (__INT64_C(9223372036854775807)) ++UINT_LEAST8_MAX = (255) ++UINT_LEAST16_MAX = (65535) ++UINT_LEAST64_MAX = (__UINT64_C(18446744073709551615)) ++INT_FAST8_MIN = (-128) ++INT_FAST16_MIN = (-9223372036854775807-1) ++INT_FAST32_MIN = (-9223372036854775807-1) ++INT_FAST16_MIN = (-2147483647-1) ++INT_FAST32_MIN = (-2147483647-1) ++INT_FAST64_MIN = (-__INT64_C(9223372036854775807)-1) ++INT_FAST8_MAX = (127) ++INT_FAST16_MAX = (9223372036854775807) ++INT_FAST32_MAX = (9223372036854775807) ++INT_FAST16_MAX = (2147483647) ++INT_FAST32_MAX = (2147483647) ++INT_FAST64_MAX = (__INT64_C(9223372036854775807)) ++UINT_FAST8_MAX = (255) ++UINT_FAST64_MAX = (__UINT64_C(18446744073709551615)) ++INTPTR_MIN = (-9223372036854775807-1) ++INTPTR_MAX = (9223372036854775807) ++INTPTR_MIN = (-2147483647-1) ++INTPTR_MAX = (2147483647) ++INTMAX_MIN = (-__INT64_C(9223372036854775807)-1) ++INTMAX_MAX = (__INT64_C(9223372036854775807)) ++UINTMAX_MAX = (__UINT64_C(18446744073709551615)) ++PTRDIFF_MIN = (-9223372036854775807-1) ++PTRDIFF_MAX = (9223372036854775807) ++PTRDIFF_MIN = (-2147483647-1) ++PTRDIFF_MAX = (2147483647) ++SIG_ATOMIC_MIN = (-2147483647-1) ++SIG_ATOMIC_MAX = (2147483647) ++WCHAR_MIN = __WCHAR_MIN ++WCHAR_MAX = __WCHAR_MAX ++def INT8_C(c): return c ++ ++def INT16_C(c): return c ++ ++def INT32_C(c): return c ++ ++def INT64_C(c): return c ## L ++ ++def INT64_C(c): return c ## LL ++ ++def UINT8_C(c): return c ++ ++def UINT16_C(c): return c ++ ++def UINT32_C(c): return c ## U ++ ++def UINT64_C(c): return c ## UL ++ ++def UINT64_C(c): return c ## ULL ++ ++def INTMAX_C(c): return c ## L ++ ++def UINTMAX_C(c): return c ## UL ++ ++def INTMAX_C(c): return c ## LL ++ ++def UINTMAX_C(c): return c ## ULL ++ ++ ++# Included from sys/socket.h ++_SYS_SOCKET_H = 1 ++ ++# Included from sys/uio.h ++_SYS_UIO_H = 1 ++from TYPES import * ++ ++# Included from bits/uio.h ++_BITS_UIO_H = 1 ++from TYPES import * ++UIO_MAXIOV = 1024 ++ ++# Included from bits/sigset.h ++_SIGSET_H_types = 1 ++_SIGSET_H_fns = 1 ++def __sigword(sig): return (((sig) - 1) >> 5) ++ ++def __sigemptyset(set): return \ ++ ++def __sigfillset(set): return \ ++ ++def __sigisemptyset(set): return \ ++ ++ ++# Included from bits/socket.h ++__BITS_SOCKET_H = 1 ++ ++# Included from limits.h ++_LIBC_LIMITS_H_ = 1 ++MB_LEN_MAX = 16 ++_LIMITS_H = 1 ++CHAR_BIT = 8 ++SCHAR_MIN = (-128) ++SCHAR_MAX = 127 ++UCHAR_MAX = 255 ++CHAR_MIN = 0 ++CHAR_MAX = UCHAR_MAX ++CHAR_MIN = SCHAR_MIN ++CHAR_MAX = SCHAR_MAX ++SHRT_MIN = (-32768) ++SHRT_MAX = 32767 ++USHRT_MAX = 65535 ++INT_MAX = 2147483647 ++LONG_MAX = 9223372036854775807 ++LONG_MAX = 2147483647 ++LONG_MIN = (-LONG_MAX - 1) ++ ++# Included from bits/posix1_lim.h ++_BITS_POSIX1_LIM_H = 1 ++_POSIX_AIO_LISTIO_MAX = 2 ++_POSIX_AIO_MAX = 1 ++_POSIX_ARG_MAX = 4096 ++_POSIX_CHILD_MAX = 25 ++_POSIX_CHILD_MAX = 6 ++_POSIX_DELAYTIMER_MAX = 32 ++_POSIX_HOST_NAME_MAX = 255 ++_POSIX_LINK_MAX = 8 ++_POSIX_LOGIN_NAME_MAX = 9 ++_POSIX_MAX_CANON = 255 ++_POSIX_MAX_INPUT = 255 ++_POSIX_MQ_OPEN_MAX = 8 ++_POSIX_MQ_PRIO_MAX = 32 ++_POSIX_NAME_MAX = 14 ++_POSIX_NGROUPS_MAX = 8 ++_POSIX_NGROUPS_MAX = 0 ++_POSIX_OPEN_MAX = 20 ++_POSIX_OPEN_MAX = 16 ++_POSIX_FD_SETSIZE = _POSIX_OPEN_MAX ++_POSIX_PATH_MAX = 256 ++_POSIX_PIPE_BUF = 512 ++_POSIX_RE_DUP_MAX = 255 ++_POSIX_RTSIG_MAX = 8 ++_POSIX_SEM_NSEMS_MAX = 256 ++_POSIX_SEM_VALUE_MAX = 32767 ++_POSIX_SIGQUEUE_MAX = 32 ++_POSIX_SSIZE_MAX = 32767 ++_POSIX_STREAM_MAX = 8 ++_POSIX_SYMLINK_MAX = 255 ++_POSIX_SYMLOOP_MAX = 8 ++_POSIX_TIMER_MAX = 32 ++_POSIX_TTY_NAME_MAX = 9 ++_POSIX_TZNAME_MAX = 6 ++_POSIX_QLIMIT = 1 ++_POSIX_HIWAT = _POSIX_PIPE_BUF ++_POSIX_UIO_MAXIOV = 16 ++_POSIX_CLOCKRES_MIN = 20000000 ++ ++# Included from bits/local_lim.h ++ ++# Included from sys/syslimits.h ++ARG_MAX = 262144 ++CHILD_MAX = 40 ++LINK_MAX = 32767 ++MAX_CANON = 255 ++MAX_INPUT = 255 ++NAME_MAX = 255 ++NGROUPS_MAX = 1023 ++OPEN_MAX = 64 ++PATH_MAX = 1024 ++PIPE_BUF = 512 ++IOV_MAX = 1024 ++_POSIX_THREAD_KEYS_MAX = 128 ++PTHREAD_KEYS_MAX = 1024 ++_POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4 ++PTHREAD_DESTRUCTOR_ITERATIONS = _POSIX_THREAD_DESTRUCTOR_ITERATIONS ++_POSIX_THREAD_THREADS_MAX = 64 ++PTHREAD_THREADS_MAX = 1024 ++AIO_PRIO_DELTA_MAX = 20 ++PTHREAD_STACK_MIN = 16384 ++TIMER_MAX = 256 ++DELAYTIMER_MAX = 2147483647 ++SSIZE_MAX = LONG_MAX ++NGROUPS_MAX = 8 ++ ++# Included from bits/posix2_lim.h ++_BITS_POSIX2_LIM_H = 1 ++_POSIX2_BC_BASE_MAX = 99 ++_POSIX2_BC_DIM_MAX = 2048 ++_POSIX2_BC_SCALE_MAX = 99 ++_POSIX2_BC_STRING_MAX = 1000 ++_POSIX2_COLL_WEIGHTS_MAX = 2 ++_POSIX2_EXPR_NEST_MAX = 32 ++_POSIX2_LINE_MAX = 2048 ++_POSIX2_RE_DUP_MAX = 255 ++_POSIX2_CHARCLASS_NAME_MAX = 14 ++BC_BASE_MAX = _POSIX2_BC_BASE_MAX ++BC_DIM_MAX = _POSIX2_BC_DIM_MAX ++BC_SCALE_MAX = _POSIX2_BC_SCALE_MAX ++BC_STRING_MAX = _POSIX2_BC_STRING_MAX ++COLL_WEIGHTS_MAX = 255 ++EXPR_NEST_MAX = _POSIX2_EXPR_NEST_MAX ++LINE_MAX = _POSIX2_LINE_MAX ++CHARCLASS_NAME_MAX = 2048 ++RE_DUP_MAX = (0x7fff) ++ ++# Included from bits/xopen_lim.h ++_XOPEN_LIM_H = 1 ++ ++# Included from bits/stdio_lim.h ++L_tmpnam = 20 ++TMP_MAX = 238328 ++FILENAME_MAX = 1024 ++L_ctermid = 9 ++L_cuserid = 9 ++FOPEN_MAX = 64 ++IOV_MAX = 1024 ++_XOPEN_IOV_MAX = _POSIX_UIO_MAXIOV ++NL_ARGMAX = _POSIX_ARG_MAX ++NL_LANGMAX = _POSIX2_LINE_MAX ++NL_MSGMAX = INT_MAX ++NL_NMAX = INT_MAX ++NL_SETMAX = INT_MAX ++NL_TEXTMAX = INT_MAX ++NZERO = 20 ++WORD_BIT = 16 ++WORD_BIT = 32 ++WORD_BIT = 64 ++WORD_BIT = 16 ++WORD_BIT = 32 ++WORD_BIT = 64 ++WORD_BIT = 32 ++LONG_BIT = 32 ++LONG_BIT = 64 ++LONG_BIT = 32 ++LONG_BIT = 64 ++LONG_BIT = 64 ++LONG_BIT = 32 ++ ++# Included from bits/types.h ++_BITS_TYPES_H = 1 ++__S32_TYPE = int ++__SWORD_TYPE = int ++__SLONG32_TYPE = int ++ ++# Included from bits/typesizes.h ++_BITS_TYPESIZES_H = 1 ++__PID_T_TYPE = __S32_TYPE ++__CLOCK_T_TYPE = __S32_TYPE ++__SWBLK_T_TYPE = __S32_TYPE ++__CLOCKID_T_TYPE = __S32_TYPE ++__TIMER_T_TYPE = __S32_TYPE ++__SSIZE_T_TYPE = __SWORD_TYPE ++__FD_SETSIZE = 1024 ++PF_UNSPEC = 0 ++PF_LOCAL = 1 ++PF_UNIX = PF_LOCAL ++PF_FILE = PF_LOCAL ++PF_INET = 2 ++PF_IMPLINK = 3 ++PF_PUP = 4 ++PF_CHAOS = 5 ++PF_NS = 6 ++PF_ISO = 7 ++PF_OSI = PF_ISO ++PF_ECMA = 8 ++PF_DATAKIT = 9 ++PF_CCITT = 10 ++PF_SNA = 11 ++PF_DECnet = 12 ++PF_DLI = 13 ++PF_LAT = 14 ++PF_HYLINK = 15 ++PF_APPLETALK = 16 ++PF_ROUTE = 17 ++PF_LINK = 18 ++PF_XTP = 19 ++PF_COIP = 20 ++PF_CNT = 21 ++PF_RTIP = 22 ++PF_IPX = 23 ++PF_SIP = 24 ++PF_PIP = 25 ++PF_ISDN = 26 ++PF_KEY = 27 ++PF_INET6 = 28 ++PF_NATM = 29 ++PF_ATM = 30 ++PF_HDRCMPLT = 31 ++PF_NETGRAPH = 32 ++PF_MAX = 33 ++AF_UNSPEC = PF_UNSPEC ++AF_LOCAL = PF_LOCAL ++AF_UNIX = PF_UNIX ++AF_FILE = PF_FILE ++AF_INET = PF_INET ++AF_IMPLINK = PF_IMPLINK ++AF_PUP = PF_PUP ++AF_CHAOS = PF_CHAOS ++AF_NS = PF_NS ++AF_ISO = PF_ISO ++AF_OSI = PF_OSI ++AF_ECMA = PF_ECMA ++AF_DATAKIT = PF_DATAKIT ++AF_CCITT = PF_CCITT ++AF_SNA = PF_SNA ++AF_DECnet = PF_DECnet ++AF_DLI = PF_DLI ++AF_LAT = PF_LAT ++AF_HYLINK = PF_HYLINK ++AF_APPLETALK = PF_APPLETALK ++AF_ROUTE = PF_ROUTE ++AF_LINK = PF_LINK ++pseudo_AF_XTP = PF_XTP ++AF_COIP = PF_COIP ++AF_CNT = PF_CNT ++pseudo_AF_RTIP = PF_RTIP ++AF_IPX = PF_IPX ++AF_SIP = PF_SIP ++pseudo_AF_PIP = PF_PIP ++AF_ISDN = PF_ISDN ++AF_E164 = AF_ISDN ++pseudo_AF_KEY = PF_KEY ++AF_INET6 = PF_INET6 ++AF_NATM = PF_NATM ++AF_ATM = PF_ATM ++pseudo_AF_HDRCMPLT = PF_HDRCMPLT ++AF_NETGRAPH = PF_NETGRAPH ++AF_MAX = PF_MAX ++SOMAXCONN = 128 ++ ++# Included from bits/sockaddr.h ++_BITS_SOCKADDR_H = 1 ++def __SOCKADDR_COMMON(sa_prefix): return \ ++ ++_HAVE_SA_LEN = 1 ++_SS_SIZE = 128 ++def CMSG_FIRSTHDR(mhdr): return \ ++ ++CMGROUP_MAX = 16 ++SOL_SOCKET = 0xffff ++LOCAL_PEERCRED = 0x001 ++LOCAL_CREDS = 0x002 ++LOCAL_CONNWAIT = 0x004 ++ ++# Included from bits/socket2.h ++def IN_CLASSA(a): return ((((in_addr_t)(a)) & (-2147483648)) == 0) ++ ++IN_CLASSA_NET = (-16777216) ++IN_CLASSA_NSHIFT = 24 ++IN_CLASSA_HOST = ((-1) & ~IN_CLASSA_NET) ++IN_CLASSA_MAX = 128 ++def IN_CLASSB(a): return ((((in_addr_t)(a)) & (-1073741824)) == (-2147483648)) ++ ++IN_CLASSB_NET = (-65536) ++IN_CLASSB_NSHIFT = 16 ++IN_CLASSB_HOST = ((-1) & ~IN_CLASSB_NET) ++IN_CLASSB_MAX = 65536 ++def IN_CLASSC(a): return ((((in_addr_t)(a)) & (-536870912)) == (-1073741824)) ++ ++IN_CLASSC_NET = (-256) ++IN_CLASSC_NSHIFT = 8 ++IN_CLASSC_HOST = ((-1) & ~IN_CLASSC_NET) ++def IN_CLASSD(a): return ((((in_addr_t)(a)) & (-268435456)) == (-536870912)) ++ ++def IN_MULTICAST(a): return IN_CLASSD(a) ++ ++def IN_EXPERIMENTAL(a): return ((((in_addr_t)(a)) & (-536870912)) == (-536870912)) ++ ++def IN_BADCLASS(a): return ((((in_addr_t)(a)) & (-268435456)) == (-268435456)) ++ ++IN_LOOPBACKNET = 127 ++INET_ADDRSTRLEN = 16 ++INET6_ADDRSTRLEN = 46 ++ ++# Included from bits/in.h ++IMPLINK_IP = 155 ++IMPLINK_LOWEXPER = 156 ++IMPLINK_HIGHEXPER = 158 ++IPPROTO_DIVERT = 258 ++SOL_IP = 0 ++IP_OPTIONS = 1 ++IP_HDRINCL = 2 ++IP_TOS = 3 ++IP_TTL = 4 ++IP_RECVOPTS = 5 ++IP_RECVRETOPTS = 6 ++IP_RECVDSTADDR = 7 ++IP_SENDSRCADDR = IP_RECVDSTADDR ++IP_RETOPTS = 8 ++IP_MULTICAST_IF = 9 ++IP_MULTICAST_TTL = 10 ++IP_MULTICAST_LOOP = 11 ++IP_ADD_MEMBERSHIP = 12 ++IP_DROP_MEMBERSHIP = 13 ++IP_MULTICAST_VIF = 14 ++IP_RSVP_ON = 15 ++IP_RSVP_OFF = 16 ++IP_RSVP_VIF_ON = 17 ++IP_RSVP_VIF_OFF = 18 ++IP_PORTRANGE = 19 ++IP_RECVIF = 20 ++IP_IPSEC_POLICY = 21 ++IP_FAITH = 22 ++IP_ONESBCAST = 23 ++IP_NONLOCALOK = 24 ++IP_FW_TABLE_ADD = 40 ++IP_FW_TABLE_DEL = 41 ++IP_FW_TABLE_FLUSH = 42 ++IP_FW_TABLE_GETSIZE = 43 ++IP_FW_TABLE_LIST = 44 ++IP_FW_ADD = 50 ++IP_FW_DEL = 51 ++IP_FW_FLUSH = 52 ++IP_FW_ZERO = 53 ++IP_FW_GET = 54 ++IP_FW_RESETLOG = 55 ++IP_FW_NAT_CFG = 56 ++IP_FW_NAT_DEL = 57 ++IP_FW_NAT_GET_CONFIG = 58 ++IP_FW_NAT_GET_LOG = 59 ++IP_DUMMYNET_CONFIGURE = 60 ++IP_DUMMYNET_DEL = 61 ++IP_DUMMYNET_FLUSH = 62 ++IP_DUMMYNET_GET = 64 ++IP_RECVTTL = 65 ++IP_MINTTL = 66 ++IP_DONTFRAG = 67 ++IP_ADD_SOURCE_MEMBERSHIP = 70 ++IP_DROP_SOURCE_MEMBERSHIP = 71 ++IP_BLOCK_SOURCE = 72 ++IP_UNBLOCK_SOURCE = 73 ++IP_MSFILTER = 74 ++MCAST_JOIN_GROUP = 80 ++MCAST_LEAVE_GROUP = 81 ++MCAST_JOIN_SOURCE_GROUP = 82 ++MCAST_LEAVE_SOURCE_GROUP = 83 ++MCAST_BLOCK_SOURCE = 84 ++MCAST_UNBLOCK_SOURCE = 85 ++IP_DEFAULT_MULTICAST_TTL = 1 ++IP_DEFAULT_MULTICAST_LOOP = 1 ++IP_MIN_MEMBERSHIPS = 31 ++IP_MAX_MEMBERSHIPS = 4095 ++IP_MAX_SOURCE_FILTER = 1024 ++MCAST_UNDEFINED = 0 ++MCAST_INCLUDE = 1 ++MCAST_EXCLUDE = 2 ++IP_PORTRANGE_DEFAULT = 0 ++IP_PORTRANGE_HIGH = 1 ++IP_PORTRANGE_LOW = 2 ++IPCTL_FORWARDING = 1 ++IPCTL_SENDREDIRECTS = 2 ++IPCTL_DEFTTL = 3 ++IPCTL_DEFMTU = 4 ++IPCTL_RTEXPIRE = 5 ++IPCTL_RTMINEXPIRE = 6 ++IPCTL_RTMAXCACHE = 7 ++IPCTL_SOURCEROUTE = 8 ++IPCTL_DIRECTEDBROADCAST = 9 ++IPCTL_INTRQMAXLEN = 10 ++IPCTL_INTRQDROPS = 11 ++IPCTL_STATS = 12 ++IPCTL_ACCEPTSOURCEROUTE = 13 ++IPCTL_FASTFORWARDING = 14 ++IPCTL_KEEPFAITH = 15 ++IPCTL_GIF_TTL = 16 ++IPCTL_MAXID = 17 ++IPV6_SOCKOPT_RESERVED1 = 3 ++IPV6_UNICAST_HOPS = 4 ++IPV6_MULTICAST_IF = 9 ++IPV6_MULTICAST_HOPS = 10 ++IPV6_MULTICAST_LOOP = 11 ++IPV6_JOIN_GROUP = 12 ++IPV6_LEAVE_GROUP = 13 ++IPV6_PORTRANGE = 14 ++ICMP6_FILTER = 18 ++IPV6_CHECKSUM = 26 ++IPV6_V6ONLY = 27 ++IPV6_IPSEC_POLICY = 28 ++IPV6_FAITH = 29 ++IPV6_FW_ADD = 30 ++IPV6_FW_DEL = 31 ++IPV6_FW_FLUSH = 32 ++IPV6_FW_ZERO = 33 ++IPV6_FW_GET = 34 ++IPV6_RTHDRDSTOPTS = 35 ++IPV6_RECVPKTINFO = 36 ++IPV6_RECVHOPLIMIT = 37 ++IPV6_RECVRTHDR = 38 ++IPV6_RECVHOPOPTS = 39 ++IPV6_RECVDSTOPTS = 40 ++IPV6_USE_MIN_MTU = 42 ++IPV6_RECVPATHMTU = 43 ++IPV6_PATHMTU = 44 ++IPV6_PKTINFO = 46 ++IPV6_HOPLIMIT = 47 ++IPV6_NEXTHOP = 48 ++IPV6_HOPOPTS = 49 ++IPV6_DSTOPTS = 50 ++IPV6_RTHDR = 51 ++IPV6_RECVTCLASS = 57 ++IPV6_AUTOFLOWLABEL = 59 ++IPV6_TCLASS = 61 ++IPV6_DONTFRAG = 62 ++IPV6_PREFER_TEMPADDR = 63 ++IPV6_ADD_MEMBERSHIP = IPV6_JOIN_GROUP ++IPV6_DROP_MEMBERSHIP = IPV6_LEAVE_GROUP ++IPV6_RXHOPOPTS = IPV6_HOPOPTS ++IPV6_RXDSTOPTS = IPV6_DSTOPTS ++SOL_IPV6 = 41 ++SOL_ICMPV6 = 58 ++IPV6_DEFAULT_MULTICAST_HOPS = 1 ++IPV6_DEFAULT_MULTICAST_LOOP = 1 ++IPV6_PORTRANGE_DEFAULT = 0 ++IPV6_PORTRANGE_HIGH = 1 ++IPV6_PORTRANGE_LOW = 2 ++IPV6_RTHDR_LOOSE = 0 ++IPV6_RTHDR_STRICT = 1 ++IPV6_RTHDR_TYPE_0 = 0 ++IPV6CTL_FORWARDING = 1 ++IPV6CTL_SENDREDIRECTS = 2 ++IPV6CTL_DEFHLIM = 3 ++IPV6CTL_FORWSRCRT = 5 ++IPV6CTL_STATS = 6 ++IPV6CTL_MRTSTATS = 7 ++IPV6CTL_MRTPROTO = 8 ++IPV6CTL_MAXFRAGPACKETS = 9 ++IPV6CTL_SOURCECHECK = 10 ++IPV6CTL_SOURCECHECK_LOGINT = 11 ++IPV6CTL_ACCEPT_RTADV = 12 ++IPV6CTL_KEEPFAITH = 13 ++IPV6CTL_LOG_INTERVAL = 14 ++IPV6CTL_HDRNESTLIMIT = 15 ++IPV6CTL_DAD_COUNT = 16 ++IPV6CTL_AUTO_FLOWLABEL = 17 ++IPV6CTL_DEFMCASTHLIM = 18 ++IPV6CTL_GIF_HLIM = 19 ++IPV6CTL_KAME_VERSION = 20 ++IPV6CTL_USE_DEPRECATED = 21 ++IPV6CTL_RR_PRUNE = 22 ++IPV6CTL_V6ONLY = 24 ++IPV6CTL_RTEXPIRE = 25 ++IPV6CTL_RTMINEXPIRE = 26 ++IPV6CTL_RTMAXCACHE = 27 ++IPV6CTL_USETEMPADDR = 32 ++IPV6CTL_TEMPPLTIME = 33 ++IPV6CTL_TEMPVLTIME = 34 ++IPV6CTL_AUTO_LINKLOCAL = 35 ++IPV6CTL_RIP6STATS = 36 ++IPV6CTL_PREFER_TEMPADDR = 37 ++IPV6CTL_ADDRCTLPOLICY = 38 ++IPV6CTL_USE_DEFAULTZONE = 39 ++IPV6CTL_MAXFRAGS = 41 ++IPV6CTL_MCAST_PMTU = 44 ++IPV6CTL_STEALTH = 45 ++ICMPV6CTL_ND6_ONLINKNSRFC4861 = 47 ++IPV6CTL_MAXID = 48 ++ ++# Included from endian.h ++_ENDIAN_H = 1 ++__LITTLE_ENDIAN = 1234 ++__BIG_ENDIAN = 4321 ++__PDP_ENDIAN = 3412 ++ ++# Included from bits/endian.h ++__BYTE_ORDER = __LITTLE_ENDIAN ++__FLOAT_WORD_ORDER = __BYTE_ORDER ++LITTLE_ENDIAN = __LITTLE_ENDIAN ++BIG_ENDIAN = __BIG_ENDIAN ++PDP_ENDIAN = __PDP_ENDIAN ++BYTE_ORDER = __BYTE_ORDER ++ ++# Included from bits/byteswap.h ++_BITS_BYTESWAP_H = 1 ++def __bswap_constant_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_constant_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_constant_64(x): return \ ++ ++def __bswap_64(x): return \ ++ ++def htobe16(x): return __bswap_16 (x) ++ ++def htole16(x): return (x) ++ ++def be16toh(x): return __bswap_16 (x) ++ ++def le16toh(x): return (x) ++ ++def htobe32(x): return __bswap_32 (x) ++ ++def htole32(x): return (x) ++ ++def be32toh(x): return __bswap_32 (x) ++ ++def le32toh(x): return (x) ++ ++def htobe64(x): return __bswap_64 (x) ++ ++def htole64(x): return (x) ++ ++def be64toh(x): return __bswap_64 (x) ++ ++def le64toh(x): return (x) ++ ++def htobe16(x): return (x) ++ ++def htole16(x): return __bswap_16 (x) ++ ++def be16toh(x): return (x) ++ ++def le16toh(x): return __bswap_16 (x) ++ ++def htobe32(x): return (x) ++ ++def htole32(x): return __bswap_32 (x) ++ ++def be32toh(x): return (x) ++ ++def le32toh(x): return __bswap_32 (x) ++ ++def htobe64(x): return (x) ++ ++def htole64(x): return __bswap_64 (x) ++ ++def be64toh(x): return (x) ++ ++def le64toh(x): return __bswap_64 (x) ++ ++def ntohl(x): return (x) ++ ++def ntohs(x): return (x) ++ ++def htonl(x): return (x) ++ ++def htons(x): return (x) ++ ++def ntohl(x): return __bswap_32 (x) ++ ++def ntohs(x): return __bswap_16 (x) ++ ++def htonl(x): return __bswap_32 (x) ++ ++def htons(x): return __bswap_16 (x) ++ ++def IN6_IS_ADDR_UNSPECIFIED(a): return \ ++ ++def IN6_IS_ADDR_LOOPBACK(a): return \ ++ ++def IN6_IS_ADDR_LINKLOCAL(a): return \ ++ ++def IN6_IS_ADDR_SITELOCAL(a): return \ ++ ++def IN6_IS_ADDR_V4MAPPED(a): return \ ++ ++def IN6_IS_ADDR_V4COMPAT(a): return \ ++ ++def IN6_IS_ADDR_MC_NODELOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_LINKLOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_SITELOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_ORGLOCAL(a): return \ ++ ++def IN6_IS_ADDR_MC_GLOBAL(a): return \ ++ +--- /dev/null ++++ b/Lib/plat-gnukfreebsd8/TYPES.py +@@ -0,0 +1,303 @@ ++# Generated by h2py from /usr/include/sys/types.h ++_SYS_TYPES_H = 1 ++ ++# Included from features.h ++_FEATURES_H = 1 ++__USE_ANSI = 1 ++__FAVOR_BSD = 1 ++_ISOC99_SOURCE = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 200809 ++_XOPEN_SOURCE = 700 ++_XOPEN_SOURCE_EXTENDED = 1 ++_LARGEFILE64_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++_ATFILE_SOURCE = 1 ++_BSD_SOURCE = 1 ++_SVID_SOURCE = 1 ++__USE_ISOC99 = 1 ++__USE_ISOC95 = 1 ++_POSIX_SOURCE = 1 ++_POSIX_C_SOURCE = 2 ++_POSIX_C_SOURCE = 199506 ++_POSIX_C_SOURCE = 200112 ++_POSIX_C_SOURCE = 200809 ++__USE_POSIX_IMPLICITLY = 1 ++__USE_POSIX = 1 ++__USE_POSIX2 = 1 ++__USE_POSIX199309 = 1 ++__USE_POSIX199506 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN2K8 = 1 ++_ATFILE_SOURCE = 1 ++__USE_XOPEN = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_UNIX98 = 1 ++_LARGEFILE_SOURCE = 1 ++__USE_XOPEN2K8 = 1 ++__USE_XOPEN2K = 1 ++__USE_ISOC99 = 1 ++__USE_XOPEN_EXTENDED = 1 ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_FILE_OFFSET64 = 1 ++__USE_MISC = 1 ++__USE_BSD = 1 ++__USE_SVID = 1 ++__USE_ATFILE = 1 ++__USE_GNU = 1 ++__USE_REENTRANT = 1 ++__USE_FORTIFY_LEVEL = 2 ++__USE_FORTIFY_LEVEL = 1 ++__USE_FORTIFY_LEVEL = 0 ++ ++# Included from bits/predefs.h ++__STDC_IEC_559__ = 1 ++__STDC_IEC_559_COMPLEX__ = 1 ++__STDC_ISO_10646__ = 200009 ++__GNU_LIBRARY__ = 6 ++__GLIBC__ = 2 ++__GLIBC_MINOR__ = 11 ++__GLIBC_HAVE_LONG_LONG = 1 ++ ++# Included from sys/cdefs.h ++_SYS_CDEFS_H = 1 ++def __NTH(fct): return fct ++ ++def __NTH(fct): return fct ++ ++def __P(args): return args ++ ++def __PMT(args): return args ++ ++def __STRING(x): return #x ++ ++def __bos(ptr): return __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) ++ ++def __bos0(ptr): return __builtin_object_size (ptr, 0) ++ ++def __warnattr(msg): return __attribute__((__warning__ (msg))) ++ ++__flexarr = [] ++__flexarr = [0] ++__flexarr = [] ++__flexarr = [1] ++def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) ++ ++def __attribute__(xyz): return ++ ++def __attribute_format_arg__(x): return __attribute__ ((__format_arg__ (x))) ++ ++def __attribute_format_arg__(x): return ++ ++ ++# Included from bits/wordsize.h ++__WORDSIZE = 32 ++__LDBL_COMPAT = 1 ++def __LDBL_REDIR_DECL(name): return \ ++ ++__USE_LARGEFILE = 1 ++__USE_LARGEFILE64 = 1 ++__USE_EXTERN_INLINES = 1 ++__USE_EXTERN_INLINES_IN_LIBC = 1 ++ ++# Included from gnu/stubs.h ++ ++# Included from bits/types.h ++_BITS_TYPES_H = 1 ++__S32_TYPE = int ++__SWORD_TYPE = int ++__SLONG32_TYPE = int ++ ++# Included from bits/typesizes.h ++_BITS_TYPESIZES_H = 1 ++__PID_T_TYPE = __S32_TYPE ++__CLOCK_T_TYPE = __S32_TYPE ++__SWBLK_T_TYPE = __S32_TYPE ++__CLOCKID_T_TYPE = __S32_TYPE ++__TIMER_T_TYPE = __S32_TYPE ++__SSIZE_T_TYPE = __SWORD_TYPE ++__FD_SETSIZE = 1024 ++ ++# Included from time.h ++_TIME_H = 1 ++ ++# Included from bits/time.h ++_BITS_TIME_H = 1 ++CLOCKS_PER_SEC = 1000000 ++CLK_TCK = 128 ++CLOCK_REALTIME = 0 ++CLOCK_PROCESS_CPUTIME_ID = 2 ++CLOCK_THREAD_CPUTIME_ID = 3 ++CLOCK_MONOTONIC = 4 ++CLOCK_VIRTUAL = 1 ++CLOCK_PROF = 2 ++CLOCK_UPTIME = 5 ++CLOCK_UPTIME_PRECISE = 7 ++CLOCK_UPTIME_FAST = 8 ++CLOCK_REALTIME_PRECISE = 9 ++CLOCK_REALTIME_FAST = 10 ++CLOCK_MONOTONIC_PRECISE = 11 ++CLOCK_MONOTONIC_FAST = 12 ++CLOCK_SECOND = 13 ++TIMER_RELTIME = 0 ++TIMER_ABSTIME = 1 ++_STRUCT_TIMEVAL = 1 ++CLK_TCK = CLOCKS_PER_SEC ++__clock_t_defined = 1 ++__time_t_defined = 1 ++__clockid_t_defined = 1 ++__timer_t_defined = 1 ++__timespec_defined = 1 ++ ++# Included from xlocale.h ++_XLOCALE_H = 1 ++def __isleap(year): return \ ++ ++__BIT_TYPES_DEFINED__ = 1 ++ ++# Included from endian.h ++_ENDIAN_H = 1 ++__LITTLE_ENDIAN = 1234 ++__BIG_ENDIAN = 4321 ++__PDP_ENDIAN = 3412 ++ ++# Included from bits/endian.h ++__BYTE_ORDER = __LITTLE_ENDIAN ++__FLOAT_WORD_ORDER = __BYTE_ORDER ++LITTLE_ENDIAN = __LITTLE_ENDIAN ++BIG_ENDIAN = __BIG_ENDIAN ++PDP_ENDIAN = __PDP_ENDIAN ++BYTE_ORDER = __BYTE_ORDER ++ ++# Included from bits/byteswap.h ++_BITS_BYTESWAP_H = 1 ++def __bswap_constant_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_16(x): return \ ++ ++def __bswap_constant_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_32(x): return \ ++ ++def __bswap_constant_64(x): return \ ++ ++def __bswap_64(x): return \ ++ ++def htobe16(x): return __bswap_16 (x) ++ ++def htole16(x): return (x) ++ ++def be16toh(x): return __bswap_16 (x) ++ ++def le16toh(x): return (x) ++ ++def htobe32(x): return __bswap_32 (x) ++ ++def htole32(x): return (x) ++ ++def be32toh(x): return __bswap_32 (x) ++ ++def le32toh(x): return (x) ++ ++def htobe64(x): return __bswap_64 (x) ++ ++def htole64(x): return (x) ++ ++def be64toh(x): return __bswap_64 (x) ++ ++def le64toh(x): return (x) ++ ++def htobe16(x): return (x) ++ ++def htole16(x): return __bswap_16 (x) ++ ++def be16toh(x): return (x) ++ ++def le16toh(x): return __bswap_16 (x) ++ ++def htobe32(x): return (x) ++ ++def htole32(x): return __bswap_32 (x) ++ ++def be32toh(x): return (x) ++ ++def le32toh(x): return __bswap_32 (x) ++ ++def htobe64(x): return (x) ++ ++def htole64(x): return __bswap_64 (x) ++ ++def be64toh(x): return (x) ++ ++def le64toh(x): return __bswap_64 (x) ++ ++ ++# Included from sys/select.h ++_SYS_SELECT_H = 1 ++ ++# Included from bits/select.h ++def __FD_ZERO(fdsp): return \ ++ ++def __FD_ZERO(set): return \ ++ ++ ++# Included from bits/sigset.h ++_SIGSET_H_types = 1 ++_SIGSET_H_fns = 1 ++def __sigword(sig): return (((sig) - 1) >> 5) ++ ++def __sigemptyset(set): return \ ++ ++def __sigfillset(set): return \ ++ ++def __sigisemptyset(set): return \ ++ ++def __FDELT(d): return ((d) / __NFDBITS) ++ ++FD_SETSIZE = __FD_SETSIZE ++def FD_ZERO(fdsetp): return __FD_ZERO (fdsetp) ++ ++ ++# Included from sys/sysmacros.h ++_SYS_SYSMACROS_H = 1 ++def minor(dev): return ((int)((dev) & (-65281))) ++ ++def gnu_dev_major(dev): return major (dev) ++ ++def gnu_dev_minor(dev): return minor (dev) ++ ++ ++# Included from bits/pthreadtypes.h ++_BITS_PTHREADTYPES_H = 1 ++ ++# Included from bits/sched.h ++SCHED_OTHER = 2 ++SCHED_FIFO = 1 ++SCHED_RR = 3 ++CSIGNAL = 0x000000ff ++CLONE_VM = 0x00000100 ++CLONE_FS = 0x00000200 ++CLONE_FILES = 0x00000400 ++CLONE_SIGHAND = 0x00000800 ++CLONE_PTRACE = 0x00002000 ++CLONE_VFORK = 0x00004000 ++CLONE_SYSVSEM = 0x00040000 ++__defined_schedparam = 1 ++__CPU_SETSIZE = 128 ++def __CPUELT(cpu): return ((cpu) / __NCPUBITS) ++ ++def __CPU_ALLOC_SIZE(count): return \ ++ ++def __CPU_ALLOC(count): return __sched_cpualloc (count) ++ ++def __CPU_FREE(cpuset): return __sched_cpufree (cpuset) ++ --- python3.2-3.2.3.orig/debian/patches/distutils-sysconfig.diff +++ python3.2-3.2.3/debian/patches/distutils-sysconfig.diff @@ -0,0 +1,31 @@ +# DP: Allow setting BASECFLAGS, OPT and EXTRA_LDFLAGS (like, CC, CXX, CPP, +# DP: CFLAGS, CPPFLAGS, CCSHARED, LDSHARED) from the environment. + +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -163,8 +163,9 @@ + varies across Unices and is stored in Python's Makefile. + """ + if compiler.compiler_type == "unix": +- (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ ++ (cc, cxx, opt, cflags, extra_cflags, basecflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ + get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', ++ 'EXTRA_CFLAGS', 'BASECFLAGS', + 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS') + + if 'CC' in os.environ: +@@ -179,8 +180,13 @@ + cpp = cc + " -E" # not always + if 'LDFLAGS' in os.environ: + ldshared = ldshared + ' ' + os.environ['LDFLAGS'] ++ if 'BASECFLAGS' in os.environ: ++ basecflags = os.environ['BASECFLAGS'] ++ if 'OPT' in os.environ: ++ opt = os.environ['OPT'] ++ cflags = ' '.join(str(x) for x in (basecflags, opt, extra_cflags) if x) + if 'CFLAGS' in os.environ: +- cflags = opt + ' ' + os.environ['CFLAGS'] ++ cflags = ' '.join(str(x) for x in (basecflags, opt, os.environ['CFLAGS'], extra_cflags) if x) + ldshared = ldshared + ' ' + os.environ['CFLAGS'] + if 'CPPFLAGS' in os.environ: + cpp = cpp + ' ' + os.environ['CPPFLAGS'] --- python3.2-3.2.3.orig/debian/patches/doc-build.diff +++ python3.2-3.2.3/debian/patches/doc-build.diff @@ -0,0 +1,38 @@ +# DP: Allow docs to be built with Sphinx 0.5.x. + +--- a/Doc/tools/sphinxext/pyspecific.py ++++ b/Doc/tools/sphinxext/pyspecific.py +@@ -171,8 +171,15 @@ + from docutils.io import StringOutput + from docutils.utils import new_document + +-from sphinx.builders import Builder +-from sphinx.writers.text import TextWriter ++try: ++ from sphinx.builders import Builder ++except ImportError: ++ from sphinx.builder import Builder ++ ++try: ++ from sphinx.writers.text import TextWriter ++except ImportError: ++ from sphinx.textwriter import TextWriter + + + class PydocTopicsBuilder(Builder): +--- a/Doc/tools/sphinxext/suspicious.py ++++ b/Doc/tools/sphinxext/suspicious.py +@@ -47,7 +47,12 @@ + import sys + + from docutils import nodes +-from sphinx.builders import Builder ++ ++try: ++ from sphinx.builders import Builder ++except ImportError: ++ from sphinx.builder import Builder ++ + + detect_all = re.compile(r''' + ::(?=[^=])| # two :: (but NOT ::=) --- python3.2-3.2.3.orig/debian/patches/disable-utimes.diff +++ python3.2-3.2.3/debian/patches/disable-utimes.diff @@ -0,0 +1,13 @@ +# DP: disable check for utimes function, which is broken in glibc-2.3.2 + +--- a/configure.ac ++++ b/configure.ac +@@ -2588,7 +2588,7 @@ + setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setuid setvbuf \ + sigaction siginterrupt sigrelse snprintf strftime strlcpy \ + sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ +- truncate uname unsetenv utimes waitpid wait3 wait4 \ ++ truncate uname unsetenv waitpid wait3 wait4 \ + wcscoll wcsftime wcsxfrm _getpty) + + # For some functions, having a definition is not sufficient, since --- python3.2-3.2.3.orig/debian/patches/plat-linux2_alpha.diff +++ python3.2-3.2.3/debian/patches/plat-linux2_alpha.diff @@ -0,0 +1,73 @@ +Index: Lib/plat-linux2/IN.py +=================================================================== +--- ./Lib/plat-linux2/IN.py (Revision 77754) ++++ ./Lib/plat-linux2/IN.py (Arbeitskopie) +@@ -436,43 +436,43 @@ + # Included from asm/socket.h + + # Included from asm/sockios.h +-FIOSETOWN = 0x8901 +-SIOCSPGRP = 0x8902 +-FIOGETOWN = 0x8903 +-SIOCGPGRP = 0x8904 +-SIOCATMARK = 0x8905 ++FIOSETOWN = 0x8004667c ++SIOCSPGRP = 0x80047308 ++FIOGETOWN = 0x4004667b ++SIOCGPGRP = 0x40047309 ++SIOCATMARK = 0x40047307 + SIOCGSTAMP = 0x8906 +-SOL_SOCKET = 1 +-SO_DEBUG = 1 +-SO_REUSEADDR = 2 +-SO_TYPE = 3 +-SO_ERROR = 4 +-SO_DONTROUTE = 5 +-SO_BROADCAST = 6 +-SO_SNDBUF = 7 +-SO_RCVBUF = 8 +-SO_KEEPALIVE = 9 +-SO_OOBINLINE = 10 ++SOL_SOCKET = 0xffff ++SO_DEBUG = 0x0001 ++SO_REUSEADDR = 0x0004 ++SO_TYPE = 0x1008 ++SO_ERROR = 0x1007 ++SO_DONTROUTE = 0x0010 ++SO_BROADCAST = 0x0020 ++SO_SNDBUF = 0x1001 ++SO_RCVBUF = 0x1002 ++SO_KEEPALIVE = 0x0008 ++SO_OOBINLINE = 0x0100 + SO_NO_CHECK = 11 + SO_PRIORITY = 12 +-SO_LINGER = 13 ++SO_LINGER = 0x0080 + SO_BSDCOMPAT = 14 + SO_PASSCRED = 16 + SO_PEERCRED = 17 +-SO_RCVLOWAT = 18 +-SO_SNDLOWAT = 19 +-SO_RCVTIMEO = 20 +-SO_SNDTIMEO = 21 +-SO_SECURITY_AUTHENTICATION = 22 +-SO_SECURITY_ENCRYPTION_TRANSPORT = 23 +-SO_SECURITY_ENCRYPTION_NETWORK = 24 ++SO_RCVLOWAT = 0x1010 ++SO_SNDLOWAT = 0x1011 ++SO_RCVTIMEO = 0x1012 ++SO_SNDTIMEO = 0x1013 ++SO_SECURITY_AUTHENTICATION = 19 ++SO_SECURITY_ENCRYPTION_TRANSPORT = 20 ++SO_SECURITY_ENCRYPTION_NETWORK = 21 + SO_BINDTODEVICE = 25 + SO_ATTACH_FILTER = 26 + SO_DETACH_FILTER = 27 + SO_PEERNAME = 28 + SO_TIMESTAMP = 29 + SCM_TIMESTAMP = SO_TIMESTAMP +-SO_ACCEPTCONN = 30 ++SO_ACCEPTCONN = 0x1014 + SOCK_STREAM = 1 + SOCK_DGRAM = 2 + SOCK_RAW = 3 --- python3.2-3.2.3.orig/debian/patches/no-zip-on-sys.path.diff +++ python3.2-3.2.3/debian/patches/no-zip-on-sys.path.diff @@ -0,0 +1,52 @@ +# DP: Do not add /usr/lib/pythonXY.zip on sys.path. + +--- a/Modules/getpath.c ++++ b/Modules/getpath.c +@@ -413,7 +413,9 @@ + wchar_t *path = NULL; + wchar_t *prog = Py_GetProgramName(); + wchar_t argv0_path[MAXPATHLEN+1]; ++#ifdef WITH_ZIP_PATH + wchar_t zip_path[MAXPATHLEN+1]; ++#endif + int pfound, efound; /* 1 if found; -1 if found build directory */ + wchar_t *buf; + size_t bufsz; +@@ -575,6 +577,7 @@ + else + reduce(prefix); + ++#ifdef WITH_ZIP_PATH + wcsncpy(zip_path, prefix, MAXPATHLEN); + zip_path[MAXPATHLEN] = L'\0'; + if (pfound > 0) { /* Use the reduced prefix returned by Py_GetPrefix() */ +@@ -587,6 +590,7 @@ + bufsz = wcslen(zip_path); /* Replace "00" with version */ + zip_path[bufsz - 6] = VERSION[0]; + zip_path[bufsz - 5] = VERSION[2]; ++#endif + + if (!(efound = search_for_exec_prefix(argv0_path, home, _exec_prefix))) { + if (!Py_FrozenFlag) +@@ -632,7 +636,9 @@ + defpath = delim + 1; + } + ++#ifdef WITH_ZIP_PATH + bufsz += wcslen(zip_path) + 1; ++#endif + bufsz += wcslen(exec_prefix) + 1; + + buf = (wchar_t *)PyMem_Malloc(bufsz*sizeof(wchar_t)); +@@ -652,9 +658,11 @@ + else + buf[0] = '\0'; + ++#ifdef WITH_ZIP_PATH + /* Next is the default zip path */ + wcscat(buf, zip_path); + wcscat(buf, delimiter); ++#endif + + /* Next goes merge of compile-time $PYTHONPATH with + * dynamically located prefix. --- python3.2-3.2.3.orig/debian/patches/distutils-install-layout.diff +++ python3.2-3.2.3/debian/patches/distutils-install-layout.diff @@ -0,0 +1,347 @@ +# DP: distutils: Add an option --install-layout=deb, which +# DP: - installs into $prefix/dist-packages instead of $prefix/site-packages. +# DP: - doesn't encode the python version into the egg name. + +Index: b/Doc/install/index.rst +=================================================================== +--- a/Doc/install/index.rst ++++ b/Doc/install/index.rst +@@ -240,6 +240,8 @@ + +-----------------+-----------------------------------------------------+--------------------------------------------------+-------+ + | Platform | Standard installation location | Default value | Notes | + +=================+=====================================================+==================================================+=======+ ++| Debian/Ubuntu | :file:`{prefix}/lib/python3/dist-packages` | :file:`/usr/local/lib/python{X.Y}/dist-packages` | \(0) | +++-----------------+-----------------------------------------------------+--------------------------------------------------+-------+ + | Unix (pure) | :file:`{prefix}/lib/python{X.Y}/site-packages` | :file:`/usr/local/lib/python{X.Y}/site-packages` | \(1) | + +-----------------+-----------------------------------------------------+--------------------------------------------------+-------+ + | Unix (non-pure) | :file:`{exec-prefix}/lib/python{X.Y}/site-packages` | :file:`/usr/local/lib/python{X.Y}/site-packages` | \(1) | +@@ -249,6 +251,17 @@ + + Notes: + ++(0) ++ Starting with Python-2.6 Debian/Ubuntu uses for the Python which comes within ++ the Linux distribution a non-default name for the installation directory. This ++ is to avoid overwriting of the python modules which come with the distribution, ++ which unfortunately is the upstream behaviour of the installation tools. The ++ non-default name in :file:`/usr/local` is used not to overwrite a local python ++ installation (defaulting to :file:`/usr/local`). ++ ++ Starting with Python3, Debian/Ubuntu use a common installation directory for ++ all Python3 versions. ++ + (1) + Most Linux distributions include Python as a standard part of the system, so + :file:`{prefix}` and :file:`{exec-prefix}` are usually both :file:`/usr` on +@@ -432,6 +445,15 @@ + + /usr/bin/python setup.py install --prefix=/usr/local + ++Starting with Python3 Debian/Ubuntu does use ++:file:`/usr/lib/python3/dist-packages` and ++:file:`/usr/local/lib/python{X.Y}/dist-packages` for the installation ++of python modules included in the Linux distribution. To overwrite ++the name of the site directory, explicitely use the :option:`--prefix` ++option, however make sure that the installation path is included in ++``sys.path``. For packaging of python modules for Debian/Ubuntu, use ++the new ``setup.py install`` option :option:`--install-layout=deb`. ++ + Another possibility is a network filesystem where the name used to write to a + remote directory is different from the name used to read it: for example, the + Python interpreter accessed as :file:`/usr/local/bin/python` might search for +@@ -683,6 +705,17 @@ + import them, this directory must be added to ``sys.path``. There are several + different ways to add the directory. + ++On Debian/Ubuntu, starting with Python3 the convention for system ++installed packages is to put then in the ++:file:`/usr/lib/python3/dist-packages/` directory, and for locally ++installed packages is to put them in the ++:file:`/usr/local/lib/python{X.Y}/dist-packages/` directory. To share the ++locally installed packages for the system provided Python with the ++locally installed packages of a local python installation, make ++:file:`/usr/local/lib/python{X.Y}/dist-packages/` a symbolic link to the ++:file:`{...}/site-packages/` directory of your local python ++installation. ++ + The most convenient way is to add a path configuration file to a directory + that's already on Python's path, usually to the :file:`.../site-packages/` + directory. Path configuration files have an extension of :file:`.pth`, and each +Index: b/Lib/distutils/command/install_egg_info.py +=================================================================== +--- a/Lib/distutils/command/install_egg_info.py ++++ b/Lib/distutils/command/install_egg_info.py +@@ -14,18 +14,38 @@ + description = "Install package's PKG-INFO metadata as an .egg-info file" + user_options = [ + ('install-dir=', 'd', "directory to install to"), ++ ('install-layout', None, "custom installation layout"), + ] + + def initialize_options(self): + self.install_dir = None ++ self.install_layout = None ++ self.prefix_option = None + + def finalize_options(self): + self.set_undefined_options('install_lib',('install_dir','install_dir')) +- basename = "%s-%s-py%s.egg-info" % ( +- to_filename(safe_name(self.distribution.get_name())), +- to_filename(safe_version(self.distribution.get_version())), +- sys.version[:3] +- ) ++ self.set_undefined_options('install',('install_layout','install_layout')) ++ self.set_undefined_options('install',('prefix_option','prefix_option')) ++ if self.install_layout: ++ if not self.install_layout.lower() in ['deb', 'unix']: ++ raise DistutilsOptionError( ++ "unknown value for --install-layout") ++ no_pyver = (self.install_layout.lower() == 'deb') ++ elif self.prefix_option: ++ no_pyver = False ++ else: ++ no_pyver = True ++ if no_pyver: ++ basename = "%s-%s.egg-info" % ( ++ to_filename(safe_name(self.distribution.get_name())), ++ to_filename(safe_version(self.distribution.get_version())) ++ ) ++ else: ++ basename = "%s-%s-py%s.egg-info" % ( ++ to_filename(safe_name(self.distribution.get_name())), ++ to_filename(safe_version(self.distribution.get_version())), ++ sys.version[:3] ++ ) + self.target = os.path.join(self.install_dir, basename) + self.outputs = [self.target] + +Index: b/Lib/distutils/command/install.py +=================================================================== +--- a/Lib/distutils/command/install.py ++++ b/Lib/distutils/command/install.py +@@ -50,6 +50,20 @@ + 'scripts': '$base/bin', + 'data' : '$base', + }, ++ 'unix_local': { ++ 'purelib': '$base/local/lib/python$py_version_short/dist-packages', ++ 'platlib': '$platbase/local/lib/python$py_version_short/dist-packages', ++ 'headers': '$base/local/include/python$py_version_short/$dist_name', ++ 'scripts': '$base/local/bin', ++ 'data' : '$base/local', ++ }, ++ 'deb_system': { ++ 'purelib': '$base/lib/python3/dist-packages', ++ 'platlib': '$platbase/lib/python3/dist-packages', ++ 'headers': '$base/include/python$py_version_short/$dist_name', ++ 'scripts': '$base/bin', ++ 'data' : '$base', ++ }, + 'unix_home': { + 'purelib': '$base/lib/python', + 'platlib': '$base/lib/python', +@@ -161,6 +175,9 @@ + + ('record=', None, + "filename in which to record list of installed files"), ++ ++ ('install-layout=', None, ++ "installation layout to choose (known values: deb, unix)"), + ] + + boolean_options = ['compile', 'force', 'skip-build'] +@@ -181,6 +198,7 @@ + self.exec_prefix = None + self.home = None + self.user = 0 ++ self.prefix_option = None + + # These select only the installation base; it's up to the user to + # specify the installation scheme (currently, that means supplying +@@ -202,6 +220,9 @@ + self.install_userbase = USER_BASE + self.install_usersite = USER_SITE + ++ # enable custom installation, known values: deb ++ self.install_layout = None ++ + self.compile = None + self.optimize = None + +@@ -441,6 +462,7 @@ + self.install_base = self.install_platbase = self.home + self.select_scheme("unix_home") + else: ++ self.prefix_option = self.prefix + if self.prefix is None: + if self.exec_prefix is not None: + raise DistutilsOptionError( +@@ -455,7 +477,23 @@ + + self.install_base = self.prefix + self.install_platbase = self.exec_prefix +- self.select_scheme("unix_prefix") ++ if self.install_layout: ++ if self.install_layout.lower() in ['deb']: ++ self.select_scheme("deb_system") ++ elif self.install_layout.lower() in ['unix']: ++ self.select_scheme("unix_prefix") ++ else: ++ raise DistutilsOptionError( ++ "unknown value for --install-layout") ++ elif (self.prefix_option and os.path.normpath(self.prefix) != '/usr/local') \ ++ or 'PYTHONUSERBASE' in os.environ \ ++ or 'real_prefix' in sys.__dict__: ++ self.select_scheme("unix_prefix") ++ else: ++ if os.path.normpath(self.prefix) == '/usr/local': ++ self.prefix = self.exec_prefix = '/usr' ++ self.install_base = self.install_platbase = '/usr' ++ self.select_scheme("unix_local") + + def finalize_other(self): + """Finalizes options for non-posix platforms""" +Index: b/Lib/distutils/sysconfig.py +=================================================================== +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -118,6 +118,7 @@ + If 'prefix' is supplied, use it instead of sys.prefix or + sys.exec_prefix -- i.e., ignore 'plat_specific'. + """ ++ is_default_prefix = not prefix or os.path.normpath(prefix) in ('/usr', '/usr/local') + if prefix is None: + prefix = plat_specific and EXEC_PREFIX or PREFIX + +@@ -126,6 +127,8 @@ + "lib", "python" + get_python_version()) + if standard_lib: + return libpython ++ elif is_default_prefix and 'PYTHONUSERBASE' not in os.environ and 'real_prefix' not in sys.__dict__: ++ return os.path.join(prefix, "lib", "python3", "dist-packages") + else: + return os.path.join(libpython, "site-packages") + elif os.name == "nt": +Index: b/Lib/site.py +=================================================================== +--- a/Lib/site.py ++++ b/Lib/site.py +@@ -270,6 +270,13 @@ + + if ENABLE_USER_SITE and os.path.isdir(user_site): + addsitedir(user_site, known_paths) ++ if ENABLE_USER_SITE: ++ for dist_libdir in ("lib", "local/lib"): ++ user_site = os.path.join(USER_BASE, dist_libdir, ++ "python" + sys.version[:3], ++ "dist-packages") ++ if os.path.isdir(user_site): ++ addsitedir(user_site, known_paths) + return known_paths + + def getsitepackages(): +Index: b/Lib/sysconfig.py +=================================================================== +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -32,6 +32,26 @@ + 'scripts': '{base}/bin', + 'data': '{base}', + }, ++ 'posix_local': { ++ 'stdlib': '{base}/local/lib/python{py_version_short}', ++ 'platstdlib': '{platbase}/local/lib/python{py_version_short}', ++ 'purelib': '{base}/local/lib/python{py_version_short}/dist-packages', ++ 'platlib': '{platbase}/local/lib/python{py_version_short}/dist-packages', ++ 'include': '{base}/local/include/python{py_version_short}', ++ 'platinclude': '{platbase}/local/include/python{py_version_short}', ++ 'scripts': '{base}/local/bin', ++ 'data': '{base}/local', ++ }, ++ 'deb_system': { ++ 'stdlib': '{base}/lib/python{py_version_short}', ++ 'platstdlib': '{platbase}/lib/python{py_version_short}', ++ 'purelib': '{base}/lib/python3/dist-packages', ++ 'platlib': '{platbase}/lib/python3/dist-packages', ++ 'include': '{base}/include/python{py_version_short}', ++ 'platinclude': '{platbase}/include/python{py_version_short}', ++ 'scripts': '{base}/bin', ++ 'data': '{base}', ++ }, + 'posix_home': { + 'stdlib': '{base}/lib/python', + 'platstdlib': '{base}/lib/python', +Index: b/Lib/test/test_site.py +=================================================================== +--- a/Lib/test/test_site.py ++++ b/Lib/test/test_site.py +@@ -236,12 +236,20 @@ + self.assertEqual(dirs[2], wanted) + elif os.sep == '/': + # OS X non-framwework builds, Linux, FreeBSD, etc +- self.assertEqual(len(dirs), 2) +- wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3], +- 'site-packages') ++ self.assertEqual(len(dirs), 4) ++ wanted = os.path.join('xoxo', 'local', 'lib', ++ 'python' + sys.version[:3], ++ 'dist-packages') + self.assertEqual(dirs[0], wanted) +- wanted = os.path.join('xoxo', 'lib', 'site-python') ++ wanted = os.path.join('xoxo', 'lib', ++ 'python3', 'dist-packages') + self.assertEqual(dirs[1], wanted) ++ wanted = os.path.join('xoxo', 'lib', ++ 'python' + sys.version[:3], ++ 'dist-packages') ++ self.assertEqual(dirs[2], wanted) ++ wanted = os.path.join('xoxo', 'lib', 'dist-python') ++ self.assertEqual(dirs[3], wanted) + else: + # other platforms + self.assertEqual(len(dirs), 2) +Index: b/Lib/distutils/tests/test_bdist_dumb.py +=================================================================== +--- a/Lib/distutils/tests/test_bdist_dumb.py ++++ b/Lib/distutils/tests/test_bdist_dumb.py +@@ -88,7 +88,7 @@ + fp.close() + + contents = sorted(os.path.basename(fn) for fn in contents) +- wanted = ['foo-0.1-py%s.%s.egg-info' % sys.version_info[:2], ++ wanted = ['foo-0.1.egg-info', + 'foo.%s.pyc' % imp.get_tag(), + 'foo.py'] + self.assertEqual(contents, sorted(wanted)) +Index: b/Lib/distutils/tests/test_install.py +=================================================================== +--- a/Lib/distutils/tests/test_install.py ++++ b/Lib/distutils/tests/test_install.py +@@ -194,7 +194,7 @@ + + found = [os.path.basename(line) for line in content.splitlines()] + expected = ['hello.py', 'hello.%s.pyc' % imp.get_tag(), 'sayhi', +- 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] ++ 'UNKNOWN-0.0.0.egg-info'] + self.assertEqual(found, expected) + + def test_record_extensions(self): +@@ -224,7 +224,7 @@ + + found = [os.path.basename(line) for line in content.splitlines()] + expected = [_make_ext_name('xx'), +- 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] ++ 'UNKNOWN-0.0.0.egg-info'] + self.assertEqual(found, expected) + + def test_debug_mode(self): +--- a/Lib/pydoc.py ++++ b/Lib/pydoc.py +@@ -368,6 +368,7 @@ + 'marshal', 'posix', 'signal', 'sys', + '_thread', 'zipimport') or + (file.startswith(basedir) and ++ not file.startswith(os.path.join(basedir, 'dist-packages')) and + not file.startswith(os.path.join(basedir, 'site-packages')))) and + object.__name__ not in ('xml.etree', 'test.pydoc_mod')): + if docloc.startswith("http://"): --- python3.2-3.2.3.orig/debian/patches/no-large-file-support.diff +++ python3.2-3.2.3/debian/patches/no-large-file-support.diff @@ -0,0 +1,14 @@ +# DP: disable large file support for GNU/Hurd + +--- a/configure.ac ++++ b/configure.ac +@@ -1402,6 +1402,9 @@ + use_lfs=no + fi + ++# Don't use largefile support anyway. ++use_lfs=no ++ + if test "$use_lfs" = "yes"; then + # Two defines needed to enable largefile support on various platforms + # These may affect some typedefs --- python3.2-3.2.3.orig/debian/patches/lto-link-flags.diff +++ python3.2-3.2.3/debian/patches/lto-link-flags.diff @@ -0,0 +1,20 @@ +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -118,7 +118,7 @@ + # Symbols used for using shared libraries + SO= @SO@ + LDSHARED= @LDSHARED@ $(PY_LDFLAGS) +-BLDSHARED= @BLDSHARED@ $(PY_LDFLAGS) ++BLDSHARED= @BLDSHARED@ $(PY_LDFLAGS) $(PY_CFLAGS) + LDCXXSHARED= @LDCXXSHARED@ + DESTSHARED= $(BINLIBDEST)/lib-dynload + +@@ -427,7 +427,7 @@ + + # Build the interpreter + $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY) +- $(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ Modules/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) ++ $(LINKCC) $(PY_LDFLAGS) $(PY_CFLAGS) $(LINKFORSHARED) -o $@ Modules/python.o $(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 --- python3.2-3.2.3.orig/debian/patches/autoconf-version.diff +++ python3.2-3.2.3/debian/patches/autoconf-version.diff @@ -0,0 +1,18 @@ +# DP: Remove autoconf version check + +--- a/configure.ac ++++ b/configure.ac +@@ -5,13 +5,6 @@ + # Set VERSION so we only need to edit in one place (i.e., here) + m4_define(PYTHON_VERSION, 3.2) + +-dnl Some m4 magic to ensure that the configure script is generated +-dnl by the correct autoconf version. +-m4_define([version_required], +-[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]), [$1]), 0, +- [], +- [m4_fatal([Autoconf version $1 is required for Python], 63)]) +-]) + AC_PREREQ(2.65) + + AC_REVISION($Revision: 88440 $) --- python3.2-3.2.3.orig/debian/patches/site-locations.diff +++ python3.2-3.2.3/debian/patches/site-locations.diff @@ -0,0 +1,46 @@ +# DP: Set site-packages/dist-packages + +--- a/Lib/site.py ++++ b/Lib/site.py +@@ -6,13 +6,19 @@ + + This will append site-specific paths to the module search path. On + Unix (including Mac OSX), it starts with sys.prefix and +-sys.exec_prefix (if different) and appends +-lib/python/site-packages as well as lib/site-python. ++sys.exec_prefix (if different) and appends lib/python3/dist-packages, ++lib/python/dist-packages as well as lib/site-python. + On other platforms (such as Windows), it tries each of the + prefixes directly, as well as with lib/site-packages appended. The + resulting directories, if they exist, are appended to sys.path, and + also inspected for path configuration files. + ++For Debian and derivatives, this sys.path is augmented with directories ++for packages distributed within the distribution. Local addons go ++into /usr/local/lib/python/dist-packages, Debian addons ++install into /usr/lib/python3/dist-packages. ++/usr/lib/python/site-packages is not used. ++ + A path configuration file is a file whose name has the form + .pth; its contents are additional directories (one per line) + to be added to sys.path. Non-existing directories (or +@@ -285,10 +291,17 @@ + if sys.platform in ('os2emx', 'riscos'): + sitepackages.append(os.path.join(prefix, "Lib", "site-packages")) + elif os.sep == '/': ++ sitepackages.append(os.path.join(prefix, "local/lib", ++ "python" + sys.version[:3], ++ "dist-packages")) ++ sitepackages.append(os.path.join(prefix, "lib", ++ "python3", ++ "dist-packages")) ++ # this one is deprecated for Debian + sitepackages.append(os.path.join(prefix, "lib", + "python" + sys.version[:3], +- "site-packages")) +- sitepackages.append(os.path.join(prefix, "lib", "site-python")) ++ "dist-packages")) ++ sitepackages.append(os.path.join(prefix, "lib", "dist-python")) + else: + sitepackages.append(prefix) + sitepackages.append(os.path.join(prefix, "lib", "site-packages")) --- python3.2-3.2.3.orig/debian/patches/deb-locations.diff +++ python3.2-3.2.3/debian/patches/deb-locations.diff @@ -0,0 +1,26 @@ +# DP: adjust locations of directories to debian policy + +--- a/Lib/pydoc.py ++++ b/Lib/pydoc.py +@@ -32,6 +32,10 @@ + + Module docs for core modules are assumed to be in + ++ /usr/share/doc/pythonX.Y/html/library ++ ++if the pythonX.Y-doc package is installed or in ++ + http://docs.python.org/X.Y/library/ + + This can be overridden by setting the PYTHONDOCS environment variable +--- a/Misc/python.man ++++ b/Misc/python.man +@@ -316,7 +316,7 @@ + These are subject to difference depending on local installation + conventions; ${prefix} and ${exec_prefix} are installation-dependent + and should be interpreted as for GNU software; they may be the same. +-The default for both is \fI/usr/local\fP. ++On Debian GNU/{Hurd,Linux} the default for both is \fI/usr\fP. + .IP \fI${exec_prefix}/bin/python\fP + Recommended location of the interpreter. + .PP --- python3.2-3.2.3.orig/debian/patches/distutils-link.diff +++ python3.2-3.2.3/debian/patches/distutils-link.diff @@ -0,0 +1,18 @@ +# DP: Don't add standard library dirs to library_dirs and runtime_library_dirs. + +--- a/Lib/distutils/unixccompiler.py ++++ b/Lib/distutils/unixccompiler.py +@@ -213,6 +213,13 @@ + runtime_library_dirs) + libraries, library_dirs, runtime_library_dirs = fixed_args + ++ # filter out standard library paths, which are not explicitely needed ++ # for linking ++ library_dirs = [dir for dir in library_dirs ++ if not dir in ('/lib', '/lib64', '/usr/lib', '/usr/lib64')] ++ runtime_library_dirs = [dir for dir in runtime_library_dirs ++ if not dir in ('/lib', '/lib64', '/usr/lib', '/usr/lib64')] ++ + lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs, + libraries) + if not isinstance(output_dir, (str, type(None))): --- python3.2-3.2.3.orig/debian/patches/plat-linux2_mips.diff +++ python3.2-3.2.3/debian/patches/plat-linux2_mips.diff @@ -0,0 +1,88 @@ +Index: Lib/plat-linux2/DLFCN.py +=================================================================== +--- ./Lib/plat-linux2/DLFCN.py (Revision 77754) ++++ ./Lib/plat-linux2/DLFCN.py (Arbeitskopie) +@@ -77,7 +77,7 @@ + RTLD_LAZY = 0x00001 + RTLD_NOW = 0x00002 + RTLD_BINDING_MASK = 0x3 +-RTLD_NOLOAD = 0x00004 +-RTLD_GLOBAL = 0x00100 ++RTLD_NOLOAD = 0x00008 ++RTLD_GLOBAL = 0x00004 + RTLD_LOCAL = 0 + RTLD_NODELETE = 0x01000 +Index: Lib/plat-linux2/IN.py +=================================================================== +--- ./Lib/plat-linux2/IN.py (Revision 77754) ++++ ./Lib/plat-linux2/IN.py (Arbeitskopie) +@@ -436,33 +436,33 @@ + # Included from asm/socket.h + + # Included from asm/sockios.h +-FIOSETOWN = 0x8901 +-SIOCSPGRP = 0x8902 +-FIOGETOWN = 0x8903 +-SIOCGPGRP = 0x8904 +-SIOCATMARK = 0x8905 ++FIOSETOWN = 0x8004667c ++SIOCSPGRP = 0x80047308 ++FIOGETOWN = 0x4004667b ++SIOCGPGRP = 0x40047309 ++SIOCATMARK = 0x40047307 + SIOCGSTAMP = 0x8906 +-SOL_SOCKET = 1 +-SO_DEBUG = 1 +-SO_REUSEADDR = 2 +-SO_TYPE = 3 +-SO_ERROR = 4 +-SO_DONTROUTE = 5 +-SO_BROADCAST = 6 +-SO_SNDBUF = 7 +-SO_RCVBUF = 8 +-SO_KEEPALIVE = 9 +-SO_OOBINLINE = 10 ++SOL_SOCKET = 0xffff ++SO_DEBUG = 0x0001 ++SO_REUSEADDR = 0x0004 ++SO_TYPE = 0x1008 ++SO_ERROR = 0x1007 ++SO_DONTROUTE = 0x0010 ++SO_BROADCAST = 0x0020 ++SO_SNDBUF = 0x1001 ++SO_RCVBUF = 0x1002 ++SO_KEEPALIVE = 0x0008 ++SO_OOBINLINE = 0x0100 + SO_NO_CHECK = 11 + SO_PRIORITY = 12 +-SO_LINGER = 13 ++SO_LINGER = 0x0080 + SO_BSDCOMPAT = 14 +-SO_PASSCRED = 16 +-SO_PEERCRED = 17 +-SO_RCVLOWAT = 18 +-SO_SNDLOWAT = 19 +-SO_RCVTIMEO = 20 +-SO_SNDTIMEO = 21 ++SO_PASSCRED = 17 ++SO_PEERCRED = 18 ++SO_RCVLOWAT = 0x1004 ++SO_SNDLOWAT = 0x1003 ++SO_RCVTIMEO = 0x1006 ++SO_SNDTIMEO = 0x1005 + SO_SECURITY_AUTHENTICATION = 22 + SO_SECURITY_ENCRYPTION_TRANSPORT = 23 + SO_SECURITY_ENCRYPTION_NETWORK = 24 +@@ -472,9 +472,9 @@ + SO_PEERNAME = 28 + SO_TIMESTAMP = 29 + SCM_TIMESTAMP = SO_TIMESTAMP +-SO_ACCEPTCONN = 30 +-SOCK_STREAM = 1 +-SOCK_DGRAM = 2 ++SO_ACCEPTCONN = 0x1009 ++SOCK_STREAM = 2 ++SOCK_DGRAM = 1 + SOCK_RAW = 3 + SOCK_RDM = 4 + SOCK_SEQPACKET = 5