--- python3.3-3.3.3.orig/debian/2to3-3.1 +++ python3.3-3.3.3/debian/2to3-3.1 @@ -0,0 +1,41 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.40.4. +.TH 2TO3-3.3 "1" "January 2012" "2to3-3.3 3.3" "User Commands" +.SH NAME +2to3-3.3 \- 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.3-3.3.3.orig/debian/FAQ.html +++ python3.3-3.3.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.3-3.3.3.orig/debian/PVER-dbg.README.Debian.in +++ python3.3-3.3.3/debian/PVER-dbg.README.Debian.in @@ -0,0 +1,52 @@ +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 (found in the @PVER@-dev package) 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.3-3.3.3.orig/debian/PVER-dbg.overrides.in +++ python3.3-3.3.3/debian/PVER-dbg.overrides.in @@ -0,0 +1,5 @@ +# just the gdb debug file +@PVER@-dbg binary: python-script-but-no-python-dep + +# pointless lintian ... +@PVER@-dbg binary: hardening-no-fortify-functions --- python3.3-3.3.3.orig/debian/PVER-dbg.postinst.in +++ python3.3-3.3.3/debian/PVER-dbg.postinst.in @@ -0,0 +1,36 @@ +#! /bin/sh + +set -e + +if [ "$1" = configure ]; then + files=$(dpkg -L lib@PVER@-dbg | sed -n '/^\/usr\/lib\/@PVER@\/.*\.py$/p') + if [ -n "$files" ]; then + @PVER@ -E -S /usr/lib/@PVER@/py_compile.py $files + if grep -sq '^byte-compile[^#]*optimize' /etc/python/debian_config; then + @PVER@ -E -S -O /usr/lib/@PVER@/py_compile.py $files + fi + else + echo >&2 "@PVER@-dbg: can't get files for byte-compilation" + fi + + 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.3-3.3.3.orig/debian/PVER-dbg.prerm.in +++ python3.3-3.3.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 lib@PVER@-dbg + ;; + upgrade) + remove_bytecode lib@PVER@-dbg + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python3.3-3.3.3.orig/debian/PVER-dev.postinst.in +++ python3.3-3.3.3/debian/PVER-dev.postinst.in @@ -0,0 +1,26 @@ +#! /bin/sh + +set -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.3-3.3.3.orig/debian/PVER-doc.doc-base.PVER-api.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/PVER-doc.doc-base.PVER-dist.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/PVER-doc.doc-base.PVER-ext.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/PVER-doc.doc-base.PVER-inst.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/PVER-doc.doc-base.PVER-lib.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/PVER-doc.doc-base.PVER-new.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/PVER-doc.doc-base.PVER-ref.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/PVER-doc.doc-base.PVER-tut.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/PVER-doc.overrides.in +++ python3.3-3.3.3/debian/PVER-doc.overrides.in @@ -0,0 +1,2 @@ +# this is referenced by the html docs +@PVER@-doc binary: extra-license-file --- python3.3-3.3.3.orig/debian/PVER-examples.overrides.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/PVER-minimal.README.Debian.in +++ python3.3-3.3.3/debian/PVER-minimal.README.Debian.in @@ -0,0 +1,154 @@ +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 + _bisect extension + _bytesio builtin + _codecs builtin + _collections extension + _compat_pickle module + _datetime extension + _elementtree extension + _fileio builtin + _functools extension + _hashlib extensionx + _heapq extension + _imp builtin + _io builtin + _locale extension + _md5 extension + _pickle extension + _posixsubprocess extension + _random extension + _sha1 extension + _sha256 extension + _sha512 extension + _socket extension + _sre builtin + _ssl extensionx + _stringio extension + _struct extension + _string builtin + _stringio builtin + _symtable builtin + _sysconfigdata 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 package + 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 module + importlib package + 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.3-3.3.3.orig/debian/PVER-minimal.postinst.in +++ python3.3-3.3.3/debian/PVER-minimal.postinst.in @@ -0,0 +1,82 @@ +#! /bin/sh + +set -e + +if [ ! -f /etc/@PVER@/sitecustomize.py ]; then + cat <<-EOF + # Empty sitecustomize.py to avoid a dangling symlink +EOF +fi + +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 + localsite=/usr/local/lib/@PVER@/dist-packages + 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 which update-binfmts >/dev/null; then + update-binfmts --import @PVER@ + fi + + ;; +esac + +if [ "$1" = configure ]; then + + # only available before removal of the packaging package + rm -f /etc/@PVER@/sysconfig.cfg + + if ls -L /usr/lib/@PVER@/sitecustomize.py >/dev/null 2>&1; then + filt='cat' + else + filt='fgrep -v sitecustomize.py' + fi + files=$(dpkg -L lib@PVER@-minimal \ + | sed -n '/^\/usr\/lib\/@PVER@\/.*\.py$/p' | $filt) + if [ -n "$files" ]; then + @PVER@ -E -S /usr/lib/@PVER@/py_compile.py $files + if grep -sq '^byte-compile[^#]*optimize' /etc/python/debian_config; then + @PVER@ -E -S -O /usr/lib/@PVER@/py_compile.py $files + fi + else + echo >&2 "@PVER@-minimal: can't get files for byte-compilation" + 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.3-3.3.3.orig/debian/PVER-minimal.postrm.in +++ python3.3-3.3.3/debian/PVER-minimal.postrm.in @@ -0,0 +1,13 @@ +#! /bin/sh + +set -e + +if [ "$1" = "remove" ]; then + + 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 --- python3.3-3.3.3.orig/debian/PVER-minimal.preinst.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/PVER-minimal.prerm.in +++ python3.3-3.3.3/debian/PVER-minimal.prerm.in @@ -0,0 +1,36 @@ +#! /bin/sh + +set -e + +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 + + if which update-binfmts >/dev/null; then + update-binfmts --package @PVER@ --remove @PVER@ /usr/bin/@PVER@ + fi + + localsite=/usr/local/lib/@PVER@/dist-packages + [ -d $localsite ] && rmdir $localsite 2>/dev/null || true + [ -d $(dirname $localsite) ] \ + && rmdir $(dirname $localsite) 2>/dev/null || true + ;; + upgrade) + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python3.3-3.3.3.orig/debian/PVER.desktop.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/PVER.menu.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/PVER.overrides.in +++ python3.3-3.3.3/debian/PVER.overrides.in @@ -0,0 +1,8 @@ +# yes, we have to +@PVER@ binary: depends-on-python-minimal + +@PVER@ binary: desktop-command-not-in-package +@PVER@ binary: menu-command-not-in-package + +# no, not useless +@PVER@ binary: manpage-has-useless-whatis-entry --- python3.3-3.3.3.orig/debian/PVER.postinst.in +++ python3.3-3.3.3/debian/PVER.postinst.in @@ -0,0 +1,20 @@ +#! /bin/sh + +set -e + +case "$1" in + configure) + files=$(dpkg -L lib@PVER@-stdlib | sed -n '/^\/usr\/lib\/@PVER@\/.*\.py$/p') + if [ -n "$files" ]; then + @PVER@ -E -S /usr/lib/@PVER@/py_compile.py $files + if grep -sq '^byte-compile[^#]*optimize' /etc/python/debian_config; then + @PVER@ -E -S -O /usr/lib/@PVER@/py_compile.py $files + fi + else + echo >&2 "@PVER@: can't get files for byte-compilation" + fi +esac + +#DEBHELPER# + +exit 0 --- python3.3-3.3.3.orig/debian/PVER.prerm.in +++ python3.3-3.3.3/debian/PVER.prerm.in @@ -0,0 +1,31 @@ +#! /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 + 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 lib@PVER@-stdlib + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python3.3-3.3.3.orig/debian/README.Debian.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/README.PVER.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/README.Tk +++ python3.3-3.3.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.3-3.3.3.orig/debian/README.dbm +++ python3.3-3.3.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.3-3.3.3.orig/debian/README.idle-PVER.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/README.maintainers.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/README.python +++ python3.3-3.3.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.3-3.3.3.orig/debian/README.source +++ python3.3-3.3.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.3-3.3.3.orig/debian/_sysconfigdata.py +++ python3.3-3.3.3/debian/_sysconfigdata.py @@ -0,0 +1,6 @@ +import sys + +if hasattr(sys, 'gettotalrefcount'): + from _sysconfigdata_dm import * +else: + from _sysconfigdata_m import * --- python3.3-3.3.3.orig/debian/changelog +++ python3.3-3.3.3/debian/changelog @@ -0,0 +1,2734 @@ +python3.3 (3.3.3-4) unstable; urgency=low + + * Update to 20131208 from the 3.3 branch. + * Disable the test_uuid autopkg test, hanging, missing entropy? + * Build-depend on python3:any. + + -- Matthias Klose Sun, 08 Dec 2013 15:17:54 +0100 + +python3.3 (3.3.3-3) unstable; urgency=low + + * Update to 20131127 from the 3.3 branch. + * Don't provide python3.3-dbm, available in a separate package. + * (Build-)depend on net-tools, test_uuid requires ifconfig. + * Fix distutils.sysconfig.get_makefile_filename(). Closes: #730601. + + -- Matthias Klose Wed, 27 Nov 2013 17:19:49 +0100 + +python3.3 (3.3.3-2) unstable; urgency=low + + * Update to 20131123 from the 3.3 branch. + * Update hurd-path_max.diff. + + -- Matthias Klose Sat, 23 Nov 2013 08:57:21 +0100 + +python3.3 (3.3.3-1) unstable; urgency=low + + * Python 3.3.3 release. + * Update to 20131119 from the 3.3 branch. + * Regenerate the patches. + * Update the symbols files. + * Fix test support when the running kernel doesn't handle port reuse. + * libpython3.3-minimal replaces libpython3.3-stdlib (<< 3.2.3-7). + Closes: #725240. + + -- Matthias Klose Tue, 19 Nov 2013 08:46:55 +0100 + +python3.3 (3.3.2-7) unstable; urgency=low + + * Update to 20130918 from the 3.3 branch. + * Update symbols file. + * Fail the build if extensions for the minimal package are not in + the libpython-minimal package. Closes: #723624. + * Fix indentation in regenerated platform-lsbrelease.diff (Dmitry Shachnev). + LP: #1220508. + * Point to the python3-tk (instead of the python-tk) package when missing. + LP: #1184082. + + -- Matthias Klose Wed, 18 Sep 2013 12:19:47 +0200 + +python3.3 (3.3.2-6) unstable; urgency=medium + + * Update to 20130917 from the 3.3 branch. + - Fix SSL module to handle NULL bytes inside subjectAltNames general + names (CVE-2013-4238). Closes: #719567. + * Don't run the curses autopkg test. + * Set Multi-Arch attributes for binary packages. + * Fix multiarch include header for sparc64. Closes: #714802. + + -- Matthias Klose Tue, 17 Sep 2013 15:12:00 +0200 + +python3.3 (3.3.2-5) unstable; urgency=low + + * Update to 20130803 from the 3.3 branch. + - Fix fcntl test case on KFreeBSD (Petr Salinger). + * Disable some socket tests on KFreeBSD (Petr Salinger). + * Fix multiarch include header for sparc64. Closes: #714802. + * Update package descriptions (Filipus Klutiero). Closes: #715801. + + -- Matthias Klose Sun, 04 Aug 2013 17:38:35 +0200 + +python3.3 (3.3.2-4) unstable; urgency=low + + * Update to 20130612 from the 3.3 branch. + * Refresh patches. + * Don't run consistency check for cross builds. + * Really skip byte compile of non-existing sitecustomize.py. + * Fix the multiarch header file for mips64 (YunQiang Su). Closes: #710374. + + -- Matthias Klose Wed, 12 Jun 2013 22:55:02 +0200 + +python3.3 (3.3.2-3) unstable; urgency=low + + * Update to 20130527 from the 3.3 branch. + - Fix #17980, possible abuse of ssl.match_hostname() for denial of service + using certificates with many wildcards (CVE-2013-2099). Closes: #708530. + * Disable the test_io test on armel, armhf, mips, mipsel. Hangs the + buildds. + * Don't try to byte-compile sitecustomize.py if the target of the + symlink doesn't exist anymore. Addresses: #709157. + * Fix directory removal in maintainer scripts. Closes: #709963. + * Handle byte compilation in python3.3{-minimal,}, byte removal in + libpython3.3{-minimal,-stdlib}. + * Backport patch to fix issue #13146, possible race conditions when writing + .pyc/.pyo files in py_compile.py (Barry Warsaw). LP: #1058884. + * Mark all _Py_dg_* symbols as optional on m68k. Closes: #709888. + + -- Matthias Klose Mon, 27 May 2013 20:44:03 +0200 + +python3.3 (3.3.2-2) unstable; urgency=high + + * Fix the multiarch header file for ppc64. Closes: #708646. + * Disable running the tests on kfreebsd and the hurd. Please + follow-up in #708652 and #708653. + + -- Matthias Klose Fri, 17 May 2013 23:16:04 +0200 + +python3.3 (3.3.2-1) unstable; urgency=low + + * Python 3.3.2 release. + * Fix sysconfig.get_makefile_name() for the multiarch location. + * Set the platinclude dir back to the non-multiarch include path, + where the multiarch pyconfig.h compatibility header is found. + * Remove obsolete profile-doc patch. + * Run the pgo profile task in batches to avoid crashes during the + pgo profile run. + * Don't set yet any Multi-Arch: attributes in Debian. + * Build a libpython3.3-testsuite package. + * Add autopkg tests to run the installed testsuite in normal and debug + mode. + * Re-enable running the tests during the build. + * Add pyconfig.h compatibility headers. + + -- Matthias Klose Wed, 15 May 2013 19:41:15 +0200 + +python3.3 (3.3.1-1ubuntu5) raring; urgency=low + + * Remove obsolete profile-doc patch. + * Run the pgo profile task in batches to avoid crashes during the + pgo profile run. + * Disable the lto build on armhf for now. + * Final (?) set of autopkg test fixes. + * Issue #17012: shutil.which() no longer fallbacks to the PATH environment. + variable if empty path argument is specified. + * Issue #17782: Fix undefined behaviour on platforms where + ``struct timespec``'s "tv_nsec" member is not a C long. + + -- Matthias Klose Wed, 17 Apr 2013 23:35:49 +0200 + +python3.3 (3.3.1-1ubuntu4) raring; urgency=low + + * Don't run the test suite in random order. + * More autopkg test fixes. + + -- Matthias Klose Wed, 17 Apr 2013 13:33:00 +0200 + +python3.3 (3.3.1-1ubuntu3) raring; urgency=low + + * Fix sysconfig.get_makefile_name() for the multiarch location. + * Set the platinclude dir back to the non-multiarch include path, + where the multiarch pyconfig.h compatibility header is found. + * Fix autopkg tests. + * More autopkgtest fixes (Jean-Baptiste Lallement): + - redirect stderr of command 'stop apport' to /dev/null. output to stderr + is an error for adt. + - script.py waits for child to exit and exit with child's return code. + - xpickle is not a valid value for option -u of regrtest.py. Removed it + LP: #1169150. + * Issue #17754, setting LANG and LC_ALL for the compiler call in ctypes/util. + * Issue #17761, platform._parse_release_file doesn't close the + /etc/lsb-release file, and doesn't know about 'Ubuntu'. + + -- Matthias Klose Tue, 16 Apr 2013 17:33:35 +0200 + +python3.3 (3.3.1-1ubuntu2) raring; urgency=low + + * Idle updates: + - Issue #17657: Show full Tk version in IDLE's about dialog. + - Issue #17613: Prevent traceback when removing syntax colorizer. + - Issue #1207589: Backwards-compatibility patch for right-click menu. + - Issue #16887: Now accepts Cancel in tabify/untabify dialog box. + - Issue #17625: Close the replace dialog after it is used. + - Issue #14254: Now handles readline correctly across shell restarts. + - Issue #17614: No longer raises exception when quickly closing a file. + - Issue #6698: Now opens just an editor window when configured to do so. + - Issue #8900: Using keyboard shortcuts in IDLE to open a file no longer + raises an exception. + - Issue #6649: Fixed missing exit status. + * Build a libpython3.3-testsuite package. LP: #301629. + * Add autopkg tests to run the installed testsuite in normal and debug + mode. + * Re-enable running the tests during the build. + * Add pyconfig.h compatibility headers. LP: #1094246. + + -- Matthias Klose Wed, 10 Apr 2013 23:05:23 +0200 + +python3.3 (3.3.1-1ubuntu1) raring; urgency=low + + * Merge with Debian; remaining changes: + - Build-depend on python3:any instead of python3. + + -- Matthias Klose Sat, 06 Apr 2013 16:21:34 +0200 + +python3.3 (3.3.1-1) unstable; urgency=low + + * Python 3.3.1 release. + * Call python with -E -S for the byte compilation. + + -- Matthias Klose Sat, 06 Apr 2013 15:12:07 +0200 + +python3.3 (3.3.1~rc1-2) experimental; urgency=low + + * Fix byte-compiliation/-removal for the split-out library packages. + LP: #1160944. + + -- Matthias Klose Sat, 30 Mar 2013 13:36:40 +0100 + +python3.3 (3.3.1~rc1-1) experimental; urgency=low + + * Python 3.3.1 release candidate 1. + + -- Matthias Klose Tue, 26 Mar 2013 10:45:37 +0100 + +python3.3 (3.3.0-12) experimental; urgency=low + + * Update to 20130306 from the 3.3 branch. + * Remove the HAVE_FSYNC configure workaround, not needed for 3.3. + * Remove the python3 manual symlink (now shipped upstream by default). + Closes: #701051. + + -- Matthias Klose Wed, 06 Mar 2013 16:38:41 +0800 + +python3.3 (3.3.0-11) experimental; urgency=low + + * Update to 20130220 from the 3.3 branch. + + -- Matthias Klose Wed, 20 Feb 2013 15:40:05 +0100 + +python3.3 (3.3.0-10) experimental; urgency=low + + * Update to 20130126 from the 3.3 branch. + * Update hurd patches. + * python3.3-dbg, libpython3.3-dbg: Drop dependency on python. + * python3.3-dbg: Make gdb (not gdb-minimal) a recommendation. + * Git rid of build-dependency on python. + * Add site-packages in virtual environments created by pyvenv. + Closes: #698777. + + -- Matthias Klose Sat, 26 Jan 2013 12:17:05 +0100 + +python3.3 (3.3.0-9) experimental; urgency=low + + * Update to 20130125 from the 3.3 branch. + * Update cross build patches, and allow the package to cross build. + + -- Matthias Klose Fri, 25 Jan 2013 17:06:25 +0100 + +python3.3 (3.3.0-8) experimental; urgency=low + + * Update to 20130105 from the 3.3 branch. + * python-config --help returns with an exit value 0. LP: #1093860. + * Update package description for the -dbg packages. Closes: #696616. + + -- Matthias Klose Sat, 05 Jan 2013 18:39:32 +0100 + +python3.3 (3.3.0-7) experimental; urgency=low + + * Update to 20121220 from the 3.3 branch. + * debian/patches/sys-multiarch.diff: Expose multiarch triplet value + as sys.implementation._multiarch (Barry Warsaw). Closes: #695959. + Note: Usage of sysconfig.get_config_var('MULTIARCH') is preferred. + * Set the install schema to `unix_prefix', if a virtual environment + is detected (VIRTUAL_ENV env var present). Closes: #695758. + * python3.3-dev, libpython3.3-dev: Drop the dependency on libssl-dev. + + -- Matthias Klose Fri, 21 Dec 2012 07:24:41 +0100 + +python3.3 (3.3.0-6) experimental; urgency=low + + * Don't use xattrs on kfreebsd and the Hurd. + + -- Matthias Klose Tue, 04 Dec 2012 04:36:42 +0100 + +python3.3 (3.3.0-5) experimental; urgency=low + + * Update to 20121203 from the 3.3 branch. + * Make python3.3, python3.3-{minimal,dev,dbg} Multi-Arch: allowed. + * Use a shell implementation for the python-config script. + + -- Matthias Klose Mon, 03 Dec 2012 21:52:33 +0100 + +python3.3 (3.3.0-4) experimental; urgency=low + + * Update to 20121128 from the 3.3 branch. + * Don't link extensions with the shared libpython library. + * Override pointless lintian warning `hardening-no-fortify-functions' + for binaries built without optimization. + + -- Matthias Klose Wed, 28 Nov 2012 13:47:16 +0100 + +python3.3 (3.3.0-3) experimental; urgency=low + + * Update to 20121106 from the 3.3 branch. + * Filter-out cflags for profiled builds from _sysconfigdata. + * Fix multiarch plat-linux installation. LP: #1075891. + * Install _sysconfigdata.py from the shared builds. LP: #1075903. + + -- Matthias Klose Wed, 07 Nov 2012 14:31:02 +0100 + +python3.3 (3.3.0-2) experimental; urgency=low + + * Update to 20121021 from the 3.3 branch. + * Fix the interpreter name for the python3.3-dbg-config script. + + -- Matthias Klose Sun, 21 Oct 2012 09:51:05 +0200 + +python3.3 (3.3.0-1) experimental; urgency=low + + * Python 3.3.0 release. + + -- Matthias Klose Sat, 29 Sep 2012 12:59:24 +0200 + +python3.3 (3.3.0~rc3-1) experimental; urgency=low + + * Python 3.3.0 release candidate 3. + * Don't try to write lib2to3's pickled grammar files. Closes: #687200. + * Fix python-config manpage symlink. Closes: #687201. + + -- Matthias Klose Mon, 24 Sep 2012 16:22:17 +0200 + +python3.3 (3.3.0~rc2-2ubuntu1) quantal; urgency=low + + * Encode the version in the devhelp documentation name. LP: #787039. + + -- Matthias Klose Mon, 10 Sep 2012 12:56:13 +0200 + +python3.3 (3.3.0~rc2-2) experimental; urgency=low + + * Fix typo fixing the pkgconfig file. + + -- Matthias Klose Mon, 10 Sep 2012 11:13:51 +0200 + +python3.3 (3.3.0~rc2-1) experimental; urgency=low + + * Python 3.3.0 release candidate 2. + * Add the platform include dir to pkgconfig's CFlags. + * Hint on installing the python-gdbm package on failing _gdbm import. + LP: #995616. + * libpython3.3: Fix libpython3.3.so symlink. Closes: #686377. + * Don't use `-n' anymore to start idle in the desktop/menu files. + + -- Matthias Klose Sun, 09 Sep 2012 13:38:55 +0200 + +python3.3 (3.3.0~rc1-2) experimental; urgency=low + + * distutils: Add the multiarch python path to the include directories. + Closes: #685041. + * Remove /etc/python3.3 in libpython3.3-minimal instead of python3.3-minimal. + Closes: #681979. + * Remove /etc/python/sysconfig.cfg, not available anymore in python3.3. + Closes: #685016. + * Don't ship the _gdbm and _tkinter extensions in the -dbg package. + Closes: #685261. + * Fix verbose parallel builds for the sharedmods target. + * Don't install the pickled lib2to3 grammar files. Closes: #685214. + * Build extensions with fortify flags. + * Overwrite arch-dependent-file-not-in-arch-specific-directory warnings. + + -- Matthias Klose Tue, 28 Aug 2012 19:47:58 +0200 + +python3.3 (3.3.0~rc1-1) experimental; urgency=low + + * Python 3.3.0 release candidate 1. + + -- Matthias Klose Sun, 26 Aug 2012 23:15:00 +0200 + +python3.3 (3.3.0~b2-1) experimental; urgency=low + + * Python 3.3.0 beta2 release. + * Fix removal of the _tkinter and dbm extensions for multiarch builds. + Closes: #684461. + * Use _sysconfigdata.py in distutils to initialize distutils. + Closes: #682475. + * Fix symlink for static libpython. Closes: #684608. + + -- Matthias Klose Mon, 13 Aug 2012 11:05:00 +0200 + +python3.3 (3.3.0~b1-3) experimental; urgency=low + + * Update to 20120712 from the trunk. + * Install separate _sysconfigdata.py for normal and debug builds. + * Install into multiarch locations. + * Split out multiarch packages libpython3.3-{minimal,stdlib,dev,dbg}. + + -- Matthias Klose Fri, 13 Jul 2012 00:43:42 +0200 + +python3.3 (3.3.0~b1-2) experimental; urgency=low + + * Update to 20120701 from the trunk. + + -- Matthias Klose Sun, 01 Jul 2012 11:45:12 +0200 + +python3.3 (3.3.0~b1-1) experimental; urgency=low + + * Python 3.3.0 beta1 release. + * Fix symlink for the -gdb.py file. + * debian/copyright: Add libmpdec license. + * Enable fortified build. + + -- Matthias Klose Wed, 27 Jun 2012 08:44:56 +0200 + +python3.3 (3.3.0~a4-1) experimental; urgency=low + + * Python 3.3.0 alpha4 release. + * Update to 20120620 from the trunk. + * Build _ctypes as an extension, not a builtin. + * Mark symbols defined in the _ctypes extension as optional. + * Remove references to the removed pyton3.3-documenting file. + * 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. + * Use the underscore.js file provided by the libjs-underscore package. + * Let pydoc handle dist-packages the same as site-packages. + * Avoid runtime path for the sqlite extension. + + -- Matthias Klose Wed, 20 Jun 2012 13:09:19 +0200 + +python3.3 (3.3.0~a3-1) experimental; urgency=low + + * Python 3.3.0 alpha3 release. + * Build the dbm extension using db5.3. + * Update symbols file for a3. + + -- Matthias Klose Wed, 02 May 2012 23:28:46 +0200 + +python3.3 (3.3.0~a2-1) experimental; urgency=low + + * Python 3.3.0 alpha2 release. + * Update to 20120404 from the trunk. + * Build-depend on expat (>= 2.1). + + -- Matthias Klose Wed, 04 Apr 2012 16:31:34 +0200 + +python3.3 (3.3.0~a1-1) experimental; urgency=low + + * Python 3.3.0 alpha1 release. + * Update to 20120321 from the trunk. + * Update debian/copyright. + * Build-depend on expat (>= 2.1~). + + -- Matthias Klose Thu, 22 Mar 2012 06:14:01 +0100 + +python3.3 (3.3~20120109-1) experimental; urgency=low + + * 3.3 20120109 snapshot from the trunk. + * Merge packaging from python3.2 3.2.2-4. + + -- Matthias Klose Sun, 08 Jan 2012 09:44:33 +0100 + +python3.3 (3.3~20110523-1) experimental; urgency=low + + * Initial Python 3.3 packaging. + + -- Matthias Klose Mon, 23 May 2011 09:20:52 +0200 + +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.3-3.3.3.orig/debian/changelog.shared +++ python3.3-3.3.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.3-3.3.3.orig/debian/compat +++ python3.3-3.3.3/debian/compat @@ -0,0 +1 @@ +5 --- python3.3-3.3.3.orig/debian/control +++ python3.3-3.3.3/debian/control @@ -0,0 +1,208 @@ +Source: python3.3 +Section: python +Priority: optional +Maintainer: Matthias Klose +Build-Depends: debhelper (>= 5.0.51~), quilt, autoconf, lsb-release, sharutils, + libreadline6-dev, libncursesw5-dev (>= 5.3), + zlib1g-dev, libbz2-dev, liblzma-dev, + libgdbm-dev, libdb-dev, + tk8.5-dev, blt-dev (>= 2.4z), libssl-dev, + libexpat1-dev, + libbluetooth-dev [!hurd-i386 !kfreebsd-i386 !kfreebsd-amd64], + locales [!armel !avr32 !hppa !ia64 !mipsel], + libsqlite3-dev, libffi-dev (>= 3.0.5), + libgpm2 [!hurd-i386 !kfreebsd-i386 !kfreebsd-amd64], + mime-support, netbase, bzip2, python3:any, + gcc (>= 4:4.8) [amd64 armel armhf i386 x32 kfreebsd-any hurd-any], + net-tools, xvfb, xauth +Build-Depends-Indep: python-sphinx +Standards-Version: 3.9.5 +Vcs-Browser: https://code.launchpad.net/~doko/python/pkg3.3-debian +Vcs-Bzr: http://bazaar.launchpad.net/~doko/python/pkg3.3-debian +XS-Testsuite: autopkgtest + +Package: python3.3 +Architecture: any +Multi-Arch: allowed +Priority: optional +Depends: python3.3-minimal (= ${binary:Version}), libpython3.3-stdlib (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends} +Suggests: python3.3-doc, binutils +Description: Interactive high-level object-oriented language (version 3.3) + Python is a high-level, interactive, object-oriented language. Its 3.3 version + includes an extensive class library with lots of goodies for + network programming, system administration, sounds and graphics. + +Package: libpython3.3-stdlib +Architecture: any +Multi-Arch: same +Priority: optional +Pre-Depends: multiarch-support +Depends: libpython3.3-minimal (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends} +Provides: python3.3-cjkcodecs, python3.3-ctypes, python3.3-elementtree, python3.3-celementtree, python3.3-wsgiref, python3.3-profiler, python3.3-lzma +Replaces: python3.3 (<< 3.3.1~rc1-2~) +Description: Interactive high-level object-oriented language (standard library, version 3.3) + Python is a high-level, interactive, object-oriented language. Its 3.3 version + includes an extensive class library with lots of goodies for + network programming, system administration, sounds and graphics. + . + This package contains Python 3.3's standard library. It is normally not + used on its own, but as a dependency of python3.3. + +Package: python3.3-minimal +Architecture: any +Multi-Arch: allowed +Priority: optional +Pre-Depends: ${shlibs:Pre-Depends} +Depends: libpython3.3-minimal (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Recommends: python3.3 +Suggests: binfmt-support +Replaces: python3.3 (<< 3.3~a4-1~) +Conflicts: binfmt-support (<< 1.1.2) +Description: Minimal subset of the Python language (version 3.3) + 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.3-minimal/README.Debian for a list of the modules + contained in this package. + +Package: libpython3.3-minimal +Architecture: any +Multi-Arch: same +Priority: optional +Pre-Depends: multiarch-support +Depends: ${shlibs:Depends}, ${misc:Depends} +Recommends: libpython3.3-stdlib +Replaces: python3.3 (<< 3.3~a4-1~), python3.3-minimal (<< 3.3.2-7), libpython3.3-stdlib (<< 3.3.2-7) +Breaks: python3.3-minimal (<< 3.3.1-0~) +Conflicts: binfmt-support (<< 1.1.2) +Description: Minimal subset of the Python language (version 3.3) + This package contains some essential modules. It is normally not + used on it's own, but as a dependency of python3.3-minimal. + +Package: libpython3.3 +Architecture: any +Multi-Arch: same +Section: libs +Priority: optional +Pre-Depends: multiarch-support +Depends: libpython3.3-stdlib (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Replaces: python3.3 (<< 3.0~rc1) +Description: Shared Python runtime library (version 3.3) + Python is a high-level, interactive, object-oriented language. Its 3.3 version + 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.3-examples +Architecture: all +Depends: python3.3 (>= ${source:Version}), ${misc:Depends} +Description: Examples for the Python language (v3.3) + Examples, Demos and Tools for Python (v3.3). These are files included in + the upstream Python distribution (v3.3). + +Package: python3.3-dev +Architecture: any +Multi-Arch: allowed +Depends: python3.3 (= ${binary:Version}), libpython3.3-dev (= ${binary:Version}), libpython3.3 (= ${binary:Version}), libexpat1-dev, ${shlibs:Depends}, ${misc:Depends} +Replaces: python3.3 (<< 3.2~rc1-2) +Recommends: libc6-dev | libc-dev +Description: Header files and a static library for Python (v3.3) + Header files, a static library and development tools for building + Python (v3.3) modules, extending the Python interpreter or embedding + Python (v3.3) in applications. + . + Maintainers of Python packages should read README.maintainers. + +Package: libpython3.3-dev +Section: libdevel +Architecture: any +Multi-Arch: same +Pre-Depends: multiarch-support +Depends: libpython3.3-stdlib (= ${binary:Version}), libpython3.3 (= ${binary:Version}), libexpat1-dev, ${shlibs:Depends}, ${misc:Depends} +Replaces: python3.3 (<< 3.2~rc1-2), python3.3-dev (<< 3.3.0~b1-2), python3.3-minimal (<< 3.3.0~rc1-1~) +Recommends: libc6-dev | libc-dev +Description: Header files and a static library for Python (v3.3) + Header files, a static library and development tools for building + Python (v3.3) modules, extending the Python interpreter or embedding + Python (v3.3) in applications. + . + Maintainers of Python packages should read README.maintainers. + . + This package contains development files. It is normally not + used on it's own, but as a dependency of python3.3-dev. + +Package: libpython3.3-testsuite +Section: libdevel +Architecture: all +Depends: libpython3.3-stdlib (>= ${binary:Version}), ${misc:Depends}, net-tools +Suggests: python3-gdbm, python3-tk +Description: Testsuite for the Python standard library (v3.3) + The complete testsuite for the Python standard library. Note that + a subset is found in the libpython3.3-stdlib package, which should + be enough for other packages to use (please do not build-depend + on this package, but file a bug report to include additional + testsuite files in the libpython3.3-stdlib package). + +Package: idle-python3.3 +Architecture: all +Depends: python3.3, python3-tk, python3.3-tk, ${misc:Depends} +Enhances: python3.3 +Description: IDE for Python (v3.3) using Tkinter + IDLE is an Integrated Development Environment for Python (v3.3). + IDLE is written using Tkinter and therefore quite platform-independent. + +Package: python3.3-doc +Section: doc +Architecture: all +Depends: libjs-jquery, libjs-underscore, ${misc:Depends} +Suggests: python3.3 +Description: Documentation for the high-level object-oriented language Python (v3.3) + These is the official set of documentation for the interactive high-level + object-oriented language Python (v3.3). All documents are provided + in HTML format. The package consists of ten documents: + . + * What's New in Python3.3 + * 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.3-dbg +Section: debug +Architecture: any +Multi-Arch: allowed +Priority: extra +Depends: python3.3 (= ${binary:Version}), libpython3.3-dbg (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Recommends: gdb +Suggests: python3-gdbm-dbg, python3-tk-dbg +Description: Debug Build of the Python Interpreter (version 3.3) + The package holds two things: + . + - A Python interpreter configured with --pydebug. Dynamically loaded modules + are searched as _d.so first. Third party extensions need a separate + build to be used by this interpreter. + - Debug information for standard python interpreter and extensions. + . + See the README.debug for more information. + +Package: libpython3.3-dbg +Section: debug +Architecture: any +Multi-Arch: same +Priority: extra +Pre-Depends: multiarch-support +Depends: libpython3.3-stdlib (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Replaces: python3.3-dbg (<< 3.3.0~rc1-1) +Description: Debug Build of the Python Interpreter (version 3.3) + The package holds two things: + . + - Extensions for a Python interpreter configured with --pydebug. + - Debug information for standard python extensions. + . + See the README.debug for more information. --- python3.3-3.3.3.orig/debian/control.in +++ python3.3-3.3.3/debian/control.in @@ -0,0 +1,208 @@ +Source: @PVER@ +Section: python +Priority: optional +Maintainer: Matthias Klose +Build-Depends: debhelper (>= 5.0.51~), quilt, autoconf, lsb-release, sharutils, + libreadline6-dev, libncursesw5-dev (>= 5.3), + zlib1g-dev, libbz2-dev, liblzma-dev, + libgdbm-dev, libdb-dev, + tk8.5-dev, blt-dev (>= 2.4z), libssl-dev, + libexpat1-dev, + libbluetooth-dev [!hurd-i386 !kfreebsd-i386 !kfreebsd-amd64], + locales [!armel !avr32 !hppa !ia64 !mipsel], + libsqlite3-dev, libffi-dev (>= 3.0.5), + libgpm2 [!hurd-i386 !kfreebsd-i386 !kfreebsd-amd64], + mime-support, netbase, bzip2, python3@bd_qual@, + gcc (>= 4:4.8) [amd64 armel armhf i386 x32 kfreebsd-any hurd-any], + net-tools, xvfb, xauth +Build-Depends-Indep: python-sphinx +Standards-Version: 3.9.5 +Vcs-Browser: https://code.launchpad.net/~doko/python/pkg@VER@-debian +Vcs-Bzr: http://bazaar.launchpad.net/~doko/python/pkg@VER@-debian +XS-Testsuite: autopkgtest + +Package: @PVER@ +Architecture: any +Multi-Arch: allowed +Priority: @PRIO@ +Depends: @PVER@-minimal (= ${binary:Version}), lib@PVER@-stdlib (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends} +Suggests: @PVER@-doc, binutils +Description: Interactive high-level object-oriented language (version @VER@) + Python is a high-level, interactive, object-oriented language. Its @VER@ version + includes an extensive class library with lots of goodies for + network programming, system administration, sounds and graphics. + +Package: lib@PVER@-stdlib +Architecture: any +Multi-Arch: same +Priority: @PRIO@ +Pre-Depends: multiarch-support +Depends: lib@PVER@-minimal (= ${binary:Version}), mime-support, ${shlibs:Depends}, ${misc:Depends} +Provides: python@VER@-cjkcodecs, python@VER@-ctypes, python@VER@-elementtree, python@VER@-celementtree, python@VER@-wsgiref, @PVER@-profiler, @PVER@-lzma +Replaces: @PVER@ (<< 3.3.1~rc1-2~) +Description: Interactive high-level object-oriented language (standard library, version @VER@) + Python is a high-level, interactive, object-oriented language. Its @VER@ version + includes an extensive class library with lots of goodies for + network programming, system administration, sounds and graphics. + . + This package contains Python @VER@'s standard library. It is normally not + used on its own, but as a dependency of python@VER@. + +Package: @PVER@-minimal +Architecture: any +Multi-Arch: allowed +Priority: @MINPRIO@ +Pre-Depends: ${shlibs:Pre-Depends} +Depends: lib@PVER@-minimal (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Recommends: @PVER@ +Suggests: binfmt-support +Replaces: @PVER@ (<< 3.3~a4-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@-minimal +Architecture: any +Multi-Arch: same +Priority: @MINPRIO@ +Pre-Depends: multiarch-support +Depends: ${shlibs:Depends}, ${misc:Depends} +Recommends: lib@PVER@-stdlib +Replaces: @PVER@ (<< 3.3~a4-1~), @PVER@-minimal (<< 3.3.2-7), lib@PVER@-stdlib (<< 3.3.2-7) +Breaks: @PVER@-minimal (<< 3.3.1-0~) +Conflicts: binfmt-support (<< 1.1.2) +Description: Minimal subset of the Python language (version @VER@) + This package contains some essential modules. It is normally not + used on it's own, but as a dependency of @PVER@-minimal. + +Package: lib@PVER@ +Architecture: any +Multi-Arch: same +Section: libs +Priority: @PRIO@ +Pre-Depends: multiarch-support +Depends: lib@PVER@-stdlib (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Replaces: @PVER@ (<< 3.0~rc1) +Description: Shared Python runtime library (version @VER@) + Python is a high-level, interactive, object-oriented language. Its @VER@ version + 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 +Multi-Arch: allowed +Depends: @PVER@ (= ${binary:Version}), lib@PVER@-dev (= ${binary:Version}), lib@PVER@ (= ${binary:Version}), libexpat1-dev, ${shlibs:Depends}, ${misc:Depends} +Replaces: @PVER@ (<< 3.2~rc1-2) +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: lib@PVER@-dev +Section: libdevel +Architecture: any +Multi-Arch: same +Pre-Depends: multiarch-support +Depends: lib@PVER@-stdlib (= ${binary:Version}), lib@PVER@ (= ${binary:Version}), libexpat1-dev, ${shlibs:Depends}, ${misc:Depends} +Replaces: @PVER@ (<< 3.2~rc1-2), @PVER@-dev (<< 3.3.0~b1-2), @PVER@-minimal (<< 3.3.0~rc1-1~) +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. + . + This package contains development files. It is normally not + used on it's own, but as a dependency of @PVER@-dev. + +Package: lib@PVER@-testsuite +Section: libdevel +Architecture: all +Depends: lib@PVER@-stdlib (>= ${binary:Version}), ${misc:Depends}, net-tools +Suggests: python3-gdbm, python3-tk +Description: Testsuite for the Python standard library (v@VER@) + The complete testsuite for the Python standard library. Note that + a subset is found in the lib@PVER@-stdlib package, which should + be enough for other packages to use (please do not build-depend + on this package, but file a bug report to include additional + testsuite files in the lib@PVER@-stdlib package). + +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 +Multi-Arch: allowed +Priority: extra +Depends: @PVER@ (= ${binary:Version}), lib@PVER@-dbg (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Recommends: gdb +Suggests: python3-gdbm-dbg, python3-tk-dbg +Description: Debug Build of the Python Interpreter (version @VER@) + The package holds two things: + . + - A Python interpreter configured with --pydebug. Dynamically loaded modules + are searched as _d.so first. Third party extensions need a separate + build to be used by this interpreter. + - Debug information for standard python interpreter and extensions. + . + See the README.debug for more information. + +Package: lib@PVER@-dbg +Section: debug +Architecture: any +Multi-Arch: same +Priority: extra +Pre-Depends: multiarch-support +Depends: lib@PVER@-stdlib (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} +Replaces: @PVER@-dbg (<< 3.3.0~rc1-1) +Description: Debug Build of the Python Interpreter (version @VER@) + The package holds two things: + . + - Extensions for a Python interpreter configured with --pydebug. + - Debug information for standard python extensions. + . + See the README.debug for more information. --- python3.3-3.3.3.orig/debian/control.stdlib +++ python3.3-3.3.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.3-3.3.3.orig/debian/control.udeb +++ python3.3-3.3.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.3-3.3.3.orig/debian/copyright +++ python3.3-3.3.3/debian/copyright @@ -0,0 +1,1027 @@ +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 + 3.3 3.2 2012 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: Include/dynamic_annotations.h +Files: Python/dynamic_annotations.c +Copyright: (c) 2008-2009, Google Inc. +License: Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Neither the name of Google Inc. 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 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. + +Files: Include/unicodeobject.h +Copyright: (c) Corporation for National Research Initiatives. +Copyright: (c) 1999 by Secret Labs AB. +Copyright: (c) 1999 by Fredrik Lundh. +License: 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 MERCHANTABILITY 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. + +Files: Lib/logging/* +Copyright: 2001-2010 by Vinay Sajip. All Rights Reserved. +License: 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 Vinay Sajip + not be used in advertising or publicity pertaining to distribution + of the software without specific, written prior permission. + VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL + VINAY SAJIP 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: Lib/multiprocessing/* +Files: Modules/_multiprocessing/* +Copyright: (c) 2006-2008, R Oudkerk. All rights reserved. +License: Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of author nor the names of any contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + +Files: Lib/sqlite3/* +Files: Modules/_sqlite/* +Copyright: (C) 2004-2005 Gerhard Häring +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. + +Files: Lib/async* +Copyright: Copyright 1996 by Sam Rushing +License: 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 Sam + Rushing not be used in advertising or publicity pertaining to + distribution of the software without specific, written prior + permission. + + SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + NO EVENT SHALL SAM RUSHING 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: Lib/tarfile.py +Copyright: (C) 2002 Lars Gustaebel +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: Lib/turtle.py +Copyright: (C) 2006 - 2010 Gregor Lingl +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. + + is copyright Gregor Lingl and licensed under a BSD-like license + +Files: Modules/_ctypes/libffi/* +Copyright: Copyright (C) 1996-2011 Red Hat, Inc and others. + Copyright (C) 1996-2011 Anthony Green + Copyright (C) 1996-2010 Free Software Foundation, Inc + Copyright (c) 2003, 2004, 2006, 2007, 2008 Kaz Kojima + Copyright (c) 2010, 2011, Plausible Labs Cooperative , Inc. + Copyright (c) 2010 CodeSourcery + Copyright (c) 1998 Andreas Schwab + Copyright (c) 2000 Hewlett Packard Company + Copyright (c) 2009 Bradley Smith + Copyright (c) 2008 David Daney + Copyright (c) 2004 Simon Posnjak + Copyright (c) 2005 Axis Communications AB + Copyright (c) 1998 Cygnus Solutions + Copyright (c) 2004 Renesas Technology + Copyright (c) 2002, 2007 Bo Thorsen + Copyright (c) 2002 Ranjit Mathew + Copyright (c) 2002 Roger Sayle + Copyright (c) 2000, 2007 Software AG + Copyright (c) 2003 Jakub Jelinek + Copyright (c) 2000, 2001 John Hornkvist + Copyright (c) 1998 Geoffrey Keating + Copyright (c) 2008 Björn König + +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/_gestalt.c +Copyright: 1991-1997 by Stichting Mathematisch Centrum, Amsterdam. +License: 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 names 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. + +Files: Modules/syslogmodule.c +Copyright: 1994 by Lance Ellinghouse +License: 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 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: 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/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: Modules/_decimal/libmpdec/* +Copyright: Copyright (c) 2008-2012 Stefan Krah. All rights reserved. +License: 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. + , + THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + +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: Python/dtoa.c +Copyright: (c) 1991, 2000, 2001 by Lucent Technologies. +License: Permission to use, copy, modify, and distribute this software for any + purpose without fee is hereby granted, provided that this entire 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 SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED + WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY + REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY + OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. + +Files: Python/getopt.c +Copyright: 1992-1994, David Gottner +License: 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, this permission notice and + the following disclaimer notice appear unmodified in all copies. + + I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL I + 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/_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 */ + +Files: Tools/pybench/* +Copyright: (c), 1997-2006, Marc-Andre Lemburg (mal@lemburg.com) + (c), 2000-2006, eGenix.com Software GmbH (info@egenix.com) +License: Permission to use, copy, modify, and distribute this software and its + documentation for any purpose and without fee or royalty 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 or portions thereof, including + modifications, that you make. + + THE AUTHOR MARC-ANDRE LEMBURG DISCLAIMS ALL WARRANTIES WITH REGARD TO + THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS, IN NO EVENT SHALL 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 ! --- python3.3-3.3.3.orig/debian/depgraph.py +++ python3.3-3.3.3/debian/depgraph.py @@ -0,0 +1,199 @@ +#! /usr/bin/python3 + +# 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 list(p.items()): + for v in list(d.keys()): + if v not in p: + 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 = list(p.items()) + allkd.sort() + for k,d in allkd: + tk = t.get(k) + if self.use(k,tk): + allv = list(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.3-3.3.3.orig/debian/dh_doclink +++ python3.3-3.3.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 <. +# + +set -e + +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.3-3.3.3.orig/debian/idle-PVER.postrm.in +++ python3.3-3.3.3/debian/idle-PVER.postrm.in @@ -0,0 +1,11 @@ +#! /bin/sh + +set -e + +if [ "$1" = "purge" ]; then + rm -rf /etc/idle-@PVER@ +fi + +#DEBHELPER# + +exit 0 --- python3.3-3.3.3.orig/debian/idle-PVER.prerm.in +++ python3.3-3.3.3/debian/idle-PVER.prerm.in @@ -0,0 +1,33 @@ +#! /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 + 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.3-3.3.3.orig/debian/idle.desktop.in +++ python3.3-3.3.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@ +Icon=/usr/share/pixmaps/@PVER@.xpm +Terminal=false +Type=Application +Categories=Application;Development; +StartupNotify=true --- python3.3-3.3.3.orig/debian/libPVER-dbg.overrides.in +++ python3.3-3.3.3/debian/libPVER-dbg.overrides.in @@ -0,0 +1,13 @@ +lib@PVER@-dbg binary: package-name-doesnt-match-sonames +lib@PVER@-dbg binary: non-dev-pkg-with-shlib-symlink + +# no, it's not unusual +lib@PVER@-dbg binary: unusual-interpreter + +# just the gdb debug file +lib@PVER@-dbg binary: python-script-but-no-python-dep + +# pointless lintian ... +lib@PVER@-dbg binary: hardening-no-fortify-functions + +lib@PVER@-dbg binary: arch-dependent-file-not-in-arch-specific-directory --- python3.3-3.3.3.orig/debian/libPVER-dbg.prerm.in +++ python3.3-3.3.3/debian/libPVER-dbg.prerm.in @@ -0,0 +1,23 @@ +#! /bin/sh + +set -e + +case "$1" in + remove) + dpkg -L lib@PVER@-dbg \ + | awk '/\.py$/ {print $0"c\n" $0"o"}' \ + | xargs -r rm -f >&2 + ;; + upgrade) + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python3.3-3.3.3.orig/debian/libPVER-dbg.symbols.i386.in +++ python3.3-3.3.3/debian/libPVER-dbg.symbols.i386.in @@ -0,0 +1,40 @@ +libpython@VER@dm.so.1.0 libpython@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@ + _PyUnicode_CheckConsistency@Base @SVER@ + _PyUnicode_Dump@Base @SVER@ + _PyUnicode_compact_data@Base @SVER@ + _PyUnicode_data@Base @SVER@ + _PyUnicode_utf8@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.3-3.3.3.orig/debian/libPVER-dbg.symbols.in +++ python3.3-3.3.3/debian/libPVER-dbg.symbols.in @@ -0,0 +1,38 @@ +libpython@VER@dm.so.1.0 libpython@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@ + _PyUnicode_CheckConsistency@Base @SVER@ + _PyUnicode_Dump@Base @SVER@ + _PyUnicode_compact_data@Base @SVER@ + _PyUnicode_data@Base @SVER@ + _PyUnicode_utf8@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.3-3.3.3.orig/debian/libPVER-dev.overrides.in +++ python3.3-3.3.3/debian/libPVER-dev.overrides.in @@ -0,0 +1,3 @@ +lib@PVER@-dev binary: python-script-but-no-python-dep + +lib@PVER@-dev binary: arch-dependent-file-not-in-arch-specific-directory --- python3.3-3.3.3.orig/debian/libPVER-minimal.overrides.in +++ python3.3-3.3.3/debian/libPVER-minimal.overrides.in @@ -0,0 +1,5 @@ +# intentional +lib@PVER@-minimal binary: python-script-but-no-python-dep + +# lintian omission, multiarch string is encoded in the filename +lib@PVER@-minimal binary: arch-dependent-file-not-in-arch-specific-directory --- python3.3-3.3.3.orig/debian/libPVER-minimal.postinst.in +++ python3.3-3.3.3/debian/libPVER-minimal.postinst.in @@ -0,0 +1,13 @@ +#! /bin/sh + +set -e + +if [ ! -f /etc/@PVER@/sitecustomize.py ]; then + cat <<-EOF + # Empty sitecustomize.py to avoid a dangling symlink +EOF +fi + +#DEBHELPER# + +exit 0 --- python3.3-3.3.3.orig/debian/libPVER-minimal.postrm.in +++ python3.3-3.3.3/debian/libPVER-minimal.postrm.in @@ -0,0 +1,21 @@ +#! /bin/sh + +set -e + +if [ "$1" = "purge" ]; then + pc=$(dpkg-query -f '${db:Status-Abbrev} ${binary:Package}\n' -W pkgname \ + | grep -v '^.n' | wc -l) + if [ "$pc" -lt 1 ]; then + find /usr/lib/@PVER@ -depth -type d -name __pycache__ \ + | xargs -r rm -rf + rm -f /etc/@PVER@/sitecustomize.py + rm -rf /etc/@PVER@/__pycache__ + if [ -d /etc/@PVER@ ]; then + rmdir --ignore-fail-on-non-empty /etc/@PVER@ + fi + fi +fi + +#DEBHELPER# + +exit 0 --- python3.3-3.3.3.orig/debian/libPVER-minimal.prerm.in +++ python3.3-3.3.3/debian/libPVER-minimal.prerm.in @@ -0,0 +1,41 @@ +#! /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 + find /usr/lib/python3 /usr/lib/@PVER@ \ + \( -name dist-packages -prune \) -o \ + \( -name __pycache__ -type d -empty -print \) \ + | xargs -r rm -rf +} + +case "$1" in + remove) + pc=$(dpkg-query -f '${db:Status-Abbrev} ${binary:Package}\n' -W pkgname \ + | grep -v '^.n' | wc -l) + if [ "$pc" -le 1 ]; then + remove_bytecode lib@PVER@-minimal + fi + ;; + upgrade) + remove_bytecode lib@PVER@-minimal + # byte compilation in @PVER@-minimal postinst, strict dependency + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python3.3-3.3.3.orig/debian/libPVER-stdlib.overrides.in +++ python3.3-3.3.3/debian/libPVER-stdlib.overrides.in @@ -0,0 +1,15 @@ +# idlelib images +lib@PVER@-stdlib binary: image-file-in-usr-lib + +# license file referred by the standard library +lib@PVER@-stdlib binary: extra-license-file + +# template files +lib@PVER@-stdlib binary: interpreter-not-absolute usr/lib/python3.3/venv/scripts/posix/pydoc #!__VENV_PYTHON__ +lib@PVER@-stdlib binary: unusual-interpreter usr/lib/python3.3/venv/scripts/posix/pydoc #!__VENV_PYTHON__ + +# the split is the reason for that +lib@PVER@-stdlib binary: python-script-but-no-python-dep + +# lintian omission, multiarch string is encoded in the filename +lib@PVER@-stdlib binary: arch-dependent-file-not-in-arch-specific-directory --- python3.3-3.3.3.orig/debian/libPVER-stdlib.prerm.in +++ python3.3-3.3.3/debian/libPVER-stdlib.prerm.in @@ -0,0 +1,41 @@ +#! /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 + find /usr/lib/python3 /usr/lib/@PVER@ \ + \( -name dist-packages -prune \) -o \ + \( -name __pycache__ -type d -empty -print \) \ + | xargs -r rm -rf +} + +case "$1" in + remove) + pc=$(dpkg-query -f '${db:Status-Abbrev} ${binary:Package}\n' -W pkgname \ + | grep -v '^.n' | wc -l) + if [ "$pc" -le 1 ]; then + remove_bytecode lib@PVER@-stdlib + fi + ;; + upgrade) + remove_bytecode lib@PVER@-stdlib + # byte compilation in @PVER@ postinst, strict dependency + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python3.3-3.3.3.orig/debian/libPVER-testsuite.overrides.in +++ python3.3-3.3.3/debian/libPVER-testsuite.overrides.in @@ -0,0 +1,2 @@ +lib@PVER@-testsuite binary: python-script-but-no-python-dep +lib@PVER@-testsuite binary: image-file-in-usr-lib --- python3.3-3.3.3.orig/debian/libPVER-testsuite.prerm.in +++ python3.3-3.3.3/debian/libPVER-testsuite.prerm.in @@ -0,0 +1,31 @@ +#! /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 +} + +case "$1" in + remove) + remove_bytecode lib@PVER@-testsuite + ;; + upgrade) + ;; + deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# --- python3.3-3.3.3.orig/debian/libPVER.overrides.in +++ python3.3-3.3.3/debian/libPVER.overrides.in @@ -0,0 +1 @@ +lib@PVER@ binary: package-name-doesnt-match-sonames --- python3.3-3.3.3.orig/debian/libPVER.symbols.i386.in +++ python3.3-3.3.3/debian/libPVER.symbols.i386.in @@ -0,0 +1,8 @@ +libpython@VER@m.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@ + + (optional)__gnu_lto_v1@Base @SVER@ --- python3.3-3.3.3.orig/debian/libPVER.symbols.in +++ python3.3-3.3.3/debian/libPVER.symbols.in @@ -0,0 +1,5 @@ +libpython@VER@m.so.1.0 libpython@VER@ #MINVER# +#include "libpython.symbols" + PyModule_Create2@Base @SVER@ + + (optional)__gnu_lto_v1@Base @SVER@ --- python3.3-3.3.3.orig/debian/libPVER.symbols.lpia.in +++ python3.3-3.3.3/debian/libPVER.symbols.lpia.in @@ -0,0 +1,6 @@ +libpython@VER@m.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.3-3.3.3.orig/debian/libpython.symbols.in +++ python3.3-3.3.3/debian/libpython.symbols.in @@ -0,0 +1,1472 @@ + PyAST_Check@Base @SVER@ + PyAST_Compile@Base @SVER@ + PyAST_CompileEx@Base @SVER@ + PyAST_FromNode@Base @SVER@ + PyAST_Validate@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_ClearFreeList@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_GetExcInfo@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_SetExcInfo@Base @SVER@ + PyErr_SetFromErrno@Base @SVER@ + PyErr_SetFromErrnoWithFilename@Base @SVER@ + PyErr_SetFromErrnoWithFilenameObject@Base @SVER@ + PyErr_SetImportError@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_BrokenPipeError@Base @SVER@ + PyExc_BufferError@Base @SVER@ + PyExc_BytesWarning@Base @SVER@ + PyExc_ChildProcessError@Base @SVER@ + PyExc_ConnectionAbortedError@Base @SVER@ + PyExc_ConnectionError@Base @SVER@ + PyExc_ConnectionRefusedError@Base @SVER@ + PyExc_ConnectionResetError@Base @SVER@ + PyExc_DeprecationWarning@Base @SVER@ + PyExc_EOFError@Base @SVER@ + PyExc_EnvironmentError@Base @SVER@ + PyExc_Exception@Base @SVER@ + PyExc_FileExistsError@Base @SVER@ + PyExc_FileNotFoundError@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_InterruptedError@Base @SVER@ + PyExc_IsADirectoryError@Base @SVER@ + PyExc_KeyError@Base @SVER@ + PyExc_KeyboardInterrupt@Base @SVER@ + PyExc_LookupError@Base @SVER@ + PyExc_MemoryError@Base @SVER@ + PyExc_NameError@Base @SVER@ + PyExc_NotADirectoryError@Base @SVER@ + PyExc_NotImplementedError@Base @SVER@ + PyExc_OSError@Base @SVER@ + PyExc_OverflowError@Base @SVER@ + PyExc_PendingDeprecationWarning@Base @SVER@ + PyExc_PermissionError@Base @SVER@ + PyExc_ProcessLookupError@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_TimeoutError@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_NewWithQualName@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_AddModuleObject@Base @SVER@ + PyImport_AppendInittab@Base @SVER@ + PyImport_Cleanup@Base @SVER@ + PyImport_ExecCodeModule@Base @SVER@ + PyImport_ExecCodeModuleEx@Base @SVER@ + PyImport_ExecCodeModuleObject@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_ImportFrozenModuleObject@Base @SVER@ + PyImport_ImportModule@Base @SVER@ + PyImport_ImportModuleLevel@Base @SVER@ + PyImport_ImportModuleLevelObject@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_ClearFreeList@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_FromUnicodeObject@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_FromMemory@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_GetNameObject@Base @SVER@ + PyModule_GetState@Base @SVER@ + PyModule_GetWarningsModule@Base @SVER@ + PyModule_New@Base @SVER@ + PyModule_NewObject@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@ + 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_GenericGetDict@Base @SVER@ + PyObject_GenericSetAttr@Base @SVER@ + PyObject_GenericSetDict@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_ClearError@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_ClearFreeList@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_Fini@Base @SVER@ + PySlice_GetIndices@Base @SVER@ + PySlice_GetIndicesEx@Base @SVER@ + PySlice_New@Base @SVER@ + PySlice_Type@Base @SVER@ + PyState_AddModule@Base @SVER@ + PyState_FindModule@Base @SVER@ + PyState_RemoveModule@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_GetInfo@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_FindEncodingFilename@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_FromSpecWithBases@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@ + PyUnicode_Append@Base @SVER@ + PyUnicode_AppendAndDel@Base @SVER@ + PyUnicode_AsASCIIString@Base @SVER@ + PyUnicode_AsCharmapString@Base @SVER@ + PyUnicode_AsDecodedObject@Base @SVER@ + PyUnicode_AsDecodedUnicode@Base @SVER@ + PyUnicode_AsEncodedObject@Base @SVER@ + PyUnicode_AsEncodedString@Base @SVER@ + PyUnicode_AsEncodedUnicode@Base @SVER@ + PyUnicode_AsLatin1String@Base @SVER@ + PyUnicode_AsRawUnicodeEscapeString@Base @SVER@ + PyUnicode_AsUCS4@Base @SVER@ + PyUnicode_AsUCS4Copy@Base @SVER@ + PyUnicode_AsUTF16String@Base @SVER@ + PyUnicode_AsUTF32String@Base @SVER@ + PyUnicode_AsUTF8@Base @SVER@ + PyUnicode_AsUTF8AndSize@Base @SVER@ + PyUnicode_AsUTF8String@Base @SVER@ + PyUnicode_AsUnicode@Base @SVER@ + PyUnicode_AsUnicodeAndSize@Base @SVER@ + PyUnicode_AsUnicodeCopy@Base @SVER@ + PyUnicode_AsUnicodeEscapeString@Base @SVER@ + PyUnicode_AsWideChar@Base @SVER@ + PyUnicode_AsWideCharString@Base @SVER@ + PyUnicode_BuildEncodingMap@Base @SVER@ + PyUnicode_ClearFreeList@Base @SVER@ + PyUnicode_Compare@Base @SVER@ + PyUnicode_CompareWithASCIIString@Base @SVER@ + PyUnicode_Concat@Base @SVER@ + PyUnicode_Contains@Base @SVER@ + PyUnicode_CopyCharacters@Base @SVER@ + PyUnicode_Count@Base @SVER@ + PyUnicode_Decode@Base @SVER@ + PyUnicode_DecodeASCII@Base @SVER@ + PyUnicode_DecodeCharmap@Base @SVER@ + PyUnicode_DecodeFSDefault@Base @SVER@ + PyUnicode_DecodeFSDefaultAndSize@Base @SVER@ + PyUnicode_DecodeLatin1@Base @SVER@ + PyUnicode_DecodeLocale@Base @SVER@ + PyUnicode_DecodeLocaleAndSize@Base @SVER@ + PyUnicode_DecodeRawUnicodeEscape@Base @SVER@ + PyUnicode_DecodeUTF16@Base @SVER@ + PyUnicode_DecodeUTF16Stateful@Base @SVER@ + PyUnicode_DecodeUTF32@Base @SVER@ + PyUnicode_DecodeUTF32Stateful@Base @SVER@ + PyUnicode_DecodeUTF7@Base @SVER@ + PyUnicode_DecodeUTF7Stateful@Base @SVER@ + PyUnicode_DecodeUTF8@Base @SVER@ + PyUnicode_DecodeUTF8Stateful@Base @SVER@ + PyUnicode_DecodeUnicodeEscape@Base @SVER@ + PyUnicode_Encode@Base @SVER@ + PyUnicode_EncodeASCII@Base @SVER@ + PyUnicode_EncodeCharmap@Base @SVER@ + PyUnicode_EncodeDecimal@Base @SVER@ + PyUnicode_EncodeFSDefault@Base @SVER@ + PyUnicode_EncodeUTF8@Base @SVER@ + PyUnicode_EncodeUnicodeEscape@Base @SVER@ + PyUnicode_FSConverter@Base @SVER@ + PyUnicode_FSDecoder@Base @SVER@ + PyUnicode_Fill@Base @SVER@ + PyUnicode_Find@Base @SVER@ + PyUnicode_FindChar@Base @SVER@ + PyUnicode_Format@Base @SVER@ + PyUnicode_FromEncodedObject@Base @SVER@ + PyUnicode_FromFormat@Base @SVER@ + PyUnicode_FromFormatV@Base @SVER@ + PyUnicode_FromKindAndData@Base @SVER@ + PyUnicode_FromObject@Base @SVER@ + PyUnicode_FromOrdinal@Base @SVER@ + PyUnicode_FromString@Base @SVER@ + PyUnicode_FromStringAndSize@Base @SVER@ + PyUnicode_FromUnicode@Base @SVER@ + PyUnicode_FromWideChar@Base @SVER@ + PyUnicode_GetDefaultEncoding@Base @SVER@ + PyUnicode_GetLength@Base @SVER@ + PyUnicode_GetMax@Base @SVER@ + PyUnicode_GetSize@Base @SVER@ + PyUnicode_EncodeLatin1@Base @SVER@ + PyUnicode_EncodeLocale@Base @SVER@ + PyUnicode_EncodeRawUnicodeEscape@Base @SVER@ + PyUnicode_EncodeUTF16@Base @SVER@ + PyUnicode_EncodeUTF32@Base @SVER@ + PyUnicode_EncodeUTF7@Base @SVER@ + PyUnicode_InternFromString@Base @SVER@ + PyUnicode_InternImmortal@Base @SVER@ + PyUnicode_InternInPlace@Base @SVER@ + PyUnicode_IsIdentifier@Base @SVER@ + PyUnicode_Join@Base @SVER@ + PyUnicode_New@Base @SVER@ + PyUnicode_Partition@Base @SVER@ + PyUnicode_RPartition@Base @SVER@ + PyUnicode_RSplit@Base @SVER@ + PyUnicode_ReadChar@Base @SVER@ + PyUnicode_Replace@Base @SVER@ + PyUnicode_Resize@Base @SVER@ + PyUnicode_RichCompare@Base @SVER@ + PyUnicode_Split@Base @SVER@ + PyUnicode_Splitlines@Base @SVER@ + PyUnicode_Substring@Base @SVER@ + PyUnicode_Tailmatch@Base @SVER@ + PyUnicode_TransformDecimalToASCII@Base @SVER@ + PyUnicode_Translate@Base @SVER@ + PyUnicode_TranslateCharmap@Base @SVER@ + PyUnicode_Type@Base @SVER@ + PyUnicode_WriteChar@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_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_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_hexdigits@Base @SVER@ + Py_meta_grammar@Base @SVER@ + Py_pgen@Base @SVER@ + _PyAccu_Accumulate@Base @SVER@ + _PyAccu_Destroy@Base @SVER@ + _PyAccu_Finish@Base @SVER@ + _PyAccu_FinishAsList@Base @SVER@ + _PyAccu_Init@Base @SVER@ + _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_Join@Base @SVER@ + _PyBytes_Resize@Base @SVER@ + _PyCFunction_DebugMallocStats@Base @SVER@ + _PyCapsule_hack@Base @SVER@ + _PyCode_CheckLineNumber@Base @SVER@ + _PyCodec_Lookup@Base @SVER@ + _PyComplex_FormatAdvancedWriter@Base @SVER@ + _PyDebugAllocatorStats@Base @SVER@ + _PyDictKeys_DecRef@Base @SVER@ + _PyDict_Contains@Base @SVER@ + _PyDict_DebugMallocStats@Base @SVER@ + _PyDict_GetItemId@Base @SVER@ + _PyDict_GetItemIdWithError@Base @SVER@ + _PyDict_HasOnlyStringKeys@Base @SVER@ + _PyDict_KeysSize@Base @SVER@ + _PyDict_LoadGlobal@Base @SVER@ + _PyDict_MaybeUntrack@Base @SVER@ + _PyDict_NewKeysForClass@Base @SVER@ + _PyDict_NewPresized@Base @SVER@ + _PyDict_Next@Base @SVER@ + _PyErr_BadInternalCall@Base @SVER@ + _PyDict_SetItemId@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@ + _PyFaulthandler_Fini@Base @SVER@ + _PyFaulthandler_Init@Base @SVER@ + _PyFileIO_closed@Base @SVER@ + _PyFloat_DebugMallocStats@Base @SVER@ + _PyFloat_FormatAdvancedWriter@Base @SVER@ + _PyFloat_Init@Base @SVER@ + _PyFloat_Pack4@Base @SVER@ + _PyFloat_Pack8@Base @SVER@ + _PyFloat_Unpack4@Base @SVER@ + _PyFloat_Unpack8@Base @SVER@ + _PyFrame_DebugMallocStats@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@ + _PyGen_FetchStopIterationValue@Base @SVER@ + _PyGen_Send@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_readall@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@ + _PyImportZip_Init@Base @SVER@ + _PyImport_AcquireLock@Base @SVER@ + _PyImport_DynLoadFiletab@Base @SVER@ + _PyImport_FindBuiltin@Base @SVER@ + _PyImport_FindExtensionObject@Base @SVER@ + _PyImport_Fini@Base @SVER@ + _PyImport_FixupBuiltin@Base @SVER@ + _PyImport_FixupExtensionObject@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_DebugMallocStats@Base @SVER@ + _PyList_Extend@Base @SVER@ + _PyLong_AsByteArray@Base @SVER@ + _PyLong_AsInt@Base @SVER@ + _PyLong_AsTime_t@Base @SVER@ + _PyLong_Copy@Base @SVER@ + _PyLong_DigitValue@Base @SVER@ + _PyLong_DivmodNear@Base @SVER@ + _PyLong_Format@Base @SVER@ + _PyLong_FormatAdvancedWriter@Base @SVER@ + _PyLong_FormatWriter@Base @SVER@ + _PyLong_Frexp@Base @SVER@ + _PyLong_FromByteArray@Base @SVER@ + _PyLong_FromBytes@Base @SVER@ + _PyLong_FromGid@Base @SVER@ + _PyLong_FromTime_t@Base @SVER@ + _PyLong_FromUid@Base @SVER@ + _PyLong_Init@Base @SVER@ + _PyLong_New@Base @SVER@ + _PyLong_NumBits@Base @SVER@ + _PyLong_Sign@Base @SVER@ + _PyManagedBuffer_Type@Base @SVER@ + _PyMethodWrapper_Type@Base @SVER@ + _PyMethod_DebugMallocStats@Base @SVER@ + _PyModule_Clear@Base @SVER@ + _PyNamespace_New@Base @SVER@ + _PyNamespace_Type@Base @SVER@ + _PyNode_SizeOf@Base @SVER@ + _PyOS_GetOpt@Base @SVER@ + _PyOS_IsMainThread@Base @SVER@ + _PyOS_ReadlineTState@Base @SVER@ + _PyOS_ResetGetOpt@Base @SVER@ + _PyOS_URandom@Base @SVER@ + _PyOS_mystrnicmp_hack@Base @SVER@ + _PyOS_optarg@Base @SVER@ + _PyOS_opterr@Base @SVER@ + _PyOS_optind@Base @SVER@ + _PyObjectDict_SetItem@Base @SVER@ + _PyObject_CallFunction_SizeT@Base @SVER@ + _PyObject_CallMethodId@Base @SVER@ + _PyObject_CallMethodObjIdArgs@Base @SVER@ + _PyObject_CallMethodId_SizeT@Base @SVER@ + _PyObject_CallMethod_SizeT@Base @SVER@ + _PyObject_DebugMallocStats@Base @SVER@ + _PyObject_DebugTypeStats@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_GetAttrId@Base @SVER@ + _PyObject_GetBuiltin@Base @SVER@ + _PyObject_GetDictPtr@Base @SVER@ + _PyObject_HasAttrId@Base @SVER@ + _PyObject_IsAbstract@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@ + _PyObject_SetAttrId@Base @SVER@ + _PyParser_Grammar@Base @SVER@ + _PyParser_TokenNames@Base @SVER@ + _PyRandom_Init@Base @SVER@ + _PySequence_BytesToCharpArray@Base @SVER@ + _PySequence_IterSearch@Base @SVER@ + _PySet_DebugMallocStats@Base @SVER@ + _PySet_NextEntry@Base @SVER@ + _PySet_Update@Base @SVER@ + _PySlice_FromIndices@Base @SVER@ + _PyState_AddModule@Base @SVER@ + _PySys_ImplCacheTag@Base @SVER@ + _PySys_ImplName@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_Init@Base @SVER@ + _PyTime_ObjectToTime_t@Base @SVER@ + _PyTime_ObjectToTimespec@Base @SVER@ + _PyTime_ObjectToTimeval@Base @SVER@ + _PyTime_gettimeofday@Base @SVER@ + _PyTime_gettimeofday_info@Base @SVER@ + _PyTrash_delete_later@Base @SVER@ + _PyTrash_delete_nesting@Base @SVER@ + _PyTrash_deposit_object@Base @SVER@ + _PyTrash_destroy_chain@Base @SVER@ + _PyTrash_thread_deposit_object@Base @SVER@ + _PyTrash_thread_destroy_chain@Base @SVER@ + _PyTuple_DebugMallocStats@Base @SVER@ + _PyTuple_MaybeUntrack@Base @SVER@ + _PyTuple_Resize@Base @SVER@ + _PyType_CalculateMetaclass@Base @SVER@ + _PyType_Fini@Base @SVER@ + _PyType_Lookup@Base @SVER@ + _PyType_LookupId@Base @SVER@ + _PyUnicodeTranslateError_Create@Base @SVER@ + _PyUnicodeWriter_Dealloc@Base @SVER@ + _PyUnicodeWriter_Finish@Base @SVER@ + _PyUnicodeWriter_Init@Base @SVER@ + _PyUnicodeWriter_PrepareInternal@Base @SVER@ + _PyUnicodeWriter_WriteStr@Base @SVER@ + _PyUnicode_AsASCIIString@Base @SVER@ + _PyUnicode_AsKind@Base @SVER@ + _PyUnicode_AsLatin1String@Base @SVER@ + _PyUnicode_AsUTF8String@Base @SVER@ + _PyUnicode_BidirectionalNames@Base @SVER@ + _PyUnicode_CategoryNames@Base @SVER@ + _PyUnicode_ClearStaticStrings@Base @SVER@ + _PyUnicode_Copy@Base @SVER@ + _PyUnicode_Database_Records@Base @SVER@ + _PyUnicode_DecodeUnicodeInternal@Base @SVER@ + _PyUnicode_EastAsianWidthNames@Base @SVER@ + _PyUnicode_EncodeCharmap@Base @SVER@ + _PyUnicode_EncodeUTF16@Base @SVER@ + _PyUnicode_EncodeUTF32@Base @SVER@ + _PyUnicode_EncodeUTF7@Base @SVER@ + _PyUnicode_ExtendedCase@Base @SVER@ + _PyUnicode_FastCopyCharacters@Base @SVER@ + _PyUnicode_FastFill@Base @SVER@ + _PyUnicode_FindMaxChar@Base @SVER@ + _PyUnicode_Fini@Base @SVER@ + _PyUnicode_FormatAdvancedWriter@Base @SVER@ + _PyUnicode_FromASCII@Base @SVER@ + _PyUnicode_FromId@Base @SVER@ + _PyUnicode_Init@Base @SVER@ + _PyUnicode_HasNULChars@Base @SVER@ + _PyUnicode_InsertThousandsGrouping@Base @SVER@ + _PyUnicode_IsAlpha@Base @SVER@ + _PyUnicode_IsCaseIgnorable@Base @SVER@ + _PyUnicode_IsCased@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_Ready@Base @SVER@ + _PyUnicode_ToDecimalDigit@Base @SVER@ + _PyUnicode_ToDigit@Base @SVER@ + _PyUnicode_ToFoldedFull@Base @SVER@ + _PyUnicode_ToLowerFull@Base @SVER@ + _PyUnicode_ToLowercase@Base @SVER@ + _PyUnicode_ToNumeric@Base @SVER@ + _PyUnicode_ToTitleFull@Base @SVER@ + _PyUnicode_ToTitlecase@Base @SVER@ + _PyUnicode_ToUpperFull@Base @SVER@ + _PyUnicode_ToUppercase@Base @SVER@ + _PyUnicode_TransformDecimalAndSpaceToASCII@Base @SVER@ + _PyUnicode_TranslateCharmap@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_DumpTraceback@Base @SVER@ + _Py_DumpTracebackThreads@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_Gid_Converter@Base @SVER@ + _Py_HashBytes@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_InitializeEx_Private@Base @SVER@ + _Py_Interactive@Base @SVER@ + _Py_Lambda@Base @SVER@ + _Py_List@Base @SVER@ + _Py_ListComp@Base @SVER@ + _Py_M__importlib@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_Try@Base @SVER@ + _Py_Tuple@Base @SVER@ + _Py_Uid_Converter@Base @SVER@ + _Py_UnaryOp@Base @SVER@ + _Py_VaBuildValue_SizeT@Base @SVER@ + _Py_While@Base @SVER@ + _Py_With@Base @SVER@ + _Py_Yield@Base @SVER@ + _Py_YieldFrom@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_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@ + _Py_device_encoding@Base @SVER@ + (arch=!m68k)_Py_dg_dtoa@Base @SVER@ + (arch=!m68k)_Py_dg_freedtoa@Base @SVER@ + (arch=!m68k)_Py_dg_infinity@Base @SVER@ + (arch=!m68k)_Py_dg_stdnan@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_hgidentifier@Base @SVER@ + _Py_hgversion@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_normalize_encoding@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_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_withitem@Base @SVER@ + _Py_wreadlink@Base @SVER@ + _Py_wrealpath@Base @SVER@ + _Py_wstat@Base @SVER@ + + 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.3-3.3.3.orig/debian/locale-gen +++ python3.3-3.3.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 < +# elif defined(__x86_64__) && defined(__ILP32__) +# include +# elif defined(__i386__) +# include +# elif defined(__aarch64__) && defined(__AARCH64EL__) +# include +# elif defined(__alpha__) +# include +# elif defined(__ARM_EABI__) && defined(__ARM_PCS_VFP) +# include +# elif defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP) +# include +# elif defined(__hppa__) +# include +# elif defined(__ia64__) +# include +# elif defined(__m68k__) && !defined(__mcoldfire__) +# include +# elif defined(__mips_hard_float) && defined(_MIPSEL) +# if _MIPS_SIM == _ABIO32 +# include +# elif _MIPS_SIM == _ABIN32 +# include +# elif _MIPS_SIM == _ABI64 +# include +# else +# error unknown multiarch location for @header@ +# endif +# elif defined(__mips_hard_float) +# if _MIPS_SIM == _ABIO32 +# include +# elif _MIPS_SIM == _ABIN32 +# include +# elif _MIPS_SIM == _ABI64 +# include +# else +# error unknown multiarch location for @header@ +# endif +# elif defined(__powerpc__) && defined(__SPE__) +# include +# elif defined(__powerpc64__) +# if defined(__LITTLE_ENDIAN__) +# include +# else +# include +# endif +# elif defined(__powerpc__) +# include +# elif defined(__s390x__) +# include +# elif defined(__s390__) +# include +# elif defined(__sh__) && defined(__LITTLE_ENDIAN__) +# include +# elif defined(__sparc__) && defined(__arch64__) +# include +# elif defined(__sparc__) +# include +# else +# error unknown multiarch location for @header@ +# endif +#elif defined(__FreeBSD_kernel__) +# if defined(__LP64__) +# include +# elif defined(__i386__) +# include +# else +# error unknown multiarch location for @header@ +# endif +#elif defined(__gnu_hurd__) +# include +#else +# error unknown multiarch location for @header@ +#endif --- python3.3-3.3.3.orig/debian/patches/add-python-config-sh.diff +++ python3.3-3.3.3/debian/patches/add-python-config-sh.diff @@ -0,0 +1,168 @@ +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -1182,6 +1182,8 @@ + # Substitution happens here, as the completely-expanded BINDIR + # is not available in configure + sed -e "s,@EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config ++ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR} ++ sed -e "s,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g" < Misc/python-config.sh >python-config.sh + + # Install the include files + INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY) +@@ -1240,6 +1242,7 @@ + $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup + $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh + $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(LDVERSION)-config ++ $(INSTALL_SCRIPT) python-config.sh $(DESTDIR)$(BINDIR)/python-config.sh + rm python-config + @if [ -s Modules/python.exp -a \ + "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \ +--- /dev/null ++++ b/Misc/python-config.sh.in +@@ -0,0 +1,107 @@ ++#!/bin/sh ++ ++exit_with_usage () ++{ ++ echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir" ++ exit $1 ++} ++ ++if [ "$1" = "" ] ; then ++ exit_with_usage 1 ++fi ++ ++# Returns the actual prefix where this script was installed to. ++installed_prefix () ++{ ++ local RESULT=$(dirname $(cd $(dirname "$1") && pwd -P)) ++ if [ $(which readlink) ] ; then ++ RESULT=$(readlink -f "$RESULT") ++ fi ++ echo $RESULT ++} ++ ++prefix_build="@prefix@" ++prefix_real=$(installed_prefix "$0") ++ ++# Use sed to fix paths from their built to locations to their installed to locations. ++prefix=$(echo "$prefix_build" | sed "s#$prefix_build#$prefix_real#") ++exec_prefix_build="@exec_prefix@" ++exec_prefix=$(echo "$exec_prefix_build" | sed "s#$exec_prefix_build#$prefix_real#") ++includedir=$(echo "@includedir@" | sed "s#$prefix_build#$prefix_real#") ++libdir=$(echo "@libdir@" | sed "s#$prefix_build#$prefix_real#") ++CFLAGS=$(echo "@CFLAGS@" | sed "s#$prefix_build#$prefix_real#") ++VERSION="@VERSION@" ++LIBM="@LIBM@" ++LIBC="@LIBC@" ++SYSLIBS="$LIBM $LIBC" ++ABIFLAGS="@ABIFLAGS@" ++MULTIARCH="@MULTIARCH@" ++LIBS="@LIBS@ $SYSLIBS -lpython${VERSION}${ABIFLAGS}" ++BASECFLAGS="@BASECFLAGS@" ++LDLIBRARY="@LDLIBRARY@" ++LINKFORSHARED="@LINKFORSHARED@" ++OPT="@OPT@" ++PY_ENABLE_SHARED="@PY_ENABLE_SHARED@" ++LDVERSION="@LDVERSION@" ++LIBDEST=${prefix}/lib/python${VERSION} ++LIBPL=$(echo "@LIBPL@" | sed "s#$prefix_build#$prefix_real#") ++SO="@EXT_SUFFIX@" ++PYTHONFRAMEWORK="@PYTHONFRAMEWORK@" ++INCDIR="-I$includedir/python${VERSION}${ABIFLAGS}" ++PLATINCDIR="-I$includedir/${MULTIARCH}/python${VERSION}${ABIFLAGS}" ++ ++# Scan for --help or unknown argument. ++for ARG in $* ++do ++ case $ARG in ++ --help) ++ exit_with_usage 0 ++ ;; ++ --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--abiflags|--configdir) ++ ;; ++ *) ++ exit_with_usage 1 ++ ;; ++ esac ++done ++ ++for ARG in $* ++do ++ case $ARG in ++ --prefix) ++ echo "$prefix" ++ ;; ++ --exec-prefix) ++ echo "$exec_prefix" ++ ;; ++ --includes) ++ echo "$INCDIR $PLATINCDIR" ++ ;; ++ --cflags) ++ echo "$INCDIR $PLATINCDIR $BASECFLAGS $CFLAGS $OPT" ++ ;; ++ --libs) ++ echo "$LIBS" ++ ;; ++ --ldflags) ++ LINKFORSHAREDUSED= ++ if [ -z "$PYTHONFRAMEWORK" ] ; then ++ LINKFORSHAREDUSED=$LINKFORSHARED ++ fi ++ LIBPLUSED= ++ if [ "$PY_ENABLE_SHARED" = "0" ] ; then ++ LIBPLUSED="-L$LIBPL" ++ fi ++ echo "$LIBPLUSED -L$libdir $LIBS $LINKFORSHAREDUSED" ++ ;; ++ --extension-suffix) ++ echo "$SO" ++ ;; ++ --abiflags) ++ echo "$ABIFLAGS" ++ ;; ++ --configdir) ++ echo "$LIBPL" ++ ;; ++esac ++done +--- a/configure.ac ++++ b/configure.ac +@@ -917,6 +917,7 @@ + + # Other platforms follow + if test $enable_shared = "yes"; then ++ PY_ENABLE_SHARED=1 + AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.]) + case $ac_sys_system in + CYGWIN*) +@@ -972,6 +973,7 @@ + + esac + else # shared is disabled ++ PY_ENABLE_SHARED=0 + case $ac_sys_system in + CYGWIN*) + BLDLIBRARY='$(LIBRARY)' +@@ -3982,6 +3984,11 @@ + LDVERSION='$(VERSION)$(ABIFLAGS)' + AC_MSG_RESULT($LDVERSION) + ++dnl define LIBPL after ABIFLAGS and LDVERSION are defined. ++AC_SUBST(PY_ENABLE_SHARED) ++LIBPL="${prefix}"/lib/python"${VERSION}"/config-"${LDVERSION}-${MULTIARCH}" ++AC_SUBST(LIBPL) ++ + # 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) +@@ -4672,7 +4679,7 @@ + fi + + # generate output files +-AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc) ++AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc Misc/python-config.sh) + AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) + AC_OUTPUT + --- python3.3-3.3.3.orig/debian/patches/apport-support.dpatch +++ python3.3-3.3.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.3-3.3.3.orig/debian/patches/atomic-pyc-rename.diff +++ python3.3-3.3.3/debian/patches/atomic-pyc-rename.diff @@ -0,0 +1,36 @@ +--- a/Lib/py_compile.py ++++ b/Lib/py_compile.py +@@ -138,14 +138,25 @@ + except OSError as error: + if error.errno != errno.EEXIST: + raise +- with open(cfile, 'wb') as fc: +- fc.write(b'\0\0\0\0') +- wr_long(fc, timestamp) +- wr_long(fc, size) +- marshal.dump(codeobject, fc) +- fc.flush() +- fc.seek(0, 0) +- fc.write(MAGIC) ++ # Atomically write the pyc/pyo file. Issue #13146. ++ # id() is used to generate a pseudo-random filename. ++ path_tmp = '{}.{}'.format(cfile, id(cfile)) ++ try: ++ with open(path_tmp, 'wb') as fc: ++ fc.write(b'\0\0\0\0') ++ wr_long(fc, timestamp) ++ wr_long(fc, size) ++ marshal.dump(codeobject, fc) ++ fc.flush() ++ fc.seek(0, 0) ++ fc.write(MAGIC) ++ os.rename(path_tmp, cfile) ++ except OSError: ++ try: ++ os.unlink(path_tmp) ++ except OSError: ++ pass ++ raise + return cfile + + def main(args=None): --- python3.3-3.3.3.orig/debian/patches/avoid-rpath.diff +++ python3.3-3.3.3/debian/patches/avoid-rpath.diff @@ -0,0 +1,30 @@ +# DP: avoid runtime library path for some extension modules. + +--- a/setup.py ++++ b/setup.py +@@ -1011,6 +1011,15 @@ + print("bsddb lib dir:", dblib_dir, " inc dir:", db_incdir) + db_incs = [db_incdir] + dblibs = [dblib] ++ # only add db_incdir/dblib_dir if not in the standard paths ++ # avoids a runtime library path for a system library dir ++ 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") + db_incs = None +@@ -1121,6 +1130,9 @@ + # can end up with a bad search path order. + if sqlite_incdir not in self.compiler.include_dirs: + include_dirs.append(sqlite_incdir) ++ # avoid a runtime library path for a system library dir ++ if sqlite_libdir and sqlite_libdir[0] in lib_dirs: ++ sqlite_libdir = None + exts.append(Extension('_sqlite3', sqlite_srcs, + define_macros=sqlite_defines, + include_dirs=include_dirs, --- python3.3-3.3.3.orig/debian/patches/bdist-wininst-notfound.diff +++ python3.3-3.3.3/debian/patches/bdist-wininst-notfound.diff @@ -0,0 +1,17 @@ +# DP: suggest installation of the pythonX.Y-dev package, if bdist_wininst +# DP: cannot find the wininst-* files. + +--- a/Lib/distutils/command/bdist_wininst.py ++++ b/Lib/distutils/command/bdist_wininst.py +@@ -342,7 +342,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.3-3.3.3.orig/debian/patches/ctypes-arm.diff +++ python3.3-3.3.3/debian/patches/ctypes-arm.diff @@ -0,0 +1,32 @@ +--- a/Lib/ctypes/util.py ++++ b/Lib/ctypes/util.py +@@ -199,16 +199,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() ++ # ARM has a variety of unames, e.g. armv7l ++ if uname.machine.startswith("arm"): ++ machine = "arm" + if struct.calcsize('l') == 4: +- machine = os.uname().machine + '-32' ++ machine = uname.machine + '-32' + else: +- machine = os.uname().machine + '-64' ++ machine = uname.machine + '-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.3-3.3.3.orig/debian/patches/deb-locations.diff +++ python3.3-3.3.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 +@@ -27,6 +27,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 +@@ -320,7 +320,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.3-3.3.3.orig/debian/patches/deb-setup.diff +++ python3.3-3.3.3/debian/patches/deb-setup.diff @@ -0,0 +1,31 @@ +# DP: Don't include /usr/local/include and /usr/local/lib as gcc search paths + +--- a/setup.py ++++ b/setup.py +@@ -238,8 +238,10 @@ + # unfortunately, distutils doesn't let us provide separate C and C++ + # compilers + if compiler is not None: +- (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS') +- args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags ++ (ccshared, cppflags, cflags) = \ ++ sysconfig.get_config_vars('CCSHARED', 'CPPFLAGS', 'CFLAGS') ++ cppflags = ' '.join([f for f in cppflags.split() if not f.startswith('-I')]) ++ args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cppflags + ' ' + cflags + self.compiler.set_executables(**args) + + build_ext.build_extensions(self) +@@ -435,12 +437,7 @@ + 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. +- if not cross_compiling: +- 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 + # only change this for cross builds for 3.3, issues on Mageia + if cross_compiling: + self.add_gcc_paths() --- python3.3-3.3.3.orig/debian/patches/disable-sem-check.diff +++ python3.3-3.3.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 +@@ -3827,8 +3827,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 +@@ -3863,8 +3868,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.3-3.3.3.orig/debian/patches/disable-utimes.diff +++ python3.3-3.3.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.3-3.3.3.orig/debian/patches/distutils-init.diff +++ python3.3-3.3.3/debian/patches/distutils-init.diff @@ -0,0 +1,58 @@ +# DP: Use _sysconfigdata.py in distutils to initialize distutils + +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -454,49 +454,11 @@ + + def _init_posix(): + """Initialize the module as appropriate for POSIX systems.""" +- g = {} +- # load the installed Makefile: +- try: +- filename = get_makefile_filename() +- parse_makefile(filename, g) +- except IOError as msg: +- my_msg = "invalid Python installation: unable to open %s" % filename +- if hasattr(msg, "strerror"): +- my_msg = my_msg + " (%s)" % msg.strerror +- +- raise DistutilsPlatformError(my_msg) +- +- # load the installed pyconfig.h: +- try: +- filename = get_config_h_filename() +- with open(filename) as file: +- parse_config_h(file, g) +- except IOError as msg: +- my_msg = "invalid Python installation: unable to open %s" % filename +- if hasattr(msg, "strerror"): +- my_msg = my_msg + " (%s)" % msg.strerror +- +- raise DistutilsPlatformError(my_msg) +- +- # On AIX, there are wrong paths to the linker scripts in the Makefile +- # -- these paths are relative to the Python source, but when installed +- # the scripts are in another directory. +- if python_build: +- g['LDSHARED'] = g['BLDSHARED'] +- +- elif get_python_version() < '2.1': +- # The following two branches are for 1.5.2 compatibility. +- if sys.platform == 'aix4': # what about AIX 3.x ? +- # Linker script is in the config directory, not in Modules as the +- # Makefile says. +- python_lib = get_python_lib(standard_lib=1) +- ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') +- python_exp = os.path.join(python_lib, 'config', 'python.exp') +- +- g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) +- ++ # _sysconfigdata is generated at build time, see the sysconfig module ++ from _sysconfigdata import build_time_vars + global _config_vars +- _config_vars = g ++ _config_vars = {} ++ _config_vars.update(build_time_vars) + + + def _init_nt(): --- python3.3-3.3.3.orig/debian/patches/distutils-install-layout.diff +++ python3.3-3.3.3/debian/patches/distutils-install-layout.diff @@ -0,0 +1,238 @@ +# 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. + +--- 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] + +--- 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,24 @@ + + 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 'VIRTUAL_ENV' 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""" +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -136,6 +136,7 @@ + If 'prefix' is supplied, use it instead of sys.base_prefix or + sys.base_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: + if standard_lib: + prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX +@@ -147,6 +148,8 @@ + "lib", "python" + get_python_version()) + if standard_lib: + return libpython ++ elif is_default_prefix and 'PYTHONUSERBASE' not in os.environ and 'VIRTUAL_ENV' 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": +--- a/Lib/site.py ++++ b/Lib/site.py +@@ -285,6 +285,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(prefixes=None): +--- a/Lib/test/test_site.py ++++ b/Lib/test/test_site.py +@@ -248,12 +248,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) +--- 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], 'foo.py'] ++ wanted = ['foo-0.1.egg-info', 'foo.py'] + if not sys.dont_write_bytecode: + wanted.append('foo.%s.pyc' % imp.get_tag()) + self.assertEqual(contents, sorted(wanted)) +--- 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 +@@ -383,6 +383,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.3-3.3.3.orig/debian/patches/distutils-link.diff +++ python3.3-3.3.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 +@@ -153,6 +153,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.3-3.3.3.orig/debian/patches/distutils-sysconfig.diff +++ python3.3-3.3.3/debian/patches/distutils-sysconfig.diff @@ -0,0 +1,43 @@ +# DP: Get CONFIGURE_CFLAGS, CONFIGURE_CPPFLAGS, CONFIGURE_LDFLAGS from +# DP: the python build, when CFLAGS, CPPFLAGS, LDSHARED) are not set +# DP: in the environment. + +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -194,9 +194,11 @@ + _osx_support.customize_compiler(_config_vars) + _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True' + +- (cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \ ++ (cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags, ++ configure_cppflags, configure_cflags, configure_ldflags) = \ + get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS', +- 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS') ++ 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS', ++ 'CONFIGURE_CPPFLAGS', 'CONFIGURE_CFLAGS', 'CONFIGURE_LDFLAGS') + + if 'CC' in os.environ: + newcc = os.environ['CC'] +@@ -217,13 +219,22 @@ + cpp = cc + " -E" # not always + if 'LDFLAGS' in os.environ: + ldshared = ldshared + ' ' + os.environ['LDFLAGS'] ++ elif configure_ldflags: ++ ldshared = ldshared + ' ' + configure_ldflags + if 'CFLAGS' in os.environ: + cflags = opt + ' ' + os.environ['CFLAGS'] + ldshared = ldshared + ' ' + os.environ['CFLAGS'] ++ elif configure_cflags: ++ cflags = opt + ' ' + configure_cflags ++ ldshared = ldshared + ' ' + configure_cflags + if 'CPPFLAGS' in os.environ: + cpp = cpp + ' ' + os.environ['CPPFLAGS'] + cflags = cflags + ' ' + os.environ['CPPFLAGS'] + ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] ++ elif configure_cppflags: ++ cpp = cpp + ' ' + configure_cppflags ++ cflags = cflags + ' ' + configure_cppflags ++ ldshared = ldshared + ' ' + configure_cppflags + if 'AR' in os.environ: + ar = os.environ['AR'] + if 'ARFLAGS' in os.environ: --- python3.3-3.3.3.orig/debian/patches/doc-build.diff +++ python3.3-3.3.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.3-3.3.3.orig/debian/patches/doc-faq.dpatch +++ python3.3-3.3.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.3-3.3.3.orig/debian/patches/doc-nodownload.diff +++ python3.3-3.3.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.3-3.3.3.orig/debian/patches/enable-fpectl.diff +++ python3.3-3.3.3/debian/patches/enable-fpectl.diff @@ -0,0 +1,14 @@ +# DP: Enable the build of the fpectl module. + +--- a/setup.py ++++ b/setup.py +@@ -1292,6 +1292,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.3-3.3.3.orig/debian/patches/ext-no-libpython-link.diff +++ python3.3-3.3.3/debian/patches/ext-no-libpython-link.diff @@ -0,0 +1,22 @@ +# DP: Don't link extensions with the shared libpython library. + +--- a/Lib/distutils/command/build_ext.py ++++ b/Lib/distutils/command/build_ext.py +@@ -250,7 +250,7 @@ + # For building extensions with a shared Python library, + # Python's library directory must be appended to library_dirs + # See Issues: #1600860, #4366 +- if (sysconfig.get_config_var('Py_ENABLE_SHARED')): ++ if False and (sysconfig.get_config_var('Py_ENABLE_SHARED')): + if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): + # building third party extensions + self.library_dirs.append(sysconfig.get_config_var('LIBDIR')) +@@ -759,7 +759,7 @@ + return ext.libraries + else: + from distutils import sysconfig +- if sysconfig.get_config_var('Py_ENABLE_SHARED'): ++ if False and sysconfig.get_config_var('Py_ENABLE_SHARED'): + pythonlib = 'python{}.{}{}'.format( + sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff, + sys.abiflags) --- python3.3-3.3.3.orig/debian/patches/gdbm-import.diff +++ python3.3-3.3.3/debian/patches/gdbm-import.diff @@ -0,0 +1,12 @@ +# DP: suggest installation of python3-gdbm package on failing _gdbm import + +--- a/Lib/dbm/gnu.py ++++ b/Lib/dbm/gnu.py +@@ -1,3 +1,6 @@ + """Provide the _gdbm module as a dbm submodule.""" + +-from _gdbm import * ++try: ++ from _gdbm import * ++except ImportError as msg: ++ raise ImportError(str(msg) + ', please install the python3-gdbm package') --- python3.3-3.3.3.orig/debian/patches/hg-updates.diff +++ python3.3-3.3.3/debian/patches/hg-updates.diff @@ -0,0 +1,17413 @@ +# DP: hg updates of the 3.3 release branch (until 2013-12-08, 87826:3580c718add3). + +# hg diff -r v3.3.3 | filterdiff --exclude=.hgignore --exclude=.hgeol --exclude=.hgtags --remove-timestamps + +diff -r c3896275c0f6 Doc/Makefile +--- a/Doc/Makefile ++++ b/Doc/Makefile +@@ -186,6 +186,7 @@ + autobuild-dev: + make update + make dist SPHINXOPTS='-A daily=1 -A versionswitcher=1' ++ -make suspicious + + # for quick rebuilds (HTML only) + autobuild-html: +diff -r c3896275c0f6 Doc/distutils/examples.rst +--- a/Doc/distutils/examples.rst ++++ b/Doc/distutils/examples.rst +@@ -284,6 +284,48 @@ + warning: check: Title underline too short. (line 2) + warning: check: Could not finish the parsing. + ++Reading the metadata ++===================== ++ ++The :func:`distutils.core.setup` function provides a command-line interface ++that allows you to query the metadata fields of a project through the ++`setup.py` script of a given project:: ++ ++ $ python setup.py --name ++ distribute ++ ++This call reads the `name` metadata by running the ++:func:`distutils.core.setup` function. Although, when a source or binary ++distribution is created with Distutils, the metadata fields are written ++in a static file called :file:`PKG-INFO`. When a Distutils-based project is ++installed in Python, the :file:`PKG-INFO` file is copied alongside the modules ++and packages of the distribution under :file:`NAME-VERSION-pyX.X.egg-info`, ++where `NAME` is the name of the project, `VERSION` its version as defined ++in the Metadata, and `pyX.X` the major and minor version of Python like ++`2.7` or `3.2`. ++ ++You can read back this static file, by using the ++:class:`distutils.dist.DistributionMetadata` class and its ++:func:`read_pkg_file` method:: ++ ++ >>> from distutils.dist import DistributionMetadata ++ >>> metadata = DistributionMetadata() ++ >>> metadata.read_pkg_file(open('distribute-0.6.8-py2.7.egg-info')) ++ >>> metadata.name ++ 'distribute' ++ >>> metadata.version ++ '0.6.8' ++ >>> metadata.description ++ 'Easily download, build, install, upgrade, and uninstall Python packages' ++ ++Notice that the class can also be instanciated with a metadata file path to ++loads its values:: ++ ++ >>> pkg_info_path = 'distribute-0.6.8-py2.7.egg-info' ++ >>> DistributionMetadata(pkg_info_path).name ++ 'distribute' ++ ++ + .. % \section{Multiple extension modules} + .. % \label{multiple-ext} + +diff -r c3896275c0f6 Doc/faq/programming.rst +--- a/Doc/faq/programming.rst ++++ b/Doc/faq/programming.rst +@@ -1193,34 +1193,10 @@ + Dictionaries + ============ + +-How can I get a dictionary to display its keys in a consistent order? +---------------------------------------------------------------------- ++How can I get a dictionary to store and display its keys in a consistent order? ++------------------------------------------------------------------------------- + +-You can't. Dictionaries store their keys in an unpredictable order, so the +-display order of a dictionary's elements will be similarly unpredictable. +- +-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. In this +-case, use the ``pprint`` module to pretty-print the dictionary; the items will +-be presented in order sorted by the key. +- +-A more complicated solution is to subclass ``dict`` to create a +-``SortedDict`` class that prints itself in a predictable order. Here's one +-simpleminded implementation of such a class:: +- +- class SortedDict(dict): +- def __repr__(self): +- keys = sorted(self.keys()) +- result = ("{!r}: {!r}".format(k, self[k]) for k in keys) +- return "{{{}}}".format(", ".join(result)) +- +- __str__ = __repr__ +- +-This will work for many common situations you might encounter, though it's far +-from a perfect solution. The largest flaw is that if some values in the +-dictionary are also dictionaries, their values won't be presented in any +-particular order. +- ++Use :class:`collections.OrderedDict`. + + I want to do a complicated sort: can you do a Schwartzian Transform in Python? + ------------------------------------------------------------------------------ +diff -r c3896275c0f6 Doc/glossary.rst +--- a/Doc/glossary.rst ++++ b/Doc/glossary.rst +@@ -41,7 +41,7 @@ + + argument + A value passed to a :term:`function` (or :term:`method`) when calling the +- function. There are two types of arguments: ++ function. There are two kinds of argument: + + * :dfn:`keyword argument`: an argument preceded by an identifier (e.g. + ``name=``) in a function call or passed as a value in a dictionary +@@ -78,6 +78,13 @@ + Benevolent Dictator For Life, a.k.a. `Guido van Rossum + `_, Python's creator. + ++ binary file ++ A :term:`file object` able to read and write ++ :term:`bytes-like objects `. ++ ++ .. seealso:: ++ A :term:`text file` reads and writes :class:`str` objects. ++ + bytes-like object + An object that supports the :ref:`bufferobjects`, like :class:`bytes`, + :class:`bytearray` or :class:`memoryview`. Bytes-like objects can +@@ -225,10 +232,11 @@ + etc.). File objects are also called :dfn:`file-like objects` or + :dfn:`streams`. + +- There are actually three categories of file objects: raw binary files, +- buffered binary files and text files. Their interfaces are defined in the +- :mod:`io` module. The canonical way to create a file object is by using +- the :func:`open` function. ++ There are actually three categories of file objects: raw ++ :term:`binary files `, buffered ++ :term:`binary files ` and :term:`text files `. ++ Their interfaces are defined in the :mod:`io` module. The canonical ++ way to create a file object is by using the :func:`open` function. + + file-like object + A synonym for :term:`file object`. +@@ -592,7 +600,7 @@ + parameter + A named entity in a :term:`function` (or method) definition that + specifies an :term:`argument` (or in some cases, arguments) that the +- function can accept. There are five types of parameters: ++ function can accept. There are five kinds of parameter: + + * :dfn:`positional-or-keyword`: specifies an argument that can be passed + either :term:`positionally ` or as a :term:`keyword argument +@@ -606,6 +614,8 @@ + parameters. However, some built-in functions have positional-only + parameters (e.g. :func:`abs`). + ++ .. _keyword-only_parameter: ++ + * :dfn:`keyword-only`: specifies an argument that can be supplied only + by keyword. Keyword-only parameters can be defined by including a + single var-positional parameter or bare ``*`` in the parameter list +@@ -778,6 +788,14 @@ + :meth:`~collections.somenamedtuple._asdict`. Examples of struct sequences + include :data:`sys.float_info` and the return value of :func:`os.stat`. + ++ text file ++ A :term:`file object` able to read and write :class:`str` objects. ++ Often, a text file actually accesses a byte-oriented datastream ++ and handles the text encoding automatically. ++ ++ .. seealso:: ++ A :term:`binary file` reads and write :class:`bytes` objects. ++ + triple-quoted string + A string which is bound by three instances of either a quotation mark + (") or an apostrophe ('). While they don't provide any functionality +diff -r c3896275c0f6 Doc/howto/curses.rst +--- a/Doc/howto/curses.rst ++++ b/Doc/howto/curses.rst +@@ -422,7 +422,7 @@ + blue or any other color you like. Unfortunately, the Linux console doesn't + support this, so I'm unable to try it out, and can't provide any examples. You + can check if your terminal can do this by calling +-:func:`~curses.can_change_color`, which returns True if the capability is ++:func:`~curses.can_change_color`, which returns ``True`` if the capability is + there. If you're lucky enough to have such a talented terminal, consult your + system's man pages for more information. + +diff -r c3896275c0f6 Doc/howto/functional.rst +--- a/Doc/howto/functional.rst ++++ b/Doc/howto/functional.rst +@@ -687,8 +687,8 @@ + + + The :func:`any(iter) ` and :func:`all(iter) ` built-ins look at the +-truth values of an iterable's contents. :func:`any` returns True if any element +-in the iterable is a true value, and :func:`all` returns True if all of the ++truth values of an iterable's contents. :func:`any` returns ``True`` if any element ++in the iterable is a true value, and :func:`all` returns ``True`` if all of the + elements are true values: + + >>> any([0,1,0]) +diff -r c3896275c0f6 Doc/howto/logging-cookbook.rst +--- a/Doc/howto/logging-cookbook.rst ++++ b/Doc/howto/logging-cookbook.rst +@@ -1098,7 +1098,7 @@ + + .. _custom-logrecord: + +-Customising ``LogRecord`` ++Customizing ``LogRecord`` + ------------------------- + + Every logging event is represented by a :class:`LogRecord` instance. +@@ -1315,7 +1315,7 @@ + + .. _cookbook-rotator-namer: + +-Using a rotator and namer to customise log rotation processing ++Using a rotator and namer to customize log rotation processing + -------------------------------------------------------------- + + An example of how you can define a namer and rotator is given in the following +@@ -1694,3 +1694,138 @@ + Note that the order of items might be different according to the version of + Python used. + ++.. currentmodule:: logging.config ++ ++Customizing handlers with :func:`dictConfig` ++-------------------------------------------- ++ ++There are times when you want to customize logging handlers in particular ways, ++and if you use :func:`dictConfig` you may be able to do this without ++subclassing. As an example, consider that you may want to set the ownership of a ++log file. On POSIX, this is easily done using :func:`shutil.chown`, but the file ++handlers in the stdlib don't offer built-in support. You can customize handler ++creation using a plain function such as:: ++ ++ def owned_file_handler(filename, mode='a', encoding=None, owner=None): ++ if owner: ++ if not os.path.exists(filename): ++ open(filename, 'a').close() ++ shutil.chown(filename, *owner) ++ return logging.FileHandler(filename, mode, encoding) ++ ++You can then specify, in a logging configuration passed to :func:`dictConfig`, ++that a logging handler be created by calling this function:: ++ ++ LOGGING = { ++ 'version': 1, ++ 'disable_existing_loggers': False, ++ 'formatters': { ++ 'default': { ++ 'format': '%(asctime)s %(levelname)s %(name)s %(message)s' ++ }, ++ }, ++ 'handlers': { ++ 'file':{ ++ # The values below are popped from this dictionary and ++ # used to create the handler, set the handler's level and ++ # its formatter. ++ '()': owned_file_handler, ++ 'level':'DEBUG', ++ 'formatter': 'default', ++ # The values below are passed to the handler creator callable ++ # as keyword arguments. ++ 'owner': ['pulse', 'pulse'], ++ 'filename': 'chowntest.log', ++ 'mode': 'w', ++ 'encoding': 'utf-8', ++ }, ++ }, ++ 'root': { ++ 'handlers': ['file'], ++ 'level': 'DEBUG', ++ }, ++ } ++ ++In this example I am setting the ownership using the ``pulse`` user and group, ++just for the purposes of illustration. Putting it together into a working ++script, ``chowntest.py``:: ++ ++ import logging, logging.config, os, shutil ++ ++ def owned_file_handler(filename, mode='a', encoding=None, owner=None): ++ if owner: ++ if not os.path.exists(filename): ++ open(filename, 'a').close() ++ shutil.chown(filename, *owner) ++ return logging.FileHandler(filename, mode, encoding) ++ ++ LOGGING = { ++ 'version': 1, ++ 'disable_existing_loggers': False, ++ 'formatters': { ++ 'default': { ++ 'format': '%(asctime)s %(levelname)s %(name)s %(message)s' ++ }, ++ }, ++ 'handlers': { ++ 'file':{ ++ # The values below are popped from this dictionary and ++ # used to create the handler, set the handler's level and ++ # its formatter. ++ '()': owned_file_handler, ++ 'level':'DEBUG', ++ 'formatter': 'default', ++ # The values below are passed to the handler creator callable ++ # as keyword arguments. ++ 'owner': ['pulse', 'pulse'], ++ 'filename': 'chowntest.log', ++ 'mode': 'w', ++ 'encoding': 'utf-8', ++ }, ++ }, ++ 'root': { ++ 'handlers': ['file'], ++ 'level': 'DEBUG', ++ }, ++ } ++ ++ logging.config.dictConfig(LOGGING) ++ logger = logging.getLogger('mylogger') ++ logger.debug('A debug message') ++ ++To run this, you will probably need to run as ``root``:: ++ ++ $ sudo python3.3 chowntest.py ++ $ cat chowntest.log ++ 2013-11-05 09:34:51,128 DEBUG mylogger A debug message ++ $ ls -l chowntest.log ++ -rw-r--r-- 1 pulse pulse 55 2013-11-05 09:34 chowntest.log ++ ++Note that this example uses Python 3.3 because that's where :func:`shutil.chown` ++makes an appearance. This approach should work with any Python version that ++supports :func:`dictConfig` - namely, Python 2.7, 3.2 or later. With pre-3.3 ++versions, you would need to implement the actual ownership change using e.g. ++:func:`os.chown`. ++ ++In practice, the handler-creating function may be in a utility module somewhere ++in your project. Instead of the line in the configuration:: ++ ++ '()': owned_file_handler, ++ ++you could use e.g.:: ++ ++ '()': 'ext://project.util.owned_file_handler', ++ ++where ``project.util`` can be replaced with the actual name of the package ++where the function resides. In the above working script, using ++``'ext://__main__.owned_file_handler'`` should work. Here, the actual callable ++is resolved by :func:`dictConfig` from the ``ext://`` specification. ++ ++This example hopefully also points the way to how you could implement other ++types of file change - e.g. setting specific POSIX permission bits - in the ++same way, using :func:`os.chmod`. ++ ++Of course, the approach could also be extended to types of handler other than a ++:class:`~logging.FileHandler` - for example, one of the rotating file handlers, ++or a different type of handler altogether. ++ +diff -r c3896275c0f6 Doc/howto/logging.rst +--- a/Doc/howto/logging.rst ++++ b/Doc/howto/logging.rst +@@ -122,7 +122,8 @@ + ^^^^^^^^^^^^^^^^^ + + A very common situation is that of recording logging events in a file, so let's +-look at that next:: ++look at that next. Be sure to try the following in a newly-started Python ++interpreter, and don't just continue from the session described above:: + + import logging + logging.basicConfig(filename='example.log',level=logging.DEBUG) +diff -r c3896275c0f6 Doc/howto/unicode.rst +--- a/Doc/howto/unicode.rst ++++ b/Doc/howto/unicode.rst +@@ -514,7 +514,7 @@ + + Unicode data is usually converted to a particular encoding before it gets + written to disk or sent over a socket. It's possible to do all the work +-yourself: open a file, read an 8-bit bytes object from it, and convert the string ++yourself: open a file, read an 8-bit bytes object from it, and convert the bytes + with ``bytes.decode(encoding)``. However, the manual approach is not recommended. + + One problem is the multi-byte nature of encodings; one Unicode character can be +diff -r c3896275c0f6 Doc/library/argparse.rst +--- a/Doc/library/argparse.rst ++++ b/Doc/library/argparse.rst +@@ -1371,12 +1371,14 @@ + >>> parser.parse_args(['--', '-f']) + Namespace(foo='-f', one=None) + ++.. _prefix-matching: + +-Argument abbreviations +-^^^^^^^^^^^^^^^^^^^^^^ ++Argument abbreviations (prefix matching) ++^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + The :meth:`~ArgumentParser.parse_args` method allows long options to be +-abbreviated if the abbreviation is unambiguous:: ++abbreviated to a prefix, if the abbreviation is unambiguous (the prefix matches ++a unique option):: + + >>> parser = argparse.ArgumentParser(prog='PROG') + >>> parser.add_argument('-bacon') +@@ -1852,6 +1854,12 @@ + >>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam']) + (Namespace(bar='BAR', foo=True), ['--badger', 'spam']) + ++.. warning:: ++ :ref:`Prefix matching ` rules apply to ++ :meth:`parse_known_args`. The parser may consume an option even if it's just ++ a prefix of one of its known options, instead of leaving it in the remaining ++ arguments list. ++ + + Customizing file parsing + ^^^^^^^^^^^^^^^^^^^^^^^^ +diff -r c3896275c0f6 Doc/library/ast.rst +--- a/Doc/library/ast.rst ++++ b/Doc/library/ast.rst +@@ -244,6 +244,6 @@ + Return a formatted dump of the tree in *node*. This is mainly useful for + debugging purposes. The returned string will show the names and the values + for fields. This makes the code impossible to evaluate, so if evaluation is +- wanted *annotate_fields* must be set to False. Attributes such as line ++ wanted *annotate_fields* must be set to ``False``. Attributes such as line + numbers and column offsets are not dumped by default. If this is wanted, + *include_attributes* can be set to ``True``. +diff -r c3896275c0f6 Doc/library/bdb.rst +--- a/Doc/library/bdb.rst ++++ b/Doc/library/bdb.rst +@@ -194,17 +194,17 @@ + .. method:: user_line(frame) + + This method is called from :meth:`dispatch_line` when either +- :meth:`stop_here` or :meth:`break_here` yields True. ++ :meth:`stop_here` or :meth:`break_here` yields ``True``. + + .. method:: user_return(frame, return_value) + + This method is called from :meth:`dispatch_return` when :meth:`stop_here` +- yields True. ++ yields ``True``. + + .. method:: user_exception(frame, exc_info) + + This method is called from :meth:`dispatch_exception` when +- :meth:`stop_here` yields True. ++ :meth:`stop_here` yields ``True``. + + .. method:: do_clear(arg) + +@@ -245,7 +245,7 @@ + + .. method:: set_quit() + +- Set the :attr:`quitting` attribute to True. This raises :exc:`BdbQuit` in ++ Set the :attr:`quitting` attribute to ``True``. This raises :exc:`BdbQuit` in + the next call to one of the :meth:`dispatch_\*` methods. + + +diff -r c3896275c0f6 Doc/library/binascii.rst +--- a/Doc/library/binascii.rst ++++ b/Doc/library/binascii.rst +@@ -145,7 +145,7 @@ + + Return the hexadecimal representation of the binary *data*. Every byte of + *data* is converted into the corresponding 2-digit hex representation. The +- resulting string is therefore twice as long as the length of *data*. ++ returned bytes object is therefore twice as long as the length of *data*. + + + .. function:: a2b_hex(hexstr) +diff -r c3896275c0f6 Doc/library/bz2.rst +--- a/Doc/library/bz2.rst ++++ b/Doc/library/bz2.rst +@@ -162,7 +162,7 @@ + + .. attribute:: eof + +- True if the end-of-stream marker has been reached. ++ ``True`` if the end-of-stream marker has been reached. + + .. versionadded:: 3.3 + +diff -r c3896275c0f6 Doc/library/ctypes.rst +--- a/Doc/library/ctypes.rst ++++ b/Doc/library/ctypes.rst +@@ -2242,7 +2242,7 @@ + .. class:: c_bool + + Represent the C :c:type:`bool` datatype (more accurately, :c:type:`_Bool` from +- C99). Its value can be True or False, and the constructor accepts any object ++ C99). Its value can be ``True`` or ``False``, and the constructor accepts any object + that has a truth value. + + +diff -r c3896275c0f6 Doc/library/curses.rst +--- a/Doc/library/curses.rst ++++ b/Doc/library/curses.rst +@@ -377,7 +377,7 @@ + is to be displayed. + + +-.. function:: newwin(begin_y, begin_x) ++.. function:: newwin(nlines, ncols) + newwin(nlines, ncols, begin_y, begin_x) + + Return a new window, whose left-upper corner is at ``(begin_y, begin_x)``, and +diff -r c3896275c0f6 Doc/library/datetime.rst +--- a/Doc/library/datetime.rst ++++ b/Doc/library/datetime.rst +@@ -1896,7 +1896,7 @@ + making assumptions about the output value. Field orderings will vary (for + example, "month/day/year" versus "day/month/year"), and the output may + contain Unicode characters encoded using the locale's default encoding (for +- example, if the current locale is ``js_JP``, the default encoding could be ++ example, if the current locale is ``ja_JP``, the default encoding could be + any one of ``eucJP``, ``SJIS``, or ``utf-8``; use :meth:`locale.getlocale` + to determine the current locale's encoding). + +diff -r c3896275c0f6 Doc/library/decimal.rst +--- a/Doc/library/decimal.rst ++++ b/Doc/library/decimal.rst +@@ -1183,52 +1183,52 @@ + + .. method:: is_canonical(x) + +- Returns True if *x* is canonical; otherwise returns False. ++ Returns ``True`` if *x* is canonical; otherwise returns ``False``. + + + .. method:: is_finite(x) + +- Returns True if *x* is finite; otherwise returns False. ++ Returns ``True`` if *x* is finite; otherwise returns ``False``. + + + .. method:: is_infinite(x) + +- Returns True if *x* is infinite; otherwise returns False. ++ Returns ``True`` if *x* is infinite; otherwise returns ``False``. + + + .. method:: is_nan(x) + +- Returns True if *x* is a qNaN or sNaN; otherwise returns False. ++ Returns ``True`` if *x* is a qNaN or sNaN; otherwise returns ``False``. + + + .. method:: is_normal(x) + +- Returns True if *x* is a normal number; otherwise returns False. ++ Returns ``True`` if *x* is a normal number; otherwise returns ``False``. + + + .. method:: is_qnan(x) + +- Returns True if *x* is a quiet NaN; otherwise returns False. ++ Returns ``True`` if *x* is a quiet NaN; otherwise returns ``False``. + + + .. method:: is_signed(x) + +- Returns True if *x* is negative; otherwise returns False. ++ Returns ``True`` if *x* is negative; otherwise returns ``False``. + + + .. method:: is_snan(x) + +- Returns True if *x* is a signaling NaN; otherwise returns False. ++ Returns ``True`` if *x* is a signaling NaN; otherwise returns ``False``. + + + .. method:: is_subnormal(x) + +- Returns True if *x* is subnormal; otherwise returns False. ++ Returns ``True`` if *x* is subnormal; otherwise returns ``False``. + + + .. method:: is_zero(x) + +- Returns True if *x* is a zero; otherwise returns False. ++ Returns ``True`` if *x* is a zero; otherwise returns ``False``. + + + .. method:: ln(x) +@@ -1390,7 +1390,7 @@ + + .. method:: same_quantum(x, y) + +- Returns True if the two operands have the same exponent. ++ Returns ``True`` if the two operands have the same exponent. + + + .. method:: scaleb (x, y) +@@ -1452,9 +1452,9 @@ + + .. data:: HAVE_THREADS + +- The default value is True. If Python is compiled without threads, the ++ The default value is ``True``. If Python is compiled without threads, the + C version automatically disables the expensive thread local context +- machinery. In this case, the value is False. ++ machinery. In this case, the value is ``False``. + + Rounding modes + -------------- +diff -r c3896275c0f6 Doc/library/difflib.rst +--- a/Doc/library/difflib.rst ++++ b/Doc/library/difflib.rst +@@ -359,7 +359,7 @@ + The *autojunk* parameter. + + SequenceMatcher objects get three data attributes: *bjunk* is the +- set of elements of *b* for which *isjunk* is True; *bpopular* is the set of ++ set of elements of *b* for which *isjunk* is ``True``; *bpopular* is the set of + non-junk elements considered popular by the heuristic (if it is not + disabled); *b2j* is a dict mapping the remaining elements of *b* to a list + of positions where they occur. All three are reset whenever *b* is reset +diff -r c3896275c0f6 Doc/library/email.message.rst +--- a/Doc/library/email.message.rst ++++ b/Doc/library/email.message.rst +@@ -75,7 +75,7 @@ + + Return ``True`` if the message's payload is a list of sub-\ + :class:`Message` objects, otherwise return ``False``. When +- :meth:`is_multipart` returns False, the payload should be a string object. ++ :meth:`is_multipart` returns ``False``, the payload should be a string object. + + + .. method:: set_unixfrom(unixfrom) +diff -r c3896275c0f6 Doc/library/exceptions.rst +--- a/Doc/library/exceptions.rst ++++ b/Doc/library/exceptions.rst +@@ -281,8 +281,7 @@ + + Raised when an error is detected that doesn't fall in any of the other + categories. The associated value is a string indicating what precisely went +- wrong. (This exception is mostly a relic from a previous version of the +- interpreter; it is not used very much any more.) ++ wrong. + + + .. exception:: StopIteration +diff -r c3896275c0f6 Doc/library/fcntl.rst +--- a/Doc/library/fcntl.rst ++++ b/Doc/library/fcntl.rst +@@ -30,11 +30,11 @@ + + .. function:: fcntl(fd, op[, arg]) + +- Perform the requested operation on file descriptor *fd* (file objects providing +- a :meth:`~io.IOBase.fileno` method are accepted as well). The operation is +- defined by *op* +- and is operating system dependent. These codes are also found in the +- :mod:`fcntl` module. The argument *arg* is optional, and defaults to the integer ++ Perform the operation *op* on file descriptor *fd* (file objects providing ++ a :meth:`~io.IOBase.fileno` method are accepted as well). The values used ++ for *op* are operating system dependent, and are available as constants ++ in the :mod:`fcntl` module, using the same names as used in the relevant C ++ header files. The argument *arg* is optional, and defaults to the integer + value ``0``. When present, it can either be an integer value, or a string. + With the argument missing or an integer value, the return value of this function + is the integer return value of the C :c:func:`fcntl` call. When the argument is +@@ -56,6 +56,9 @@ + that the argument handling is even more complicated. + + The op parameter is limited to values that can fit in 32-bits. ++ Additional constants of interest for use as the *op* argument can be ++ found in the :mod:`termios` module, under the same names as used in ++ the relevant C header files. + + The parameter *arg* can be one of an integer, absent (treated identically to the + integer ``0``), an object supporting the read-only buffer interface (most likely +diff -r c3896275c0f6 Doc/library/functions.rst +--- a/Doc/library/functions.rst ++++ b/Doc/library/functions.rst +@@ -48,7 +48,7 @@ + + .. function:: all(iterable) + +- Return True if all elements of the *iterable* are true (or if the iterable ++ Return ``True`` if all elements of the *iterable* are true (or if the iterable + is empty). Equivalent to:: + + def all(iterable): +@@ -60,8 +60,8 @@ + + .. function:: any(iterable) + +- Return True if any element of the *iterable* is true. If the iterable +- is empty, return False. Equivalent to:: ++ Return ``True`` if any element of the *iterable* is true. If the iterable ++ is empty, return ``False``. Equivalent to:: + + def any(iterable): + for element in iterable: +@@ -193,9 +193,9 @@ + .. function:: compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1) + + Compile the *source* into a code or AST object. Code objects can be executed +- by :func:`exec` or :func:`eval`. *source* can either be a string or an AST +- object. Refer to the :mod:`ast` module documentation for information on how +- to work with AST objects. ++ by :func:`exec` or :func:`eval`. *source* can either be a normal string, a ++ byte string, or an AST object. Refer to the :mod:`ast` module documentation ++ for information on how to work with AST objects. + + The *filename* argument should give the file from which the code was read; + pass some recognizable value if it wasn't read from a file (``''`` is +@@ -890,7 +890,7 @@ + the buffer will typically be 4096 or 8192 bytes long. + + * "Interactive" text files (files for which :meth:`~io.IOBase.isatty` +- returns True) use line buffering. Other text files use the policy ++ returns ``True``) use line buffering. Other text files use the policy + described above for binary files. + + *encoding* is the name of the encoding used to decode or encode the file. +diff -r c3896275c0f6 Doc/library/gc.rst +--- a/Doc/library/gc.rst ++++ b/Doc/library/gc.rst +@@ -130,8 +130,8 @@ + + .. function:: is_tracked(obj) + +- Returns True if the object is currently tracked by the garbage collector, +- False otherwise. As a general rule, instances of atomic types aren't ++ Returns ``True`` if the object is currently tracked by the garbage collector, ++ ``False`` otherwise. As a general rule, instances of atomic types aren't + tracked and instances of non-atomic types (containers, user-defined + objects...) are. However, some type-specific optimizations can be present + in order to suppress the garbage collector footprint of simple instances +diff -r c3896275c0f6 Doc/library/gettext.rst +--- a/Doc/library/gettext.rst ++++ b/Doc/library/gettext.rst +@@ -3,8 +3,8 @@ + + .. module:: gettext + :synopsis: Multilingual internationalization services. +-.. moduleauthor:: Barry A. Warsaw +-.. sectionauthor:: Barry A. Warsaw ++.. moduleauthor:: Barry A. Warsaw ++.. sectionauthor:: Barry A. Warsaw + + **Source code:** :source:`Lib/gettext.py` + +@@ -94,9 +94,10 @@ + + The Plural formula is taken from the catalog header. It is a C or Python + expression that has a free variable *n*; the expression evaluates to the index +- of the plural in the catalog. See the GNU gettext documentation for the precise +- syntax to be used in :file:`.po` files and the formulas for a variety of +- languages. ++ of the plural in the catalog. See ++ `the GNU gettext documentation `__ ++ for the precise syntax to be used in :file:`.po` files and the ++ formulas for a variety of languages. + + + .. function:: lngettext(singular, plural, n) +@@ -451,35 +452,42 @@ + In this example, the string ``'writing a log message'`` is marked as a candidate + for translation, while the strings ``'mylog.txt'`` and ``'w'`` are not. + +-The Python distribution comes with two tools which help you generate the message +-catalogs once you've prepared your source code. These may or may not be +-available from a binary distribution, but they can be found in a source +-distribution, in the :file:`Tools/i18n` directory. ++There are a few tools to extract the strings meant for translation. ++The original GNU :program:`gettext` only supported C or C++ source ++code but its extended version :program:`xgettext` scans code written ++in a number of languages, including Python, to find strings marked as ++translatable. `Babel `__ is a Python ++internationalization library that includes a :file:`pybabel` script to ++extract and compile message catalogs. François Pinard's program ++called :program:`xpot` does a similar job and is available as part of ++his `po-utils package `__. + +-The :program:`pygettext` [#]_ program scans all your Python source code looking +-for the strings you previously marked as translatable. It is similar to the GNU +-:program:`gettext` program except that it understands all the intricacies of +-Python source code, but knows nothing about C or C++ source code. You don't +-need GNU ``gettext`` unless you're also going to be translating C code (such as +-C extension modules). ++(Python also includes pure-Python versions of these programs, called ++:program:`pygettext.py` and :program:`msgfmt.py`; some Python distributions ++will install them for you. :program:`pygettext.py` is similar to ++:program:`xgettext`, but only understands Python source code and ++cannot handle other programming languages such as C or C++. ++:program:`pygettext.py` supports a command-line interface similar to ++:program:`xgettext`; for details on its use, run ``pygettext.py ++--help``. :program:`msgfmt.py` is binary compatible with GNU ++:program:`msgfmt`. With these two programs, you may not need the GNU ++:program:`gettext` package to internationalize your Python ++applications.) + +-:program:`pygettext` generates textual Uniforum-style human readable message +-catalog :file:`.pot` files, essentially structured human readable files which +-contain every marked string in the source code, along with a placeholder for the +-translation strings. :program:`pygettext` is a command line script that supports +-a similar command line interface as :program:`xgettext`; for details on its use, +-run:: ++:program:`xgettext`, :program:`pygettext`, and similar tools generate ++:file:`.po` files that are message catalogs. They are structured ++human-readable files that contain every marked string in the source ++code, along with a placeholder for the translated versions of these ++strings. + +- pygettext.py --help +- +-Copies of these :file:`.pot` files are then handed over to the individual human +-translators who write language-specific versions for every supported natural +-language. They send you back the filled in language-specific versions as a +-:file:`.po` file. Using the :program:`msgfmt.py` [#]_ program (in the +-:file:`Tools/i18n` directory), you take the :file:`.po` files from your +-translators and generate the machine-readable :file:`.mo` binary catalog files. +-The :file:`.mo` files are what the :mod:`gettext` module uses for the actual +-translation processing during run-time. ++Copies of these :file:`.po` files are then handed over to the ++individual human translators who write translations for every ++supported natural language. They send back the completed ++language-specific versions as a :file:`.po` file that's ++compiled into a machine-readable :file:`.mo` binary catalog file using ++the :program:`msgfmt` program. The :file:`.mo` files are used by the ++:mod:`gettext` module for the actual translation processing at ++run-time. + + How you use the :mod:`gettext` module in your code depends on whether you are + internationalizing a single module or your entire application. The next two +@@ -517,7 +525,7 @@ + import gettext + gettext.install('myapplication') + +-If you need to set the locale directory, you can pass these into the ++If you need to set the locale directory, you can pass it into the + :func:`install` function:: + + import gettext +@@ -590,7 +598,8 @@ + namespace. + + Note that the second use of :func:`_` will not identify "a" as being +-translatable to the :program:`pygettext` program, since it is not a string. ++translatable to the :program:`gettext` program, because the parameter ++is not a string literal. + + Another way to handle this is with the following example:: + +@@ -606,11 +615,14 @@ + for a in animals: + print(_(a)) + +-In this case, you are marking translatable strings with the function :func:`N_`, +-[#]_ which won't conflict with any definition of :func:`_`. However, you will +-need to teach your message extraction program to look for translatable strings +-marked with :func:`N_`. :program:`pygettext` and :program:`xpot` both support +-this through the use of command line switches. ++In this case, you are marking translatable strings with the function ++:func:`N_`, which won't conflict with any definition of :func:`_`. ++However, you will need to teach your message extraction program to ++look for translatable strings marked with :func:`N_`. :program:`xgettext`, ++:program:`pygettext`, ``pybabel extract``, and :program:`xpot` all ++support this through the use of the :option:`-k` command-line switch. ++The choice of :func:`N_` here is totally arbitrary; it could have just ++as easily been :func:`MarkThisStringForTranslation`. + + + Acknowledgements +@@ -645,16 +657,3 @@ + absolute path at the start of your application. + + .. [#] See the footnote for :func:`bindtextdomain` above. +- +-.. [#] François Pinard has written a program called :program:`xpot` which does a +- similar job. It is available as part of his `po-utils package +- `_. +- +-.. [#] :program:`msgfmt.py` is binary compatible with GNU :program:`msgfmt` except that +- it provides a simpler, all-Python implementation. With this and +- :program:`pygettext.py`, you generally won't need to install the GNU +- :program:`gettext` package to internationalize your Python applications. +- +-.. [#] The choice of :func:`N_` here is totally arbitrary; it could have just as easily +- been :func:`MarkThisStringForTranslation`. +- +diff -r c3896275c0f6 Doc/library/html.entities.rst +--- a/Doc/library/html.entities.rst ++++ b/Doc/library/html.entities.rst +@@ -42,4 +42,4 @@ + + .. rubric:: Footnotes + +-.. [#] See http://www.w3.org/TR/html5/named-character-references.html ++.. [#] See http://www.w3.org/TR/html5/syntax.html#named-character-references +diff -r c3896275c0f6 Doc/library/http.client.rst +--- a/Doc/library/http.client.rst ++++ b/Doc/library/http.client.rst +@@ -573,7 +573,7 @@ + + .. attribute:: HTTPResponse.closed + +- Is True if the stream is closed. ++ Is ``True`` if the stream is closed. + + Examples + -------- +diff -r c3896275c0f6 Doc/library/http.cookiejar.rst +--- a/Doc/library/http.cookiejar.rst ++++ b/Doc/library/http.cookiejar.rst +@@ -90,7 +90,7 @@ + Netscape and RFC 2965 cookies. By default, RFC 2109 cookies (ie. cookies + received in a :mailheader:`Set-Cookie` header with a version cookie-attribute of + 1) are treated according to the RFC 2965 rules. However, if RFC 2965 handling +- is turned off or :attr:`rfc2109_as_netscape` is True, RFC 2109 cookies are ++ is turned off or :attr:`rfc2109_as_netscape` is ``True``, RFC 2109 cookies are + 'downgraded' by the :class:`CookieJar` instance to Netscape cookies, by + setting the :attr:`version` attribute of the :class:`Cookie` instance to 0. + :class:`DefaultCookiePolicy` also provides some parameters to allow some +@@ -644,7 +644,7 @@ + + .. attribute:: Cookie.secure + +- True if cookie should only be returned over a secure connection. ++ ``True`` if cookie should only be returned over a secure connection. + + + .. attribute:: Cookie.expires +@@ -655,7 +655,7 @@ + + .. attribute:: Cookie.discard + +- True if this is a session cookie. ++ ``True`` if this is a session cookie. + + + .. attribute:: Cookie.comment +@@ -672,7 +672,7 @@ + + .. attribute:: Cookie.rfc2109 + +- True if this cookie was received as an RFC 2109 cookie (ie. the cookie ++ ``True`` if this cookie was received as an RFC 2109 cookie (ie. the cookie + arrived in a :mailheader:`Set-Cookie` header, and the value of the Version + cookie-attribute in that header was 1). This attribute is provided because + :mod:`http.cookiejar` may 'downgrade' RFC 2109 cookies to Netscape cookies, in +@@ -681,18 +681,18 @@ + + .. attribute:: Cookie.port_specified + +- True if a port or set of ports was explicitly specified by the server (in the ++ ``True`` if a port or set of ports was explicitly specified by the server (in the + :mailheader:`Set-Cookie` / :mailheader:`Set-Cookie2` header). + + + .. attribute:: Cookie.domain_specified + +- True if a domain was explicitly specified by the server. ++ ``True`` if a domain was explicitly specified by the server. + + + .. attribute:: Cookie.domain_initial_dot + +- True if the domain explicitly specified by the server began with a dot ++ ``True`` if the domain explicitly specified by the server began with a dot + (``'.'``). + + Cookies may have additional non-standard cookie-attributes. These may be +@@ -719,7 +719,7 @@ + + .. method:: Cookie.is_expired(now=None) + +- True if cookie has passed the time at which the server requested it should ++ ``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 + cookie has expired at the specified time. + +diff -r c3896275c0f6 Doc/library/imp.rst +--- a/Doc/library/imp.rst ++++ b/Doc/library/imp.rst +@@ -190,8 +190,8 @@ + The ``cpython-32`` string comes from the current magic tag (see + :func:`get_tag`; if :attr:`sys.implementation.cache_tag` is not defined then + :exc:`NotImplementedError` will be raised). The returned path will end in +- ``.pyc`` when ``__debug__`` is True or ``.pyo`` for an optimized Python +- (i.e. ``__debug__`` is False). By passing in True or False for ++ ``.pyc`` when ``__debug__`` is ``True`` or ``.pyo`` for an optimized Python ++ (i.e. ``__debug__`` is ``False``). By passing in ``True`` or ``False`` for + *debug_override* you can override the system's value for ``__debug__`` for + extension selection. + +diff -r c3896275c0f6 Doc/library/io.rst +--- a/Doc/library/io.rst ++++ b/Doc/library/io.rst +@@ -280,7 +280,7 @@ + + .. method:: readable() + +- Return ``True`` if the stream can be read from. If False, :meth:`read` ++ Return ``True`` if the stream can be read from. If ``False``, :meth:`read` + will raise :exc:`OSError`. + + .. method:: readline(limit=-1) +diff -r c3896275c0f6 Doc/library/itertools.rst +--- a/Doc/library/itertools.rst ++++ b/Doc/library/itertools.rst +@@ -51,7 +51,7 @@ + chain.from_iterable iterable p0, p1, ... plast, q0, q1, ... ``chain.from_iterable(['ABC', 'DEF']) --> A B C D E F`` + :func:`compress` data, selectors (d[0] if s[0]), (d[1] if s[1]), ... ``compress('ABCDEF', [1,0,1,0,1,1]) --> A C E F`` + :func:`dropwhile` pred, seq seq[n], seq[n+1], starting when pred fails ``dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1`` +-:func:`filterfalse` pred, seq elements of seq where pred(elem) is False ``filterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8`` ++:func:`filterfalse` pred, seq elements of seq where pred(elem) is false ``filterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8`` + :func:`groupby` iterable[, keyfunc] sub-iterators grouped by value of keyfunc(v) + :func:`islice` seq, [start,] stop [, step] elements from seq[start:stop:step] ``islice('ABCDEFG', 2, None) --> C D E F G`` + :func:`starmap` func, seq func(\*seq[0]), func(\*seq[1]), ... ``starmap(pow, [(2,5), (3,2), (10,3)]) --> 32 9 1000`` +diff -r c3896275c0f6 Doc/library/logging.handlers.rst +--- a/Doc/library/logging.handlers.rst ++++ b/Doc/library/logging.handlers.rst +@@ -831,7 +831,7 @@ + + Returns a new instance of the :class:`HTTPHandler` class. The *host* can be + of the form ``host:port``, should you need to use a specific port number. +- If no *method* is specified, ``GET`` is used. If *secure* is True, an HTTPS ++ If no *method* is specified, ``GET`` is used. If *secure* is true, an HTTPS + connection will be used. If *credentials* is specified, it should be a + 2-tuple consisting of userid and password, which will be placed in an HTTP + 'Authorization' header using Basic authentication. If you specify +@@ -892,7 +892,7 @@ + + Enqueues the record on the queue using ``put_nowait()``; you may + want to override this if you want to use blocking behaviour, or a +- timeout, or a customised queue implementation. ++ timeout, or a customized queue implementation. + + + +diff -r c3896275c0f6 Doc/library/logging.rst +--- a/Doc/library/logging.rst ++++ b/Doc/library/logging.rst +@@ -160,7 +160,7 @@ + is called to get the exception information. + + The second optional keyword argument is *stack_info*, which defaults to +- False. If specified as True, stack information is added to the logging ++ ``False``. If true, stack information is added to the logging + message, including the actual logging call. Note that this is not the same + stack information as that displayed through specifying *exc_info*: The + former is stack frames from the bottom of the stack up to the logging call +@@ -308,7 +308,7 @@ + + Checks to see if this logger has any handlers configured. This is done by + looking for handlers in this logger and its parents in the logger hierarchy. +- Returns True if a handler was found, else False. The method stops searching ++ Returns ``True`` if a handler was found, else ``False``. The method stops searching + up the hierarchy whenever a logger with the 'propagate' attribute set to + False is found - that will be the last logger which is checked for the + existence of handlers. +@@ -794,17 +794,18 @@ + (possibly modified) versions of the arguments passed in. + + In addition to the above, :class:`LoggerAdapter` supports the following +-methods of :class:`Logger`, i.e. :meth:`debug`, :meth:`info`, :meth:`warning`, +-:meth:`error`, :meth:`exception`, :meth:`critical`, :meth:`log`, +-:meth:`isEnabledFor`, :meth:`getEffectiveLevel`, :meth:`setLevel`, +-:meth:`hasHandlers`. These methods have the same signatures as their ++methods of :class:`Logger`: :meth:`~Logger.debug`, :meth:`~Logger.info`, ++:meth:`~Logger.warning`, :meth:`~Logger.error`, :meth:`~Logger.exception`, ++:meth:`~Logger.critical`, :meth:`~Logger.log`, :meth:`~Logger.isEnabledFor`, ++:meth:`~Logger.getEffectiveLevel`, :meth:`~Logger.setLevel` and ++:meth:`~Logger.hasHandlers`. These methods have the same signatures as their + counterparts in :class:`Logger`, so you can use the two types of instances + interchangeably. + + .. versionchanged:: 3.2 +- The :meth:`isEnabledFor`, :meth:`getEffectiveLevel`, :meth:`setLevel` and +- :meth:`hasHandlers` methods were added to :class:`LoggerAdapter`. These +- methods delegate to the underlying logger. ++ The :meth:`~Logger.isEnabledFor`, :meth:`~Logger.getEffectiveLevel`, ++ :meth:`~Logger.setLevel` and :meth:`~Logger.hasHandlers` methods were added ++ to :class:`LoggerAdapter`. These methods delegate to the underlying logger. + + + Thread Safety +@@ -844,8 +845,8 @@ + + Return either the standard :class:`Logger` class, or the last class passed to + :func:`setLoggerClass`. This function may be called from within a new class +- definition, to ensure that installing a customised :class:`Logger` class will +- not undo customisations already applied by other code. For example:: ++ definition, to ensure that installing a customized :class:`Logger` class will ++ not undo customizations already applied by other code. For example:: + + class MyLogger(logging.getLoggerClass()): + # ... override behaviour here +@@ -877,7 +878,7 @@ + is called to get the exception information. + + The second optional keyword argument is *stack_info*, which defaults to +- False. If specified as True, stack information is added to the logging ++ ``False``. If true, stack information is added to the logging + message, including the actual logging call. Note that this is not the same + stack information as that displayed through specifying *exc_info*: The + former is stack frames from the bottom of the stack up to the logging call +@@ -986,8 +987,10 @@ + 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. To undo the effect of a call to +- ``logging.disable(lvl)``, call ``logging.disable(logging.NOTSET)``. ++ according to the logger's effective level. If ++ ``logging.disable(logging.NOTSET)`` is called, it effectively removes this ++ overriding level, so that logging output again depends on the effective ++ levels of individual loggers. + + + .. function:: addLevelName(lvl, levelName) +diff -r c3896275c0f6 Doc/library/lzma.rst +--- a/Doc/library/lzma.rst ++++ b/Doc/library/lzma.rst +@@ -225,7 +225,7 @@ + + .. attribute:: eof + +- True if the end-of-stream marker has been reached. ++ ``True`` if the end-of-stream marker has been reached. + + .. attribute:: unused_data + +diff -r c3896275c0f6 Doc/library/mmap.rst +--- a/Doc/library/mmap.rst ++++ b/Doc/library/mmap.rst +@@ -162,7 +162,7 @@ + + .. attribute:: closed + +- True if the file is closed. ++ ``True`` if the file is closed. + + .. versionadded:: 3.2 + +diff -r c3896275c0f6 Doc/library/multiprocessing.rst +--- a/Doc/library/multiprocessing.rst ++++ b/Doc/library/multiprocessing.rst +@@ -1006,12 +1006,24 @@ + ctypes type or a one character typecode of the kind used by the :mod:`array` + module. *\*args* is passed on to the constructor for the type. + +- If *lock* is ``True`` (the default) then a new lock object is created to +- synchronize access to the value. If *lock* is a :class:`Lock` or +- :class:`RLock` object then that will be used to synchronize access to the +- value. If *lock* is ``False`` then access to the returned object will not be +- automatically protected by a lock, so it will not necessarily be +- "process-safe". ++ If *lock* is ``True`` (the default) then a new recursive lock ++ object is created to synchronize access to the value. If *lock* is ++ a :class:`Lock` or :class:`RLock` object then that will be used to ++ synchronize access to the value. If *lock* is ``False`` then ++ access to the returned object will not be automatically protected ++ by a lock, so it will not necessarily be "process-safe". ++ ++ Operations like ``+=`` which involve a read and write are not ++ atomic. So if, for instance, you want to atomically increment a ++ shared value it is insufficient to just do :: ++ ++ counter.value += 1 ++ ++ Assuming the associated lock is recursive (which it is by default) ++ you can instead do :: ++ ++ with counter.get_lock(): ++ counter.value += 1 + + Note that *lock* is a keyword-only argument. + +diff -r c3896275c0f6 Doc/library/nntplib.rst +--- a/Doc/library/nntplib.rst ++++ b/Doc/library/nntplib.rst +@@ -83,7 +83,7 @@ + + + .. versionchanged:: 3.2 +- *usenetrc* is now False by default. ++ *usenetrc* is now ``False`` by default. + + .. versionchanged:: 3.3 + Support for the :keyword:`with` statement was added. +@@ -217,7 +217,7 @@ + .. method:: NNTP.login(user=None, password=None, usenetrc=True) + + Send ``AUTHINFO`` commands with the user name and password. If *user* +- and *password* are None and *usenetrc* is True, credentials from ++ and *password* are None and *usenetrc* is true, credentials from + ``~/.netrc`` will be used if possible. + + Unless intentionally delayed, login is normally performed during the +@@ -395,18 +395,18 @@ + + .. method:: NNTP.next() + +- Send a ``NEXT`` command. Return as for :meth:`stat`. ++ Send a ``NEXT`` command. Return as for :meth:`.stat`. + + + .. method:: NNTP.last() + +- Send a ``LAST`` command. Return as for :meth:`stat`. ++ Send a ``LAST`` command. Return as for :meth:`.stat`. + + + .. method:: NNTP.article(message_spec=None, *, file=None) + + Send an ``ARTICLE`` command, where *message_spec* has the same meaning as +- for :meth:`stat`. Return a tuple ``(response, info)`` where *info* ++ for :meth:`.stat`. Return a tuple ``(response, info)`` where *info* + is a :class:`~collections.namedtuple` with three attributes *number*, + *message_id* and *lines* (in that order). *number* is the article number + in the group (or 0 if the information is not available), *message_id* the +diff -r c3896275c0f6 Doc/library/os.path.rst +--- a/Doc/library/os.path.rst ++++ b/Doc/library/os.path.rst +@@ -133,7 +133,7 @@ + the number of seconds since the epoch (see the :mod:`time` module). Raise + :exc:`OSError` if the file does not exist or is inaccessible. + +- If :func:`os.stat_float_times` returns True, the result is a floating point ++ If :func:`os.stat_float_times` returns ``True``, the result is a floating point + number. + + +@@ -143,7 +143,7 @@ + giving the number of seconds since the epoch (see the :mod:`time` module). + Raise :exc:`OSError` if the file does not exist or is inaccessible. + +- If :func:`os.stat_float_times` returns True, the result is a floating point ++ If :func:`os.stat_float_times` returns ``True``, the result is a floating point + number. + + +@@ -334,5 +334,5 @@ + + .. data:: supports_unicode_filenames + +- True if arbitrary Unicode strings can be used as file names (within limitations ++ ``True`` if arbitrary Unicode strings can be used as file names (within limitations + imposed by the file system). +diff -r c3896275c0f6 Doc/library/os.rst +--- a/Doc/library/os.rst ++++ b/Doc/library/os.rst +@@ -551,7 +551,7 @@ + + .. data:: supports_bytes_environ + +- True if the native OS type of the environment is bytes (eg. False on ++ ``True`` if the native OS type of the environment is bytes (eg. ``False`` on + Windows). + + .. versionadded:: 3.2 +@@ -2582,6 +2582,10 @@ + Note that some platforms including FreeBSD <= 6.3, Cygwin and OS/2 EMX have + known issues when using fork() from a thread. + ++ .. warning:: ++ ++ See :mod:`ssl` for applications that use the SSL module with fork(). ++ + Availability: Unix. + + +diff -r c3896275c0f6 Doc/library/pickle.rst +--- a/Doc/library/pickle.rst ++++ b/Doc/library/pickle.rst +@@ -12,16 +12,17 @@ + .. module:: pickle + :synopsis: Convert Python objects to streams of bytes and back. + .. sectionauthor:: Jim Kerr . +-.. sectionauthor:: Barry Warsaw ++.. sectionauthor:: Barry Warsaw + + +-The :mod:`pickle` module implements a fundamental, but powerful algorithm for +-serializing and de-serializing a Python object structure. "Pickling" is the +-process whereby a Python object hierarchy is converted into a byte stream, and +-"unpickling" is the inverse operation, whereby a byte stream is converted back +-into an object hierarchy. Pickling (and unpickling) is alternatively known as +-"serialization", "marshalling," [#]_ or "flattening", however, to avoid +-confusion, the terms used here are "pickling" and "unpickling".. ++The :mod:`pickle` module implements binary protocols for serializing and ++de-serializing a Python object structure. *"Pickling"* is the process ++whereby a Python object hierarchy is converted into a byte stream, and ++*"unpickling"* is the inverse operation, whereby a byte stream ++(from a :term:`binary file` or :term:`bytes-like object`) is converted ++back into an object hierarchy. Pickling (and unpickling) is alternatively ++known as "serialization", "marshalling," [#]_ or "flattening"; however, to ++avoid confusion, the terms used here are "pickling" and "unpickling". + + .. warning:: + +@@ -33,9 +34,8 @@ + Relationship to other Python modules + ------------------------------------ + +-The :mod:`pickle` module has an transparent optimizer (:mod:`_pickle`) written +-in C. It is used whenever available. Otherwise the pure Python implementation is +-used. ++Comparison with ``marshal`` ++^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + Python has a more primitive serialization module called :mod:`marshal`, but in + general :mod:`pickle` should always be the preferred way to serialize Python +@@ -69,17 +69,30 @@ + The :mod:`pickle` serialization format is guaranteed to be backwards compatible + across Python releases. + +-Note that serialization is a more primitive notion than persistence; although +-:mod:`pickle` reads and writes file objects, it does not handle the issue of +-naming persistent objects, nor the (even more complicated) issue of concurrent +-access to persistent objects. The :mod:`pickle` module can transform a complex +-object into a byte stream and it can transform the byte stream into an object +-with the same internal structure. Perhaps the most obvious thing to do with +-these byte streams is to write them onto a file, but it is also conceivable to +-send them across a network or store them in a database. The module +-:mod:`shelve` provides a simple interface to pickle and unpickle objects on +-DBM-style database files. ++Comparison with ``json`` ++^^^^^^^^^^^^^^^^^^^^^^^^ + ++There are fundamental differences between the pickle protocols and ++`JSON (JavaScript Object Notation) `_: ++ ++* JSON is a text serialization format (it outputs unicode text, although ++ most of the time it is then encoded to ``utf-8``), while pickle is ++ a binary serialization format; ++ ++* JSON is human-readable, while pickle is not; ++ ++* JSON is interoperable and widely used outside of the Python ecosystem, ++ while pickle is Python-specific; ++ ++* JSON, by default, can only represent a subset of the Python built-in ++ types, and no custom classes; pickle can represent an extremely large ++ number of Python types (many of them automatically, by clever usage ++ of Python's introspection facilities; complex cases can be tackled by ++ implementing :ref:`specific object APIs `). ++ ++.. seealso:: ++ The :mod:`json` module: a standard library module allowing JSON ++ serialization and deserialization. + + Data stream format + ------------------ +@@ -117,6 +130,18 @@ + the default as well as the current recommended protocol; use it whenever + possible. + ++.. note:: ++ Serialization is a more primitive notion than persistence; although ++ :mod:`pickle` reads and writes file objects, it does not handle the issue of ++ naming persistent objects, nor the (even more complicated) issue of concurrent ++ access to persistent objects. The :mod:`pickle` module can transform a complex ++ object into a byte stream and it can transform the byte stream into an object ++ with the same internal structure. Perhaps the most obvious thing to do with ++ these byte streams is to write them onto a file, but it is also conceivable to ++ send them across a network or store them in a database. The :mod:`shelve` ++ module provides a simple interface to pickle and unpickle objects on ++ DBM-style database files. ++ + + Module Interface + ---------------- +@@ -161,7 +186,7 @@ + :class:`io.BytesIO` instance, or any other custom object that meets this + interface. + +- If *fix_imports* is True and *protocol* is less than 3, pickle will try to ++ If *fix_imports* is true and *protocol* is less than 3, pickle will try to + map the new Python 3.x names to the old module names used in Python 2.x, + so that the pickle data stream is readable with Python 2.x. + +@@ -178,7 +203,7 @@ + supported. The higher the protocol used, the more recent the version of + Python needed to read the pickle produced. + +- If *fix_imports* is True and *protocol* is less than 3, pickle will try to ++ If *fix_imports* is true and *protocol* is less than 3, pickle will try to + map the new Python 3.x names to the old module names used in Python 2.x, + so that the pickle data stream is readable with Python 2.x. + +@@ -200,7 +225,7 @@ + + Optional keyword arguments are *fix_imports*, *encoding* and *errors*, + which are used to control compatibility support for pickle stream generated +- by Python 2.x. If *fix_imports* is True, pickle will try to map the old ++ by Python 2.x. If *fix_imports* is true, pickle will try to map the old + Python 2.x names to the new names used in Python 3.x. The *encoding* and + *errors* tell pickle how to decode 8-bit string instances pickled by Python + 2.x; these default to 'ASCII' and 'strict', respectively. +@@ -216,7 +241,7 @@ + + Optional keyword arguments are *fix_imports*, *encoding* and *errors*, + which are used to control compatibility support for pickle stream generated +- by Python 2.x. If *fix_imports* is True, pickle will try to map the old ++ by Python 2.x. If *fix_imports* is true, pickle will try to map the old + Python 2.x names to the new names used in Python 3.x. The *encoding* and + *errors* tell pickle how to decode 8-bit string instances pickled by Python + 2.x; these default to 'ASCII' and 'strict', respectively. +@@ -266,7 +291,7 @@ + argument. It can thus be an on-disk file opened for binary writing, a + :class:`io.BytesIO` instance, or any other custom object that meets this interface. + +- If *fix_imports* is True and *protocol* is less than 3, pickle will try to ++ If *fix_imports* is true and *protocol* is less than 3, pickle will try to + map the new Python 3.x names to the old module names used in Python 2.x, + so that the pickle data stream is readable with Python 2.x. + +@@ -336,7 +361,7 @@ + + Optional keyword arguments are *fix_imports*, *encoding* and *errors*, + which are used to control compatibility support for pickle stream generated +- by Python 2.x. If *fix_imports* is True, pickle will try to map the old ++ by Python 2.x. If *fix_imports* is true, pickle will try to map the old + Python 2.x names to the new names used in Python 3.x. The *encoding* and + *errors* tell pickle how to decode 8-bit string instances pickled by Python + 2.x; these default to 'ASCII' and 'strict', respectively. +@@ -793,6 +818,14 @@ + third-party solutions. + + ++Performance ++----------- ++ ++Recent versions of the pickle protocol (from protocol 2 and upwards) feature ++efficient binary encodings for several common features and built-in types. ++Also, the :mod:`pickle` module has a transparent optimizer written in C. ++ ++ + .. _pickle-example: + + Examples +diff -r c3896275c0f6 Doc/library/sched.rst +--- a/Doc/library/sched.rst ++++ b/Doc/library/sched.rst +@@ -113,7 +113,7 @@ + function passed to the constructor) for the next event, then execute it and so + on until there are no more scheduled events. + +- If *blocking* is False executes the scheduled events due to expire soonest ++ If *blocking* is false executes the scheduled events due to expire soonest + (if any) and then return the deadline of the next scheduled call in the + scheduler (if any). + +diff -r c3896275c0f6 Doc/library/smtpd.rst +--- a/Doc/library/smtpd.rst ++++ b/Doc/library/smtpd.rst +@@ -4,7 +4,7 @@ + .. module:: smtpd + :synopsis: A SMTP server implementation in Python. + +-.. moduleauthor:: Barry Warsaw ++.. moduleauthor:: Barry Warsaw + .. sectionauthor:: Moshe Zadka + + **Source code:** :source:`Lib/smtpd.py` +diff -r c3896275c0f6 Doc/library/socket.rst +--- a/Doc/library/socket.rst ++++ b/Doc/library/socket.rst +@@ -138,9 +138,12 @@ + Module contents + --------------- + +-The module :mod:`socket` exports the following constants and functions: ++The module :mod:`socket` exports the following elements. + + ++Exceptions ++^^^^^^^^^^ ++ + .. exception:: error + + A deprecated alias of :exc:`OSError`. +@@ -186,6 +189,10 @@ + .. versionchanged:: 3.3 + This class was made a subclass of :exc:`OSError`. + ++ ++Constants ++^^^^^^^^^ ++ + .. data:: AF_UNIX + AF_INET + AF_INET6 +@@ -290,6 +297,43 @@ + this platform. + + ++Functions ++^^^^^^^^^ ++ ++Creating sockets ++'''''''''''''''' ++ ++The following functions all create :ref:`socket objects `. ++ ++ ++.. function:: socket([family[, type[, proto]]]) ++ ++ Create a new socket using the given address family, socket type and protocol ++ number. The address family should be :const:`AF_INET` (the default), ++ :const:`AF_INET6`, :const:`AF_UNIX`, :const:`AF_CAN` or :const:`AF_RDS`. The ++ socket type should be :const:`SOCK_STREAM` (the default), ++ :const:`SOCK_DGRAM`, :const:`SOCK_RAW` or perhaps one of the other ``SOCK_`` ++ constants. The protocol number is usually zero and may be omitted in that ++ case or :const:`CAN_RAW` in case the address family is :const:`AF_CAN`. ++ ++ .. versionchanged:: 3.3 ++ The AF_CAN family was added. ++ The AF_RDS family was added. ++ ++ ++.. function:: socketpair([family[, type[, proto]]]) ++ ++ Build a pair of connected socket objects using the given address family, socket ++ type, and protocol number. Address family, socket type, and protocol number are ++ as for the :func:`.socket` function above. The default family is :const:`AF_UNIX` ++ if defined on the platform; otherwise, the default is :const:`AF_INET`. ++ Availability: Unix. ++ ++ .. versionchanged:: 3.2 ++ The returned socket objects now support the whole socket API, rather ++ than a subset. ++ ++ + .. function:: create_connection(address[, timeout[, source_address]]) + + Connect to a TCP service listening on the Internet *address* (a 2-tuple +@@ -316,6 +360,40 @@ + support for the :keyword:`with` statement was added. + + ++.. function:: fromfd(fd, family, type[, proto]) ++ ++ Duplicate the file descriptor *fd* (an integer as returned by a file object's ++ :meth:`fileno` method) and build a socket object from the result. Address ++ family, socket type and protocol number are as for the :func:`.socket` function ++ above. The file descriptor should refer to a socket, but this is not checked --- ++ subsequent operations on the object may fail if the file descriptor is invalid. ++ This function is rarely needed, but can be used to get or set socket options on ++ a socket passed to a program as standard input or output (such as a server ++ started by the Unix inet daemon). The socket is assumed to be in blocking mode. ++ ++ ++.. function:: fromshare(data) ++ ++ Instantiate a socket from data obtained from the :meth:`socket.share` ++ method. The socket is assumed to be in blocking mode. ++ ++ Availability: Windows. ++ ++ .. versionadded:: 3.3 ++ ++ ++.. data:: SocketType ++ ++ This is a Python type object that represents the socket object type. It is the ++ same as ``type(socket(...))``. ++ ++ ++Other functions ++''''''''''''''' ++ ++The :mod:`socket` module also offers various network-related services: ++ ++ + .. function:: getaddrinfo(host, port, family=0, type=0, proto=0, flags=0) + + Translate the *host*/*port* argument into a sequence of 5-tuples that contain +@@ -445,46 +523,6 @@ + ``'udp'``, otherwise any protocol will match. + + +-.. function:: socket([family[, type[, proto]]]) +- +- Create a new socket using the given address family, socket type and protocol +- number. The address family should be :const:`AF_INET` (the default), +- :const:`AF_INET6`, :const:`AF_UNIX`, :const:`AF_CAN` or :const:`AF_RDS`. The +- socket type should be :const:`SOCK_STREAM` (the default), +- :const:`SOCK_DGRAM`, :const:`SOCK_RAW` or perhaps one of the other ``SOCK_`` +- constants. The protocol number is usually zero and may be omitted in that +- case or :const:`CAN_RAW` in case the address family is :const:`AF_CAN`. +- +- .. versionchanged:: 3.3 +- The AF_CAN family was added. +- The AF_RDS family was added. +- +- +-.. function:: socketpair([family[, type[, proto]]]) +- +- Build a pair of connected socket objects using the given address family, socket +- type, and protocol number. Address family, socket type, and protocol number are +- as for the :func:`.socket` function above. The default family is :const:`AF_UNIX` +- if defined on the platform; otherwise, the default is :const:`AF_INET`. +- Availability: Unix. +- +- .. versionchanged:: 3.2 +- The returned socket objects now support the whole socket API, rather +- than a subset. +- +- +-.. function:: fromfd(fd, family, type[, proto]) +- +- Duplicate the file descriptor *fd* (an integer as returned by a file object's +- :meth:`fileno` method) and build a socket object from the result. Address +- family, socket type and protocol number are as for the :func:`.socket` function +- above. The file descriptor should refer to a socket, but this is not checked --- +- subsequent operations on the object may fail if the file descriptor is invalid. +- This function is rarely needed, but can be used to get or set socket options on +- a socket passed to a program as standard input or output (such as a server +- started by the Unix inet daemon). The socket is assumed to be in blocking mode. +- +- + .. function:: ntohl(x) + + Convert 32-bit positive integers from network to host byte order. On machines +@@ -680,29 +718,14 @@ + .. versionadded:: 3.3 + + +-.. function:: fromshare(data) +- +- Instantiate a socket from data obtained from :meth:`~socket.share`. +- The socket is assumed to be in blocking mode. +- +- Availability: Windows. +- +- .. versionadded:: 3.3 +- +- +-.. data:: SocketType +- +- This is a Python type object that represents the socket object type. It is the +- same as ``type(socket(...))``. +- +- + .. _socket-objects: + + Socket Objects + -------------- + +-Socket objects have the following methods. Except for :meth:`makefile` these +-correspond to Unix system calls applicable to sockets. ++Socket objects have the following methods. Except for ++:meth:`~socket.makefile`, these correspond to Unix system calls applicable ++to sockets. + + + .. method:: socket.accept() +@@ -721,9 +744,15 @@ + + .. method:: socket.close() + +- Close the socket. All future operations on the socket object will fail. The +- remote end will receive no more data (after queued data is flushed). Sockets are +- automatically closed when they are garbage-collected. ++ Mark the socket closed. The underlying system resource (e.g. a file ++ descriptor) is also closed when all file objects from :meth:`makefile()` ++ are closed. Once that happens, all future operations on the socket ++ object will fail. The remote end will receive no more data (after ++ queued data is flushed). ++ ++ Sockets are automatically closed when they are garbage-collected, but ++ it is recommended to :meth:`close` them explicitly, or to use a ++ :keyword:`with` statement around them. + + .. note:: + :meth:`close()` releases the resource associated with a connection but +@@ -829,10 +858,13 @@ + type depends on the arguments given to :meth:`makefile`. These arguments are + interpreted the same way as by the built-in :func:`open` function. + +- Closing the file object won't close the socket unless there are no remaining +- references to the socket. The socket must be in blocking mode; it can have +- a timeout, but the file object's internal buffer may end up in a inconsistent +- state if a timeout occurs. ++ The socket must be in blocking mode; it can have a timeout, but the file ++ object's internal buffer may end up in a inconsistent state if a timeout ++ occurs. ++ ++ Closing the file object returned by :meth:`makefile` won't close the ++ original socket unless all other file objects have been closed and ++ :meth:`socket.close` has been called on the socket object. + + .. note:: + +@@ -1096,14 +1128,14 @@ + + .. method:: socket.share(process_id) + +- :platform: Windows ++ Duplicate a socket and prepare it for sharing with a target process. The ++ target process must be provided with *process_id*. The resulting bytes object ++ can then be passed to the target process using some form of interprocess ++ communication and the socket can be recreated there using :func:`fromshare`. ++ Once this method has been called, it is safe to close the socket since ++ the operating system has already duplicated it for the target process. + +- Duplacet a socket and prepare it for sharing with a target process. The +- target process must be provided with *process_id*. The resulting bytes object +- can then be passed to the target process using some form of interprocess +- communication and the socket can be recreated there using :func:`fromshare`. +- Once this method has been called, it is safe to close the socket since +- the operating system has already duplicated it for the target process. ++ Availability: Windows. + + .. versionadded:: 3.3 + +diff -r c3896275c0f6 Doc/library/sqlite3.rst +--- a/Doc/library/sqlite3.rst ++++ b/Doc/library/sqlite3.rst +@@ -229,10 +229,10 @@ + .. function:: enable_callback_tracebacks(flag) + + By default you will not get any tracebacks in user-defined functions, +- aggregates, converters, authorizer callbacks etc. If you want to debug them, you +- can call this function with *flag* as True. Afterwards, you will get tracebacks +- from callbacks on ``sys.stderr``. Use :const:`False` to disable the feature +- again. ++ aggregates, converters, authorizer callbacks etc. If you want to debug them, ++ you can call this function with *flag* set to ``True``. Afterwards, you will ++ get tracebacks from callbacks on ``sys.stderr``. Use :const:`False` to ++ disable the feature again. + + + .. _sqlite3-connection-objects: +diff -r c3896275c0f6 Doc/library/ssl.rst +--- a/Doc/library/ssl.rst ++++ b/Doc/library/ssl.rst +@@ -28,6 +28,12 @@ + operating system socket APIs. The installed version of OpenSSL may also + cause variations in behavior. + ++.. warning:: ++ Don't use this module without reading the :ref:`ssl-security`. Doing so ++ may lead to a false sense of security, as the default settings of the ++ ssl module are not necessarily appropriate for your application. ++ ++ + This section documents the objects and functions in the ``ssl`` module; for more + general information about TLS, SSL, and certificates, the reader is referred to + the documents in the "See Also" section at the bottom. +@@ -239,7 +245,7 @@ + .. function:: RAND_pseudo_bytes(num) + + Returns (bytes, is_cryptographic): bytes are *num* pseudo-random bytes, +- is_cryptographic is True if the bytes generated are cryptographically ++ is_cryptographic is ``True`` if the bytes generated are cryptographically + strong. Raises an :class:`SSLError` if the operation is not supported by the + current RAND method. + +@@ -252,8 +258,8 @@ + + .. function:: RAND_status() + +- Returns True if the SSL pseudo-random number generator has been seeded with +- 'enough' randomness, and False otherwise. You can use :func:`ssl.RAND_egd` ++ Returns ``True`` if the SSL pseudo-random number generator has been seeded with ++ 'enough' randomness, and ``False`` otherwise. You can use :func:`ssl.RAND_egd` + and :func:`ssl.RAND_add` to increase the randomness of the pseudo-random + number generator. + +@@ -1306,6 +1312,17 @@ + If you want to check which ciphers are enabled by a given cipher list, + use the ``openssl ciphers`` command on your system. + ++Multi-processing ++^^^^^^^^^^^^^^^^ ++ ++If using this module as part of a multi-processed application (using, ++for example the :mod:`multiprocessing` or :mod:`concurrent.futures` modules), ++be aware that OpenSSL's internal random number generator does not properly ++handle forked processes. Applications must change the PRNG state of the ++parent process if they use any SSL feature with :func:`os.fork`. Any ++successful call of :func:`~ssl.RAND_add`, :func:`~ssl.RAND_bytes` or ++:func:`~ssl.RAND_pseudo_bytes` is sufficient. ++ + + .. seealso:: + +diff -r c3896275c0f6 Doc/library/stdtypes.rst +--- a/Doc/library/stdtypes.rst ++++ b/Doc/library/stdtypes.rst +@@ -1149,6 +1149,9 @@ + fail, the entire sort operation will fail (and the list will likely be left + in a partially modified state). + ++ :meth:`sort` accepts two arguments that can only be passed by keyword ++ (:ref:`keyword-only arguments `): ++ + *key* specifies a function of one argument that is used to extract a + comparison key from each list element (for example, ``key=str.lower``). + The key corresponding to each item in the list is calculated once and +@@ -2844,7 +2847,7 @@ + + .. method:: isdisjoint(other) + +- Return True if the set has no elements in common with *other*. Sets are ++ Return ``True`` if the set has no elements in common with *other*. Sets are + disjoint if and only if their intersection is the empty set. + + .. method:: issubset(other) +diff -r c3896275c0f6 Doc/library/string.rst +--- a/Doc/library/string.rst ++++ b/Doc/library/string.rst +@@ -300,7 +300,7 @@ + precision: `integer` + type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%" + +-If a valid *align* value is specified, it can be preceeded by a *fill* ++If a valid *align* value is specified, it can be preceded by a *fill* + character that can be any character and defaults to a space if omitted. + Note that it is not possible to use ``{`` and ``}`` as *fill* char while + using the :meth:`str.format` method; this limitation however doesn't +diff -r c3896275c0f6 Doc/library/struct.rst +--- a/Doc/library/struct.rst ++++ b/Doc/library/struct.rst +@@ -282,7 +282,7 @@ + For the ``'?'`` format character, the return value is either :const:`True` or + :const:`False`. When packing, the truth value of the argument object is used. + Either 0 or 1 in the native or standard bool representation will be packed, and +-any non-zero value will be True when unpacking. ++any non-zero value will be ``True`` when unpacking. + + + +diff -r c3896275c0f6 Doc/library/subprocess.rst +--- a/Doc/library/subprocess.rst ++++ b/Doc/library/subprocess.rst +@@ -441,13 +441,12 @@ + approximately that size. A negative bufsize (the default) means + the system default of io.DEFAULT_BUFFER_SIZE will be used. + +- .. versionchanged:: 3.2.4, 3.3.1 +- ++ .. versionchanged:: 3.3.1 + *bufsize* now defaults to -1 to enable buffering by default to match the +- behavior that most code expects. In 3.2.0 through 3.2.3 and 3.3.0 it +- incorrectly defaulted to :const:`0` which was unbuffered and allowed +- short reads. This was unintentional and did not match the behavior of +- Python 2 as most code expected. ++ behavior that most code expects. In versions prior to Python 3.2.4 and ++ 3.3.1 it incorrectly defaulted to :const:`0` which was unbuffered ++ and allowed short reads. This was unintentional and did not match the ++ behavior of Python 2 as most code expected. + + The *executable* argument specifies a replacement program to execute. It + is very seldom needed. When ``shell=False``, *executable* replaces the +@@ -513,7 +512,7 @@ + *executable* (or for the first item in *args*) relative to *cwd* if the + executable path is a relative path. + +- If *restore_signals* is True (the default) all signals that Python has set to ++ If *restore_signals* is true (the default) all signals that Python has set to + SIG_IGN are restored to SIG_DFL in the child process before the exec. + Currently this includes the SIGPIPE, SIGXFZ and SIGXFSZ signals. + (Unix only) +@@ -521,7 +520,7 @@ + .. versionchanged:: 3.2 + *restore_signals* was added. + +- If *start_new_session* is True the setsid() system call will be made in the ++ If *start_new_session* is true the setsid() system call will be made in the + child process prior to the execution of the subprocess. (Unix only) + + .. versionchanged:: 3.2 +@@ -1050,10 +1049,12 @@ + + Return ``(status, output)`` of executing *cmd* in a shell. + +- Execute the string *cmd* in a shell with :func:`os.popen` and return a 2-tuple +- ``(status, output)``. *cmd* is actually run as ``{ cmd ; } 2>&1``, so that the +- returned output will contain output or error messages. A trailing newline is +- stripped from the output. The exit status for the command can be interpreted ++ Execute the string *cmd* in a shell with :class:`Popen` and return a 2-tuple ++ ``(status, output)`` via :func:`Popen.communicate`. Universal newlines mode ++ is used; see the notes on :ref:`frequently-used-arguments` for more details. ++ ++ A trailing newline is stripped from the output. ++ The exit status for the command can be interpreted + according to the rules for the C function :c:func:`wait`. Example:: + + >>> subprocess.getstatusoutput('ls /bin/ls') +@@ -1063,7 +1064,8 @@ + >>> subprocess.getstatusoutput('/bin/junk') + (256, 'sh: /bin/junk: not found') + +- Availability: UNIX. ++ .. versionchanged:: 3.3 ++ Availability: Unix & Windows + + + .. function:: getoutput(cmd) +@@ -1076,7 +1078,8 @@ + >>> subprocess.getoutput('ls /bin/ls') + '/bin/ls' + +- Availability: UNIX. ++ .. versionchanged:: 3.3 ++ Availability: Unix & Windows + + + Notes +diff -r c3896275c0f6 Doc/library/sys.rst +--- a/Doc/library/sys.rst ++++ b/Doc/library/sys.rst +@@ -409,7 +409,7 @@ + * On Mac OS X, the encoding is ``'utf-8'``. + + * On Unix, the encoding is the user's preference according to the result of +- nl_langinfo(CODESET), or ``'utf-8'`` if ``nl_langinfo(CODESET)`` failed. ++ nl_langinfo(CODESET). + + * On Windows NT+, file names are Unicode natively, so no conversion is + performed. :func:`getfilesystemencoding` still returns ``'mbcs'``, as +@@ -420,8 +420,7 @@ + * On Windows 9x, the encoding is ``'mbcs'``. + + .. versionchanged:: 3.2 +- On Unix, use ``'utf-8'`` instead of ``None`` if ``nl_langinfo(CODESET)`` +- failed. :func:`getfilesystemencoding` result cannot be ``None``. ++ :func:`getfilesystemencoding` result cannot be ``None`` anymore. + + + .. function:: getrefcount(object) +@@ -1032,7 +1031,7 @@ + :func:`open` function. Their parameters are chosen as follows: + + * The character encoding is platform-dependent. Under Windows, if the stream +- is interactive (that is, if its :meth:`isatty` method returns True), the ++ is interactive (that is, if its :meth:`isatty` method returns ``True``), the + console codepage is used, otherwise the ANSI code page. Under other + platforms, the locale encoding is used (see :meth:`locale.getpreferredencoding`). + +diff -r c3896275c0f6 Doc/library/tarfile.rst +--- a/Doc/library/tarfile.rst ++++ b/Doc/library/tarfile.rst +@@ -359,7 +359,7 @@ + full name. Its file information is extracted as accurately as possible. *member* + may be a filename or a :class:`TarInfo` object. You can specify a different + directory using *path*. File attributes (owner, mtime, mode) are set unless +- *set_attrs* is False. ++ *set_attrs* is false. + + .. note:: + +diff -r c3896275c0f6 Doc/library/tkinter.ttk.rst +--- a/Doc/library/tkinter.ttk.rst ++++ b/Doc/library/tkinter.ttk.rst +@@ -272,8 +272,8 @@ + + .. method:: instate(statespec, callback=None, *args, **kw) + +- Test the widget's state. If a callback is not specified, returns True +- if the widget state matches *statespec* and False otherwise. If callback ++ Test the widget's state. If a callback is not specified, returns ``True`` ++ if the widget state matches *statespec* and ``False`` otherwise. If callback + is specified then it is called with args if widget state matches + *statespec*. + +@@ -938,7 +938,7 @@ + + .. method:: exists(item) + +- Returns True if the specified *item* is present in the tree. ++ Returns ``True`` if the specified *item* is present in the tree. + + + .. method:: focus(item=None) +@@ -1084,7 +1084,7 @@ + + Ensure that *item* is visible. + +- Sets all of *item*'s ancestors open option to True, and scrolls the ++ Sets all of *item*'s ancestors open option to ``True``, and scrolls the + widget if necessary so that *item* is within the visible portion of + the tree. + +diff -r c3896275c0f6 Doc/library/turtle.rst +--- a/Doc/library/turtle.rst ++++ b/Doc/library/turtle.rst +@@ -1055,8 +1055,8 @@ + + Write text - the string representation of *arg* - at the current turtle + position according to *align* ("left", "center" or right") and with the given +- font. If *move* is True, the pen is moved to the bottom-right corner of the +- text. By default, *move* is False. ++ font. If *move* is true, the pen is moved to the bottom-right corner of the ++ text. By default, *move* is ``False``. + + >>> turtle.write("Home = ", True, align="center") + >>> turtle.write((0,0), True) +@@ -1092,7 +1092,7 @@ + + .. function:: isvisible() + +- Return True if the Turtle is shown, False if it's hidden. ++ Return ``True`` if the Turtle is shown, ``False`` if it's hidden. + + >>> turtle.hideturtle() + >>> turtle.isvisible() +diff -r c3896275c0f6 Doc/library/unittest.mock.rst +--- a/Doc/library/unittest.mock.rst ++++ b/Doc/library/unittest.mock.rst +@@ -299,11 +299,11 @@ + assert the mock has been called with the specified calls. + The `mock_calls` list is checked for the calls. + +- If `any_order` is False (the default) then the calls must be ++ If `any_order` is false (the default) then the calls must be + sequential. There can be extra calls before or after the + specified calls. + +- If `any_order` is True then the calls can be in any order, but ++ If `any_order` is true then the calls can be in any order, but + they must all appear in :attr:`mock_calls`. + + >>> mock = Mock(return_value=None) +@@ -1180,7 +1180,7 @@ + `values` can be a dictionary of values to set in the dictionary. `values` + can also be an iterable of `(key, value)` pairs. + +- If `clear` is True then the dictionary will be cleared before the new ++ If `clear` is true then the dictionary will be cleared before the new + values are set. + + `patch.dict` can also be called with arbitrary keyword arguments to set +diff -r c3896275c0f6 Doc/library/urllib.request.rst +--- a/Doc/library/urllib.request.rst ++++ b/Doc/library/urllib.request.rst +@@ -59,7 +59,7 @@ + some non-Windows platforms. + + .. warning:: +- If neither *cafile* nor *capath* is specified, and *cadefault* is False, ++ If neither *cafile* nor *capath* is specified, and *cadefault* is ``False``, + an HTTPS request will not do any verification of the server's + certificate. + +@@ -211,7 +211,7 @@ + containing the image. + + *unverifiable* should indicate whether the request is unverifiable, +- as defined by RFC 2965. It defaults to False. An unverifiable ++ as defined by RFC 2965. It defaults to ``False``. An unverifiable + request is one whose URL the user did not have the option to + approve. For example, if the request is for an image in an HTML + document, and the user had no option to approve the automatic +diff -r c3896275c0f6 Doc/library/venv.rst +--- a/Doc/library/venv.rst ++++ b/Doc/library/venv.rst +@@ -93,7 +93,7 @@ + * ``system_site_packages`` -- a Boolean value indicating that the system Python + site-packages should be available to the environment (defaults to ``False``). + +- * ``clear`` -- a Boolean value which, if True, will delete any existing target ++ * ``clear`` -- a Boolean value which, if true, will delete any existing target + directory instead of raising an exception (defaults to ``False``). + + * ``symlinks`` -- a Boolean value indicating whether to attempt to symlink the +@@ -101,7 +101,7 @@ + e.g. ``pythonw.exe``), rather than copying. Defaults to ``True`` on Linux and + Unix systems, but ``False`` on Windows. + +- * ``upgrade`` -- a Boolean value which, if True, will upgrade an existing ++ * ``upgrade`` -- a Boolean value which, if true, will upgrade an existing + environment with the running Python - for use when that Python has been + upgraded in-place (defaults to ``False``). + +diff -r c3896275c0f6 Doc/library/xml.etree.elementtree.rst +--- a/Doc/library/xml.etree.elementtree.rst ++++ b/Doc/library/xml.etree.elementtree.rst +@@ -379,7 +379,7 @@ + + 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. The ++ containing XML data. *events* is a tuple 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. +diff -r c3896275c0f6 Doc/library/zipimport.rst +--- a/Doc/library/zipimport.rst ++++ b/Doc/library/zipimport.rst +@@ -111,7 +111,7 @@ + + .. method:: is_package(fullname) + +- Return True if the module specified by *fullname* is a package. Raise ++ Return ``True`` if the module specified by *fullname* is a package. Raise + :exc:`ZipImportError` if the module couldn't be found. + + +diff -r c3896275c0f6 Doc/reference/datamodel.rst +--- a/Doc/reference/datamodel.rst ++++ b/Doc/reference/datamodel.rst +@@ -201,7 +201,7 @@ + single: True + + These represent the truth values False and True. The two objects representing +- the values False and True are the only Boolean objects. The Boolean type is a ++ the values ``False`` and ``True`` are the only Boolean objects. The Boolean type is a + subtype of the integer type, and Boolean values behave like the values 0 and 1, + respectively, in almost all contexts, the exception being that when converted to + a string, the strings ``"False"`` or ``"True"`` are returned, respectively. +diff -r c3896275c0f6 Doc/tutorial/controlflow.rst +--- a/Doc/tutorial/controlflow.rst ++++ b/Doc/tutorial/controlflow.rst +@@ -19,14 +19,14 @@ + >>> x = int(input("Please enter an integer: ")) + Please enter an integer: 42 + >>> if x < 0: +- ... x = 0 +- ... print('Negative changed to zero') ++ ... x = 0 ++ ... print('Negative changed to zero') + ... elif x == 0: +- ... print('Zero') ++ ... print('Zero') + ... elif x == 1: +- ... print('Single') ++ ... print('Single') + ... else: +- ... print('More') ++ ... print('More') + ... + More + +diff -r c3896275c0f6 Doc/tutorial/inputoutput.rst +--- a/Doc/tutorial/inputoutput.rst ++++ b/Doc/tutorial/inputoutput.rst +@@ -377,47 +377,64 @@ + Reference for a complete guide to file objects. + + +-.. _tut-pickle: ++.. _tut-json: + +-The :mod:`pickle` Module +------------------------- ++Saving structured data with :mod:`json` ++--------------------------------------- + +-.. index:: module: pickle ++.. index:: module: json + +-Strings can easily be written to and read from a file. Numbers take a bit more ++Strings can easily be written to and read from a file. Numbers take a bit more + effort, since the :meth:`read` method only returns strings, which will have to + be passed to a function like :func:`int`, which takes a string like ``'123'`` +-and returns its numeric value 123. However, when you want to save more complex +-data types like lists, dictionaries, or class instances, things get a lot more +-complicated. ++and returns its numeric value 123. When you want to save more complex data ++types like nested lists and dictionaries, parsing and serializing by hand ++becomes complicated. + +-Rather than have users be constantly writing and debugging code to save +-complicated data types, Python provides a standard module called :mod:`pickle`. +-This is an amazing module that can take almost any Python object (even some +-forms of Python code!), and convert it to a string representation; this process +-is called :dfn:`pickling`. Reconstructing the object from the string +-representation is called :dfn:`unpickling`. Between pickling and unpickling, +-the string representing the object may have been stored in a file or data, or ++Rather than having users constantly writing and debugging code to save ++complicated data types to files, Python allows you to use the popular data ++interchange format called `JSON (JavaScript Object Notation) ++`_. The standard module called :mod:`json` can take Python ++data hierarchies, and convert them to string representations; this process is ++called :dfn:`serializing`. Reconstructing the data from the string representation ++is called :dfn:`deserializing`. Between serializing and deserializing, the ++string representing the object may have been stored in a file or data, or + sent over a network connection to some distant machine. + +-If you have an object ``x``, and a file object ``f`` that's been opened for +-writing, the simplest way to pickle the object takes only one line of code:: ++.. note:: ++ The JSON format is commonly used by modern applications to allow for data ++ exchange. Many programmers are already familiar with it, which makes ++ it a good choice for interoperability. + +- pickle.dump(x, f) ++If you have an object ``x``, you can view its JSON string representation with a ++simple line of code:: + +-To unpickle the object again, if ``f`` is a file object which has been opened +-for reading:: ++ >>> json.dumps([1, 'simple', 'list']) ++ '[1, "simple", "list"]' + +- x = pickle.load(f) ++Another variant of the :func:`~json.dumps` function, called :func:`~json.dump`, ++simply serializes the object to a :term:`text file`. So if ``f`` is a ++:term:`text file` object opened for writing, we can do this:: + +-(There are other variants of this, used when pickling many objects or when you +-don't want to write the pickled data to a file; consult the complete +-documentation for :mod:`pickle` in the Python Library Reference.) ++ json.dump(x, f) + +-:mod:`pickle` is the standard way to make Python objects which can be stored and +-reused by other programs or by a future invocation of the same program; the +-technical term for this is a :dfn:`persistent` object. Because :mod:`pickle` is +-so widely used, many authors who write Python extensions take care to ensure +-that new data types such as matrices can be properly pickled and unpickled. ++To decode the object again, if ``f`` is a :term:`text file` object which has ++been opened for reading:: + ++ x = json.load(f) + ++This simple serialization technique can handle lists and dictionaries, but ++serializing arbitrary class instances in JSON requires a bit of extra effort. ++The reference for the :mod:`json` module contains an explanation of this. ++ ++.. seealso:: ++ ++ :mod:`pickle` - the pickle module ++ ++ Contrary to :ref:`JSON `, *pickle* is a protocol which allows ++ the serialization of arbitrarily complex Python objects. As such, it is ++ specific to Python and cannot be used to communicate with applications ++ written in other languages. It is also insecure by default: ++ deserializing pickle data coming from an untrusted source can execute ++ arbitrary code, if the data was crafted by a skilled attacker. ++ +diff -r c3896275c0f6 Doc/using/windows.rst +--- a/Doc/using/windows.rst ++++ b/Doc/using/windows.rst +@@ -556,9 +556,9 @@ + latest release's source or just grab a fresh `checkout + `_. + +-For Microsoft Visual C++, which is the compiler with which official Python +-releases are built, the source tree contains solutions/project files. View the +-:file:`readme.txt` in their respective directories: ++The source tree contains a build solution and project files for Microsoft ++Visual C++, which is the compiler used to build the official Python releases. ++View the :file:`readme.txt` in their respective directories: + + +--------------------+--------------+-----------------------+ + | Directory | MSVC version | Visual Studio version | +@@ -569,14 +569,16 @@ + +--------------------+--------------+-----------------------+ + | :file:`PC/VS8.0/` | 8.0 | 2005 | + +--------------------+--------------+-----------------------+ +-| :file:`PCbuild/` | 9.0 | 2008 | ++| :file:`PC/VS9.0/` | 9.0 | 2008 | +++--------------------+--------------+-----------------------+ ++| :file:`PCbuild/` | 10.0 | 2010 | + +--------------------+--------------+-----------------------+ + +-Note that not all of these build directories are fully supported. Read the +-release notes to see which compiler version the official releases for your +-version are built with. ++Note that any build directories within the :file:`PC` directory are not ++necessarily fully supported. The :file:`PCbuild` directory contains the files ++for the compiler used to build the official release. + +-Check :file:`PC/readme.txt` for general information on the build process. ++Check :file:`PCbuild/readme.txt` for general information on the build process. + + + For extension modules, consult :ref:`building-on-windows`. +diff -r c3896275c0f6 Doc/whatsnew/3.3.rst +--- a/Doc/whatsnew/3.3.rst ++++ b/Doc/whatsnew/3.3.rst +@@ -1125,7 +1125,7 @@ + + * If Python is compiled without threads, the C version automatically + disables the expensive thread local context machinery. In this case, +- the variable :data:`~decimal.HAVE_THREADS` is set to False. ++ the variable :data:`~decimal.HAVE_THREADS` is set to ``False``. + + API changes + ~~~~~~~~~~~ +diff -r c3896275c0f6 Include/object.h +--- a/Include/object.h ++++ b/Include/object.h +@@ -831,6 +831,9 @@ + PyAPI_FUNC(void) Py_IncRef(PyObject *); + PyAPI_FUNC(void) Py_DecRef(PyObject *); + ++PyAPI_DATA(PyTypeObject) _PyNone_Type; ++PyAPI_DATA(PyTypeObject) _PyNotImplemented_Type; ++ + /* + _Py_NoneStruct is an object of undefined type which can be used in contexts + where NULL (nil) is not suitable (since NULL often means 'error'). +diff -r c3896275c0f6 Lib/_compat_pickle.py +--- a/Lib/_compat_pickle.py ++++ b/Lib/_compat_pickle.py +@@ -76,6 +76,62 @@ + ('itertools', 'ifilterfalse'): ('itertools', 'filterfalse'), + } + ++PYTHON2_EXCEPTIONS = ( ++ "ArithmeticError", ++ "AssertionError", ++ "AttributeError", ++ "BaseException", ++ "BufferError", ++ "BytesWarning", ++ "DeprecationWarning", ++ "EOFError", ++ "EnvironmentError", ++ "Exception", ++ "FloatingPointError", ++ "FutureWarning", ++ "GeneratorExit", ++ "IOError", ++ "ImportError", ++ "ImportWarning", ++ "IndentationError", ++ "IndexError", ++ "KeyError", ++ "KeyboardInterrupt", ++ "LookupError", ++ "MemoryError", ++ "NameError", ++ "NotImplementedError", ++ "OSError", ++ "OverflowError", ++ "PendingDeprecationWarning", ++ "ReferenceError", ++ "RuntimeError", ++ "RuntimeWarning", ++ # StandardError is gone in Python 3, so we map it to Exception ++ "StopIteration", ++ "SyntaxError", ++ "SyntaxWarning", ++ "SystemError", ++ "SystemExit", ++ "TabError", ++ "TypeError", ++ "UnboundLocalError", ++ "UnicodeDecodeError", ++ "UnicodeEncodeError", ++ "UnicodeError", ++ "UnicodeTranslateError", ++ "UnicodeWarning", ++ "UserWarning", ++ "ValueError", ++ "Warning", ++ "ZeroDivisionError", ++) ++ ++for excname in PYTHON2_EXCEPTIONS: ++ NAME_MAPPING[("exceptions", excname)] = ("builtins", excname) ++ ++NAME_MAPPING[("exceptions", "StandardError")] = ("builtins", "Exception") ++ + # Same, but for 3.x to 2.x + REVERSE_IMPORT_MAPPING = dict((v, k) for (k, v) in IMPORT_MAPPING.items()) + REVERSE_NAME_MAPPING = dict((v, k) for (k, v) in NAME_MAPPING.items()) +diff -r c3896275c0f6 Lib/_strptime.py +--- a/Lib/_strptime.py ++++ b/Lib/_strptime.py +@@ -329,7 +329,7 @@ + (bad_directive, format)) from None + # IndexError only occurs when the format string is "%" + except IndexError: +- raise ValueError("stray %% in format '%s'" % format) ++ raise ValueError("stray %% in format '%s'" % format) from None + _regex_cache[format] = format_regex + found = format_regex.match(data_string) + if not found: +diff -r c3896275c0f6 Lib/bz2.py +--- a/Lib/bz2.py ++++ b/Lib/bz2.py +@@ -199,8 +199,15 @@ + # Continue to next stream. + if self._decompressor.eof: + self._decompressor = BZ2Decompressor() +- +- self._buffer = self._decompressor.decompress(rawblock) ++ try: ++ self._buffer = self._decompressor.decompress(rawblock) ++ except OSError: ++ # Trailing data isn't a valid bzip2 stream. We're done here. ++ self._mode = _MODE_READ_EOF ++ self._size = self._pos ++ return False ++ else: ++ self._buffer = self._decompressor.decompress(rawblock) + self._buffer_offset = 0 + return True + +@@ -488,17 +495,19 @@ + + For incremental decompression, use a BZ2Decompressor object instead. + """ +- if len(data) == 0: +- return b"" +- + results = [] +- while True: ++ while data: + decomp = BZ2Decompressor() +- results.append(decomp.decompress(data)) ++ try: ++ res = decomp.decompress(data) ++ except OSError: ++ if results: ++ break # Leftover data is not a valid bzip2 stream; ignore it. ++ else: ++ raise # Error on the first iteration; bail out. ++ results.append(res) + if not decomp.eof: + raise ValueError("Compressed data ended before the " + "end-of-stream marker was reached") +- if not decomp.unused_data: +- return b"".join(results) +- # There is unused data left over. Proceed to next stream. + data = decomp.unused_data ++ return b"".join(results) +diff -r c3896275c0f6 Lib/copy.py +--- a/Lib/copy.py ++++ b/Lib/copy.py +@@ -76,6 +76,14 @@ + if copier: + return copier(x) + ++ try: ++ issc = issubclass(cls, type) ++ except TypeError: # cls is not a class ++ issc = False ++ if issc: ++ # treat it as a regular class: ++ return _copy_immutable(x) ++ + copier = getattr(cls, "__copy__", None) + if copier: + return copier(x) +diff -r c3896275c0f6 Lib/csv.py +--- a/Lib/csv.py ++++ b/Lib/csv.py +@@ -146,7 +146,7 @@ + wrong_fields = [k for k in rowdict if k not in self.fieldnames] + if wrong_fields: + raise ValueError("dict contains fields not in fieldnames: " +- + ", ".join(wrong_fields)) ++ + ", ".join([repr(x) for x in wrong_fields])) + return [rowdict.get(key, self.restval) for key in self.fieldnames] + + def writerow(self, rowdict): +diff -r c3896275c0f6 Lib/ctypes/test/test_arrays.py +--- a/Lib/ctypes/test/test_arrays.py ++++ b/Lib/ctypes/test/test_arrays.py +@@ -84,8 +84,8 @@ + self.assertEqual(values, [1, 2, 3, 4, 5]) + + def test_classcache(self): +- self.assertTrue(not ARRAY(c_int, 3) is ARRAY(c_int, 4)) +- self.assertTrue(ARRAY(c_int, 3) is ARRAY(c_int, 3)) ++ self.assertIsNot(ARRAY(c_int, 3), ARRAY(c_int, 4)) ++ self.assertIs(ARRAY(c_int, 3), ARRAY(c_int, 3)) + + def test_from_address(self): + # Failed with 0.9.8, reported by JUrner +@@ -125,7 +125,7 @@ + # Create a new array type based on it: + t1 = my_int * 1 + t2 = my_int * 1 +- self.assertTrue(t1 is t2) ++ self.assertIs(t1, t2) + + def test_subclass(self): + class T(Array): +diff -r c3896275c0f6 Lib/ctypes/test/test_as_parameter.py +--- a/Lib/ctypes/test/test_as_parameter.py ++++ b/Lib/ctypes/test/test_as_parameter.py +@@ -134,7 +134,7 @@ + f.argtypes = [c_longlong, MyCallback] + + def callback(value): +- self.assertTrue(isinstance(value, int)) ++ self.assertIsInstance(value, int) + return value & 0x7FFFFFFF + + cb = MyCallback(callback) +diff -r c3896275c0f6 Lib/ctypes/test/test_buffers.py +--- a/Lib/ctypes/test/test_buffers.py ++++ b/Lib/ctypes/test/test_buffers.py +@@ -7,12 +7,12 @@ + b = create_string_buffer(32) + self.assertEqual(len(b), 32) + self.assertEqual(sizeof(b), 32 * sizeof(c_char)) +- self.assertTrue(type(b[0]) is bytes) ++ self.assertIs(type(b[0]), bytes) + + b = create_string_buffer(b"abc") + self.assertEqual(len(b), 4) # trailing nul char + self.assertEqual(sizeof(b), 4 * sizeof(c_char)) +- self.assertTrue(type(b[0]) is bytes) ++ self.assertIs(type(b[0]), bytes) + self.assertEqual(b[0], b"a") + self.assertEqual(b[:], b"abc\0") + self.assertEqual(b[::], b"abc\0") +@@ -33,12 +33,12 @@ + b = create_unicode_buffer(32) + self.assertEqual(len(b), 32) + self.assertEqual(sizeof(b), 32 * sizeof(c_wchar)) +- self.assertTrue(type(b[0]) is str) ++ self.assertIs(type(b[0]), str) + + b = create_unicode_buffer("abc") + self.assertEqual(len(b), 4) # trailing nul char + self.assertEqual(sizeof(b), 4 * sizeof(c_wchar)) +- self.assertTrue(type(b[0]) is str) ++ self.assertIs(type(b[0]), str) + self.assertEqual(b[0], "a") + self.assertEqual(b[:], "abc\0") + self.assertEqual(b[::], "abc\0") +@@ -50,7 +50,7 @@ + b = create_unicode_buffer("abc") + self.assertEqual(len(b), 4) # trailing nul char + self.assertEqual(sizeof(b), 4 * sizeof(c_wchar)) +- self.assertTrue(type(b[0]) is str) ++ self.assertIs(type(b[0]), str) + self.assertEqual(b[0], "a") + self.assertEqual(b[:], "abc\0") + self.assertEqual(b[::], "abc\0") +diff -r c3896275c0f6 Lib/ctypes/test/test_byteswap.py +--- a/Lib/ctypes/test/test_byteswap.py ++++ b/Lib/ctypes/test/test_byteswap.py +@@ -23,11 +23,11 @@ + + def test_endian_short(self): + if sys.byteorder == "little": +- self.assertTrue(c_short.__ctype_le__ is c_short) +- self.assertTrue(c_short.__ctype_be__.__ctype_le__ is c_short) ++ self.assertIs(c_short.__ctype_le__, c_short) ++ self.assertIs(c_short.__ctype_be__.__ctype_le__, c_short) + else: +- self.assertTrue(c_short.__ctype_be__ is c_short) +- self.assertTrue(c_short.__ctype_le__.__ctype_be__ is c_short) ++ self.assertIs(c_short.__ctype_be__, c_short) ++ self.assertIs(c_short.__ctype_le__.__ctype_be__, c_short) + s = c_short.__ctype_be__(0x1234) + self.assertEqual(bin(struct.pack(">h", 0x1234)), "1234") + self.assertEqual(bin(s), "1234") +@@ -50,11 +50,11 @@ + + def test_endian_int(self): + if sys.byteorder == "little": +- self.assertTrue(c_int.__ctype_le__ is c_int) +- self.assertTrue(c_int.__ctype_be__.__ctype_le__ is c_int) ++ self.assertIs(c_int.__ctype_le__, c_int) ++ self.assertIs(c_int.__ctype_be__.__ctype_le__, c_int) + else: +- self.assertTrue(c_int.__ctype_be__ is c_int) +- self.assertTrue(c_int.__ctype_le__.__ctype_be__ is c_int) ++ self.assertIs(c_int.__ctype_be__, c_int) ++ self.assertIs(c_int.__ctype_le__.__ctype_be__, c_int) + + s = c_int.__ctype_be__(0x12345678) + self.assertEqual(bin(struct.pack(">i", 0x12345678)), "12345678") +@@ -78,11 +78,11 @@ + + def test_endian_longlong(self): + if sys.byteorder == "little": +- self.assertTrue(c_longlong.__ctype_le__ is c_longlong) +- self.assertTrue(c_longlong.__ctype_be__.__ctype_le__ is c_longlong) ++ self.assertIs(c_longlong.__ctype_le__, c_longlong) ++ self.assertIs(c_longlong.__ctype_be__.__ctype_le__, c_longlong) + else: +- self.assertTrue(c_longlong.__ctype_be__ is c_longlong) +- self.assertTrue(c_longlong.__ctype_le__.__ctype_be__ is c_longlong) ++ self.assertIs(c_longlong.__ctype_be__, c_longlong) ++ self.assertIs(c_longlong.__ctype_le__.__ctype_be__, c_longlong) + + s = c_longlong.__ctype_be__(0x1234567890ABCDEF) + self.assertEqual(bin(struct.pack(">q", 0x1234567890ABCDEF)), "1234567890ABCDEF") +@@ -106,11 +106,11 @@ + + def test_endian_float(self): + if sys.byteorder == "little": +- self.assertTrue(c_float.__ctype_le__ is c_float) +- self.assertTrue(c_float.__ctype_be__.__ctype_le__ is c_float) ++ self.assertIs(c_float.__ctype_le__, c_float) ++ self.assertIs(c_float.__ctype_be__.__ctype_le__, c_float) + else: +- self.assertTrue(c_float.__ctype_be__ is c_float) +- self.assertTrue(c_float.__ctype_le__.__ctype_be__ is c_float) ++ self.assertIs(c_float.__ctype_be__, c_float) ++ self.assertIs(c_float.__ctype_le__.__ctype_be__, c_float) + s = c_float(math.pi) + self.assertEqual(bin(struct.pack("f", math.pi)), bin(s)) + # Hm, what's the precision of a float compared to a double? +@@ -124,11 +124,11 @@ + + def test_endian_double(self): + if sys.byteorder == "little": +- self.assertTrue(c_double.__ctype_le__ is c_double) +- self.assertTrue(c_double.__ctype_be__.__ctype_le__ is c_double) ++ self.assertIs(c_double.__ctype_le__, c_double) ++ self.assertIs(c_double.__ctype_be__.__ctype_le__, c_double) + else: +- self.assertTrue(c_double.__ctype_be__ is c_double) +- self.assertTrue(c_double.__ctype_le__.__ctype_be__ is c_double) ++ self.assertIs(c_double.__ctype_be__, c_double) ++ self.assertIs(c_double.__ctype_le__.__ctype_be__, c_double) + s = c_double(math.pi) + self.assertEqual(s.value, math.pi) + self.assertEqual(bin(struct.pack("d", math.pi)), bin(s)) +@@ -140,14 +140,14 @@ + self.assertEqual(bin(struct.pack(">d", math.pi)), bin(s)) + + def test_endian_other(self): +- self.assertTrue(c_byte.__ctype_le__ is c_byte) +- self.assertTrue(c_byte.__ctype_be__ is c_byte) ++ self.assertIs(c_byte.__ctype_le__, c_byte) ++ self.assertIs(c_byte.__ctype_be__, c_byte) + +- self.assertTrue(c_ubyte.__ctype_le__ is c_ubyte) +- self.assertTrue(c_ubyte.__ctype_be__ is c_ubyte) ++ self.assertIs(c_ubyte.__ctype_le__, c_ubyte) ++ self.assertIs(c_ubyte.__ctype_be__, c_ubyte) + +- self.assertTrue(c_char.__ctype_le__ is c_char) +- self.assertTrue(c_char.__ctype_be__ is c_char) ++ self.assertIs(c_char.__ctype_le__, c_char) ++ self.assertIs(c_char.__ctype_be__, c_char) + + def test_struct_fields_1(self): + if sys.byteorder == "little": +diff -r c3896275c0f6 Lib/ctypes/test/test_cast.py +--- a/Lib/ctypes/test/test_cast.py ++++ b/Lib/ctypes/test/test_cast.py +@@ -38,14 +38,14 @@ + + p = cast(array, POINTER(c_char_p)) + # array and p share a common _objects attribute +- self.assertTrue(p._objects is array._objects) ++ self.assertIs(p._objects, array._objects) + self.assertEqual(array._objects, {'0': b"foo bar", id(array): array}) + p[0] = b"spam spam" + self.assertEqual(p._objects, {'0': b"spam spam", id(array): array}) +- self.assertTrue(array._objects is p._objects) ++ self.assertIs(array._objects, p._objects) + p[1] = b"foo bar" + self.assertEqual(p._objects, {'1': b'foo bar', '0': b"spam spam", id(array): array}) +- self.assertTrue(array._objects is p._objects) ++ self.assertIs(array._objects, p._objects) + + def test_other(self): + p = cast((c_int * 4)(1, 2, 3, 4), POINTER(c_int)) +diff -r c3896275c0f6 Lib/ctypes/test/test_frombuffer.py +--- a/Lib/ctypes/test/test_frombuffer.py ++++ b/Lib/ctypes/test/test_frombuffer.py +@@ -23,7 +23,7 @@ + a[0], a[-1] = 200, -200 + self.assertEqual(x[:], a.tolist()) + +- self.assertTrue(a in x._objects.values()) ++ self.assertIn(a, x._objects.values()) + + self.assertRaises(ValueError, + c_int.from_buffer, a, -1) +diff -r c3896275c0f6 Lib/ctypes/test/test_funcptr.py +--- a/Lib/ctypes/test/test_funcptr.py ++++ b/Lib/ctypes/test/test_funcptr.py +@@ -75,7 +75,7 @@ + ## "lpfnWndProc", WNDPROC_2(wndproc)) + # instead: + +- self.assertTrue(WNDPROC is WNDPROC_2) ++ self.assertIs(WNDPROC, WNDPROC_2) + # 'wndclass.lpfnWndProc' leaks 94 references. Why? + self.assertEqual(wndclass.lpfnWndProc(1, 2, 3, 4), 10) + +diff -r c3896275c0f6 Lib/ctypes/test/test_functions.py +--- a/Lib/ctypes/test/test_functions.py ++++ b/Lib/ctypes/test/test_functions.py +@@ -306,7 +306,7 @@ + f.argtypes = [c_longlong, MyCallback] + + def callback(value): +- self.assertTrue(isinstance(value, int)) ++ self.assertIsInstance(value, int) + return value & 0x7FFFFFFF + + cb = MyCallback(callback) +diff -r c3896275c0f6 Lib/ctypes/test/test_loading.py +--- a/Lib/ctypes/test/test_loading.py ++++ b/Lib/ctypes/test/test_loading.py +@@ -43,7 +43,7 @@ + + if os.name in ("nt", "ce"): + def test_load_library(self): +- self.assertFalse(libc_name is None) ++ self.assertIsNotNone(libc_name) + if is_resource_enabled("printing"): + print(find_library("kernel32")) + print(find_library("user32")) +diff -r c3896275c0f6 Lib/ctypes/test/test_numbers.py +--- a/Lib/ctypes/test/test_numbers.py ++++ b/Lib/ctypes/test/test_numbers.py +@@ -181,10 +181,10 @@ + a = array(t._type_, [3.14]) + v = t.from_address(a.buffer_info()[0]) + self.assertEqual(v.value, a[0]) +- self.assertTrue(type(v) is t) ++ self.assertIs(type(v), t) + a[0] = 2.3456e17 + self.assertEqual(v.value, a[0]) +- self.assertTrue(type(v) is t) ++ self.assertIs(type(v), t) + + def test_char_from_address(self): + from ctypes import c_char +@@ -194,7 +194,7 @@ + a[0] = ord('x') + v = c_char.from_address(a.buffer_info()[0]) + self.assertEqual(v.value, b'x') +- self.assertTrue(type(v) is c_char) ++ self.assertIs(type(v), c_char) + + a[0] = ord('?') + self.assertEqual(v.value, b'?') +diff -r c3896275c0f6 Lib/ctypes/test/test_parameters.py +--- a/Lib/ctypes/test/test_parameters.py ++++ b/Lib/ctypes/test/test_parameters.py +@@ -54,7 +54,7 @@ + # c_char_p.from_param on a Python String packs the string + # into a cparam object + s = b"123" +- self.assertTrue(c_char_p.from_param(s)._obj is s) ++ self.assertIs(c_char_p.from_param(s)._obj, s) + + # new in 0.9.1: convert (encode) unicode to ascii + self.assertEqual(c_char_p.from_param(b"123")._obj, b"123") +@@ -64,7 +64,7 @@ + # calling c_char_p.from_param with a c_char_p instance + # returns the argument itself: + a = c_char_p(b"123") +- self.assertTrue(c_char_p.from_param(a) is a) ++ self.assertIs(c_char_p.from_param(a), a) + + def test_cw_strings(self): + from ctypes import byref +diff -r c3896275c0f6 Lib/ctypes/test/test_pointers.py +--- a/Lib/ctypes/test/test_pointers.py ++++ b/Lib/ctypes/test/test_pointers.py +@@ -78,7 +78,7 @@ + + ## i = c_int(42) + ## callback(byref(i)) +-## self.assertTrue(i.value == 84) ++## self.assertEqual(i.value, 84) + + doit(callback) + ## print self.result +@@ -91,11 +91,11 @@ + i = ct(42) + p = pointer(i) + ## print type(p.contents), ct +- self.assertTrue(type(p.contents) is ct) ++ self.assertIs(type(p.contents), ct) + # p.contents is the same as p[0] + ## print p.contents +-## self.assertTrue(p.contents == 42) +-## self.assertTrue(p[0] == 42) ++## self.assertEqual(p.contents, 42) ++## self.assertEqual(p[0], 42) + + self.assertRaises(TypeError, delitem, p, 0) + +diff -r c3896275c0f6 Lib/ctypes/test/test_python_api.py +--- a/Lib/ctypes/test/test_python_api.py ++++ b/Lib/ctypes/test/test_python_api.py +@@ -64,7 +64,7 @@ + ref = grc(s) + # id(python-object) is the address + pyobj = PyObj_FromPtr(id(s)) +- self.assertTrue(s is pyobj) ++ self.assertIs(s, pyobj) + + self.assertEqual(grc(s), ref + 1) + del pyobj +diff -r c3896275c0f6 Lib/ctypes/test/test_refcounts.py +--- a/Lib/ctypes/test/test_refcounts.py ++++ b/Lib/ctypes/test/test_refcounts.py +@@ -26,7 +26,7 @@ + self.assertEqual(grc(callback), 2) + cb = MyCallback(callback) + +- self.assertTrue(grc(callback) > 2) ++ self.assertGreater(grc(callback), 2) + result = f(-10, cb) + self.assertEqual(result, -18) + cb = None +@@ -46,15 +46,15 @@ + + # the CFuncPtr instance holds at least one refcount on func: + f = OtherCallback(func) +- self.assertTrue(grc(func) > 2) ++ self.assertGreater(grc(func), 2) + + # and may release it again + del f +- self.assertTrue(grc(func) >= 2) ++ self.assertGreaterEqual(grc(func), 2) + + # but now it must be gone + gc.collect() +- self.assertTrue(grc(func) == 2) ++ self.assertEqual(grc(func), 2) + + class X(ctypes.Structure): + _fields_ = [("a", OtherCallback)] +@@ -62,11 +62,11 @@ + x.a = OtherCallback(func) + + # the CFuncPtr instance holds at least one refcount on func: +- self.assertTrue(grc(func) > 2) ++ self.assertGreater(grc(func), 2) + + # and may release it again + del x +- self.assertTrue(grc(func) >= 2) ++ self.assertGreaterEqual(grc(func), 2) + + # and now it must be gone again + gc.collect() +@@ -75,7 +75,7 @@ + f = OtherCallback(func) + + # the CFuncPtr instance holds at least one refcount on func: +- self.assertTrue(grc(func) > 2) ++ self.assertGreater(grc(func), 2) + + # create a cycle + f.cycle = f +diff -r c3896275c0f6 Lib/ctypes/test/test_strings.py +--- a/Lib/ctypes/test/test_strings.py ++++ b/Lib/ctypes/test/test_strings.py +@@ -115,24 +115,24 @@ + + # New in releases later than 0.4.0: + # c_string(number) returns an empty string of size number +- self.assertTrue(len(c_string(32).raw) == 32) ++ self.assertEqual(len(c_string(32).raw), 32) + self.assertRaises(ValueError, c_string, -1) + self.assertRaises(ValueError, c_string, 0) + + # These tests fail, because it is no longer initialized +-## self.assertTrue(c_string(2).value == "") +-## self.assertTrue(c_string(2).raw == "\000\000") +- self.assertTrue(c_string(2).raw[-1] == "\000") +- self.assertTrue(len(c_string(2).raw) == 2) ++## self.assertEqual(c_string(2).value, "") ++## self.assertEqual(c_string(2).raw, "\000\000") ++ self.assertEqual(c_string(2).raw[-1], "\000") ++ self.assertEqual(len(c_string(2).raw), 2) + + def XX_test_initialized_strings(self): + +- self.assertTrue(c_string("ab", 4).raw[:2] == "ab") +- self.assertTrue(c_string("ab", 4).raw[:2:] == "ab") +- self.assertTrue(c_string("ab", 4).raw[:2:-1] == "ba") +- self.assertTrue(c_string("ab", 4).raw[:2:2] == "a") +- self.assertTrue(c_string("ab", 4).raw[-1] == "\000") +- self.assertTrue(c_string("ab", 2).raw == "a\000") ++ self.assertEqual(c_string("ab", 4).raw[:2], "ab") ++ self.assertEqual(c_string("ab", 4).raw[:2:], "ab") ++ self.assertEqual(c_string("ab", 4).raw[:2:-1], "ba") ++ self.assertEqual(c_string("ab", 4).raw[:2:2], "a") ++ self.assertEqual(c_string("ab", 4).raw[-1], "\000") ++ self.assertEqual(c_string("ab", 2).raw, "a\000") + + def XX_test_toolong(self): + cs = c_string("abcdef") +@@ -163,22 +163,22 @@ + # XXX This behaviour is about to change: + # len returns the size of the internal buffer in bytes. + # This includes the terminating NUL character. +- self.assertTrue(sizeof(cs) == 14) ++ self.assertEqual(sizeof(cs), 14) + + # The value property is the string up to the first terminating NUL. +- self.assertTrue(cs.value == "abcdef") +- self.assertTrue(c_wstring("abc\000def").value == "abc") ++ self.assertEqual(cs.value, "abcdef") ++ self.assertEqual(c_wstring("abc\000def").value, "abc") + +- self.assertTrue(c_wstring("abc\000def").value == "abc") ++ self.assertEqual(c_wstring("abc\000def").value, "abc") + + # The raw property is the total buffer contents: +- self.assertTrue(cs.raw == "abcdef\000") +- self.assertTrue(c_wstring("abc\000def").raw == "abc\000def\000") ++ self.assertEqual(cs.raw, "abcdef\000") ++ self.assertEqual(c_wstring("abc\000def").raw, "abc\000def\000") + + # We can change the value: + cs.value = "ab" +- self.assertTrue(cs.value == "ab") +- self.assertTrue(cs.raw == "ab\000\000\000\000\000") ++ self.assertEqual(cs.value, "ab") ++ self.assertEqual(cs.raw, "ab\000\000\000\000\000") + + self.assertRaises(TypeError, c_wstring, "123") + self.assertRaises(ValueError, c_wstring, 0) +diff -r c3896275c0f6 Lib/ctypes/test/test_structures.py +--- a/Lib/ctypes/test/test_structures.py ++++ b/Lib/ctypes/test/test_structures.py +@@ -374,9 +374,9 @@ + ## class X(Structure): + ## _fields_ = [] + +- self.assertTrue("in_dll" in dir(type(Structure))) +- self.assertTrue("from_address" in dir(type(Structure))) +- self.assertTrue("in_dll" in dir(type(Structure))) ++ self.assertIn("in_dll", dir(type(Structure))) ++ self.assertIn("from_address", dir(type(Structure))) ++ self.assertIn("in_dll", dir(type(Structure))) + + def test_positional_args(self): + # see also http://bugs.python.org/issue5042 +@@ -446,8 +446,8 @@ + try: + Recursive._fields_ = [("next", Recursive)] + except AttributeError as details: +- self.assertTrue("Structure or union cannot contain itself" in +- str(details)) ++ self.assertIn("Structure or union cannot contain itself", ++ str(details)) + else: + self.fail("Structure or union cannot contain itself") + +@@ -463,8 +463,7 @@ + try: + Second._fields_ = [("first", First)] + except AttributeError as details: +- self.assertTrue("_fields_ is final" in +- str(details)) ++ self.assertIn("_fields_ is final", str(details)) + else: + self.fail("AttributeError not raised") + +diff -r c3896275c0f6 Lib/decimal.py +--- a/Lib/decimal.py ++++ b/Lib/decimal.py +@@ -140,6 +140,7 @@ + + __version__ = '1.70' # Highest version of the spec this complies with + # See http://speleotrove.com/decimal/ ++__libmpdec_version__ = "2.4.0" # compatible libmpdec version + + import copy as _copy + import math as _math +diff -r c3896275c0f6 Lib/distutils/command/build_py.py +--- a/Lib/distutils/command/build_py.py ++++ b/Lib/distutils/command/build_py.py +@@ -127,7 +127,8 @@ + # Each pattern has to be converted to a platform-specific path + filelist = glob(os.path.join(src_dir, convert_path(pattern))) + # Files that match more than one pattern are only added once +- files.extend([fn for fn in filelist if fn not in files]) ++ files.extend([fn for fn in filelist if fn not in files ++ and os.path.isfile(fn)]) + return files + + def build_package_data(self): +diff -r c3896275c0f6 Lib/distutils/command/upload.py +--- a/Lib/distutils/command/upload.py ++++ b/Lib/distutils/command/upload.py +@@ -10,10 +10,9 @@ + import os, io + import socket + import platform +-import configparser +-import http.client as httpclient + from base64 import standard_b64encode +-import urllib.parse ++from urllib.request import urlopen, Request, HTTPError ++from urllib.parse import urlparse + + # this keeps compatibility for 2.3 and 2.4 + if sys.version < "2.5": +@@ -66,6 +65,15 @@ + self.upload_file(command, pyversion, filename) + + def upload_file(self, command, pyversion, filename): ++ # Makes sure the repository URL is compliant ++ schema, netloc, url, params, query, fragments = \ ++ urlparse(self.repository) ++ if params or query or fragments: ++ raise AssertionError("Incompatible url %s" % self.repository) ++ ++ if schema not in ('http', 'https'): ++ raise AssertionError("unsupported schema " + schema) ++ + # Sign if requested + if self.sign: + gpg_args = ["gpg", "--detach-sign", "-a", filename] +@@ -162,41 +170,31 @@ + self.announce("Submitting %s to %s" % (filename, self.repository), log.INFO) + + # build the Request +- # We can't use urllib since we need to send the Basic +- # auth right with the first request +- # TODO(jhylton): Can we fix urllib? +- schema, netloc, url, params, query, fragments = \ +- urllib.parse.urlparse(self.repository) +- assert not params and not query and not fragments +- if schema == 'http': +- http = httpclient.HTTPConnection(netloc) +- elif schema == 'https': +- http = httpclient.HTTPSConnection(netloc) +- else: +- raise AssertionError("unsupported schema "+schema) ++ headers = {'Content-type': ++ 'multipart/form-data; boundary=%s' % boundary, ++ 'Content-length': str(len(body)), ++ 'Authorization': auth} + +- data = '' +- loglevel = log.INFO ++ request = Request(self.repository, data=body, ++ headers=headers) ++ # send the data + try: +- http.connect() +- http.putrequest("POST", url) +- http.putheader('Content-type', +- 'multipart/form-data; boundary=%s'%boundary) +- http.putheader('Content-length', str(len(body))) +- http.putheader('Authorization', auth) +- http.endheaders() +- http.send(body) ++ result = urlopen(request) ++ status = result.getcode() ++ reason = result.msg + except socket.error as e: + self.announce(str(e), log.ERROR) + return ++ except HTTPError as e: ++ status = e.code ++ reason = e.msg + +- r = http.getresponse() +- if r.status == 200: +- self.announce('Server response (%s): %s' % (r.status, r.reason), ++ if status == 200: ++ self.announce('Server response (%s): %s' % (status, reason), + log.INFO) + else: +- self.announce('Upload failed (%s): %s' % (r.status, r.reason), ++ self.announce('Upload failed (%s): %s' % (status, reason), + log.ERROR) + if self.show_response: +- msg = '\n'.join(('-' * 75, r.read(), '-' * 75)) ++ msg = '\n'.join(('-' * 75, result.read(), '-' * 75)) + self.announce(msg, log.INFO) +diff -r c3896275c0f6 Lib/distutils/dist.py +--- a/Lib/distutils/dist.py ++++ b/Lib/distutils/dist.py +@@ -5,6 +5,7 @@ + """ + + import sys, os, re ++from email import message_from_file + + try: + import warnings +@@ -999,25 +1000,80 @@ + "provides", "requires", "obsoletes", + ) + +- def __init__ (self): +- self.name = None +- self.version = None +- self.author = None +- self.author_email = None ++ def __init__(self, path=None): ++ if path is not None: ++ self.read_pkg_file(open(path)) ++ else: ++ self.name = None ++ self.version = None ++ self.author = None ++ self.author_email = None ++ self.maintainer = None ++ self.maintainer_email = None ++ self.url = None ++ self.license = None ++ self.description = None ++ self.long_description = None ++ self.keywords = None ++ self.platforms = None ++ self.classifiers = None ++ self.download_url = None ++ # PEP 314 ++ self.provides = None ++ self.requires = None ++ self.obsoletes = None ++ ++ def read_pkg_file(self, file): ++ """Reads the metadata values from a file object.""" ++ msg = message_from_file(file) ++ ++ def _read_field(name): ++ value = msg[name] ++ if value == 'UNKNOWN': ++ return None ++ return value ++ ++ def _read_list(name): ++ values = msg.get_all(name, None) ++ if values == []: ++ return None ++ return values ++ ++ metadata_version = msg['metadata-version'] ++ self.name = _read_field('name') ++ self.version = _read_field('version') ++ self.description = _read_field('summary') ++ # we are filling author only. ++ self.author = _read_field('author') + self.maintainer = None ++ self.author_email = _read_field('author-email') + self.maintainer_email = None +- self.url = None +- self.license = None +- self.description = None +- self.long_description = None +- self.keywords = None +- self.platforms = None +- self.classifiers = None +- self.download_url = None +- # PEP 314 +- self.provides = None +- self.requires = None +- self.obsoletes = None ++ self.url = _read_field('home-page') ++ self.license = _read_field('license') ++ ++ if 'download-url' in msg: ++ self.download_url = _read_field('download-url') ++ else: ++ self.download_url = None ++ ++ self.long_description = _read_field('description') ++ self.description = _read_field('summary') ++ ++ if 'keywords' in msg: ++ self.keywords = _read_field('keywords').split(',') ++ ++ self.platforms = _read_list('platform') ++ self.classifiers = _read_list('classifier') ++ ++ # PEP 314 - these fields only exist in 1.1 ++ if metadata_version == '1.1': ++ self.requires = _read_list('requires') ++ self.provides = _read_list('provides') ++ self.obsoletes = _read_list('obsoletes') ++ else: ++ self.requires = None ++ self.provides = None ++ self.obsoletes = None + + def write_pkg_info(self, base_dir): + """Write the PKG-INFO file into the release tree. +diff -r c3896275c0f6 Lib/distutils/tests/test_archive_util.py +--- a/Lib/distutils/tests/test_archive_util.py ++++ b/Lib/distutils/tests/test_archive_util.py +@@ -210,7 +210,7 @@ + dry_run=True) + finally: + os.chdir(old_dir) +- self.assertTrue(not os.path.exists(tarball)) ++ self.assertFalse(os.path.exists(tarball)) + self.assertEqual(len(w.warnings), 1) + + @unittest.skipUnless(ZIP_SUPPORT and ZLIB_SUPPORT, +diff -r c3896275c0f6 Lib/distutils/tests/test_bdist_rpm.py +--- a/Lib/distutils/tests/test_bdist_rpm.py ++++ b/Lib/distutils/tests/test_bdist_rpm.py +@@ -81,7 +81,7 @@ + cmd.run() + + dist_created = os.listdir(os.path.join(pkg_dir, 'dist')) +- self.assertTrue('foo-0.1-1.noarch.rpm' in dist_created) ++ self.assertIn('foo-0.1-1.noarch.rpm', dist_created) + + # bug #2945: upload ignores bdist_rpm files + self.assertIn(('bdist_rpm', 'any', 'dist/foo-0.1-1.src.rpm'), dist.dist_files) +@@ -125,7 +125,7 @@ + cmd.run() + + dist_created = os.listdir(os.path.join(pkg_dir, 'dist')) +- self.assertTrue('foo-0.1-1.noarch.rpm' in dist_created) ++ self.assertIn('foo-0.1-1.noarch.rpm', dist_created) + + # bug #2945: upload ignores bdist_rpm files + self.assertIn(('bdist_rpm', 'any', 'dist/foo-0.1-1.src.rpm'), dist.dist_files) +diff -r c3896275c0f6 Lib/distutils/tests/test_bdist_wininst.py +--- a/Lib/distutils/tests/test_bdist_wininst.py ++++ b/Lib/distutils/tests/test_bdist_wininst.py +@@ -22,7 +22,7 @@ + # and make sure it finds it and returns its content + # no matter what platform we have + exe_file = cmd.get_exe_bytes() +- self.assertTrue(len(exe_file) > 10) ++ self.assertGreater(len(exe_file), 10) + + def test_suite(): + return unittest.makeSuite(BuildWinInstTestCase) +diff -r c3896275c0f6 Lib/distutils/tests/test_build_clib.py +--- a/Lib/distutils/tests/test_build_clib.py ++++ b/Lib/distutils/tests/test_build_clib.py +@@ -137,7 +137,7 @@ + cmd.run() + + # let's check the result +- self.assertTrue('libfoo.a' in os.listdir(build_temp)) ++ self.assertIn('libfoo.a', os.listdir(build_temp)) + + def test_suite(): + return unittest.makeSuite(BuildCLibTestCase) +diff -r c3896275c0f6 Lib/distutils/tests/test_build_ext.py +--- a/Lib/distutils/tests/test_build_ext.py ++++ b/Lib/distutils/tests/test_build_ext.py +@@ -76,8 +76,8 @@ + if support.HAVE_DOCSTRINGS: + doc = 'This is a template module just for instruction.' + self.assertEqual(xx.__doc__, doc) +- self.assertTrue(isinstance(xx.Null(), xx.Null)) +- self.assertTrue(isinstance(xx.Str(), xx.Str)) ++ self.assertIsInstance(xx.Null(), xx.Null) ++ self.assertIsInstance(xx.Str(), xx.Str) + + def tearDown(self): + # Get everything back to normal +@@ -110,7 +110,7 @@ + _config_vars['Py_ENABLE_SHARED'] = old_var + + # make sure we get some library dirs under solaris +- self.assertTrue(len(cmd.library_dirs) > 0) ++ self.assertGreater(len(cmd.library_dirs), 0) + + def test_user_site(self): + # site.USER_SITE was introduced in 2.6 +@@ -124,7 +124,7 @@ + # making sure the user option is there + options = [name for name, short, lable in + cmd.user_options] +- self.assertTrue('user' in options) ++ self.assertIn('user', options) + + # setting a value + cmd.user = 1 +@@ -171,10 +171,10 @@ + + from distutils import sysconfig + py_include = sysconfig.get_python_inc() +- self.assertTrue(py_include in cmd.include_dirs) ++ self.assertIn(py_include, cmd.include_dirs) + + plat_py_include = sysconfig.get_python_inc(plat_specific=1) +- self.assertTrue(plat_py_include in cmd.include_dirs) ++ self.assertIn(plat_py_include, cmd.include_dirs) + + # make sure cmd.libraries is turned into a list + # if it's a string +@@ -255,13 +255,13 @@ + 'some': 'bar'})] + cmd.check_extensions_list(exts) + ext = exts[0] +- self.assertTrue(isinstance(ext, Extension)) ++ self.assertIsInstance(ext, Extension) + + # check_extensions_list adds in ext the values passed + # when they are in ('include_dirs', 'library_dirs', 'libraries' + # 'extra_objects', 'extra_compile_args', 'extra_link_args') + self.assertEqual(ext.libraries, 'foo') +- self.assertTrue(not hasattr(ext, 'some')) ++ self.assertFalse(hasattr(ext, 'some')) + + # 'macros' element of build info dict must be 1- or 2-tuple + exts = [('foo.bar', {'sources': [''], 'libraries': 'foo', +diff -r c3896275c0f6 Lib/distutils/tests/test_build_py.py +--- a/Lib/distutils/tests/test_build_py.py ++++ b/Lib/distutils/tests/test_build_py.py +@@ -121,6 +121,37 @@ + found = os.listdir(os.path.join(cmd.build_lib, '__pycache__')) + self.assertEqual(sorted(found), ['boiledeggs.%s.pyo' % imp.get_tag()]) + ++ def test_dir_in_package_data(self): ++ """ ++ A directory in package_data should not be added to the filelist. ++ """ ++ # See bug 19286 ++ sources = self.mkdtemp() ++ pkg_dir = os.path.join(sources, "pkg") ++ ++ os.mkdir(pkg_dir) ++ open(os.path.join(pkg_dir, "__init__.py"), "w").close() ++ ++ docdir = os.path.join(pkg_dir, "doc") ++ os.mkdir(docdir) ++ open(os.path.join(docdir, "testfile"), "w").close() ++ ++ # create the directory that could be incorrectly detected as a file ++ os.mkdir(os.path.join(docdir, 'otherdir')) ++ ++ os.chdir(sources) ++ dist = Distribution({"packages": ["pkg"], ++ "package_data": {"pkg": ["doc/*"]}}) ++ # script_name need not exist, it just need to be initialized ++ dist.script_name = os.path.join(sources, "setup.py") ++ dist.script_args = ["build"] ++ dist.parse_command_line() ++ ++ try: ++ dist.run_commands() ++ except DistutilsFileError: ++ self.fail("failed package_data when data dir includes a dir") ++ + def test_dont_write_bytecode(self): + # makes sure byte_compile is not used + dist = self.create_dist()[1] +diff -r c3896275c0f6 Lib/distutils/tests/test_build_scripts.py +--- a/Lib/distutils/tests/test_build_scripts.py ++++ b/Lib/distutils/tests/test_build_scripts.py +@@ -17,8 +17,8 @@ + + def test_default_settings(self): + cmd = self.get_build_scripts_cmd("/foo/bar", []) +- self.assertTrue(not cmd.force) +- self.assertTrue(cmd.build_dir is None) ++ self.assertFalse(cmd.force) ++ self.assertIsNone(cmd.build_dir) + + cmd.finalize_options() + +@@ -38,7 +38,7 @@ + + built = os.listdir(target) + for name in expected: +- self.assertTrue(name in built) ++ self.assertIn(name, built) + + def get_build_scripts_cmd(self, target, scripts): + import sys +@@ -103,7 +103,7 @@ + + built = os.listdir(target) + for name in expected: +- self.assertTrue(name in built) ++ self.assertIn(name, built) + + def test_suite(): + return unittest.makeSuite(BuildScriptsTestCase) +diff -r c3896275c0f6 Lib/distutils/tests/test_clean.py +--- a/Lib/distutils/tests/test_clean.py ++++ b/Lib/distutils/tests/test_clean.py +@@ -36,7 +36,7 @@ + + # make sure the files where removed + for name, path in dirs: +- self.assertTrue(not os.path.exists(path), ++ self.assertFalse(os.path.exists(path), + '%s was not removed' % path) + + # let's run the command again (should spit warnings but succeed) +diff -r c3896275c0f6 Lib/distutils/tests/test_config.py +--- a/Lib/distutils/tests/test_config.py ++++ b/Lib/distutils/tests/test_config.py +@@ -103,7 +103,7 @@ + def test_server_empty_registration(self): + cmd = self._cmd(self.dist) + rc = cmd._get_rc_file() +- self.assertTrue(not os.path.exists(rc)) ++ self.assertFalse(os.path.exists(rc)) + cmd._store_pypirc('tarek', 'xxx') + self.assertTrue(os.path.exists(rc)) + f = open(rc) +diff -r c3896275c0f6 Lib/distutils/tests/test_config_cmd.py +--- a/Lib/distutils/tests/test_config_cmd.py ++++ b/Lib/distutils/tests/test_config_cmd.py +@@ -81,7 +81,7 @@ + cmd._clean(f1, f2) + + for f in (f1, f2): +- self.assertTrue(not os.path.exists(f)) ++ self.assertFalse(os.path.exists(f)) + + def test_suite(): + return unittest.makeSuite(ConfigTestCase) +diff -r c3896275c0f6 Lib/distutils/tests/test_dist.py +--- a/Lib/distutils/tests/test_dist.py ++++ b/Lib/distutils/tests/test_dist.py +@@ -8,7 +8,7 @@ + + from unittest import mock + +-from distutils.dist import Distribution, fix_help_options ++from distutils.dist import Distribution, fix_help_options, DistributionMetadata + from distutils.cmd import Command + + from test.support import TESTFN, captured_stdout, run_unittest +@@ -388,6 +388,33 @@ + self.assertTrue(output) + + ++ def test_read_metadata(self): ++ attrs = {"name": "package", ++ "version": "1.0", ++ "long_description": "desc", ++ "description": "xxx", ++ "download_url": "http://example.com", ++ "keywords": ['one', 'two'], ++ "requires": ['foo']} ++ ++ dist = Distribution(attrs) ++ metadata = dist.metadata ++ ++ # write it then reloads it ++ PKG_INFO = io.StringIO() ++ metadata.write_pkg_file(PKG_INFO) ++ PKG_INFO.seek(0) ++ metadata.read_pkg_file(PKG_INFO) ++ ++ self.assertEquals(metadata.name, "package") ++ self.assertEquals(metadata.version, "1.0") ++ self.assertEquals(metadata.description, "xxx") ++ self.assertEquals(metadata.download_url, 'http://example.com') ++ self.assertEquals(metadata.keywords, ['one', 'two']) ++ self.assertEquals(metadata.platforms, ['UNKNOWN']) ++ self.assertEquals(metadata.obsoletes, None) ++ self.assertEquals(metadata.requires, ['foo']) ++ + def test_suite(): + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(DistributionTestCase)) +diff -r c3896275c0f6 Lib/distutils/tests/test_install.py +--- a/Lib/distutils/tests/test_install.py ++++ b/Lib/distutils/tests/test_install.py +@@ -236,7 +236,7 @@ + self.test_record() + finally: + install_module.DEBUG = False +- self.assertTrue(len(self.logs) > old_logs_len) ++ self.assertGreater(len(self.logs), old_logs_len) + + + def test_suite(): +diff -r c3896275c0f6 Lib/distutils/tests/test_install_lib.py +--- a/Lib/distutils/tests/test_install_lib.py ++++ b/Lib/distutils/tests/test_install_lib.py +@@ -103,7 +103,7 @@ + finally: + sys.dont_write_bytecode = old_dont_write_bytecode + +- self.assertTrue('byte-compiling is disabled' in self.logs[0][1]) ++ self.assertIn('byte-compiling is disabled', self.logs[0][1]) + + + def test_suite(): +diff -r c3896275c0f6 Lib/distutils/tests/test_install_scripts.py +--- a/Lib/distutils/tests/test_install_scripts.py ++++ b/Lib/distutils/tests/test_install_scripts.py +@@ -24,10 +24,10 @@ + skip_build=1, + ) + cmd = install_scripts(dist) +- self.assertTrue(not cmd.force) +- self.assertTrue(not cmd.skip_build) +- self.assertTrue(cmd.build_dir is None) +- self.assertTrue(cmd.install_dir is None) ++ self.assertFalse(cmd.force) ++ self.assertFalse(cmd.skip_build) ++ self.assertIsNone(cmd.build_dir) ++ self.assertIsNone(cmd.install_dir) + + cmd.finalize_options() + +@@ -72,7 +72,7 @@ + + installed = os.listdir(target) + for name in expected: +- self.assertTrue(name in installed) ++ self.assertIn(name, installed) + + + def test_suite(): +diff -r c3896275c0f6 Lib/distutils/tests/test_msvc9compiler.py +--- a/Lib/distutils/tests/test_msvc9compiler.py ++++ b/Lib/distutils/tests/test_msvc9compiler.py +@@ -128,7 +128,7 @@ + # windows registeries versions. + path = r'Control Panel\Desktop' + v = Reg.get_value(path, 'dragfullwindows') +- self.assertTrue(v in ('0', '1', '2')) ++ self.assertIn(v, ('0', '1', '2')) + + import winreg + HKCU = winreg.HKEY_CURRENT_USER +@@ -136,7 +136,7 @@ + self.assertEqual(keys, None) + + keys = Reg.read_keys(HKCU, r'Control Panel') +- self.assertTrue('Desktop' in keys) ++ self.assertIn('Desktop', keys) + + def test_remove_visual_c_ref(self): + from distutils.msvc9compiler import MSVCCompiler +@@ -174,7 +174,7 @@ + + compiler = MSVCCompiler() + got = compiler._remove_visual_c_ref(manifest) +- self.assertIs(got, None) ++ self.assertIsNone(got) + + + def test_suite(): +diff -r c3896275c0f6 Lib/distutils/tests/test_register.py +--- a/Lib/distutils/tests/test_register.py ++++ b/Lib/distutils/tests/test_register.py +@@ -98,7 +98,7 @@ + cmd = self._get_cmd() + + # we shouldn't have a .pypirc file yet +- self.assertTrue(not os.path.exists(self.rc)) ++ self.assertFalse(os.path.exists(self.rc)) + + # patching input and getpass.getpass + # so register gets happy +@@ -145,7 +145,7 @@ + + self.assertEqual(req1['Content-length'], '1374') + self.assertEqual(req2['Content-length'], '1374') +- self.assertTrue((b'xxx') in self.conn.reqs[1].data) ++ self.assertIn(b'xxx', self.conn.reqs[1].data) + + def test_password_not_in_file(self): + +@@ -175,7 +175,7 @@ + req = self.conn.reqs[0] + headers = dict(req.headers) + self.assertEqual(headers['Content-length'], '608') +- self.assertTrue((b'tarek') in req.data) ++ self.assertIn(b'tarek', req.data) + + def test_password_reset(self): + # this test runs choice 3 +@@ -193,7 +193,7 @@ + req = self.conn.reqs[0] + headers = dict(req.headers) + self.assertEqual(headers['Content-length'], '290') +- self.assertTrue((b'tarek') in req.data) ++ self.assertIn(b'tarek', req.data) + + @unittest.skipUnless(docutils is not None, 'needs docutils') + def test_strict(self): +diff -r c3896275c0f6 Lib/distutils/tests/test_sysconfig.py +--- a/Lib/distutils/tests/test_sysconfig.py ++++ b/Lib/distutils/tests/test_sysconfig.py +@@ -50,7 +50,7 @@ + + def test_get_config_vars(self): + cvars = sysconfig.get_config_vars() +- self.assertTrue(isinstance(cvars, dict)) ++ self.assertIsInstance(cvars, dict) + self.assertTrue(cvars) + + def test_srcdir(self): +diff -r c3896275c0f6 Lib/distutils/tests/test_upload.py +--- a/Lib/distutils/tests/test_upload.py ++++ b/Lib/distutils/tests/test_upload.py +@@ -1,9 +1,9 @@ + """Tests for distutils.command.upload.""" + import os + import unittest +-import http.client as httpclient + from test.support import run_unittest + ++from distutils.command import upload as upload_mod + from distutils.command.upload import upload + from distutils.core import Distribution + +@@ -37,48 +37,37 @@ + [server1] + username:me + """ +-class Response(object): +- def __init__(self, status=200, reason='OK'): +- self.status = status +- self.reason = reason + +-class FakeConnection(object): ++class FakeOpen(object): + +- def __init__(self): +- self.requests = [] +- self.headers = [] +- self.body = '' ++ def __init__(self, url): ++ self.url = url ++ if not isinstance(url, str): ++ self.req = url ++ else: ++ self.req = None ++ self.msg = 'OK' + +- def __call__(self, netloc): +- return self ++ def getcode(self): ++ return 200 + +- def connect(self): +- pass +- endheaders = connect +- +- def putrequest(self, method, url): +- self.requests.append((method, url)) +- +- def putheader(self, name, value): +- self.headers.append((name, value)) +- +- def send(self, body): +- self.body = body +- +- def getresponse(self): +- return Response() + + class uploadTestCase(PyPIRCCommandTestCase): + + def setUp(self): + super(uploadTestCase, self).setUp() +- self.old_class = httpclient.HTTPConnection +- self.conn = httpclient.HTTPConnection = FakeConnection() ++ self.old_open = upload_mod.urlopen ++ upload_mod.urlopen = self._urlopen ++ self.last_open = None + + def tearDown(self): +- httpclient.HTTPConnection = self.old_class ++ upload_mod.urlopen = self.old_open + super(uploadTestCase, self).tearDown() + ++ def _urlopen(self, url): ++ self.last_open = FakeOpen(url) ++ return self.last_open ++ + def test_finalize_options(self): + + # new format +@@ -122,14 +111,14 @@ + cmd.ensure_finalized() + cmd.run() + +- # what did we send ? +- headers = dict(self.conn.headers) ++ # what did we send ? ++ headers = dict(self.last_open.req.headers) + self.assertEqual(headers['Content-length'], '2087') +- self.assertTrue(headers['Content-type'].startswith('multipart/form-data')) +- self.assertFalse('\n' in headers['Authorization']) +- +- self.assertEqual(self.conn.requests, [('POST', '/pypi')]) +- self.assertTrue((b'xxx') in self.conn.body) ++ self.assert_(headers['Content-type'].startswith('multipart/form-data')) ++ self.assertEquals(self.last_open.req.get_method(), 'POST') ++ self.assertEquals(self.last_open.req.get_full_url(), ++ 'http://pypi.python.org/pypi') ++ self.assert_(b'xxx' in self.last_open.req.data) + + def test_suite(): + return unittest.makeSuite(uploadTestCase) +diff -r c3896275c0f6 Lib/distutils/tests/test_util.py +--- a/Lib/distutils/tests/test_util.py ++++ b/Lib/distutils/tests/test_util.py +@@ -266,7 +266,7 @@ + self.assertTrue(strtobool(y)) + + for n in no: +- self.assertTrue(not strtobool(n)) ++ self.assertFalse(strtobool(n)) + + def test_rfc822_escape(self): + header = 'I am a\npoor\nlonesome\nheader\n' +diff -r c3896275c0f6 Lib/doctest.py +--- a/Lib/doctest.py ++++ b/Lib/doctest.py +@@ -314,6 +314,32 @@ + else: + return '#' + ++def _strip_exception_details(msg): ++ # Support for IGNORE_EXCEPTION_DETAIL. ++ # Get rid of everything except the exception name; in particular, drop ++ # the possibly dotted module path (if any) and the exception message (if ++ # any). We assume that a colon is never part of a dotted name, or of an ++ # exception name. ++ # E.g., given ++ # "foo.bar.MyError: la di da" ++ # return "MyError" ++ # Or for "abc.def" or "abc.def:\n" return "def". ++ ++ start, end = 0, len(msg) ++ # The exception name must appear on the first line. ++ i = msg.find("\n") ++ if i >= 0: ++ end = i ++ # retain up to the first colon (if any) ++ i = msg.find(':', 0, end) ++ if i >= 0: ++ end = i ++ # retain just the exception name ++ i = msg.rfind('.', 0, end) ++ if i >= 0: ++ start = i+1 ++ return msg[start: end] ++ + class _OutputRedirectingPdb(pdb.Pdb): + """ + A specialized version of the python debugger that redirects stdout +@@ -1320,10 +1346,9 @@ + + # Another chance if they didn't care about the detail. + elif self.optionflags & IGNORE_EXCEPTION_DETAIL: +- m1 = re.match(r'(?:[^:]*\.)?([^:]*:)', example.exc_msg) +- m2 = re.match(r'(?:[^:]*\.)?([^:]*:)', exc_msg) +- if m1 and m2 and check(m1.group(1), m2.group(1), +- self.optionflags): ++ if check(_strip_exception_details(example.exc_msg), ++ _strip_exception_details(exc_msg), ++ self.optionflags): + outcome = SUCCESS + + # Report the outcome. +diff -r c3896275c0f6 Lib/email/message.py +--- a/Lib/email/message.py ++++ b/Lib/email/message.py +@@ -636,7 +636,7 @@ + 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') ++ rawparam = msg.get_param('foo') + param = email.utils.collapse_rfc2231_value(rawparam) + + """ +diff -r c3896275c0f6 Lib/html/parser.py +--- a/Lib/html/parser.py ++++ b/Lib/html/parser.py +@@ -23,16 +23,16 @@ + starttagopen = re.compile('<[a-zA-Z]') + piclose = re.compile('>') + commentclose = re.compile(r'--\s*>') ++# Note: ++# 1) the strict attrfind isn't really strict, but we can't make it ++# correctly strict without breaking backward compatibility; ++# 2) if you change tagfind/attrfind remember to update locatestarttagend too; ++# 3) if you change tagfind/attrfind and/or locatestarttagend the parser will ++# explode, so don't do it. + 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]*') +-# Note: +-# 1) the strict attrfind isn't really strict, but we can't make it +-# correctly strict without breaking backward compatibility; +-# 2) if you change attrfind remember to update locatestarttagend too; +-# 3) if you change attrfind and/or locatestarttagend the parser will +-# explode, so don't do it. ++tagfind_tolerant = re.compile('([a-zA-Z][^\t\n\r\f />\x00]*)(?:\s|/(?!>))*') + attrfind = re.compile( + r'\s*([a-zA-Z_][-.:a-zA-Z_0-9]*)(\s*=\s*' + r'(\'[^\']*\'|"[^"]*"|[^\s"\'=<>`]*))?') +@@ -54,7 +54,7 @@ + \s* # trailing whitespace + """, re.VERBOSE) + locatestarttagend_tolerant = re.compile(r""" +- <[a-zA-Z][-.a-zA-Z0-9:_]* # tag name ++ <[a-zA-Z][^\t\n\r\f />\x00]* # tag name + (?:[\s/]* # optional whitespace before attribute name + (?:(?<=['"\s/])[^\s/>][^\s/=>]* # attribute name + (?:\s*=+\s* # value indicator +@@ -328,7 +328,10 @@ + + # Now parse the data between i+1 and j into a tag and attrs + attrs = [] +- match = tagfind.match(rawdata, i+1) ++ if self.strict: ++ match = tagfind.match(rawdata, i+1) ++ else: ++ match = tagfind_tolerant.match(rawdata, i+1) + assert match, 'unexpected call to parse_starttag()' + k = match.end() + self.lasttag = tag = match.group(1).lower() +@@ -440,7 +443,7 @@ + return i+3 + else: + return self.parse_bogus_comment(i) +- tagname = namematch.group().lower() ++ tagname = namematch.group(1).lower() + # consume and ignore other stuff between the name and the > + # Note: this is not 100% correct, since we might have things like + # , but looking for > after tha name should cover +diff -r c3896275c0f6 Lib/json/__init__.py +--- a/Lib/json/__init__.py ++++ b/Lib/json/__init__.py +@@ -3,11 +3,8 @@ + interchange format. + + :mod:`json` exposes an API familiar to users of the standard library +-:mod:`marshal` and :mod:`pickle` modules. It is the externally maintained +-version of the :mod:`json` library contained in Python 2.6, but maintains +-compatibility with Python 2.4 and Python 2.5 and (currently) has +-significant performance advantages, even without using the optional C +-extension for speedups. ++:mod:`marshal` and :mod:`pickle` modules. It is derived from a ++version of the externally maintained simplejson library. + + Encoding basic Python object hierarchies:: + +diff -r c3896275c0f6 Lib/json/decoder.py +--- a/Lib/json/decoder.py ++++ b/Lib/json/decoder.py +@@ -66,6 +66,16 @@ + 'b': '\b', 'f': '\f', 'n': '\n', 'r': '\r', 't': '\t', + } + ++def _decode_uXXXX(s, pos): ++ esc = s[pos + 1:pos + 5] ++ if len(esc) == 4 and esc[1] not in 'xX': ++ try: ++ return int(esc, 16) ++ except ValueError: ++ pass ++ msg = "Invalid \\uXXXX escape" ++ raise ValueError(errmsg(msg, s, pos)) ++ + def py_scanstring(s, end, strict=True, + _b=BACKSLASH, _m=STRINGCHUNK.match): + """Scan the string s for a JSON string. End is the index of the +@@ -115,25 +125,14 @@ + raise ValueError(errmsg(msg, s, end)) + end += 1 + else: +- esc = s[end + 1:end + 5] +- next_end = end + 5 +- if len(esc) != 4: +- msg = "Invalid \\uXXXX escape" +- raise ValueError(errmsg(msg, s, end)) +- uni = int(esc, 16) +- if 0xd800 <= uni <= 0xdbff: +- msg = "Invalid \\uXXXX\\uXXXX surrogate pair" +- if not s[end + 5:end + 7] == '\\u': +- raise ValueError(errmsg(msg, s, end)) +- esc2 = s[end + 7:end + 11] +- if len(esc2) != 4: +- raise ValueError(errmsg(msg, s, end)) +- uni2 = int(esc2, 16) +- uni = 0x10000 + (((uni - 0xd800) << 10) | (uni2 - 0xdc00)) +- next_end += 6 ++ uni = _decode_uXXXX(s, end) ++ end += 5 ++ if 0xd800 <= uni <= 0xdbff and s[end:end + 2] == '\\u': ++ uni2 = _decode_uXXXX(s, end + 1) ++ if 0xdc00 <= uni2 <= 0xdfff: ++ uni = 0x10000 + (((uni - 0xd800) << 10) | (uni2 - 0xdc00)) ++ end += 6 + char = chr(uni) +- +- end = next_end + _append(char) + return ''.join(chunks), end + +diff -r c3896275c0f6 Lib/lib2to3/pgen2/tokenize.py +--- a/Lib/lib2to3/pgen2/tokenize.py ++++ b/Lib/lib2to3/pgen2/tokenize.py +@@ -252,7 +252,7 @@ + def detect_encoding(readline): + """ + The detect_encoding() function is used to detect the encoding that should +- be used to decode a Python source file. It requires one argment, readline, ++ be used to decode a Python source file. It requires one argument, readline, + in the same way as the tokenize() generator. + + It will call readline a maximum of twice, and return the encoding used +@@ -343,7 +343,7 @@ + + def generate_tokens(readline): + """ +- The generate_tokens() generator requires one argment, readline, which ++ The generate_tokens() generator requires one argument, readline, which + must be a callable object which provides the same interface as the + readline() method of built-in file objects. Each call to the function + should return one line of input as a string. Alternately, readline +diff -r c3896275c0f6 Lib/lib2to3/tests/test_fixers.py +--- a/Lib/lib2to3/tests/test_fixers.py ++++ b/Lib/lib2to3/tests/test_fixers.py +@@ -41,7 +41,7 @@ + + def warns(self, before, after, message, unchanged=False): + tree = self._check(before, after) +- self.assertTrue(message in "".join(self.fixer_log)) ++ self.assertIn(message, "".join(self.fixer_log)) + if not unchanged: + self.assertTrue(tree.was_changed) + +diff -r c3896275c0f6 Lib/lib2to3/tests/test_main.py +--- a/Lib/lib2to3/tests/test_main.py ++++ b/Lib/lib2to3/tests/test_main.py +@@ -49,9 +49,9 @@ + ret = self.run_2to3_capture(["-"], input_stream, out_enc, err) + self.assertEqual(ret, 0) + output = out.getvalue().decode("ascii") +- self.assertTrue("-print 'nothing'" in output) +- self.assertTrue("WARNING: couldn't encode 's diff for " +- "your terminal" in err.getvalue()) ++ self.assertIn("-print 'nothing'", output) ++ self.assertIn("WARNING: couldn't encode 's diff for " ++ "your terminal", err.getvalue()) + + def setup_test_source_trees(self): + """Setup a test source tree and output destination tree.""" +diff -r c3896275c0f6 Lib/lib2to3/tests/test_parser.py +--- a/Lib/lib2to3/tests/test_parser.py ++++ b/Lib/lib2to3/tests/test_parser.py +@@ -168,8 +168,8 @@ + for filepath in support.all_project_files(): + with open(filepath, "rb") as fp: + encoding = tokenize.detect_encoding(fp.readline)[0] +- self.assertTrue(encoding is not None, +- "can't detect encoding for %s" % filepath) ++ self.assertIsNotNone(encoding, ++ "can't detect encoding for %s" % filepath) + with open(filepath, "r", encoding=encoding) as fp: + source = fp.read() + try: +diff -r c3896275c0f6 Lib/lib2to3/tests/test_pytree.py +--- a/Lib/lib2to3/tests/test_pytree.py ++++ b/Lib/lib2to3/tests/test_pytree.py +@@ -143,12 +143,12 @@ + l3 = pytree.Leaf(100, "bar") + n1 = pytree.Node(1000, [l1, l2, l3]) + self.assertEqual(n1.children, [l1, l2, l3]) +- self.assertTrue(isinstance(n1.children, list)) ++ self.assertIsInstance(n1.children, list) + self.assertFalse(n1.was_changed) + l2new = pytree.Leaf(100, "-") + l2.replace(l2new) + self.assertEqual(n1.children, [l1, l2new, l3]) +- self.assertTrue(isinstance(n1.children, list)) ++ self.assertIsInstance(n1.children, list) + self.assertTrue(n1.was_changed) + + def test_replace_with_list(self): +@@ -159,7 +159,7 @@ + + l2.replace([pytree.Leaf(100, "*"), pytree.Leaf(100, "*")]) + self.assertEqual(str(n1), "foo**bar") +- self.assertTrue(isinstance(n1.children, list)) ++ self.assertIsInstance(n1.children, list) + + def test_leaves(self): + l1 = pytree.Leaf(100, "foo") +@@ -330,7 +330,7 @@ + n2 = pytree.Node(1000, []) + p1 = pytree.Node(1000, [n1, n2]) + +- self.assertTrue(n1.next_sibling is n2) ++ self.assertIs(n1.next_sibling, n2) + self.assertEqual(n2.next_sibling, None) + self.assertEqual(p1.next_sibling, None) + +@@ -339,7 +339,7 @@ + l2 = pytree.Leaf(100, "b") + p1 = pytree.Node(1000, [l1, l2]) + +- self.assertTrue(l1.next_sibling is l2) ++ self.assertIs(l1.next_sibling, l2) + self.assertEqual(l2.next_sibling, None) + self.assertEqual(p1.next_sibling, None) + +@@ -348,7 +348,7 @@ + n2 = pytree.Node(1000, []) + p1 = pytree.Node(1000, [n1, n2]) + +- self.assertTrue(n2.prev_sibling is n1) ++ self.assertIs(n2.prev_sibling, n1) + self.assertEqual(n1.prev_sibling, None) + self.assertEqual(p1.prev_sibling, None) + +@@ -357,7 +357,7 @@ + l2 = pytree.Leaf(100, "b") + p1 = pytree.Node(1000, [l1, l2]) + +- self.assertTrue(l2.prev_sibling is l1) ++ self.assertIs(l2.prev_sibling, l1) + self.assertEqual(l1.prev_sibling, None) + self.assertEqual(p1.prev_sibling, None) + +@@ -430,7 +430,7 @@ + r = {} + self.assertTrue(pw.match_seq([l1, l3], r)) + self.assertEqual(r, {"pl": l3, "pw": [l1, l3]}) +- self.assertTrue(r["pl"] is l3) ++ self.assertIs(r["pl"], l3) + r = {} + + def test_generate_matches(self): +diff -r c3896275c0f6 Lib/lib2to3/tests/test_refactor.py +--- a/Lib/lib2to3/tests/test_refactor.py ++++ b/Lib/lib2to3/tests/test_refactor.py +@@ -49,9 +49,9 @@ + + def test_print_function_option(self): + rt = self.rt({"print_function" : True}) +- self.assertTrue(rt.grammar is pygram.python_grammar_no_print_statement) +- self.assertTrue(rt.driver.grammar is +- pygram.python_grammar_no_print_statement) ++ self.assertIs(rt.grammar, pygram.python_grammar_no_print_statement) ++ self.assertIs(rt.driver.grammar, ++ pygram.python_grammar_no_print_statement) + + def test_write_unchanged_files_option(self): + rt = self.rt() +diff -r c3896275c0f6 Lib/logging/__init__.py +--- a/Lib/logging/__init__.py ++++ b/Lib/logging/__init__.py +@@ -976,8 +976,10 @@ + self.flush() + if hasattr(self.stream, "close"): + self.stream.close() +- StreamHandler.close(self) + self.stream = None ++ # Issue #19523: call unconditionally to ++ # prevent a handler leak when delay is set ++ StreamHandler.close(self) + finally: + self.release() + +diff -r c3896275c0f6 Lib/lzma.py +--- a/Lib/lzma.py ++++ b/Lib/lzma.py +@@ -224,11 +224,18 @@ + raise EOFError("Compressed file ended before the " + "end-of-stream marker was reached") + +- # Continue to next stream. + if self._decompressor.eof: ++ # Continue to next stream. + self._decompressor = LZMADecompressor(**self._init_args) +- +- self._buffer = self._decompressor.decompress(rawblock) ++ try: ++ self._buffer = self._decompressor.decompress(rawblock) ++ except LZMAError: ++ # Trailing data isn't a valid compressed stream; ignore it. ++ self._mode = _MODE_READ_EOF ++ self._size = self._pos ++ return False ++ else: ++ self._buffer = self._decompressor.decompress(rawblock) + + # Read data until EOF. + # If return_data is false, consume the data without returning it. +@@ -444,11 +451,18 @@ + results = [] + while True: + decomp = LZMADecompressor(format, memlimit, filters) +- results.append(decomp.decompress(data)) ++ try: ++ res = decomp.decompress(data) ++ except LZMAError: ++ if results: ++ break # Leftover data is not a valid LZMA/XZ stream; ignore it. ++ else: ++ raise # Error on the first iteration; bail out. ++ results.append(res) + if not decomp.eof: + raise LZMAError("Compressed data ended before the " + "end-of-stream marker was reached") +- if not decomp.unused_data: +- return b"".join(results) +- # There is unused data left over. Proceed to next stream. + data = decomp.unused_data ++ if not data: ++ break ++ return b"".join(results) +diff -r c3896275c0f6 Lib/multiprocessing/pool.py +--- a/Lib/multiprocessing/pool.py ++++ b/Lib/multiprocessing/pool.py +@@ -147,7 +147,8 @@ + + self._task_handler = threading.Thread( + target=Pool._handle_tasks, +- args=(self._taskqueue, self._quick_put, self._outqueue, self._pool) ++ args=(self._taskqueue, self._quick_put, self._outqueue, ++ self._pool, self._cache) + ) + self._task_handler.daemon = True + self._task_handler._state = RUN +@@ -338,7 +339,7 @@ + debug('worker handler exiting') + + @staticmethod +- def _handle_tasks(taskqueue, put, outqueue, pool): ++ def _handle_tasks(taskqueue, put, outqueue, pool, cache): + thread = threading.current_thread() + + for taskseq, set_length in iter(taskqueue.get, None): +@@ -349,9 +350,12 @@ + break + try: + put(task) +- except IOError: +- debug('could not put task on queue') +- break ++ except Exception as e: ++ job, ind = task[:2] ++ try: ++ cache[job]._set(ind, (False, e)) ++ except KeyError: ++ pass + else: + if set_length: + debug('doing set_length()') +diff -r c3896275c0f6 Lib/multiprocessing/process.py +--- a/Lib/multiprocessing/process.py ++++ b/Lib/multiprocessing/process.py +@@ -266,7 +266,7 @@ + exitcode = e.args[0] + else: + sys.stderr.write(str(e.args[0]) + '\n') +- exitcode = 0 if isinstance(e.args[0], str) else 1 ++ exitcode = 1 + except: + exitcode = 1 + import traceback +diff -r c3896275c0f6 Lib/pickle.py +--- a/Lib/pickle.py ++++ b/Lib/pickle.py +@@ -728,9 +728,18 @@ + + self.memoize(obj) + ++ def save_type(self, obj): ++ if obj is type(None): ++ return self.save_reduce(type, (None,), obj=obj) ++ elif obj is type(NotImplemented): ++ return self.save_reduce(type, (NotImplemented,), obj=obj) ++ elif obj is type(...): ++ return self.save_reduce(type, (...,), obj=obj) ++ return self.save_global(obj) ++ + dispatch[FunctionType] = save_global + dispatch[BuiltinFunctionType] = save_global +- dispatch[type] = save_global ++ dispatch[type] = save_type + + # Pickling helpers + +diff -r c3896275c0f6 Lib/sqlite3/test/factory.py +--- a/Lib/sqlite3/test/factory.py ++++ b/Lib/sqlite3/test/factory.py +@@ -47,9 +47,7 @@ + self.con.close() + + def CheckIsInstance(self): +- self.assertTrue(isinstance(self.con, +- MyConnection), +- "connection is not instance of MyConnection") ++ self.assertIsInstance(self.con, MyConnection) + + class CursorFactoryTests(unittest.TestCase): + def setUp(self): +@@ -60,9 +58,7 @@ + + def CheckIsInstance(self): + cur = self.con.cursor(factory=MyCursor) +- self.assertTrue(isinstance(cur, +- MyCursor), +- "cursor is not instance of MyCursor") ++ self.assertIsInstance(cur, MyCursor) + + class RowFactoryTestsBackwardsCompat(unittest.TestCase): + def setUp(self): +@@ -72,9 +68,7 @@ + cur = self.con.cursor(factory=MyCursor) + cur.execute("select 4+5 as foo") + row = cur.fetchone() +- self.assertTrue(isinstance(row, +- dict), +- "row is not instance of dict") ++ self.assertIsInstance(row, dict) + cur.close() + + def tearDown(self): +@@ -87,28 +81,24 @@ + def CheckCustomFactory(self): + self.con.row_factory = lambda cur, row: list(row) + row = self.con.execute("select 1, 2").fetchone() +- self.assertTrue(isinstance(row, +- list), +- "row is not instance of list") ++ self.assertIsInstance(row, list) + + def CheckSqliteRowIndex(self): + self.con.row_factory = sqlite.Row + row = self.con.execute("select 1 as a, 2 as b").fetchone() +- self.assertTrue(isinstance(row, +- sqlite.Row), +- "row is not instance of sqlite.Row") ++ self.assertIsInstance(row, sqlite.Row) + + col1, col2 = row["a"], row["b"] +- self.assertTrue(col1 == 1, "by name: wrong result for column 'a'") +- self.assertTrue(col2 == 2, "by name: wrong result for column 'a'") ++ self.assertEqual(col1, 1, "by name: wrong result for column 'a'") ++ self.assertEqual(col2, 2, "by name: wrong result for column 'a'") + + col1, col2 = row["A"], row["B"] +- self.assertTrue(col1 == 1, "by name: wrong result for column 'A'") +- self.assertTrue(col2 == 2, "by name: wrong result for column 'B'") ++ self.assertEqual(col1, 1, "by name: wrong result for column 'A'") ++ self.assertEqual(col2, 2, "by name: wrong result for column 'B'") + + col1, col2 = row[0], row[1] +- self.assertTrue(col1 == 1, "by index: wrong result for column 0") +- self.assertTrue(col2 == 2, "by index: wrong result for column 1") ++ self.assertEqual(col1, 1, "by index: wrong result for column 0") ++ self.assertEqual(col2, 2, "by index: wrong result for column 1") + + def CheckSqliteRowIter(self): + """Checks if the row object is iterable""" +@@ -138,8 +128,8 @@ + row_2 = self.con.execute("select 1 as a, 2 as b").fetchone() + row_3 = self.con.execute("select 1 as a, 3 as b").fetchone() + +- self.assertTrue(row_1 == row_1) +- self.assertTrue(row_1 == row_2) ++ self.assertEqual(row_1, row_1) ++ self.assertEqual(row_1, row_2) + self.assertTrue(row_2 != row_3) + + self.assertFalse(row_1 != row_1) +@@ -161,20 +151,20 @@ + def CheckUnicode(self): + austria = "Österreich" + row = self.con.execute("select ?", (austria,)).fetchone() +- self.assertTrue(type(row[0]) == str, "type of row[0] must be unicode") ++ self.assertEqual(type(row[0]), str, "type of row[0] must be unicode") + + def CheckString(self): + self.con.text_factory = bytes + austria = "Österreich" + row = self.con.execute("select ?", (austria,)).fetchone() +- self.assertTrue(type(row[0]) == bytes, "type of row[0] must be bytes") +- self.assertTrue(row[0] == austria.encode("utf-8"), "column must equal original data in UTF-8") ++ self.assertEqual(type(row[0]), bytes, "type of row[0] must be bytes") ++ self.assertEqual(row[0], austria.encode("utf-8"), "column must equal original data in UTF-8") + + def CheckCustom(self): + self.con.text_factory = lambda x: str(x, "utf-8", "ignore") + austria = "Österreich" + row = self.con.execute("select ?", (austria,)).fetchone() +- self.assertTrue(type(row[0]) == str, "type of row[0] must be unicode") ++ self.assertEqual(type(row[0]), str, "type of row[0] must be unicode") + self.assertTrue(row[0].endswith("reich"), "column must contain original data") + + def CheckOptimizedUnicode(self): +@@ -185,8 +175,8 @@ + germany = "Deutchland" + a_row = self.con.execute("select ?", (austria,)).fetchone() + d_row = self.con.execute("select ?", (germany,)).fetchone() +- self.assertTrue(type(a_row[0]) == str, "type of non-ASCII row must be str") +- self.assertTrue(type(d_row[0]) == str, "type of ASCII-only row must be str") ++ self.assertEqual(type(a_row[0]), str, "type of non-ASCII row must be str") ++ self.assertEqual(type(d_row[0]), str, "type of ASCII-only row must be str") + + def tearDown(self): + self.con.close() +diff -r c3896275c0f6 Lib/sqlite3/test/hooks.py +--- a/Lib/sqlite3/test/hooks.py ++++ b/Lib/sqlite3/test/hooks.py +@@ -162,7 +162,7 @@ + create table bar (a, b) + """) + second_count = len(progress_calls) +- self.assertTrue(first_count > second_count) ++ self.assertGreater(first_count, second_count) + + def CheckCancelOperation(self): + """ +diff -r c3896275c0f6 Lib/subprocess.py +--- a/Lib/subprocess.py ++++ b/Lib/subprocess.py +@@ -662,7 +662,6 @@ + + # Various tools for executing commands and looking at their output and status. + # +-# NB This only works (and is only relevant) for POSIX. + + def getstatusoutput(cmd): + """Return (status, output) of executing cmd in a shell. +@@ -681,21 +680,15 @@ + >>> subprocess.getstatusoutput('/bin/junk') + (256, 'sh: /bin/junk: not found') + """ +- with os.popen('{ ' + cmd + '; } 2>&1', 'r') as pipe: +- try: +- text = pipe.read() +- sts = pipe.close() +- except: +- process = pipe._proc +- process.kill() +- process.wait() +- raise +- if sts is None: +- sts = 0 +- if text[-1:] == '\n': +- text = text[:-1] +- return sts, text +- ++ try: ++ data = check_output(cmd, shell=True, universal_newlines=True, stderr=STDOUT) ++ status = 0 ++ except CalledProcessError as ex: ++ data = ex.output ++ status = ex.returncode ++ if data[-1:] == '\n': ++ data = data[:-1] ++ return status, data + + def getoutput(cmd): + """Return output (stdout or stderr) of executing cmd in a shell. +@@ -1628,6 +1621,9 @@ + + self._save_input(input) + ++ if self._input: ++ input_view = memoryview(self._input) ++ + while self._fd2file: + timeout = self._remaining_time(endtime) + if timeout is not None and timeout < 0: +@@ -1645,8 +1641,8 @@ + + for fd, mode in ready: + if mode & select.POLLOUT: +- chunk = self._input[self._input_offset : +- self._input_offset + _PIPE_BUF] ++ chunk = input_view[self._input_offset : ++ self._input_offset + _PIPE_BUF] + try: + self._input_offset += os.write(fd, chunk) + except OSError as e: +diff -r c3896275c0f6 Lib/test/audiotests.py +--- a/Lib/test/audiotests.py ++++ b/Lib/test/audiotests.py +@@ -6,7 +6,8 @@ + import sys + + def byteswap2(data): +- a = array.array('h', data) ++ a = array.array('h') ++ a.frombytes(data) + a.byteswap() + return a.tobytes() + +@@ -17,7 +18,8 @@ + return bytes(ba) + + def byteswap4(data): +- a = array.array('i', data) ++ a = array.array('i') ++ a.frombytes(data) + a.byteswap() + return a.tobytes() + +diff -r c3896275c0f6 Lib/test/datetimetester.py +--- a/Lib/test/datetimetester.py ++++ b/Lib/test/datetimetester.py +@@ -115,11 +115,11 @@ + # carry no data), but they need to be picklable anyway else + # concrete subclasses can't be pickled. + orig = tzinfo.__new__(tzinfo) +- self.assertTrue(type(orig) is tzinfo) ++ self.assertIs(type(orig), tzinfo) + for pickler, unpickler, proto in pickle_choices: + green = pickler.dumps(orig, proto) + derived = unpickler.loads(green) +- self.assertTrue(type(derived) is tzinfo) ++ self.assertIs(type(derived), tzinfo) + + def test_pickling_subclass(self): + # Make sure we can pickle/unpickle an instance of a subclass. +@@ -479,9 +479,9 @@ + self.assertEqual(t1, t2) + self.assertTrue(t1 <= t2) + self.assertTrue(t1 >= t2) +- self.assertTrue(not t1 != t2) +- self.assertTrue(not t1 < t2) +- self.assertTrue(not t1 > t2) ++ self.assertFalse(t1 != t2) ++ self.assertFalse(t1 < t2) ++ self.assertFalse(t1 > t2) + + for args in (3, 3, 3), (2, 4, 4), (2, 3, 5): + t2 = timedelta(*args) # this is larger than t1 +@@ -491,12 +491,12 @@ + self.assertTrue(t2 >= t1) + self.assertTrue(t1 != t2) + self.assertTrue(t2 != t1) +- self.assertTrue(not t1 == t2) +- self.assertTrue(not t2 == t1) +- self.assertTrue(not t1 > t2) +- self.assertTrue(not t2 < t1) +- self.assertTrue(not t1 >= t2) +- self.assertTrue(not t2 <= t1) ++ self.assertFalse(t1 == t2) ++ self.assertFalse(t2 == t1) ++ self.assertFalse(t1 > t2) ++ self.assertFalse(t2 < t1) ++ self.assertFalse(t1 >= t2) ++ self.assertFalse(t2 <= t1) + + for badarg in OTHERSTUFF: + self.assertEqual(t1 == badarg, False) +@@ -629,7 +629,7 @@ + self.assertTrue(timedelta(0, 1)) + self.assertTrue(timedelta(0, 0, 1)) + self.assertTrue(timedelta(microseconds=1)) +- self.assertTrue(not timedelta(0)) ++ self.assertFalse(timedelta(0)) + + def test_subclass_timedelta(self): + +@@ -645,17 +645,17 @@ + return round(sum) + + t1 = T(days=1) +- self.assertTrue(type(t1) is T) ++ self.assertIs(type(t1), T) + self.assertEqual(t1.as_hours(), 24) + + t2 = T(days=-1, seconds=-3600) +- self.assertTrue(type(t2) is T) ++ self.assertIs(type(t2), T) + self.assertEqual(t2.as_hours(), -25) + + t3 = t1 + t2 +- self.assertTrue(type(t3) is timedelta) ++ self.assertIs(type(t3), timedelta) + t4 = T.from_td(t3) +- self.assertTrue(type(t4) is T) ++ self.assertIs(type(t4), T) + self.assertEqual(t3.days, t4.days) + self.assertEqual(t3.seconds, t4.seconds) + self.assertEqual(t3.microseconds, t4.microseconds) +@@ -1007,8 +1007,9 @@ + + # It worked or it didn't. If it didn't, assume it's reason #2, and + # let the test pass if they're within half a second of each other. +- self.assertTrue(today == todayagain or +- abs(todayagain - today) < timedelta(seconds=0.5)) ++ if today != todayagain: ++ self.assertAlmostEqual(todayagain, today, ++ delta=timedelta(seconds=0.5)) + + def test_weekday(self): + for i in range(7): +@@ -1202,9 +1203,9 @@ + self.assertEqual(t1, t2) + self.assertTrue(t1 <= t2) + self.assertTrue(t1 >= t2) +- self.assertTrue(not t1 != t2) +- self.assertTrue(not t1 < t2) +- self.assertTrue(not t1 > t2) ++ self.assertFalse(t1 != t2) ++ self.assertFalse(t1 < t2) ++ self.assertFalse(t1 > t2) + + for args in (3, 3, 3), (2, 4, 4), (2, 3, 5): + t2 = self.theclass(*args) # this is larger than t1 +@@ -1214,12 +1215,12 @@ + self.assertTrue(t2 >= t1) + self.assertTrue(t1 != t2) + self.assertTrue(t2 != t1) +- self.assertTrue(not t1 == t2) +- self.assertTrue(not t2 == t1) +- self.assertTrue(not t1 > t2) +- self.assertTrue(not t2 < t1) +- self.assertTrue(not t1 >= t2) +- self.assertTrue(not t2 <= t1) ++ self.assertFalse(t1 == t2) ++ self.assertFalse(t2 == t1) ++ self.assertFalse(t1 > t2) ++ self.assertFalse(t2 < t1) ++ self.assertFalse(t1 >= t2) ++ self.assertFalse(t2 <= t1) + + for badarg in OTHERSTUFF: + self.assertEqual(t1 == badarg, False) +@@ -1690,9 +1691,9 @@ + self.assertEqual(t1, t2) + self.assertTrue(t1 <= t2) + self.assertTrue(t1 >= t2) +- self.assertTrue(not t1 != t2) +- self.assertTrue(not t1 < t2) +- self.assertTrue(not t1 > t2) ++ self.assertFalse(t1 != t2) ++ self.assertFalse(t1 < t2) ++ self.assertFalse(t1 > t2) + + for i in range(len(args)): + newargs = args[:] +@@ -1704,12 +1705,12 @@ + self.assertTrue(t2 >= t1) + self.assertTrue(t1 != t2) + self.assertTrue(t2 != t1) +- self.assertTrue(not t1 == t2) +- self.assertTrue(not t2 == t1) +- self.assertTrue(not t1 > t2) +- self.assertTrue(not t2 < t1) +- self.assertTrue(not t1 >= t2) +- self.assertTrue(not t2 <= t1) ++ self.assertFalse(t1 == t2) ++ self.assertFalse(t2 == t1) ++ self.assertFalse(t1 > t2) ++ self.assertFalse(t2 < t1) ++ self.assertFalse(t1 >= t2) ++ self.assertFalse(t2 <= t1) + + + # A helper for timestamp constructor tests. +@@ -1846,7 +1847,7 @@ + if abs(from_timestamp - from_now) <= tolerance: + break + # Else try again a few times. +- self.assertTrue(abs(from_timestamp - from_now) <= tolerance) ++ self.assertLessEqual(abs(from_timestamp - from_now), tolerance) + + def test_strptime(self): + string = '2004-12-01 13:02:47.197' +@@ -2024,6 +2025,7 @@ + class TestSubclassDateTime(TestDateTime): + theclass = SubclassDatetime + # Override tests not designed for subclass ++ @unittest.skip('not appropriate for subclasses') + def test_roundtrip(self): + pass + +@@ -2072,9 +2074,9 @@ + self.assertEqual(t1, t2) + self.assertTrue(t1 <= t2) + self.assertTrue(t1 >= t2) +- self.assertTrue(not t1 != t2) +- self.assertTrue(not t1 < t2) +- self.assertTrue(not t1 > t2) ++ self.assertFalse(t1 != t2) ++ self.assertFalse(t1 < t2) ++ self.assertFalse(t1 > t2) + + for i in range(len(args)): + newargs = args[:] +@@ -2086,12 +2088,12 @@ + self.assertTrue(t2 >= t1) + self.assertTrue(t1 != t2) + self.assertTrue(t2 != t1) +- self.assertTrue(not t1 == t2) +- self.assertTrue(not t2 == t1) +- self.assertTrue(not t1 > t2) +- self.assertTrue(not t2 < t1) +- self.assertTrue(not t1 >= t2) +- self.assertTrue(not t2 <= t1) ++ self.assertFalse(t1 == t2) ++ self.assertFalse(t2 == t1) ++ self.assertFalse(t1 > t2) ++ self.assertFalse(t2 < t1) ++ self.assertFalse(t1 >= t2) ++ self.assertFalse(t2 <= t1) + + for badarg in OTHERSTUFF: + self.assertEqual(t1 == badarg, False) +@@ -2269,8 +2271,8 @@ + self.assertTrue(cls(0, 1)) + self.assertTrue(cls(0, 0, 1)) + self.assertTrue(cls(0, 0, 0, 1)) +- self.assertTrue(not cls(0)) +- self.assertTrue(not cls()) ++ self.assertFalse(cls(0)) ++ self.assertFalse(cls()) + + def test_replace(self): + cls = self.theclass +@@ -2367,7 +2369,7 @@ + def utcoffset(self, dt): pass + b = BetterTry() + t = cls(1, 1, 1, tzinfo=b) +- self.assertTrue(t.tzinfo is b) ++ self.assertIs(t.tzinfo, b) + + def test_utc_offset_out_of_bounds(self): + class Edgy(tzinfo): +@@ -2406,9 +2408,9 @@ + for t in (cls(1, 1, 1), + cls(1, 1, 1, tzinfo=None), + cls(1, 1, 1, tzinfo=C1())): +- self.assertTrue(t.utcoffset() is None) +- self.assertTrue(t.dst() is None) +- self.assertTrue(t.tzname() is None) ++ self.assertIsNone(t.utcoffset()) ++ self.assertIsNone(t.dst()) ++ self.assertIsNone(t.tzname()) + + class C3(tzinfo): + def utcoffset(self, dt): return timedelta(minutes=-1439) +@@ -2503,7 +2505,7 @@ + self.assertEqual(t.minute, 0) + self.assertEqual(t.second, 0) + self.assertEqual(t.microsecond, 0) +- self.assertTrue(t.tzinfo is None) ++ self.assertIsNone(t.tzinfo) + + def test_zones(self): + est = FixedOffset(-300, "EST", 1) +@@ -2518,25 +2520,25 @@ + self.assertEqual(t1.tzinfo, est) + self.assertEqual(t2.tzinfo, utc) + self.assertEqual(t3.tzinfo, met) +- self.assertTrue(t4.tzinfo is None) ++ self.assertIsNone(t4.tzinfo) + self.assertEqual(t5.tzinfo, utc) + + self.assertEqual(t1.utcoffset(), timedelta(minutes=-300)) + self.assertEqual(t2.utcoffset(), timedelta(minutes=0)) + self.assertEqual(t3.utcoffset(), timedelta(minutes=60)) +- self.assertTrue(t4.utcoffset() is None) ++ self.assertIsNone(t4.utcoffset()) + self.assertRaises(TypeError, t1.utcoffset, "no args") + + self.assertEqual(t1.tzname(), "EST") + self.assertEqual(t2.tzname(), "UTC") + self.assertEqual(t3.tzname(), "MET") +- self.assertTrue(t4.tzname() is None) ++ self.assertIsNone(t4.tzname()) + self.assertRaises(TypeError, t1.tzname, "no args") + + self.assertEqual(t1.dst(), timedelta(minutes=1)) + self.assertEqual(t2.dst(), timedelta(minutes=-2)) + self.assertEqual(t3.dst(), timedelta(minutes=3)) +- self.assertTrue(t4.dst() is None) ++ self.assertIsNone(t4.dst()) + self.assertRaises(TypeError, t1.dst, "no args") + + self.assertEqual(hash(t1), hash(t2)) +@@ -2633,10 +2635,10 @@ + self.assertTrue(t) + + t = cls(5, tzinfo=FixedOffset(300, "")) +- self.assertTrue(not t) ++ self.assertFalse(t) + + t = cls(23, 59, tzinfo=FixedOffset(23*60 + 59, "")) +- self.assertTrue(not t) ++ self.assertFalse(t) + + # Mostly ensuring this doesn't overflow internally. + t = cls(0, tzinfo=FixedOffset(23*60 + 59, "")) +@@ -2674,13 +2676,13 @@ + # Ensure we can get rid of a tzinfo. + self.assertEqual(base.tzname(), "+100") + base2 = base.replace(tzinfo=None) +- self.assertTrue(base2.tzinfo is None) +- self.assertTrue(base2.tzname() is None) ++ self.assertIsNone(base2.tzinfo) ++ self.assertIsNone(base2.tzname()) + + # Ensure we can add one. + base3 = base2.replace(tzinfo=z100) + self.assertEqual(base, base3) +- self.assertTrue(base.tzinfo is base3.tzinfo) ++ self.assertIs(base.tzinfo, base3.tzinfo) + + # Out of bounds. + base = cls(1) +@@ -2915,7 +2917,7 @@ + tz55 = FixedOffset(-330, "west 5:30") + timeaware = now.time().replace(tzinfo=tz55) + nowaware = self.theclass.combine(now.date(), timeaware) +- self.assertTrue(nowaware.tzinfo is tz55) ++ self.assertIs(nowaware.tzinfo, tz55) + self.assertEqual(nowaware.timetz(), timeaware) + + # Can't mix aware and non-aware. +@@ -2934,15 +2936,15 @@ + # Adding a delta should preserve tzinfo. + delta = timedelta(weeks=1, minutes=12, microseconds=5678) + nowawareplus = nowaware + delta +- self.assertTrue(nowaware.tzinfo is tz55) ++ self.assertIs(nowaware.tzinfo, tz55) + nowawareplus2 = delta + nowaware +- self.assertTrue(nowawareplus2.tzinfo is tz55) ++ self.assertIs(nowawareplus2.tzinfo, tz55) + self.assertEqual(nowawareplus, nowawareplus2) + + # that - delta should be what we started with, and that - what we + # started with should be delta. + diff = nowawareplus - delta +- self.assertTrue(diff.tzinfo is tz55) ++ self.assertIs(diff.tzinfo, tz55) + self.assertEqual(nowaware, diff) + self.assertRaises(TypeError, lambda: delta - nowawareplus) + self.assertEqual(nowawareplus - nowaware, delta) +@@ -2951,7 +2953,7 @@ + tzr = FixedOffset(random.randrange(-1439, 1440), "randomtimezone") + # Attach it to nowawareplus. + nowawareplus = nowawareplus.replace(tzinfo=tzr) +- self.assertTrue(nowawareplus.tzinfo is tzr) ++ self.assertIs(nowawareplus.tzinfo, tzr) + # Make sure the difference takes the timezone adjustments into account. + got = nowaware - nowawareplus + # Expected: (nowaware base - nowaware offset) - +@@ -2983,7 +2985,7 @@ + off42 = FixedOffset(42, "42") + another = meth(off42) + again = meth(tz=off42) +- self.assertTrue(another.tzinfo is again.tzinfo) ++ self.assertIs(another.tzinfo, again.tzinfo) + self.assertEqual(another.utcoffset(), timedelta(minutes=42)) + # Bad argument with and w/o naming the keyword. + self.assertRaises(TypeError, meth, 16) +@@ -3001,7 +3003,7 @@ + timezone(timedelta(hours=15, minutes=58), "weirdtz"),]: + for dummy in range(3): + now = datetime.now(weirdtz) +- self.assertTrue(now.tzinfo is weirdtz) ++ self.assertIs(now.tzinfo, weirdtz) + utcnow = datetime.utcnow().replace(tzinfo=utc) + now2 = utcnow.astimezone(weirdtz) + if abs(now - now2) < timedelta(seconds=30): +@@ -3022,7 +3024,7 @@ + off42 = FixedOffset(42, "42") + another = meth(ts, off42) + again = meth(ts, tz=off42) +- self.assertTrue(another.tzinfo is again.tzinfo) ++ self.assertIs(another.tzinfo, again.tzinfo) + self.assertEqual(another.utcoffset(), timedelta(minutes=42)) + # Bad argument with and w/o naming the keyword. + self.assertRaises(TypeError, meth, ts, 16) +@@ -3233,13 +3235,13 @@ + # Ensure we can get rid of a tzinfo. + self.assertEqual(base.tzname(), "+100") + base2 = base.replace(tzinfo=None) +- self.assertTrue(base2.tzinfo is None) +- self.assertTrue(base2.tzname() is None) ++ self.assertIsNone(base2.tzinfo) ++ self.assertIsNone(base2.tzname()) + + # Ensure we can add one. + base3 = base2.replace(tzinfo=z100) + self.assertEqual(base, base3) +- self.assertTrue(base.tzinfo is base3.tzinfo) ++ self.assertIs(base.tzinfo, base3.tzinfo) + + # Out of bounds. + base = cls(2000, 2, 29) +@@ -3252,18 +3254,18 @@ + fm5h = FixedOffset(-timedelta(hours=5), "m300") + + dt = self.theclass.now(tz=f44m) +- self.assertTrue(dt.tzinfo is f44m) ++ self.assertIs(dt.tzinfo, f44m) + # Replacing with degenerate tzinfo raises an exception. + self.assertRaises(ValueError, dt.astimezone, fnone) + # Replacing with same tzinfo makes no change. + x = dt.astimezone(dt.tzinfo) +- self.assertTrue(x.tzinfo is f44m) ++ self.assertIs(x.tzinfo, f44m) + self.assertEqual(x.date(), dt.date()) + self.assertEqual(x.time(), dt.time()) + + # Replacing with different tzinfo does adjust. + got = dt.astimezone(fm5h) +- self.assertTrue(got.tzinfo is fm5h) ++ self.assertIs(got.tzinfo, fm5h) + self.assertEqual(got.utcoffset(), timedelta(hours=-5)) + expected = dt - dt.utcoffset() # in effect, convert to UTC + expected += fm5h.utcoffset(dt) # and from there to local time +@@ -3271,7 +3273,7 @@ + self.assertEqual(got.date(), expected.date()) + self.assertEqual(got.time(), expected.time()) + self.assertEqual(got.timetz(), expected.timetz()) +- self.assertTrue(got.tzinfo is expected.tzinfo) ++ self.assertIs(got.tzinfo, expected.tzinfo) + self.assertEqual(got, expected) + + @support.run_with_tz('UTC') +@@ -3732,8 +3734,8 @@ + as_datetime = datetime.combine(as_date, time()) + self.assertTrue(as_date != as_datetime) + self.assertTrue(as_datetime != as_date) +- self.assertTrue(not as_date == as_datetime) +- self.assertTrue(not as_datetime == as_date) ++ self.assertFalse(as_date == as_datetime) ++ self.assertFalse(as_datetime == as_date) + self.assertRaises(TypeError, lambda: as_date < as_datetime) + self.assertRaises(TypeError, lambda: as_datetime < as_date) + self.assertRaises(TypeError, lambda: as_date <= as_datetime) +diff -r c3896275c0f6 Lib/test/multibytecodec_support.py +--- a/Lib/test/multibytecodec_support.py ++++ b/Lib/test/multibytecodec_support.py +@@ -73,7 +73,7 @@ + + def test_xmlcharrefreplace(self): + if self.has_iso10646: +- return ++ self.skipTest('encoding contains full ISO 10646 map') + + s = "\u0b13\u0b23\u0b60 nd eggs" + self.assertEqual( +@@ -83,7 +83,7 @@ + + def test_customreplace_encode(self): + if self.has_iso10646: +- return ++ self.skipTest('encoding contains full ISO 10646 map') + + from html.entities import codepoint2name + +diff -r c3896275c0f6 Lib/test/pickletester.py +--- a/Lib/test/pickletester.py ++++ b/Lib/test/pickletester.py +@@ -407,6 +407,71 @@ + # set([3]) pickled from 2.x with protocol 2 + DATA6 = b'\x80\x02c__builtin__\nset\nq\x00]q\x01K\x03a\x85q\x02Rq\x03.' + ++python2_exceptions_without_args = ( ++ ArithmeticError, ++ AssertionError, ++ AttributeError, ++ BaseException, ++ BufferError, ++ BytesWarning, ++ DeprecationWarning, ++ EOFError, ++ EnvironmentError, ++ Exception, ++ FloatingPointError, ++ FutureWarning, ++ GeneratorExit, ++ IOError, ++ ImportError, ++ ImportWarning, ++ IndentationError, ++ IndexError, ++ KeyError, ++ KeyboardInterrupt, ++ LookupError, ++ MemoryError, ++ NameError, ++ NotImplementedError, ++ OSError, ++ OverflowError, ++ PendingDeprecationWarning, ++ ReferenceError, ++ RuntimeError, ++ RuntimeWarning, ++ # StandardError is gone in Python 3, we map it to Exception ++ StopIteration, ++ SyntaxError, ++ SyntaxWarning, ++ SystemError, ++ SystemExit, ++ TabError, ++ TypeError, ++ UnboundLocalError, ++ UnicodeError, ++ UnicodeWarning, ++ UserWarning, ++ ValueError, ++ Warning, ++ ZeroDivisionError, ++) ++ ++exception_pickle = b'\x80\x02cexceptions\n?\nq\x00)Rq\x01.' ++ ++# Exception objects without arguments pickled from 2.x with protocol 2 ++DATA7 = { ++ exception : ++ exception_pickle.replace(b'?', exception.__name__.encode("ascii")) ++ for exception in python2_exceptions_without_args ++} ++ ++# StandardError is mapped to Exception, test that separately ++DATA8 = exception_pickle.replace(b'?', b'StandardError') ++ ++# UnicodeEncodeError object pickled from 2.x with protocol 2 ++DATA9 = (b'\x80\x02cexceptions\nUnicodeEncodeError\n' ++ b'q\x00(U\x05asciiq\x01X\x03\x00\x00\x00fooq\x02K\x00K\x01' ++ b'U\x03badq\x03tq\x04Rq\x05.') ++ + + def create_data(): + c = C() +@@ -768,6 +833,15 @@ + u = self.loads(s) + self.assertEqual(NotImplemented, u) + ++ def test_singleton_types(self): ++ # Issue #6477: Test that types of built-in singletons can be pickled. ++ singletons = [None, ..., NotImplemented] ++ for singleton in singletons: ++ for proto in protocols: ++ s = self.dumps(type(singleton), proto) ++ u = self.loads(s) ++ self.assertIs(type(singleton), u) ++ + # Tests for protocol 2 + + def test_proto(self): +@@ -1151,6 +1225,21 @@ + self.assertEqual(list(loaded.keys()), ["key"]) + self.assertEqual(loaded["key"].value, "Set-Cookie: key=value") + ++ for (exc, data) in DATA7.items(): ++ loaded = self.loads(data) ++ self.assertIs(type(loaded), exc) ++ ++ loaded = self.loads(DATA8) ++ self.assertIs(type(loaded), Exception) ++ ++ loaded = self.loads(DATA9) ++ self.assertIs(type(loaded), UnicodeEncodeError) ++ self.assertEqual(loaded.object, "foo") ++ self.assertEqual(loaded.encoding, "ascii") ++ self.assertEqual(loaded.start, 0) ++ self.assertEqual(loaded.end, 1) ++ self.assertEqual(loaded.reason, "bad") ++ + def test_pickle_to_2x(self): + # Pickle non-trivial data with protocol 2, expecting that it yields + # the same result as Python 2.x did. +@@ -1499,30 +1588,34 @@ + if isinstance(object, int) and object % 2 == 0: + self.id_count += 1 + return str(object) ++ elif object == "test_false_value": ++ self.false_count += 1 ++ return "" + else: + return None + + def persistent_load(self, oid): +- self.load_count += 1 +- object = int(oid) +- assert object % 2 == 0 +- return object ++ if not oid: ++ self.load_false_count += 1 ++ return "test_false_value" ++ else: ++ self.load_count += 1 ++ object = int(oid) ++ assert object % 2 == 0 ++ return object + + def test_persistence(self): +- self.id_count = 0 +- self.load_count = 0 +- L = list(range(10)) +- self.assertEqual(self.loads(self.dumps(L)), L) +- self.assertEqual(self.id_count, 5) +- self.assertEqual(self.load_count, 5) +- +- def test_bin_persistence(self): +- self.id_count = 0 +- self.load_count = 0 +- L = list(range(10)) +- self.assertEqual(self.loads(self.dumps(L, 1)), L) +- self.assertEqual(self.id_count, 5) +- self.assertEqual(self.load_count, 5) ++ L = list(range(10)) + ["test_false_value"] ++ for proto in protocols: ++ self.id_count = 0 ++ self.false_count = 0 ++ self.load_false_count = 0 ++ self.load_count = 0 ++ self.assertEqual(self.loads(self.dumps(L, proto)), L) ++ self.assertEqual(self.id_count, 5) ++ self.assertEqual(self.false_count, 1) ++ self.assertEqual(self.load_count, 5) ++ self.assertEqual(self.load_false_count, 1) + + + class AbstractPicklerUnpicklerObjectTests(unittest.TestCase): +diff -r c3896275c0f6 Lib/test/string_tests.py +--- a/Lib/test/string_tests.py ++++ b/Lib/test/string_tests.py +@@ -663,10 +663,10 @@ + self.checkraises(TypeError, 'hello', 'replace', 42, 'h') + self.checkraises(TypeError, 'hello', 'replace', 'h', 42) + ++ @unittest.skipIf(sys.maxsize > (1 << 32) or struct.calcsize('P') != 4, ++ 'only applies to 32-bit platforms') + def test_replace_overflow(self): + # Check for overflow checking on 32 bit machines +- if sys.maxsize != 2147483647 or struct.calcsize("P") > 4: +- return + A2_16 = "A" * (2**16) + self.checkraises(OverflowError, A2_16, "replace", "", A2_16) + self.checkraises(OverflowError, A2_16, "replace", "A", A2_16) +diff -r c3896275c0f6 Lib/test/support/__init__.py +--- a/Lib/test/support/__init__.py ++++ b/Lib/test/support/__init__.py +@@ -570,9 +570,15 @@ + raise TestFailed("tests should never set the SO_REUSEADDR " \ + "socket option on TCP/IP sockets!") + if hasattr(socket, 'SO_REUSEPORT'): +- if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT) == 1: +- raise TestFailed("tests should never set the SO_REUSEPORT " \ +- "socket option on TCP/IP sockets!") ++ try: ++ if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT) == 1: ++ raise TestFailed("tests should never set the SO_REUSEPORT " \ ++ "socket option on TCP/IP sockets!") ++ except OSError: ++ # Python's socket module was compiled using modern headers ++ # thus defining SO_REUSEPORT but this process is running ++ # under an older kernel that does not support SO_REUSEPORT. ++ pass + if hasattr(socket, 'SO_EXCLUSIVEADDRUSE'): + sock.setsockopt(socket.SOL_SOCKET, socket.SO_EXCLUSIVEADDRUSE, 1) + +diff -r c3896275c0f6 Lib/test/test_abstract_numbers.py +--- a/Lib/test/test_abstract_numbers.py ++++ b/Lib/test/test_abstract_numbers.py +@@ -4,7 +4,6 @@ + import operator + import unittest + from numbers import Complex, Real, Rational, Integral +-from test import support + + class TestNumbers(unittest.TestCase): + def test_int(self): +@@ -40,9 +39,6 @@ + self.assertRaises(TypeError, float, c1) + self.assertRaises(TypeError, int, c1) + +-def test_main(): +- support.run_unittest(TestNumbers) +- + + if __name__ == "__main__": + unittest.main() +diff -r c3896275c0f6 Lib/test/test_array.py +--- a/Lib/test/test_array.py ++++ b/Lib/test/test_array.py +@@ -11,6 +11,7 @@ + import io + import math + import struct ++import sys + import warnings + + import array +@@ -194,7 +195,7 @@ + def test_constructor(self): + a = array.array(self.typecode) + self.assertEqual(a.typecode, self.typecode) +- self.assertTrue(a.itemsize>=self.minitemsize) ++ self.assertGreaterEqual(a.itemsize, self.minitemsize) + self.assertRaises(TypeError, array.array, self.typecode, None) + + def test_len(self): +@@ -441,39 +442,39 @@ + + def test_cmp(self): + a = array.array(self.typecode, self.example) +- self.assertTrue((a == 42) is False) +- self.assertTrue((a != 42) is True) ++ self.assertIs(a == 42, False) ++ self.assertIs(a != 42, True) + +- self.assertTrue((a == a) is True) +- self.assertTrue((a != a) is False) +- self.assertTrue((a < a) is False) +- self.assertTrue((a <= a) is True) +- self.assertTrue((a > a) is False) +- self.assertTrue((a >= a) is True) ++ self.assertIs(a == a, True) ++ self.assertIs(a != a, False) ++ self.assertIs(a < a, False) ++ self.assertIs(a <= a, True) ++ self.assertIs(a > a, False) ++ self.assertIs(a >= a, True) + + al = array.array(self.typecode, self.smallerexample) + ab = array.array(self.typecode, self.biggerexample) + +- self.assertTrue((a == 2*a) is False) +- self.assertTrue((a != 2*a) is True) +- self.assertTrue((a < 2*a) is True) +- self.assertTrue((a <= 2*a) is True) +- self.assertTrue((a > 2*a) is False) +- self.assertTrue((a >= 2*a) is False) ++ self.assertIs(a == 2*a, False) ++ self.assertIs(a != 2*a, True) ++ self.assertIs(a < 2*a, True) ++ self.assertIs(a <= 2*a, True) ++ self.assertIs(a > 2*a, False) ++ self.assertIs(a >= 2*a, False) + +- self.assertTrue((a == al) is False) +- self.assertTrue((a != al) is True) +- self.assertTrue((a < al) is False) +- self.assertTrue((a <= al) is False) +- self.assertTrue((a > al) is True) +- self.assertTrue((a >= al) is True) ++ self.assertIs(a == al, False) ++ self.assertIs(a != al, True) ++ self.assertIs(a < al, False) ++ self.assertIs(a <= al, False) ++ self.assertIs(a > al, True) ++ self.assertIs(a >= al, True) + +- self.assertTrue((a == ab) is False) +- self.assertTrue((a != ab) is True) +- self.assertTrue((a < ab) is True) +- self.assertTrue((a <= ab) is True) +- self.assertTrue((a > ab) is False) +- self.assertTrue((a >= ab) is False) ++ self.assertIs(a == ab, False) ++ self.assertIs(a != ab, True) ++ self.assertIs(a < ab, True) ++ self.assertIs(a <= ab, True) ++ self.assertIs(a > ab, False) ++ self.assertIs(a >= ab, False) + + def test_add(self): + a = array.array(self.typecode, self.example) \ +@@ -492,7 +493,7 @@ + a = array.array(self.typecode, self.example[::-1]) + b = a + a += array.array(self.typecode, 2*self.example) +- self.assertTrue(a is b) ++ self.assertIs(a, b) + self.assertEqual( + a, + array.array(self.typecode, self.example[::-1]+2*self.example) +@@ -547,22 +548,22 @@ + b = a + + a *= 5 +- self.assertTrue(a is b) ++ self.assertIs(a, b) + self.assertEqual( + a, + array.array(self.typecode, 5*self.example) + ) + + a *= 0 +- self.assertTrue(a is b) ++ self.assertIs(a, b) + self.assertEqual(a, array.array(self.typecode)) + + a *= 1000 +- self.assertTrue(a is b) ++ self.assertIs(a, b) + self.assertEqual(a, array.array(self.typecode)) + + a *= -1 +- self.assertTrue(a is b) ++ self.assertIs(a, b) + self.assertEqual(a, array.array(self.typecode)) + + a = array.array(self.typecode, self.example) +@@ -945,7 +946,7 @@ + try: + import gc + except ImportError: +- return ++ self.skipTest('gc module not available') + a = array.array(self.typecode) + l = [iter(a)] + l.append(l) +@@ -993,15 +994,15 @@ + s = None + self.assertRaises(ReferenceError, len, p) + ++ @unittest.skipUnless(hasattr(sys, 'getrefcount'), ++ 'test needs sys.getrefcount()') + def test_bug_782369(self): +- import sys +- if hasattr(sys, "getrefcount"): +- for i in range(10): +- b = array.array('B', range(64)) +- rc = sys.getrefcount(10) +- for i in range(10): +- b = array.array('B', range(64)) +- self.assertEqual(rc, sys.getrefcount(10)) ++ for i in range(10): ++ b = array.array('B', range(64)) ++ rc = sys.getrefcount(10) ++ for i in range(10): ++ b = array.array('B', range(64)) ++ self.assertEqual(rc, sys.getrefcount(10)) + + def test_subclass_with_kwargs(self): + # SF bug #1486663 -- this used to erroneously raise a TypeError +diff -r c3896275c0f6 Lib/test/test_bz2.py +--- a/Lib/test/test_bz2.py ++++ b/Lib/test/test_bz2.py +@@ -5,6 +5,7 @@ + import unittest + from io import BytesIO + import os ++import pickle + import random + import subprocess + import sys +@@ -48,6 +49,7 @@ + TEXT = b''.join(TEXT_LINES) + DATA = b'BZh91AY&SY.\xc8N\x18\x00\x01>_\x80\x00\x10@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe00\x01\x99\xaa\x00\xc0\x03F\x86\x8c#&\x83F\x9a\x03\x06\xa6\xd0\xa6\x93M\x0fQ\xa7\xa8\x06\x804hh\x12$\x11\xa4i4\xf14S\xd2\x88\xe5\xcd9gd6\x0b\n\xe9\x9b\xd5\x8a\x99\xf7\x08.K\x8ev\xfb\xf7xw\xbb\xdf\xa1\x92\xf1\xdd|/";\xa2\xba\x9f\xd5\xb1#A\xb6\xf6\xb3o\xc9\xc5y\\\xebO\xe7\x85\x9a\xbc\xb6f8\x952\xd5\xd7"%\x89>V,\xf7\xa6z\xe2\x9f\xa3\xdf\x11\x11"\xd6E)I\xa9\x13^\xca\xf3r\xd0\x03U\x922\xf26\xec\xb6\xed\x8b\xc3U\x13\x9d\xc5\x170\xa4\xfa^\x92\xacDF\x8a\x97\xd6\x19\xfe\xdd\xb8\xbd\x1a\x9a\x19\xa3\x80ankR\x8b\xe5\xd83]\xa9\xc6\x08\x82f\xf6\xb9"6l$\xb8j@\xc0\x8a\xb0l1..\xbak\x83ls\x15\xbc\xf4\xc1\x13\xbe\xf8E\xb8\x9d\r\xa8\x9dk\x84\xd3n\xfa\xacQ\x07\xb1%y\xaav\xb4\x08\xe0z\x1b\x16\xf5\x04\xe9\xcc\xb9\x08z\x1en7.G\xfc]\xc9\x14\xe1B@\xbb!8`' + EMPTY_DATA = b'BZh9\x17rE8P\x90\x00\x00\x00\x00' ++ BAD_DATA = b'this is not a valid bzip2 file' + + def setUp(self): + self.filename = TESTFN +@@ -78,9 +80,10 @@ + class BZ2FileTest(BaseTest): + "Test BZ2File type miscellaneous methods." + +- def createTempFile(self, streams=1): ++ def createTempFile(self, streams=1, suffix=b""): + with open(self.filename, "wb") as f: + f.write(self.DATA * streams) ++ f.write(suffix) + + def testBadArgs(self): + with self.assertRaises(TypeError): +@@ -102,6 +105,11 @@ + self.assertRaises(TypeError, bz2f.read, None) + self.assertEqual(bz2f.read(), self.TEXT) + ++ def testReadBadFile(self): ++ self.createTempFile(streams=0, suffix=self.BAD_DATA) ++ with BZ2File(self.filename) as bz2f: ++ self.assertRaises(OSError, bz2f.read) ++ + def testReadMultiStream(self): + self.createTempFile(streams=5) + with BZ2File(self.filename) as bz2f: +@@ -121,6 +129,16 @@ + finally: + bz2._BUFFER_SIZE = buffer_size + ++ def testReadTrailingJunk(self): ++ self.createTempFile(suffix=self.BAD_DATA) ++ with BZ2File(self.filename) as bz2f: ++ self.assertEqual(bz2f.read(), self.TEXT) ++ ++ def testReadMultiStreamTrailingJunk(self): ++ self.createTempFile(streams=5, suffix=self.BAD_DATA) ++ with BZ2File(self.filename) as bz2f: ++ self.assertEqual(bz2f.read(), self.TEXT * 5) ++ + def testRead0(self): + self.createTempFile() + with BZ2File(self.filename) as bz2f: +@@ -621,6 +639,11 @@ + finally: + data = None + ++ def testPickle(self): ++ with self.assertRaises(TypeError): ++ pickle.dumps(BZ2Compressor()) ++ ++ + class BZ2DecompressorTest(BaseTest): + def test_Constructor(self): + self.assertRaises(TypeError, BZ2Decompressor, 42) +@@ -672,6 +695,10 @@ + compressed = None + decompressed = None + ++ def testPickle(self): ++ with self.assertRaises(TypeError): ++ pickle.dumps(BZ2Decompressor()) ++ + + class CompressDecompressTest(BaseTest): + def testCompress(self): +@@ -697,10 +724,21 @@ + def testDecompressIncomplete(self): + self.assertRaises(ValueError, bz2.decompress, self.DATA[:-10]) + ++ def testDecompressBadData(self): ++ self.assertRaises(OSError, bz2.decompress, self.BAD_DATA) ++ + def testDecompressMultiStream(self): + text = bz2.decompress(self.DATA * 5) + self.assertEqual(text, self.TEXT * 5) + ++ def testDecompressTrailingJunk(self): ++ text = bz2.decompress(self.DATA + self.BAD_DATA) ++ self.assertEqual(text, self.TEXT) ++ ++ def testDecompressMultiStreamTrailingJunk(self): ++ text = bz2.decompress(self.DATA * 5 + self.BAD_DATA) ++ self.assertEqual(text, self.TEXT * 5) ++ + + class OpenTest(BaseTest): + def test_binary_modes(self): +diff -r c3896275c0f6 Lib/test/test_capi.py +--- a/Lib/test/test_capi.py ++++ b/Lib/test/test_capi.py +@@ -1,7 +1,6 @@ + # Run the _testcapi module tests (tests for the Python/C API): by defn, + # these are all functions _testcapi exports whose name begins with 'test_'. + +-from __future__ import with_statement + import os + import pickle + import random +@@ -351,17 +350,12 @@ + t.start() + t.join() + +- +-def test_main(): +- support.run_unittest(CAPITest, TestPendingCalls, Test6012, +- EmbeddingTest, SkipitemTest, TestThreadState) +- +- for name in dir(_testcapi): +- if name.startswith('test_'): +- test = getattr(_testcapi, name) +- if support.verbose: +- print("internal", name) +- test() ++class Test_testcapi(unittest.TestCase): ++ def test__testcapi(self): ++ for name in dir(_testcapi): ++ if name.startswith('test_'): ++ test = getattr(_testcapi, name) ++ test() + + if __name__ == "__main__": +- test_main() ++ unittest.main() +diff -r c3896275c0f6 Lib/test/test_codecencodings_iso2022.py +--- a/Lib/test/test_codecencodings_iso2022.py ++++ b/Lib/test/test_codecencodings_iso2022.py +@@ -36,6 +36,7 @@ + + # iso2022_kr.txt cannot be used to test "chunk coding": the escape + # sequence is only written on the first line ++ @unittest.skip('iso2022_kr.txt cannot be used to test "chunk coding"') + def test_chunkcoding(self): + pass + +diff -r c3896275c0f6 Lib/test/test_compileall.py +--- a/Lib/test/test_compileall.py ++++ b/Lib/test/test_compileall.py +@@ -39,11 +39,10 @@ + compare = struct.pack('<4sl', imp.get_magic(), mtime) + return data, compare + ++ @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()') + def recreation_check(self, metadata): + """Check that compileall recreates bytecode when the new metadata is + used.""" +- if not hasattr(os, 'stat'): +- return + py_compile.compile(self.source_path) + self.assertEqual(*self.data()) + with open(self.bc_path, 'rb') as file: +diff -r c3896275c0f6 Lib/test/test_configparser.py +--- a/Lib/test/test_configparser.py ++++ b/Lib/test/test_configparser.py +@@ -707,8 +707,7 @@ + + def test_read_returns_file_list(self): + if self.delimiters[0] != '=': +- # skip reading the file if we're using an incompatible format +- return ++ self.skipTest('incompatible format') + file1 = support.findfile("cfgparser.1") + # check when we pass a mix of readable and non-readable files: + cf = self.newconfig() +diff -r c3896275c0f6 Lib/test/test_copy.py +--- a/Lib/test/test_copy.py ++++ b/Lib/test/test_copy.py +@@ -3,6 +3,7 @@ + import copy + import copyreg + import weakref ++import abc + from operator import le, lt, ge, gt, eq, ne + + import unittest +@@ -93,9 +94,11 @@ + pass + def f(): + pass ++ class WithMetaclass(metaclass=abc.ABCMeta): ++ pass + tests = [None, 42, 2**100, 3.14, True, False, 1j, + "hello", "hello\u1234", f.__code__, +- NewStyle, range(10), Classic, max] ++ NewStyle, range(10), Classic, max, WithMetaclass] + for x in tests: + self.assertIs(copy.copy(x), x) + +diff -r c3896275c0f6 Lib/test/test_csv.py +--- a/Lib/test/test_csv.py ++++ b/Lib/test/test_csv.py +@@ -570,6 +570,18 @@ + fileobj = StringIO() + self.assertRaises(TypeError, csv.DictWriter, fileobj) + ++ def test_write_fields_not_in_fieldnames(self): ++ with TemporaryFile("w+", newline='') as fileobj: ++ writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"]) ++ # Of special note is the non-string key (issue 19449) ++ with self.assertRaises(ValueError) as cx: ++ writer.writerow({"f4": 10, "f2": "spam", 1: "abc"}) ++ exception = str(cx.exception) ++ self.assertIn("fieldnames", exception) ++ self.assertIn("'f4'", exception) ++ self.assertNotIn("'f2'", exception) ++ self.assertIn("1", exception) ++ + def test_read_dict_fields(self): + with TemporaryFile("w+") as fileobj: + fileobj.write("1,2,abc\r\n") +@@ -896,78 +908,77 @@ + dialect = sniffer.sniff(self.sample9) + self.assertTrue(dialect.doublequote) + +-if not hasattr(sys, "gettotalrefcount"): +- if support.verbose: print("*** skipping leakage tests ***") +-else: +- class NUL: +- def write(s, *args): +- pass +- writelines = write ++class NUL: ++ def write(s, *args): ++ pass ++ writelines = write + +- class TestLeaks(unittest.TestCase): +- def test_create_read(self): +- delta = 0 +- lastrc = sys.gettotalrefcount() +- for i in range(20): +- gc.collect() +- self.assertEqual(gc.garbage, []) +- rc = sys.gettotalrefcount() +- csv.reader(["a,b,c\r\n"]) +- csv.reader(["a,b,c\r\n"]) +- csv.reader(["a,b,c\r\n"]) +- delta = rc-lastrc +- lastrc = rc +- # if csv.reader() leaks, last delta should be 3 or more +- self.assertEqual(delta < 3, True) ++@unittest.skipUnless(hasattr(sys, "gettotalrefcount"), ++ 'requires sys.gettotalrefcount()') ++class TestLeaks(unittest.TestCase): ++ def test_create_read(self): ++ delta = 0 ++ lastrc = sys.gettotalrefcount() ++ for i in range(20): ++ gc.collect() ++ self.assertEqual(gc.garbage, []) ++ rc = sys.gettotalrefcount() ++ csv.reader(["a,b,c\r\n"]) ++ csv.reader(["a,b,c\r\n"]) ++ csv.reader(["a,b,c\r\n"]) ++ delta = rc-lastrc ++ lastrc = rc ++ # if csv.reader() leaks, last delta should be 3 or more ++ self.assertEqual(delta < 3, True) + +- def test_create_write(self): +- delta = 0 +- lastrc = sys.gettotalrefcount() +- s = NUL() +- for i in range(20): +- gc.collect() +- self.assertEqual(gc.garbage, []) +- rc = sys.gettotalrefcount() +- csv.writer(s) +- csv.writer(s) +- csv.writer(s) +- delta = rc-lastrc +- lastrc = rc +- # if csv.writer() leaks, last delta should be 3 or more +- self.assertEqual(delta < 3, True) ++ def test_create_write(self): ++ delta = 0 ++ lastrc = sys.gettotalrefcount() ++ s = NUL() ++ for i in range(20): ++ gc.collect() ++ self.assertEqual(gc.garbage, []) ++ rc = sys.gettotalrefcount() ++ csv.writer(s) ++ csv.writer(s) ++ csv.writer(s) ++ delta = rc-lastrc ++ lastrc = rc ++ # if csv.writer() leaks, last delta should be 3 or more ++ self.assertEqual(delta < 3, True) + +- def test_read(self): +- delta = 0 +- rows = ["a,b,c\r\n"]*5 +- lastrc = sys.gettotalrefcount() +- for i in range(20): +- gc.collect() +- self.assertEqual(gc.garbage, []) +- rc = sys.gettotalrefcount() +- rdr = csv.reader(rows) +- for row in rdr: +- pass +- delta = rc-lastrc +- lastrc = rc +- # if reader leaks during read, delta should be 5 or more +- self.assertEqual(delta < 5, True) ++ def test_read(self): ++ delta = 0 ++ rows = ["a,b,c\r\n"]*5 ++ lastrc = sys.gettotalrefcount() ++ for i in range(20): ++ gc.collect() ++ self.assertEqual(gc.garbage, []) ++ rc = sys.gettotalrefcount() ++ rdr = csv.reader(rows) ++ for row in rdr: ++ pass ++ delta = rc-lastrc ++ lastrc = rc ++ # if reader leaks during read, delta should be 5 or more ++ self.assertEqual(delta < 5, True) + +- def test_write(self): +- delta = 0 +- rows = [[1,2,3]]*5 +- s = NUL() +- lastrc = sys.gettotalrefcount() +- for i in range(20): +- gc.collect() +- self.assertEqual(gc.garbage, []) +- rc = sys.gettotalrefcount() +- writer = csv.writer(s) +- for row in rows: +- writer.writerow(row) +- delta = rc-lastrc +- lastrc = rc +- # if writer leaks during write, last delta should be 5 or more +- self.assertEqual(delta < 5, True) ++ def test_write(self): ++ delta = 0 ++ rows = [[1,2,3]]*5 ++ s = NUL() ++ lastrc = sys.gettotalrefcount() ++ for i in range(20): ++ gc.collect() ++ self.assertEqual(gc.garbage, []) ++ rc = sys.gettotalrefcount() ++ writer = csv.writer(s) ++ for row in rows: ++ writer.writerow(row) ++ delta = rc-lastrc ++ lastrc = rc ++ # if writer leaks during write, last delta should be 5 or more ++ self.assertEqual(delta < 5, True) + + class TestUnicode(unittest.TestCase): + +diff -r c3896275c0f6 Lib/test/test_dbm_dumb.py +--- a/Lib/test/test_dbm_dumb.py ++++ b/Lib/test/test_dbm_dumb.py +@@ -37,11 +37,9 @@ + self.read_helper(f) + f.close() + ++ @unittest.skipUnless(hasattr(os, 'umask'), 'test needs os.umask()') ++ @unittest.skipUnless(hasattr(os, 'chmod'), 'test needs os.chmod()') + def test_dumbdbm_creation_mode(self): +- # On platforms without chmod, don't do anything. +- if not (hasattr(os, 'chmod') and hasattr(os, 'umask')): +- return +- + try: + old_umask = os.umask(0o002) + f = dumbdbm.open(_fname, 'c', 0o637) +diff -r c3896275c0f6 Lib/test/test_decimal.py +--- a/Lib/test/test_decimal.py ++++ b/Lib/test/test_decimal.py +@@ -290,7 +290,6 @@ + global skip_expected + if skip_expected: + raise unittest.SkipTest +- return + with open(file) as f: + for line in f: + line = line.replace('\r\n', '').replace('\n', '') +@@ -301,7 +300,6 @@ + #Exception raised where there shouldn't have been one. + self.fail('Exception "'+exception.__class__.__name__ + '" raised on line '+line) + +- return + + def eval_line(self, s): + if s.find(' -> ') >= 0 and s[:2] != '--' and not s.startswith(' --'): +@@ -461,7 +459,6 @@ + + self.assertEqual(myexceptions, theirexceptions, + 'Incorrect flags set in ' + s + ' -- got ' + str(myexceptions)) +- return + + def getexceptions(self): + return [e for e in Signals[self.decimal] if self.context.flags[e]] +@@ -1073,7 +1070,7 @@ + try: + from locale import CHAR_MAX + except ImportError: +- return ++ self.skipTest('locale.CHAR_MAX not available') + + def make_grouping(lst): + return ''.join([chr(x) for x in lst]) if self.decimal == C else lst +@@ -1164,8 +1161,12 @@ + + decimal_point = locale.localeconv()['decimal_point'] + thousands_sep = locale.localeconv()['thousands_sep'] +- if decimal_point != '\u066b' or thousands_sep != '\u066c': +- return ++ if decimal_point != '\u066b': ++ self.skipTest('inappropriate decimal point separator' ++ '({!r} not {!r})'.format(decimal_point, '\u066b')) ++ if thousands_sep != '\u066c': ++ self.skipTest('inappropriate thousands separator' ++ '({!r} not {!r})'.format(thousands_sep, '\u066c')) + + self.assertEqual(format(Decimal('100000000.123'), 'n'), + '100\u066c000\u066c000\u066b123') +@@ -1515,7 +1516,6 @@ + cls.assertTrue(c1.flags[Inexact]) + for sig in Overflow, Underflow, DivisionByZero, InvalidOperation: + cls.assertFalse(c1.flags[sig]) +- return + + def thfunc2(cls): + Decimal = cls.decimal.Decimal +@@ -1560,7 +1560,6 @@ + cls.assertTrue(thiscontext.flags[Inexact]) + for sig in Overflow, Underflow, DivisionByZero, InvalidOperation: + cls.assertFalse(thiscontext.flags[sig]) +- return + + class ThreadingTest(unittest.TestCase): + '''Unit tests for thread local contexts in Decimal.''' +@@ -1602,7 +1601,6 @@ + DefaultContext.prec = save_prec + DefaultContext.Emax = save_emax + DefaultContext.Emin = save_emin +- return + + @unittest.skipUnless(threading, 'threading required') + class CThreadingTest(ThreadingTest): +@@ -4150,6 +4148,7 @@ + self.assertTrue(P.HAVE_THREADS is True or P.HAVE_THREADS is False) + + self.assertEqual(C.__version__, P.__version__) ++ self.assertEqual(C.__libmpdec_version__, P.__libmpdec_version__) + + x = dir(C) + y = [s for s in dir(P) if '__' in s or not s.startswith('_')] +@@ -4524,7 +4523,6 @@ + self.assertEqual(d1._sign, b1._sign) + self.assertEqual(d1._int, b1._int) + self.assertEqual(d1._exp, b1._exp) +- return + + Decimal(d1) + self.assertEqual(d1._sign, b1._sign) +@@ -5270,7 +5268,7 @@ + try: + from locale import CHAR_MAX + except ImportError: +- return ++ self.skipTest('locale.CHAR_MAX not available') + + def make_grouping(lst): + return ''.join([chr(x) for x in lst]) +diff -r c3896275c0f6 Lib/test/test_descr.py +--- a/Lib/test/test_descr.py ++++ b/Lib/test/test_descr.py +@@ -388,13 +388,21 @@ + + class ClassPropertiesAndMethods(unittest.TestCase): + ++ def assertHasAttr(self, obj, name): ++ self.assertTrue(hasattr(obj, name), ++ '%r has no attribute %r' % (obj, name)) ++ ++ def assertNotHasAttr(self, obj, name): ++ self.assertFalse(hasattr(obj, name), ++ '%r has unexpected attribute %r' % (obj, name)) ++ + def test_python_dicts(self): + # Testing Python subclass of dict... + self.assertTrue(issubclass(dict, dict)) + self.assertIsInstance({}, dict) + d = dict() + self.assertEqual(d, {}) +- self.assertTrue(d.__class__ is dict) ++ self.assertIs(d.__class__, dict) + self.assertIsInstance(d, dict) + class C(dict): + state = -1 +@@ -572,7 +580,7 @@ + def _set_x(self, x): + self.__x = -x + a = A() +- self.assertTrue(not hasattr(a, "x")) ++ self.assertNotHasAttr(a, "x") + a.x = 12 + self.assertEqual(a.x, 12) + self.assertEqual(a._A__x, -12) +@@ -998,14 +1006,14 @@ + self.assertEqual(type(a), object) + b = object() + self.assertNotEqual(a, b) +- self.assertFalse(hasattr(a, "foo")) ++ self.assertNotHasAttr(a, "foo") + try: + a.foo = 12 + except (AttributeError, TypeError): + pass + else: + self.fail("object() should not allow setting a foo attribute") +- self.assertFalse(hasattr(object(), "__dict__")) ++ self.assertNotHasAttr(object(), "__dict__") + + class Cdict(object): + pass +@@ -1020,28 +1028,28 @@ + class C0(object): + __slots__ = [] + x = C0() +- self.assertFalse(hasattr(x, "__dict__")) +- self.assertFalse(hasattr(x, "foo")) ++ self.assertNotHasAttr(x, "__dict__") ++ self.assertNotHasAttr(x, "foo") + + class C1(object): + __slots__ = ['a'] + x = C1() +- self.assertFalse(hasattr(x, "__dict__")) +- self.assertFalse(hasattr(x, "a")) ++ self.assertNotHasAttr(x, "__dict__") ++ self.assertNotHasAttr(x, "a") + x.a = 1 + self.assertEqual(x.a, 1) + x.a = None + self.assertEqual(x.a, None) + del x.a +- self.assertFalse(hasattr(x, "a")) ++ self.assertNotHasAttr(x, "a") + + class C3(object): + __slots__ = ['a', 'b', 'c'] + x = C3() +- self.assertFalse(hasattr(x, "__dict__")) +- self.assertFalse(hasattr(x, 'a')) +- self.assertFalse(hasattr(x, 'b')) +- self.assertFalse(hasattr(x, 'c')) ++ self.assertNotHasAttr(x, "__dict__") ++ self.assertNotHasAttr(x, 'a') ++ self.assertNotHasAttr(x, 'b') ++ self.assertNotHasAttr(x, 'c') + x.a = 1 + x.b = 2 + x.c = 3 +@@ -1057,8 +1065,8 @@ + def get(self): + return self.__a + x = C4(5) +- self.assertFalse(hasattr(x, '__dict__')) +- self.assertFalse(hasattr(x, '__a')) ++ self.assertNotHasAttr(x, '__dict__') ++ self.assertNotHasAttr(x, '__a') + self.assertEqual(x.get(), 5) + try: + x.__a = 6 +@@ -1130,7 +1138,7 @@ + x = C() + x.foo = 5 + self.assertEqual(x.foo, 5) +- self.assertTrue(type(slots[0]) is str) ++ self.assertIs(type(slots[0]), str) + # this used to leak references + try: + class C(object): +@@ -1222,16 +1230,16 @@ + class D(object): + __slots__ = ["__dict__"] + a = D() +- self.assertTrue(hasattr(a, "__dict__")) +- self.assertFalse(hasattr(a, "__weakref__")) ++ self.assertHasAttr(a, "__dict__") ++ self.assertNotHasAttr(a, "__weakref__") + a.foo = 42 + self.assertEqual(a.__dict__, {"foo": 42}) + + class W(object): + __slots__ = ["__weakref__"] + a = W() +- self.assertTrue(hasattr(a, "__weakref__")) +- self.assertFalse(hasattr(a, "__dict__")) ++ self.assertHasAttr(a, "__weakref__") ++ self.assertNotHasAttr(a, "__dict__") + try: + a.foo = 42 + except AttributeError: +@@ -1242,16 +1250,16 @@ + class C1(W, D): + __slots__ = [] + a = C1() +- self.assertTrue(hasattr(a, "__dict__")) +- self.assertTrue(hasattr(a, "__weakref__")) ++ self.assertHasAttr(a, "__dict__") ++ self.assertHasAttr(a, "__weakref__") + a.foo = 42 + self.assertEqual(a.__dict__, {"foo": 42}) + + class C2(D, W): + __slots__ = [] + a = C2() +- self.assertTrue(hasattr(a, "__dict__")) +- self.assertTrue(hasattr(a, "__weakref__")) ++ self.assertHasAttr(a, "__dict__") ++ self.assertHasAttr(a, "__weakref__") + a.foo = 42 + self.assertEqual(a.__dict__, {"foo": 42}) + +@@ -1289,7 +1297,7 @@ + class C(object): + pass + a = C() +- self.assertFalse(hasattr(a, "foobar")) ++ self.assertNotHasAttr(a, "foobar") + C.foobar = 2 + self.assertEqual(a.foobar, 2) + C.method = lambda self: 42 +@@ -1299,7 +1307,7 @@ + C.__int__ = lambda self: 100 + self.assertEqual(int(a), 100) + self.assertEqual(a.foobar, 2) +- self.assertFalse(hasattr(a, "spam")) ++ self.assertNotHasAttr(a, "spam") + def mygetattr(self, name): + if name == "spam": + return "spam" +@@ -1450,7 +1458,7 @@ + self.assertEqual(cm.x, 42) + self.assertEqual(cm.__dict__, {"x" : 42}) + del cm.x +- self.assertFalse(hasattr(cm, "x")) ++ self.assertNotHasAttr(cm, "x") + + @support.impl_detail("the module 'xxsubtype' is internal") + def test_classmethods_in_c(self): +@@ -1505,7 +1513,7 @@ + self.assertEqual(sm.x, 42) + self.assertEqual(sm.__dict__, {"x" : 42}) + del sm.x +- self.assertFalse(hasattr(sm, "x")) ++ self.assertNotHasAttr(sm, "x") + + @support.impl_detail("the module 'xxsubtype' is internal") + def test_staticmethods_in_c(self): +@@ -1575,7 +1583,7 @@ + self.assertEqual(a.x, 10) + self.assertEqual(a.x, 11) + del a.x +- self.assertEqual(hasattr(a, 'x'), 0) ++ self.assertNotHasAttr(a, 'x') + + def test_newslots(self): + # Testing __new__ slot override... +@@ -1845,17 +1853,17 @@ + raise IndexError + c1 = C() + c2 = C() +- self.assertTrue(not not c1) # What? ++ self.assertFalse(not c1) + self.assertNotEqual(id(c1), id(c2)) + hash(c1) + hash(c2) + self.assertEqual(c1, c1) + self.assertTrue(c1 != c2) +- self.assertTrue(not c1 != c1) +- self.assertTrue(not c1 == c2) ++ self.assertFalse(c1 != c1) ++ self.assertFalse(c1 == c2) + # Note that the module name appears in str/repr, and that varies + # depending on whether this test is run standalone or from a framework. +- self.assertTrue(str(c1).find('C object at ') >= 0) ++ self.assertGreaterEqual(str(c1).find('C object at '), 0) + self.assertEqual(str(c1), repr(c1)) + self.assertNotIn(-1, c1) + for i in range(10): +@@ -1868,17 +1876,17 @@ + raise IndexError + d1 = D() + d2 = D() +- self.assertTrue(not not d1) ++ self.assertFalse(not d1) + self.assertNotEqual(id(d1), id(d2)) + hash(d1) + hash(d2) + self.assertEqual(d1, d1) + self.assertNotEqual(d1, d2) +- self.assertTrue(not d1 != d1) +- self.assertTrue(not d1 == d2) ++ self.assertFalse(d1 != d1) ++ self.assertFalse(d1 == d2) + # Note that the module name appears in str/repr, and that varies + # depending on whether this test is run standalone or from a framework. +- self.assertTrue(str(d1).find('D object at ') >= 0) ++ self.assertGreaterEqual(str(d1).find('D object at '), 0) + self.assertEqual(str(d1), repr(d1)) + self.assertNotIn(-1, d1) + for i in range(10): +@@ -1914,11 +1922,11 @@ + p1 = Proxy(1) + p_1 = Proxy(-1) + self.assertFalse(p0) +- self.assertTrue(not not p1) ++ self.assertFalse(not p1) + self.assertEqual(hash(p0), hash(0)) + self.assertEqual(p0, p0) + self.assertNotEqual(p0, p1) +- self.assertTrue(not p0 != p0) ++ self.assertFalse(p0 != p0) + self.assertEqual(not p0, p1) + self.assertTrue(p0 < p1) + self.assertTrue(p0 <= p1) +@@ -1950,7 +1958,7 @@ + try: + weakref.ref(no) + except TypeError as msg: +- self.assertTrue(str(msg).find("weak reference") >= 0) ++ self.assertIn("weak reference", str(msg)) + else: + self.fail("weakref.ref(no) should be illegal") + class Weak(object): +@@ -1974,17 +1982,17 @@ + del self.__x + x = property(getx, setx, delx, doc="I'm the x property.") + a = C() +- self.assertFalse(hasattr(a, "x")) ++ self.assertNotHasAttr(a, "x") + a.x = 42 + self.assertEqual(a._C__x, 42) + self.assertEqual(a.x, 42) + del a.x +- self.assertFalse(hasattr(a, "x")) +- self.assertFalse(hasattr(a, "_C__x")) ++ self.assertNotHasAttr(a, "x") ++ self.assertNotHasAttr(a, "_C__x") + C.x.__set__(a, 100) + self.assertEqual(C.x.__get__(a), 100) + C.x.__delete__(a) +- self.assertFalse(hasattr(a, "x")) ++ self.assertNotHasAttr(a, "x") + + raw = C.__dict__['x'] + self.assertIsInstance(raw, property) +@@ -1996,9 +2004,9 @@ + self.assertIn("fdel", attrs) + + self.assertEqual(raw.__doc__, "I'm the x property.") +- self.assertTrue(raw.fget is C.__dict__['getx']) +- self.assertTrue(raw.fset is C.__dict__['setx']) +- self.assertTrue(raw.fdel is C.__dict__['delx']) ++ self.assertIs(raw.fget, C.__dict__['getx']) ++ self.assertIs(raw.fset, C.__dict__['setx']) ++ self.assertIs(raw.fdel, C.__dict__['delx']) + + for attr in "__doc__", "fget", "fset", "fdel": + try: +@@ -2062,14 +2070,14 @@ + del self._foo + c = C() + self.assertEqual(C.foo.__doc__, "hello") +- self.assertFalse(hasattr(c, "foo")) ++ self.assertNotHasAttr(c, "foo") + c.foo = -42 +- self.assertTrue(hasattr(c, '_foo')) ++ self.assertHasAttr(c, '_foo') + self.assertEqual(c._foo, 42) + self.assertEqual(c.foo, 42) + del c.foo +- self.assertFalse(hasattr(c, '_foo')) +- self.assertFalse(hasattr(c, "foo")) ++ self.assertNotHasAttr(c, '_foo') ++ self.assertNotHasAttr(c, "foo") + + class D(C): + @C.foo.deleter +@@ -2421,13 +2429,13 @@ + a = hexint(12345) + self.assertEqual(a, 12345) + self.assertEqual(int(a), 12345) +- self.assertTrue(int(a).__class__ is int) ++ self.assertIs(int(a).__class__, int) + self.assertEqual(hash(a), hash(12345)) +- self.assertTrue((+a).__class__ is int) +- self.assertTrue((a >> 0).__class__ is int) +- self.assertTrue((a << 0).__class__ is int) +- self.assertTrue((hexint(0) << 12).__class__ is int) +- self.assertTrue((hexint(0) >> 12).__class__ is int) ++ self.assertIs((+a).__class__, int) ++ self.assertIs((a >> 0).__class__, int) ++ self.assertIs((a << 0).__class__, int) ++ self.assertIs((hexint(0) << 12).__class__, int) ++ self.assertIs((hexint(0) >> 12).__class__, int) + + class octlong(int): + __slots__ = [] +@@ -2444,31 +2452,31 @@ + self.assertEqual(a, 12345) + self.assertEqual(int(a), 12345) + self.assertEqual(hash(a), hash(12345)) +- self.assertTrue(int(a).__class__ is int) +- self.assertTrue((+a).__class__ is int) +- self.assertTrue((-a).__class__ is int) +- self.assertTrue((-octlong(0)).__class__ is int) +- self.assertTrue((a >> 0).__class__ is int) +- self.assertTrue((a << 0).__class__ is int) +- self.assertTrue((a - 0).__class__ is int) +- self.assertTrue((a * 1).__class__ is int) +- self.assertTrue((a ** 1).__class__ is int) +- self.assertTrue((a // 1).__class__ is int) +- self.assertTrue((1 * a).__class__ is int) +- self.assertTrue((a | 0).__class__ is int) +- self.assertTrue((a ^ 0).__class__ is int) +- self.assertTrue((a & -1).__class__ is int) +- self.assertTrue((octlong(0) << 12).__class__ is int) +- self.assertTrue((octlong(0) >> 12).__class__ is int) +- self.assertTrue(abs(octlong(0)).__class__ is int) ++ self.assertIs(int(a).__class__, int) ++ self.assertIs((+a).__class__, int) ++ self.assertIs((-a).__class__, int) ++ self.assertIs((-octlong(0)).__class__, int) ++ self.assertIs((a >> 0).__class__, int) ++ self.assertIs((a << 0).__class__, int) ++ self.assertIs((a - 0).__class__, int) ++ self.assertIs((a * 1).__class__, int) ++ self.assertIs((a ** 1).__class__, int) ++ self.assertIs((a // 1).__class__, int) ++ self.assertIs((1 * a).__class__, int) ++ self.assertIs((a | 0).__class__, int) ++ self.assertIs((a ^ 0).__class__, int) ++ self.assertIs((a & -1).__class__, int) ++ self.assertIs((octlong(0) << 12).__class__, int) ++ self.assertIs((octlong(0) >> 12).__class__, int) ++ self.assertIs(abs(octlong(0)).__class__, int) + + # Because octlong overrides __add__, we can't check the absence of +0 + # optimizations using octlong. + class longclone(int): + pass + a = longclone(1) +- self.assertTrue((a + 0).__class__ is int) +- self.assertTrue((0 + a).__class__ is int) ++ self.assertIs((a + 0).__class__, int) ++ self.assertIs((0 + a).__class__, int) + + # Check that negative clones don't segfault + a = longclone(-1) +@@ -2485,9 +2493,9 @@ + a = precfloat(12345) + self.assertEqual(a, 12345.0) + self.assertEqual(float(a), 12345.0) +- self.assertTrue(float(a).__class__ is float) ++ self.assertIs(float(a).__class__, float) + self.assertEqual(hash(a), hash(12345.0)) +- self.assertTrue((+a).__class__ is float) ++ self.assertIs((+a).__class__, float) + + class madcomplex(complex): + def __repr__(self): +@@ -2535,20 +2543,20 @@ + self.assertEqual(v, t) + a = madtuple((1,2,3,4,5)) + self.assertEqual(tuple(a), (1,2,3,4,5)) +- self.assertTrue(tuple(a).__class__ is tuple) ++ self.assertIs(tuple(a).__class__, tuple) + self.assertEqual(hash(a), hash((1,2,3,4,5))) +- self.assertTrue(a[:].__class__ is tuple) +- self.assertTrue((a * 1).__class__ is tuple) +- self.assertTrue((a * 0).__class__ is tuple) +- self.assertTrue((a + ()).__class__ is tuple) ++ self.assertIs(a[:].__class__, tuple) ++ self.assertIs((a * 1).__class__, tuple) ++ self.assertIs((a * 0).__class__, tuple) ++ self.assertIs((a + ()).__class__, tuple) + a = madtuple(()) + self.assertEqual(tuple(a), ()) +- self.assertTrue(tuple(a).__class__ is tuple) +- self.assertTrue((a + a).__class__ is tuple) +- self.assertTrue((a * 0).__class__ is tuple) +- self.assertTrue((a * 1).__class__ is tuple) +- self.assertTrue((a * 2).__class__ is tuple) +- self.assertTrue(a[:].__class__ is tuple) ++ self.assertIs(tuple(a).__class__, tuple) ++ self.assertIs((a + a).__class__, tuple) ++ self.assertIs((a * 0).__class__, tuple) ++ self.assertIs((a * 1).__class__, tuple) ++ self.assertIs((a * 2).__class__, tuple) ++ self.assertIs(a[:].__class__, tuple) + + class madstring(str): + _rev = None +@@ -2570,48 +2578,48 @@ + self.assertEqual(u, s) + s = madstring("12345") + self.assertEqual(str(s), "12345") +- self.assertTrue(str(s).__class__ is str) ++ self.assertIs(str(s).__class__, str) + + base = "\x00" * 5 + s = madstring(base) + self.assertEqual(s, base) + self.assertEqual(str(s), base) +- self.assertTrue(str(s).__class__ is str) ++ self.assertIs(str(s).__class__, str) + self.assertEqual(hash(s), hash(base)) + self.assertEqual({s: 1}[base], 1) + self.assertEqual({base: 1}[s], 1) +- self.assertTrue((s + "").__class__ is str) ++ self.assertIs((s + "").__class__, str) + self.assertEqual(s + "", base) +- self.assertTrue(("" + s).__class__ is str) ++ self.assertIs(("" + s).__class__, str) + self.assertEqual("" + s, base) +- self.assertTrue((s * 0).__class__ is str) ++ self.assertIs((s * 0).__class__, str) + self.assertEqual(s * 0, "") +- self.assertTrue((s * 1).__class__ is str) ++ self.assertIs((s * 1).__class__, str) + self.assertEqual(s * 1, base) +- self.assertTrue((s * 2).__class__ is str) ++ self.assertIs((s * 2).__class__, str) + self.assertEqual(s * 2, base + base) +- self.assertTrue(s[:].__class__ is str) ++ self.assertIs(s[:].__class__, str) + self.assertEqual(s[:], base) +- self.assertTrue(s[0:0].__class__ is str) ++ self.assertIs(s[0:0].__class__, str) + self.assertEqual(s[0:0], "") +- self.assertTrue(s.strip().__class__ is str) ++ self.assertIs(s.strip().__class__, str) + self.assertEqual(s.strip(), base) +- self.assertTrue(s.lstrip().__class__ is str) ++ self.assertIs(s.lstrip().__class__, str) + self.assertEqual(s.lstrip(), base) +- self.assertTrue(s.rstrip().__class__ is str) ++ self.assertIs(s.rstrip().__class__, str) + self.assertEqual(s.rstrip(), base) + identitytab = {} +- self.assertTrue(s.translate(identitytab).__class__ is str) ++ self.assertIs(s.translate(identitytab).__class__, str) + self.assertEqual(s.translate(identitytab), base) +- self.assertTrue(s.replace("x", "x").__class__ is str) ++ self.assertIs(s.replace("x", "x").__class__, str) + self.assertEqual(s.replace("x", "x"), base) +- self.assertTrue(s.ljust(len(s)).__class__ is str) ++ self.assertIs(s.ljust(len(s)).__class__, str) + self.assertEqual(s.ljust(len(s)), base) +- self.assertTrue(s.rjust(len(s)).__class__ is str) ++ self.assertIs(s.rjust(len(s)).__class__, str) + self.assertEqual(s.rjust(len(s)), base) +- self.assertTrue(s.center(len(s)).__class__ is str) ++ self.assertIs(s.center(len(s)).__class__, str) + self.assertEqual(s.center(len(s)), base) +- self.assertTrue(s.lower().__class__ is str) ++ self.assertIs(s.lower().__class__, str) + self.assertEqual(s.lower(), base) + + class madunicode(str): +@@ -2630,47 +2638,47 @@ + base = "12345" + u = madunicode(base) + self.assertEqual(str(u), base) +- self.assertTrue(str(u).__class__ is str) ++ self.assertIs(str(u).__class__, str) + self.assertEqual(hash(u), hash(base)) + self.assertEqual({u: 1}[base], 1) + self.assertEqual({base: 1}[u], 1) +- self.assertTrue(u.strip().__class__ is str) ++ self.assertIs(u.strip().__class__, str) + self.assertEqual(u.strip(), base) +- self.assertTrue(u.lstrip().__class__ is str) ++ self.assertIs(u.lstrip().__class__, str) + self.assertEqual(u.lstrip(), base) +- self.assertTrue(u.rstrip().__class__ is str) ++ self.assertIs(u.rstrip().__class__, str) + self.assertEqual(u.rstrip(), base) +- self.assertTrue(u.replace("x", "x").__class__ is str) ++ self.assertIs(u.replace("x", "x").__class__, str) + self.assertEqual(u.replace("x", "x"), base) +- self.assertTrue(u.replace("xy", "xy").__class__ is str) ++ self.assertIs(u.replace("xy", "xy").__class__, str) + self.assertEqual(u.replace("xy", "xy"), base) +- self.assertTrue(u.center(len(u)).__class__ is str) ++ self.assertIs(u.center(len(u)).__class__, str) + self.assertEqual(u.center(len(u)), base) +- self.assertTrue(u.ljust(len(u)).__class__ is str) ++ self.assertIs(u.ljust(len(u)).__class__, str) + self.assertEqual(u.ljust(len(u)), base) +- self.assertTrue(u.rjust(len(u)).__class__ is str) ++ self.assertIs(u.rjust(len(u)).__class__, str) + self.assertEqual(u.rjust(len(u)), base) +- self.assertTrue(u.lower().__class__ is str) ++ self.assertIs(u.lower().__class__, str) + self.assertEqual(u.lower(), base) +- self.assertTrue(u.upper().__class__ is str) ++ self.assertIs(u.upper().__class__, str) + self.assertEqual(u.upper(), base) +- self.assertTrue(u.capitalize().__class__ is str) ++ self.assertIs(u.capitalize().__class__, str) + self.assertEqual(u.capitalize(), base) +- self.assertTrue(u.title().__class__ is str) ++ self.assertIs(u.title().__class__, str) + self.assertEqual(u.title(), base) +- self.assertTrue((u + "").__class__ is str) ++ self.assertIs((u + "").__class__, str) + self.assertEqual(u + "", base) +- self.assertTrue(("" + u).__class__ is str) ++ self.assertIs(("" + u).__class__, str) + self.assertEqual("" + u, base) +- self.assertTrue((u * 0).__class__ is str) ++ self.assertIs((u * 0).__class__, str) + self.assertEqual(u * 0, "") +- self.assertTrue((u * 1).__class__ is str) ++ self.assertIs((u * 1).__class__, str) + self.assertEqual(u * 1, base) +- self.assertTrue((u * 2).__class__ is str) ++ self.assertIs((u * 2).__class__, str) + self.assertEqual(u * 2, base + base) +- self.assertTrue(u[:].__class__ is str) ++ self.assertIs(u[:].__class__, str) + self.assertEqual(u[:], base) +- self.assertTrue(u[0:0].__class__ is str) ++ self.assertIs(u[0:0].__class__, str) + self.assertEqual(u[0:0], "") + + class sublist(list): +@@ -2846,13 +2854,13 @@ + for x in 1, 2, 3: + for y in 1, 2, 3: + for op in "<", "<=", "==", "!=", ">", ">=": +- self.assertTrue(eval("c[x] %s c[y]" % op) == ++ self.assertEqual(eval("c[x] %s c[y]" % op), + eval("x %s y" % op), + "x=%d, y=%d" % (x, y)) +- self.assertTrue(eval("c[x] %s y" % op) == ++ self.assertEqual(eval("c[x] %s y" % op), + eval("x %s y" % op), + "x=%d, y=%d" % (x, y)) +- self.assertTrue(eval("x %s c[y]" % op) == ++ self.assertEqual(eval("x %s c[y]" % op), + eval("x %s y" % op), + "x=%d, y=%d" % (x, y)) + +@@ -2925,12 +2933,15 @@ + for x in 1, 2, 3: + for y in 1, 2, 3: + for op in "<", "<=", "==", "!=", ">", ">=": +- self.assertTrue(eval("c[x] %s c[y]" % op) == eval("x %s y" % op), +- "x=%d, y=%d" % (x, y)) +- self.assertTrue(eval("c[x] %s y" % op) == eval("x %s y" % op), +- "x=%d, y=%d" % (x, y)) +- self.assertTrue(eval("x %s c[y]" % op) == eval("x %s y" % op), +- "x=%d, y=%d" % (x, y)) ++ self.assertEqual(eval("c[x] %s c[y]" % op), ++ eval("x %s y" % op), ++ "x=%d, y=%d" % (x, y)) ++ self.assertEqual(eval("c[x] %s y" % op), ++ eval("x %s y" % op), ++ "x=%d, y=%d" % (x, y)) ++ self.assertEqual(eval("x %s c[y]" % op), ++ eval("x %s y" % op), ++ "x=%d, y=%d" % (x, y)) + + def test_descrdoc(self): + # Testing descriptor doc strings... +@@ -2969,9 +2980,9 @@ + for cls2 in C, D, E, F: + x = cls() + x.__class__ = cls2 +- self.assertTrue(x.__class__ is cls2) ++ self.assertIs(x.__class__, cls2) + x.__class__ = cls +- self.assertTrue(x.__class__ is cls) ++ self.assertIs(x.__class__, cls) + def cant(x, C): + try: + x.__class__ = C +@@ -3027,11 +3038,11 @@ + x = cls() + x.a = 1 + x.__class__ = cls2 +- self.assertTrue(x.__class__ is cls2, ++ self.assertIs(x.__class__, cls2, + "assigning %r as __class__ for %r silently failed" % (cls2, x)) + self.assertEqual(x.a, 1) + x.__class__ = cls +- self.assertTrue(x.__class__ is cls, ++ self.assertIs(x.__class__, cls, + "assigning %r as __class__ for %r silently failed" % (cls, x)) + self.assertEqual(x.a, 1) + for cls in G, J, K, L, M, N, P, R, list, Int: +@@ -3200,7 +3211,7 @@ + for cls in C, C1, C2: + s = pickle.dumps(cls, bin) + cls2 = pickle.loads(s) +- self.assertTrue(cls2 is cls) ++ self.assertIs(cls2, cls) + + a = C1(1, 2); a.append(42); a.append(24) + b = C2("hello", "world", 42) +@@ -3230,7 +3241,7 @@ + import copy + for cls in C, C1, C2: + cls2 = copy.deepcopy(cls) +- self.assertTrue(cls2 is cls) ++ self.assertIs(cls2, cls) + + a = C1(1, 2); a.append(42); a.append(24) + b = C2("hello", "world", 42) +@@ -3290,7 +3301,7 @@ + # Now it should work + x = C() + y = pickle.loads(pickle.dumps(x)) +- self.assertEqual(hasattr(y, 'a'), 0) ++ self.assertNotHasAttr(y, 'a') + x.a = 42 + y = pickle.loads(pickle.dumps(x)) + self.assertEqual(y.a, 42) +@@ -3590,9 +3601,9 @@ + from types import ModuleType as M + m = M.__new__(M) + str(m) +- self.assertEqual(hasattr(m, "__name__"), 0) +- self.assertEqual(hasattr(m, "__file__"), 0) +- self.assertEqual(hasattr(m, "foo"), 0) ++ self.assertNotHasAttr(m, "__name__") ++ self.assertNotHasAttr(m, "__file__") ++ self.assertNotHasAttr(m, "foo") + self.assertFalse(m.__dict__) # None or {} are both reasonable answers + m.foo = 1 + self.assertEqual(m.__dict__, {"foo": 1}) +@@ -3772,8 +3783,8 @@ + __slots__=() + if support.check_impl_detail(): + self.assertEqual(C.__basicsize__, B.__basicsize__) +- self.assertTrue(hasattr(C, '__dict__')) +- self.assertTrue(hasattr(C, '__weakref__')) ++ self.assertHasAttr(C, '__dict__') ++ self.assertHasAttr(C, '__weakref__') + C().x = 2 + + def test_rmul(self): +@@ -4251,7 +4262,7 @@ + self.assertEqual(c.attr, 1) + # this makes a crash more likely: + support.gc_collect() +- self.assertEqual(hasattr(c, 'attr'), False) ++ self.assertNotHasAttr(c, 'attr') + + def test_init(self): + # SF 1155938 +@@ -4274,17 +4285,17 @@ + l = [] + self.assertEqual(l.__add__, l.__add__) + self.assertEqual(l.__add__, [].__add__) +- self.assertTrue(l.__add__ != [5].__add__) +- self.assertTrue(l.__add__ != l.__mul__) +- self.assertTrue(l.__add__.__name__ == '__add__') ++ self.assertNotEqual(l.__add__, [5].__add__) ++ self.assertNotEqual(l.__add__, l.__mul__) ++ self.assertEqual(l.__add__.__name__, '__add__') + if hasattr(l.__add__, '__self__'): + # CPython +- self.assertTrue(l.__add__.__self__ is l) +- self.assertTrue(l.__add__.__objclass__ is list) ++ self.assertIs(l.__add__.__self__, l) ++ self.assertIs(l.__add__.__objclass__, list) + else: + # Python implementations where [].__add__ is a normal bound method +- self.assertTrue(l.__add__.im_self is l) +- self.assertTrue(l.__add__.im_class is list) ++ self.assertIs(l.__add__.im_self, l) ++ self.assertIs(l.__add__.im_class, list) + self.assertEqual(l.__add__.__doc__, list.__add__.__doc__) + try: + hash(l.__add__) +@@ -4451,7 +4462,7 @@ + + fake_str = FakeStr() + # isinstance() reads __class__ +- self.assertTrue(isinstance(fake_str, str)) ++ self.assertIsInstance(fake_str, str) + + # call a method descriptor + with self.assertRaises(TypeError): +diff -r c3896275c0f6 Lib/test/test_dis.py +--- a/Lib/test/test_dis.py ++++ b/Lib/test/test_dis.py +@@ -217,16 +217,18 @@ + def test_bug_708901(self): + self.do_disassembly_test(bug708901, dis_bug708901) + ++ # Test has been disabled due to change in the way ++ # list comps are handled. The byte code now includes ++ # a memory address and a file location, so they change from ++ # run to run. ++ @unittest.skip('disabled due to a change in the way list comps are handled') + def test_bug_1333982(self): + # XXX: re-enable this test! + # This one is checking bytecodes generated for an `assert` statement, + # so fails if the tests are run with -O. Skip this test then. +- pass # Test has been disabled due to change in the way +- # list comps are handled. The byte code now includes +- # a memory address and a file location, so they change from +- # run to run. +- # if __debug__: +- # self.do_disassembly_test(bug1333982, dis_bug1333982) ++ ++ if __debug__: ++ self.do_disassembly_test(bug1333982, dis_bug1333982) + + def test_big_linenos(self): + def func(count): +diff -r c3896275c0f6 Lib/test/test_doctest.py +--- a/Lib/test/test_doctest.py ++++ b/Lib/test/test_doctest.py +@@ -1020,6 +1020,33 @@ + ValueError: message + TestResults(failed=1, attempted=1) + ++If the exception does not have a message, you can still use ++IGNORE_EXCEPTION_DETAIL to normalize the modules between Python 2 and 3: ++ ++ >>> def f(x): ++ ... r''' ++ ... >>> from http.client import HTTPException ++ ... >>> raise HTTPException() #doctest: +IGNORE_EXCEPTION_DETAIL ++ ... Traceback (most recent call last): ++ ... foo.bar.HTTPException ++ ... ''' ++ >>> test = doctest.DocTestFinder().find(f)[0] ++ >>> doctest.DocTestRunner(verbose=False).run(test) ++ TestResults(failed=0, attempted=2) ++ ++Note that a trailing colon doesn't matter either: ++ ++ >>> def f(x): ++ ... r''' ++ ... >>> from http.client import HTTPException ++ ... >>> raise HTTPException() #doctest: +IGNORE_EXCEPTION_DETAIL ++ ... Traceback (most recent call last): ++ ... foo.bar.HTTPException: ++ ... ''' ++ >>> test = doctest.DocTestFinder().find(f)[0] ++ >>> doctest.DocTestRunner(verbose=False).run(test) ++ TestResults(failed=0, attempted=2) ++ + If an exception is raised but not expected, then it is reported as an + unexpected exception: + +diff -r c3896275c0f6 Lib/test/test_email/test_defect_handling.py +--- a/Lib/test/test_email/test_defect_handling.py ++++ b/Lib/test/test_email/test_defect_handling.py +@@ -59,8 +59,8 @@ + inner = msg.get_payload(0) + self.assertTrue(hasattr(inner, 'defects')) + self.assertEqual(len(self.get_defects(inner)), 1) +- self.assertTrue(isinstance(self.get_defects(inner)[0], +- errors.StartBoundaryNotFoundDefect)) ++ self.assertIsInstance(self.get_defects(inner)[0], ++ errors.StartBoundaryNotFoundDefect) + + def test_multipart_no_boundary(self): + source = textwrap.dedent("""\ +@@ -84,12 +84,12 @@ + with self._raise_point(errors.NoBoundaryInMultipartDefect): + msg = self._str_msg(source) + if self.raise_expected: return +- self.assertTrue(isinstance(msg.get_payload(), str)) ++ self.assertIsInstance(msg.get_payload(), str) + self.assertEqual(len(self.get_defects(msg)), 2) +- self.assertTrue(isinstance(self.get_defects(msg)[0], +- errors.NoBoundaryInMultipartDefect)) +- self.assertTrue(isinstance(self.get_defects(msg)[1], +- errors.MultipartInvariantViolationDefect)) ++ self.assertIsInstance(self.get_defects(msg)[0], ++ errors.NoBoundaryInMultipartDefect) ++ self.assertIsInstance(self.get_defects(msg)[1], ++ errors.MultipartInvariantViolationDefect) + + multipart_msg = textwrap.dedent("""\ + Date: Wed, 14 Nov 2007 12:56:23 GMT +@@ -153,10 +153,10 @@ + if self.raise_expected: return + self.assertTrue(hasattr(msg, 'defects')) + self.assertEqual(len(self.get_defects(msg)), 2) +- self.assertTrue(isinstance(self.get_defects(msg)[0], +- errors.NoBoundaryInMultipartDefect)) +- self.assertTrue(isinstance(self.get_defects(msg)[1], +- errors.MultipartInvariantViolationDefect)) ++ self.assertIsInstance(self.get_defects(msg)[0], ++ errors.NoBoundaryInMultipartDefect) ++ self.assertIsInstance(self.get_defects(msg)[1], ++ errors.MultipartInvariantViolationDefect) + + def test_missing_start_boundary(self): + source = textwrap.dedent("""\ +@@ -193,8 +193,8 @@ + if self.raise_expected: return + bad = outer.get_payload(1).get_payload(0) + self.assertEqual(len(self.get_defects(bad)), 1) +- self.assertTrue(isinstance(self.get_defects(bad)[0], +- errors.StartBoundaryNotFoundDefect)) ++ self.assertIsInstance(self.get_defects(bad)[0], ++ errors.StartBoundaryNotFoundDefect) + + def test_first_line_is_continuation_header(self): + with self._raise_point(errors.FirstHeaderLineIsContinuationDefect): +diff -r c3896275c0f6 Lib/test/test_email/test_email.py +--- a/Lib/test/test_email/test_email.py ++++ b/Lib/test/test_email/test_email.py +@@ -241,12 +241,12 @@ + msg['From'] = 'Me' + msg['to'] = 'You' + # Check for case insensitivity +- self.assertTrue('from' in msg) +- self.assertTrue('From' in msg) +- self.assertTrue('FROM' in msg) +- self.assertTrue('to' in msg) +- self.assertTrue('To' in msg) +- self.assertTrue('TO' in msg) ++ self.assertIn('from', msg) ++ self.assertIn('From', msg) ++ self.assertIn('FROM', msg) ++ self.assertIn('to', msg) ++ self.assertIn('To', msg) ++ self.assertIn('TO', msg) + + def test_as_string(self): + eq = self.ndiffAssertEqual +@@ -339,12 +339,11 @@ + self.assertEqual(msg.get_param('bar'), 'baz"foobar"baz') + + def test_field_containment(self): +- unless = self.assertTrue + msg = email.message_from_string('Header: exists') +- unless('header' in msg) +- unless('Header' in msg) +- unless('HEADER' in msg) +- self.assertFalse('headerx' in msg) ++ self.assertIn('header', msg) ++ self.assertIn('Header', msg) ++ self.assertIn('HEADER', msg) ++ self.assertNotIn('headerx', msg) + + def test_set_param(self): + eq = self.assertEqual +@@ -1400,7 +1399,6 @@ + + def test_add_header(self): + eq = self.assertEqual +- unless = self.assertTrue + self._au.add_header('Content-Disposition', 'attachment', + filename='audiotest.au') + eq(self._au['content-disposition'], +@@ -1411,12 +1409,12 @@ + 'audiotest.au') + missing = [] + eq(self._au.get_param('attachment', header='content-disposition'), '') +- unless(self._au.get_param('foo', failobj=missing, +- header='content-disposition') is missing) ++ self.assertIs(self._au.get_param('foo', failobj=missing, ++ header='content-disposition'), missing) + # Try some missing stuff +- unless(self._au.get_param('foobar', missing) is missing) +- unless(self._au.get_param('attachment', missing, +- header='foobar') is missing) ++ self.assertIs(self._au.get_param('foobar', missing), missing) ++ self.assertIs(self._au.get_param('attachment', missing, ++ header='foobar'), missing) + + + +@@ -1441,7 +1439,6 @@ + + def test_add_header(self): + eq = self.assertEqual +- unless = self.assertTrue + self._im.add_header('Content-Disposition', 'attachment', + filename='dingusfish.gif') + eq(self._im['content-disposition'], +@@ -1452,12 +1449,12 @@ + 'dingusfish.gif') + missing = [] + eq(self._im.get_param('attachment', header='content-disposition'), '') +- unless(self._im.get_param('foo', failobj=missing, +- header='content-disposition') is missing) ++ self.assertIs(self._im.get_param('foo', failobj=missing, ++ header='content-disposition'), missing) + # Try some missing stuff +- unless(self._im.get_param('foobar', missing) is missing) +- unless(self._im.get_param('attachment', missing, +- header='foobar') is missing) ++ self.assertIs(self._im.get_param('foobar', missing), missing) ++ self.assertIs(self._im.get_param('attachment', missing, ++ header='foobar'), missing) + + + +@@ -1548,17 +1545,16 @@ + + def test_types(self): + eq = self.assertEqual +- unless = self.assertTrue + eq(self._msg.get_content_type(), 'text/plain') + eq(self._msg.get_param('charset'), 'us-ascii') + missing = [] +- unless(self._msg.get_param('foobar', missing) is missing) +- unless(self._msg.get_param('charset', missing, header='foobar') +- is missing) ++ self.assertIs(self._msg.get_param('foobar', missing), missing) ++ self.assertIs(self._msg.get_param('charset', missing, header='foobar'), ++ missing) + + def test_payload(self): + self.assertEqual(self._msg.get_payload(), 'hello there') +- self.assertTrue(not self._msg.is_multipart()) ++ self.assertFalse(self._msg.is_multipart()) + + def test_charset(self): + eq = self.assertEqual +@@ -1577,7 +1573,7 @@ + msg = MIMEText('hello there') + eq(msg.get_charset(), 'us-ascii') + eq(msg['content-type'], 'text/plain; charset="us-ascii"') +- self.assertTrue('hello there' in msg.as_string()) ++ self.assertIn('hello there', msg.as_string()) + + def test_utf8_input(self): + teststr = '\u043a\u0438\u0440\u0438\u043b\u0438\u0446\u0430' +@@ -1636,21 +1632,20 @@ + def test_hierarchy(self): + # convenience + eq = self.assertEqual +- unless = self.assertTrue + raises = self.assertRaises + # tests + m = self._msg +- unless(m.is_multipart()) ++ self.assertTrue(m.is_multipart()) + eq(m.get_content_type(), 'multipart/mixed') + eq(len(m.get_payload()), 2) + raises(IndexError, m.get_payload, 2) + m0 = m.get_payload(0) + m1 = m.get_payload(1) +- unless(m0 is self._txt) +- unless(m1 is self._im) ++ self.assertIs(m0, self._txt) ++ self.assertIs(m1, self._im) + eq(m.get_payload(), [m0, m1]) +- unless(not m0.is_multipart()) +- unless(not m1.is_multipart()) ++ self.assertFalse(m0.is_multipart()) ++ self.assertFalse(m1.is_multipart()) + + def test_empty_multipart_idempotent(self): + text = """\ +@@ -1982,25 +1977,23 @@ + + # test_defect_handling + def test_same_boundary_inner_outer(self): +- unless = self.assertTrue + msg = self._msgobj('msg_15.txt') + # XXX We can probably eventually do better + inner = msg.get_payload(0) +- unless(hasattr(inner, 'defects')) ++ self.assertTrue(hasattr(inner, 'defects')) + self.assertEqual(len(inner.defects), 1) +- unless(isinstance(inner.defects[0], +- errors.StartBoundaryNotFoundDefect)) ++ self.assertIsInstance(inner.defects[0], ++ errors.StartBoundaryNotFoundDefect) + + # test_defect_handling + def test_multipart_no_boundary(self): +- unless = self.assertTrue + msg = self._msgobj('msg_25.txt') +- unless(isinstance(msg.get_payload(), str)) ++ self.assertIsInstance(msg.get_payload(), str) + self.assertEqual(len(msg.defects), 2) +- unless(isinstance(msg.defects[0], +- errors.NoBoundaryInMultipartDefect)) +- unless(isinstance(msg.defects[1], +- errors.MultipartInvariantViolationDefect)) ++ self.assertIsInstance(msg.defects[0], ++ errors.NoBoundaryInMultipartDefect) ++ self.assertIsInstance(msg.defects[1], ++ errors.MultipartInvariantViolationDefect) + + multipart_msg = textwrap.dedent("""\ + Date: Wed, 14 Nov 2007 12:56:23 GMT +@@ -2098,14 +2091,13 @@ + + # test_defect_handling + def test_lying_multipart(self): +- unless = self.assertTrue + msg = self._msgobj('msg_41.txt') +- unless(hasattr(msg, 'defects')) ++ self.assertTrue(hasattr(msg, 'defects')) + self.assertEqual(len(msg.defects), 2) +- unless(isinstance(msg.defects[0], +- errors.NoBoundaryInMultipartDefect)) +- unless(isinstance(msg.defects[1], +- errors.MultipartInvariantViolationDefect)) ++ self.assertIsInstance(msg.defects[0], ++ errors.NoBoundaryInMultipartDefect) ++ self.assertIsInstance(msg.defects[1], ++ errors.MultipartInvariantViolationDefect) + + # test_defect_handling + def test_missing_start_boundary(self): +@@ -2120,8 +2112,8 @@ + # [*] This message is missing its start boundary + bad = outer.get_payload(1).get_payload(0) + self.assertEqual(len(bad.defects), 1) +- self.assertTrue(isinstance(bad.defects[0], +- errors.StartBoundaryNotFoundDefect)) ++ self.assertIsInstance(bad.defects[0], ++ errors.StartBoundaryNotFoundDefect) + + # test_defect_handling + def test_first_line_is_continuation_header(self): +@@ -2288,17 +2280,16 @@ + + def test_valid_argument(self): + eq = self.assertEqual +- unless = self.assertTrue + subject = 'A sub-message' + m = Message() + m['Subject'] = subject + r = MIMEMessage(m) + eq(r.get_content_type(), 'message/rfc822') + payload = r.get_payload() +- unless(isinstance(payload, list)) ++ self.assertIsInstance(payload, list) + eq(len(payload), 1) + subpart = payload[0] +- unless(subpart is m) ++ self.assertIs(subpart, m) + eq(subpart['subject'], subject) + + def test_bad_multipart(self): +@@ -2331,24 +2322,22 @@ + + def test_parse_message_rfc822(self): + eq = self.assertEqual +- unless = self.assertTrue + msg = self._msgobj('msg_11.txt') + eq(msg.get_content_type(), 'message/rfc822') + payload = msg.get_payload() +- unless(isinstance(payload, list)) ++ self.assertIsInstance(payload, list) + eq(len(payload), 1) + submsg = payload[0] +- self.assertTrue(isinstance(submsg, Message)) ++ self.assertIsInstance(submsg, Message) + eq(submsg['subject'], 'An enclosed message') + eq(submsg.get_payload(), 'Here is the body of the message.\n') + + def test_dsn(self): + eq = self.assertEqual +- unless = self.assertTrue + # msg 16 is a Delivery Status Notification, see RFC 1894 + msg = self._msgobj('msg_16.txt') + eq(msg.get_content_type(), 'multipart/report') +- unless(msg.is_multipart()) ++ self.assertTrue(msg.is_multipart()) + eq(len(msg.get_payload()), 3) + # Subpart 1 is a text/plain, human readable section + subpart = msg.get_payload(0) +@@ -2377,13 +2366,13 @@ + # message/delivery-status should treat each block as a bunch of + # headers, i.e. a bunch of Message objects. + dsn1 = subpart.get_payload(0) +- unless(isinstance(dsn1, Message)) ++ self.assertIsInstance(dsn1, Message) + eq(dsn1['original-envelope-id'], '0GK500B4HD0888@cougar.noc.ucla.edu') + eq(dsn1.get_param('dns', header='reporting-mta'), '') + # Try a missing one + eq(dsn1.get_param('nsd', header='reporting-mta'), None) + dsn2 = subpart.get_payload(1) +- unless(isinstance(dsn2, Message)) ++ self.assertIsInstance(dsn2, Message) + eq(dsn2['action'], 'failed') + eq(dsn2.get_params(header='original-recipient'), + [('rfc822', ''), ('jangel1@cougar.noc.ucla.edu', '')]) +@@ -2392,10 +2381,10 @@ + subpart = msg.get_payload(2) + eq(subpart.get_content_type(), 'message/rfc822') + payload = subpart.get_payload() +- unless(isinstance(payload, list)) ++ self.assertIsInstance(payload, list) + eq(len(payload), 1) + subsubpart = payload[0] +- unless(isinstance(subsubpart, Message)) ++ self.assertIsInstance(subsubpart, Message) + eq(subsubpart.get_content_type(), 'text/plain') + eq(subsubpart['message-id'], + '<002001c144a6$8752e060$56104586@oxy.edu>') +@@ -2693,7 +2682,6 @@ + + def test_content_type(self): + eq = self.assertEqual +- unless = self.assertTrue + # Get a message object and reset the seek pointer for other tests + msg, text = self._msgobj('msg_05.txt') + eq(msg.get_content_type(), 'multipart/report') +@@ -2715,29 +2703,28 @@ + eq(msg2.get_payload(), 'Yadda yadda yadda' + self.linesep) + msg3 = msg.get_payload(2) + eq(msg3.get_content_type(), 'message/rfc822') +- self.assertTrue(isinstance(msg3, Message)) ++ self.assertIsInstance(msg3, Message) + payload = msg3.get_payload() +- unless(isinstance(payload, list)) ++ self.assertIsInstance(payload, list) + eq(len(payload), 1) + msg4 = payload[0] +- unless(isinstance(msg4, Message)) ++ self.assertIsInstance(msg4, Message) + eq(msg4.get_payload(), 'Yadda yadda yadda' + self.linesep) + + def test_parser(self): + eq = self.assertEqual +- unless = self.assertTrue + msg, text = self._msgobj('msg_06.txt') + # Check some of the outer headers + eq(msg.get_content_type(), 'message/rfc822') + # Make sure the payload is a list of exactly one sub-Message, and that + # that submessage has a type of text/plain + payload = msg.get_payload() +- unless(isinstance(payload, list)) ++ self.assertIsInstance(payload, list) + eq(len(payload), 1) + msg1 = payload[0] +- self.assertTrue(isinstance(msg1, Message)) ++ self.assertIsInstance(msg1, Message) + eq(msg1.get_content_type(), 'text/plain') +- self.assertTrue(isinstance(msg1.get_payload(), str)) ++ self.assertIsInstance(msg1.get_payload(), str) + eq(msg1.get_payload(), self.linesep) + + +@@ -2768,7 +2755,6 @@ + self.assertEqual(text, s.getvalue()) + + def test_message_from_string_with_class(self): +- unless = self.assertTrue + with openfile('msg_01.txt') as fp: + text = fp.read() + +@@ -2777,35 +2763,34 @@ + pass + + msg = email.message_from_string(text, MyMessage) +- unless(isinstance(msg, MyMessage)) ++ self.assertIsInstance(msg, MyMessage) + # Try something more complicated + with openfile('msg_02.txt') as fp: + text = fp.read() + msg = email.message_from_string(text, MyMessage) + for subpart in msg.walk(): +- unless(isinstance(subpart, MyMessage)) ++ self.assertIsInstance(subpart, MyMessage) + + def test_message_from_file_with_class(self): +- unless = self.assertTrue + # Create a subclass + class MyMessage(Message): + pass + + with openfile('msg_01.txt') as fp: + msg = email.message_from_file(fp, MyMessage) +- unless(isinstance(msg, MyMessage)) ++ self.assertIsInstance(msg, MyMessage) + # Try something more complicated + with openfile('msg_02.txt') as fp: + msg = email.message_from_file(fp, MyMessage) + for subpart in msg.walk(): +- unless(isinstance(subpart, MyMessage)) ++ self.assertIsInstance(subpart, MyMessage) + + def test_custom_message_does_not_require_arguments(self): + class MyMessage(Message): + def __init__(self): + super().__init__() + msg = self._str_msg("Subject: test\n\ntest", MyMessage) +- self.assertTrue(isinstance(msg, MyMessage)) ++ self.assertIsInstance(msg, MyMessage) + + def test__all__(self): + module = __import__('email') +@@ -3295,9 +3280,9 @@ + break + om.append(ol) + n1 += 1 +- self.assertTrue(n == n1) +- self.assertTrue(len(om) == nt) +- self.assertTrue(''.join([il for il, n in imt]) == ''.join(om)) ++ self.assertEqual(n, n1) ++ self.assertEqual(len(om), nt) ++ self.assertEqual(''.join([il for il, n in imt]), ''.join(om)) + + + +@@ -3312,7 +3297,7 @@ + eq(msg['to'], 'ppp@zzz.org') + eq(msg.get_content_type(), 'multipart/mixed') + self.assertFalse(msg.is_multipart()) +- self.assertTrue(isinstance(msg.get_payload(), str)) ++ self.assertIsInstance(msg.get_payload(), str) + + def test_bytes_header_parser(self): + eq = self.assertEqual +@@ -3323,8 +3308,8 @@ + eq(msg['to'], 'ppp@zzz.org') + eq(msg.get_content_type(), 'multipart/mixed') + self.assertFalse(msg.is_multipart()) +- self.assertTrue(isinstance(msg.get_payload(), str)) +- self.assertTrue(isinstance(msg.get_payload(decode=True), bytes)) ++ self.assertIsInstance(msg.get_payload(), str) ++ self.assertIsInstance(msg.get_payload(decode=True), bytes) + + def test_whitespace_continuation(self): + eq = self.assertEqual +@@ -4365,7 +4350,7 @@ + h = Header("I am the very model of a modern Major-General; I've information vegetable, animal, and mineral; I know the kings of England, and I quote the fights historical from Marathon to Waterloo, in order categorical; I'm very well acquainted, too, with matters mathematical; I understand equations, both the simple and quadratical; about binomial theorem I'm teeming with a lot o' news, with many cheerful facts about the square of the hypotenuse.", + maxlinelen=76) + for l in h.encode(splitchars=' ').split('\n '): +- self.assertTrue(len(l) <= 76) ++ self.assertLessEqual(len(l), 76) + + def test_multilingual(self): + eq = self.ndiffAssertEqual +@@ -4834,7 +4819,7 @@ + ''' + msg = email.message_from_string(m) + param = msg.get_param('NAME') +- self.assertFalse(isinstance(param, tuple)) ++ self.assertNotIsInstance(param, tuple) + self.assertEqual( + param, + 'file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm') +@@ -4993,7 +4978,7 @@ + """ + msg = email.message_from_string(m) + param = msg.get_param('name') +- self.assertFalse(isinstance(param, tuple)) ++ self.assertNotIsInstance(param, tuple) + self.assertEqual(param, "Frank's Document") + + # test_headerregistry.TestContentTypeHeader.rfc2231_single_quote_in_value_with_charset_and_lang +@@ -5019,7 +5004,7 @@ + """ + msg = email.message_from_string(m) + param = msg.get_param('name') +- self.assertFalse(isinstance(param, tuple)) ++ self.assertNotIsInstance(param, tuple) + self.assertEqual(param, "us-ascii'en-us'Frank's Document") + + # test_headerregistry.TestContentTypeHeader.rfc2231_single_quotes_inside_quotes +diff -r c3896275c0f6 Lib/test/test_email/test_parser.py +--- a/Lib/test/test_email/test_parser.py ++++ b/Lib/test/test_email/test_parser.py +@@ -18,7 +18,7 @@ + msg = email.message_from_string("Subject: bogus\n\nmsg\n", + self.MyMessage, + policy=self.MyPolicy) +- self.assertTrue(isinstance(msg, self.MyMessage)) ++ self.assertIsInstance(msg, self.MyMessage) + self.assertIs(msg.check_policy, self.MyPolicy) + + def test_custom_message_gets_policy_if_possible_from_file(self): +@@ -26,7 +26,7 @@ + msg = email.message_from_file(source_file, + self.MyMessage, + policy=self.MyPolicy) +- self.assertTrue(isinstance(msg, self.MyMessage)) ++ self.assertIsInstance(msg, self.MyMessage) + self.assertIs(msg.check_policy, self.MyPolicy) + + # XXX add tests for other functions that take Message arg. +diff -r c3896275c0f6 Lib/test/test_email/test_utils.py +--- a/Lib/test/test_email/test_utils.py ++++ b/Lib/test/test_email/test_utils.py +@@ -54,12 +54,12 @@ + def test_localtime_is_tz_aware_daylight_true(self): + test.support.patch(self, time, 'daylight', True) + t = utils.localtime() +- self.assertIsNot(t.tzinfo, None) ++ self.assertIsNotNone(t.tzinfo) + + def test_localtime_is_tz_aware_daylight_false(self): + test.support.patch(self, time, 'daylight', False) + t = utils.localtime() +- self.assertIsNot(t.tzinfo, None) ++ self.assertIsNotNone(t.tzinfo) + + def test_localtime_daylight_true_dst_false(self): + test.support.patch(self, time, 'daylight', True) +diff -r c3896275c0f6 Lib/test/test_enumerate.py +--- a/Lib/test/test_enumerate.py ++++ b/Lib/test/test_enumerate.py +@@ -204,11 +204,10 @@ + self.assertRaises(TypeError, reversed) + self.assertRaises(TypeError, reversed, [], 'extra') + ++ @unittest.skipUnless(hasattr(sys, 'getrefcount'), 'test needs sys.getrefcount()') + def test_bug1229429(self): + # this bug was never in reversed, it was in + # PyObject_CallMethod, and reversed_new calls that sometimes. +- if not hasattr(sys, "getrefcount"): +- return + def f(): + pass + r = f.__reversed__ = object() +diff -r c3896275c0f6 Lib/test/test_fileio.py +--- a/Lib/test/test_fileio.py ++++ b/Lib/test/test_fileio.py +@@ -341,8 +341,7 @@ + try: + fn = TESTFN.encode("ascii") + except UnicodeEncodeError: +- # Skip test +- return ++ self.skipTest('could not encode %r to ascii' % TESTFN) + f = _FileIO(fn, "w") + try: + f.write(b"abc") +diff -r c3896275c0f6 Lib/test/test_float.py +--- a/Lib/test/test_float.py ++++ b/Lib/test/test_float.py +@@ -70,7 +70,7 @@ + # it still has to accept the normal python syntax + import locale + if not locale.localeconv()['decimal_point'] == ',': +- return ++ self.skipTest('decimal_point is not ","') + + self.assertEqual(float(" 3.14 "), 3.14) + self.assertEqual(float("+3.14 "), 3.14) +diff -r c3896275c0f6 Lib/test/test_ftplib.py +--- a/Lib/test/test_ftplib.py ++++ b/Lib/test/test_ftplib.py +@@ -16,7 +16,7 @@ + except ImportError: + ssl = None + +-from unittest import TestCase ++from unittest import TestCase, skipUnless + from test import support + from test.support import HOST, HOSTv6 + threading = support.import_module('threading') +@@ -779,6 +779,7 @@ + self.assertRaises(ftplib.Error, self.client.storlines, 'stor', f) + + ++@skipUnless(support.IPV6_ENABLED, "IPv6 not enabled") + class TestIPv6Environment(TestCase): + + def setUp(self): +@@ -819,6 +820,7 @@ + retr() + + ++@skipUnless(ssl, "SSL not available") + class TestTLS_FTPClassMixin(TestFTPClass): + """Repeat TestFTPClass tests starting the TLS layer for both control + and data connections first. +@@ -834,6 +836,7 @@ + self.client.prot_p() + + ++@skipUnless(ssl, "SSL not available") + class TestTLS_FTPClass(TestCase): + """Specific TLS_FTP class tests.""" + +@@ -1015,12 +1018,9 @@ + + + def test_main(): +- tests = [TestFTPClass, TestTimeouts] +- if support.IPV6_ENABLED: +- tests.append(TestIPv6Environment) +- +- if ssl is not None: +- tests.extend([TestTLS_FTPClassMixin, TestTLS_FTPClass]) ++ tests = [TestFTPClass, TestTimeouts, ++ TestIPv6Environment, ++ TestTLS_FTPClassMixin, TestTLS_FTPClass] + + thread_info = support.threading_setup() + try: +diff -r c3896275c0f6 Lib/test/test_functools.py +--- a/Lib/test/test_functools.py ++++ b/Lib/test/test_functools.py +@@ -45,8 +45,6 @@ + self.assertEqual(p.args, (1, 2)) + self.assertEqual(p.keywords, dict(a=10, b=20)) + # attributes should not be writable +- if not isinstance(self.thetype, type): +- return + self.assertRaises(AttributeError, setattr, p, 'func', map) + self.assertRaises(AttributeError, setattr, p, 'args', (1, 2)) + self.assertRaises(AttributeError, setattr, p, 'keywords', dict(a=1, b=2)) +@@ -210,11 +208,13 @@ + thetype = PythonPartial + + # the python version hasn't a nice repr +- def test_repr(self): pass ++ test_repr = None + + # the python version isn't picklable +- def test_pickle(self): pass +- def test_setstate_refcount(self): pass ++ test_pickle = test_setstate_refcount = None ++ ++ # the python version isn't a type ++ test_attributes = None + + class TestUpdateWrapper(unittest.TestCase): + +diff -r c3896275c0f6 Lib/test/test_gdb.py +--- a/Lib/test/test_gdb.py ++++ b/Lib/test/test_gdb.py +@@ -59,7 +59,7 @@ + return out.decode('utf-8', 'replace'), err.decode('utf-8', 'replace') + + # Verify that "gdb" was built with the embedded python support enabled: +-gdbpy_version, _ = run_gdb("--eval-command=python import sys; print sys.version_info") ++gdbpy_version, _ = run_gdb("--eval-command=python import sys; print(sys.version_info)") + if not gdbpy_version: + raise unittest.SkipTest("gdb not built with embedded python support") + +@@ -141,7 +141,7 @@ + args += [script] + + # print args +- # print ' '.join(args) ++ # print (' '.join(args)) + + # Use "args" to invoke gdb, capturing stdout, stderr: + out, err = run_gdb(*args, PYTHONHASHSEED='0') +@@ -186,6 +186,11 @@ + # + # For a nested structure, the first time we hit the breakpoint will + # give us the top-level structure ++ ++ # NOTE: avoid decoding too much of the traceback as some ++ # undecodable characters may lurk there in optimized mode ++ # (issue #19743). ++ cmds_after_breakpoint = cmds_after_breakpoint or ["backtrace 1"] + gdb_output = self.get_stack_trace(source, breakpoint=BREAKPOINT_FN, + cmds_after_breakpoint=cmds_after_breakpoint, + import_site=import_site) +@@ -216,11 +221,10 @@ + gdb_output = self.get_stack_trace('id(42)') + self.assertTrue(BREAKPOINT_FN in gdb_output) + +- def assertGdbRepr(self, val, exp_repr=None, cmds_after_breakpoint=None): ++ def assertGdbRepr(self, val, exp_repr=None): + # Ensure that gdb's rendering of the value in a debugged process + # matches repr(value) in this process: +- gdb_repr, gdb_output = self.get_gdb_repr('id(' + ascii(val) + ')', +- cmds_after_breakpoint) ++ gdb_repr, gdb_output = self.get_gdb_repr('id(' + ascii(val) + ')') + if not exp_repr: + exp_repr = repr(val) + self.assertEqual(gdb_repr, exp_repr, +diff -r c3896275c0f6 Lib/test/test_grp.py +--- a/Lib/test/test_grp.py ++++ b/Lib/test/test_grp.py +@@ -26,8 +26,10 @@ + for e in entries: + self.check_value(e) + ++ def test_values_extended(self): ++ entries = grp.getgrall() + if len(entries) > 1000: # Huge group file (NIS?) -- skip the rest +- return ++ self.skipTest('huge group file, extended test skipped') + + for e in entries: + e2 = grp.getgrgid(e.gr_gid) +diff -r c3896275c0f6 Lib/test/test_htmlparser.py +--- a/Lib/test/test_htmlparser.py ++++ b/Lib/test/test_htmlparser.py +@@ -229,6 +229,11 @@ + self._parse_error("'") + self._parse_error(">xt'), + ('entityref', 'a'), +- ('data', '<", [('comment', '$')]) + self._run_check("", [('data', '", [('starttag', 'a", [('endtag', 'a'", [('data', "", [('starttag', 'a$b', [])]) ++ self._run_check("", [('startendtag', 'a$b', [])]) ++ self._run_check("", [('starttag', 'a$b', [])]) ++ self._run_check("", [('startendtag', 'a$b', [])]) + + def test_slashes_in_starttag(self): + self._run_check('', [('startendtag', 'a', [('foo', 'var')])]) +@@ -753,11 +762,5 @@ + ("data", "spam"), ("endtag", "a")]) + + +- +-def test_main(): +- support.run_unittest(HTMLParserStrictTestCase, HTMLParserTolerantTestCase, +- AttributesStrictTestCase, AttributesTolerantTestCase) +- +- + if __name__ == "__main__": +- test_main() ++ unittest.main() +diff -r c3896275c0f6 Lib/test/test_http_cookiejar.py +--- a/Lib/test/test_http_cookiejar.py ++++ b/Lib/test/test_http_cookiejar.py +@@ -28,8 +28,8 @@ + az = time2isoz() + bz = time2isoz(500000) + for text in (az, bz): +- self.assertTrue(re.search(r"^\d{4}-\d\d-\d\d \d\d:\d\d:\d\dZ$", text), +- "bad time2isoz format: %s %s" % (az, bz)) ++ self.assertRegex(text, r"^\d{4}-\d\d-\d\d \d\d:\d\d:\d\dZ$", ++ "bad time2isoz format: %s %s" % (az, bz)) + + def test_http2time(self): + def parse_date(text): +@@ -75,12 +75,9 @@ + "%s => '%s' (%s)" % (test_t, result, expected)) + + for s in tests: +- t = http2time(s) +- t2 = http2time(s.lower()) +- t3 = http2time(s.upper()) +- +- self.assertTrue(t == t2 == t3 == test_t, +- "'%s' => %s, %s, %s (%s)" % (s, t, t2, t3, test_t)) ++ self.assertEqual(http2time(s), test_t, s) ++ self.assertEqual(http2time(s.lower()), test_t, s.lower()) ++ self.assertEqual(http2time(s.upper()), test_t, s.upper()) + + def test_http2time_garbage(self): + for test in [ +@@ -134,12 +131,9 @@ + + test_t = 760233600 # assume broken POSIX counting of seconds + for s in tests: +- t = iso2time(s) +- t2 = iso2time(s.lower()) +- t3 = iso2time(s.upper()) +- +- self.assertTrue(t == t2 == t3 == test_t, +- "'%s' => %s, %s, %s (%s)" % (s, t, t2, t3, test_t)) ++ self.assertEqual(iso2time(s), test_t, s) ++ self.assertEqual(iso2time(s.lower()), test_t, s.lower()) ++ self.assertEqual(iso2time(s.upper()), test_t, s.upper()) + + def test_iso2time_garbage(self): + for test in [ +@@ -411,7 +405,7 @@ + request = urllib.request.Request(url) + r = pol.domain_return_ok(domain, request) + if ok: self.assertTrue(r) +- else: self.assertTrue(not r) ++ else: self.assertFalse(r) + + def test_missing_value(self): + # missing = sign in Cookie: header is regarded by Mozilla as a missing +@@ -421,10 +415,10 @@ + interact_netscape(c, "http://www.acme.com/", 'eggs') + interact_netscape(c, "http://www.acme.com/", '"spam"; path=/foo/') + cookie = c._cookies["www.acme.com"]["/"]["eggs"] +- self.assertTrue(cookie.value is None) ++ self.assertIsNone(cookie.value) + self.assertEqual(cookie.name, "eggs") + cookie = c._cookies["www.acme.com"]['/foo/']['"spam"'] +- self.assertTrue(cookie.value is None) ++ self.assertIsNone(cookie.value) + self.assertEqual(cookie.name, '"spam"') + self.assertEqual(lwp_cookie_str(cookie), ( + r'"spam"; path="/foo/"; domain="www.acme.com"; ' +@@ -466,7 +460,7 @@ + try: + cookie = c._cookies["www.example.com"]["/"]["ni"] + except KeyError: +- self.assertTrue(version is None) # didn't expect a stored cookie ++ self.assertIsNone(version) # didn't expect a stored cookie + else: + self.assertEqual(cookie.version, version) + # 2965 cookies are unaffected +@@ -490,26 +484,26 @@ + self.assertEqual(cookie.domain, ".acme.com") + self.assertTrue(cookie.domain_specified) + self.assertEqual(cookie.port, DEFAULT_HTTP_PORT) +- self.assertTrue(not cookie.port_specified) ++ self.assertFalse(cookie.port_specified) + # case is preserved +- self.assertTrue(cookie.has_nonstandard_attr("blArgh") and +- not cookie.has_nonstandard_attr("blargh")) ++ self.assertTrue(cookie.has_nonstandard_attr("blArgh")) ++ self.assertFalse(cookie.has_nonstandard_attr("blargh")) + + cookie = c._cookies["www.acme.com"]["/"]["ni"] + self.assertEqual(cookie.domain, "www.acme.com") +- self.assertTrue(not cookie.domain_specified) ++ self.assertFalse(cookie.domain_specified) + self.assertEqual(cookie.port, "80,8080") + self.assertTrue(cookie.port_specified) + + cookie = c._cookies["www.acme.com"]["/"]["nini"] +- self.assertTrue(cookie.port is None) +- self.assertTrue(not cookie.port_specified) ++ self.assertIsNone(cookie.port) ++ self.assertFalse(cookie.port_specified) + + # invalid expires should not cause cookie to be dropped + foo = c._cookies["www.acme.com"]["/"]["foo"] + spam = c._cookies["www.acme.com"]["/"]["foo"] +- self.assertTrue(foo.expires is None) +- self.assertTrue(spam.expires is None) ++ self.assertIsNone(foo.expires) ++ self.assertIsNone(spam.expires) + + def test_ns_parser_special_names(self): + # names such as 'expires' are not special in first name=value pair +@@ -679,12 +673,12 @@ + def test_is_HDN(self): + self.assertTrue(is_HDN("foo.bar.com")) + self.assertTrue(is_HDN("1foo2.3bar4.5com")) +- self.assertTrue(not is_HDN("192.168.1.1")) +- self.assertTrue(not is_HDN("")) +- self.assertTrue(not is_HDN(".")) +- self.assertTrue(not is_HDN(".foo.bar.com")) +- self.assertTrue(not is_HDN("..foo")) +- self.assertTrue(not is_HDN("foo.")) ++ self.assertFalse(is_HDN("192.168.1.1")) ++ self.assertFalse(is_HDN("")) ++ self.assertFalse(is_HDN(".")) ++ self.assertFalse(is_HDN(".foo.bar.com")) ++ self.assertFalse(is_HDN("..foo")) ++ self.assertFalse(is_HDN("foo.")) + + def test_reach(self): + self.assertEqual(reach("www.acme.com"), ".acme.com") +@@ -698,39 +692,39 @@ + + def test_domain_match(self): + self.assertTrue(domain_match("192.168.1.1", "192.168.1.1")) +- self.assertTrue(not domain_match("192.168.1.1", ".168.1.1")) ++ self.assertFalse(domain_match("192.168.1.1", ".168.1.1")) + self.assertTrue(domain_match("x.y.com", "x.Y.com")) + self.assertTrue(domain_match("x.y.com", ".Y.com")) +- self.assertTrue(not domain_match("x.y.com", "Y.com")) ++ self.assertFalse(domain_match("x.y.com", "Y.com")) + self.assertTrue(domain_match("a.b.c.com", ".c.com")) +- self.assertTrue(not domain_match(".c.com", "a.b.c.com")) ++ self.assertFalse(domain_match(".c.com", "a.b.c.com")) + self.assertTrue(domain_match("example.local", ".local")) +- self.assertTrue(not domain_match("blah.blah", "")) +- self.assertTrue(not domain_match("", ".rhubarb.rhubarb")) ++ self.assertFalse(domain_match("blah.blah", "")) ++ self.assertFalse(domain_match("", ".rhubarb.rhubarb")) + self.assertTrue(domain_match("", "")) + + self.assertTrue(user_domain_match("acme.com", "acme.com")) +- self.assertTrue(not user_domain_match("acme.com", ".acme.com")) ++ self.assertFalse(user_domain_match("acme.com", ".acme.com")) + self.assertTrue(user_domain_match("rhubarb.acme.com", ".acme.com")) + self.assertTrue(user_domain_match("www.rhubarb.acme.com", ".acme.com")) + self.assertTrue(user_domain_match("x.y.com", "x.Y.com")) + self.assertTrue(user_domain_match("x.y.com", ".Y.com")) +- self.assertTrue(not user_domain_match("x.y.com", "Y.com")) ++ self.assertFalse(user_domain_match("x.y.com", "Y.com")) + self.assertTrue(user_domain_match("y.com", "Y.com")) +- self.assertTrue(not user_domain_match(".y.com", "Y.com")) ++ self.assertFalse(user_domain_match(".y.com", "Y.com")) + self.assertTrue(user_domain_match(".y.com", ".Y.com")) + self.assertTrue(user_domain_match("x.y.com", ".com")) +- self.assertTrue(not user_domain_match("x.y.com", "com")) +- self.assertTrue(not user_domain_match("x.y.com", "m")) +- self.assertTrue(not user_domain_match("x.y.com", ".m")) +- self.assertTrue(not user_domain_match("x.y.com", "")) +- self.assertTrue(not user_domain_match("x.y.com", ".")) ++ self.assertFalse(user_domain_match("x.y.com", "com")) ++ self.assertFalse(user_domain_match("x.y.com", "m")) ++ self.assertFalse(user_domain_match("x.y.com", ".m")) ++ self.assertFalse(user_domain_match("x.y.com", "")) ++ self.assertFalse(user_domain_match("x.y.com", ".")) + self.assertTrue(user_domain_match("192.168.1.1", "192.168.1.1")) + # not both HDNs, so must string-compare equal to match +- self.assertTrue(not user_domain_match("192.168.1.1", ".168.1.1")) +- self.assertTrue(not user_domain_match("192.168.1.1", ".")) ++ self.assertFalse(user_domain_match("192.168.1.1", ".168.1.1")) ++ self.assertFalse(user_domain_match("192.168.1.1", ".")) + # empty string is a special case +- self.assertTrue(not user_domain_match("192.168.1.1", "")) ++ self.assertFalse(user_domain_match("192.168.1.1", "")) + + def test_wrong_domain(self): + # Cookies whose effective request-host name does not domain-match the +@@ -877,7 +871,7 @@ + self.assertEqual(len(c), 2) + # ... and check is doesn't get returned + c.add_cookie_header(req) +- self.assertTrue(not req.has_header("Cookie")) ++ self.assertFalse(req.has_header("Cookie")) + + def test_domain_block(self): + pol = DefaultCookiePolicy( +@@ -901,8 +895,8 @@ + self.assertEqual(len(c), 1) + req = urllib.request.Request("http://www.roadrunner.net/") + c.add_cookie_header(req) +- self.assertTrue((req.has_header("Cookie") and +- req.has_header("Cookie2"))) ++ self.assertTrue(req.has_header("Cookie")) ++ self.assertTrue(req.has_header("Cookie2")) + + c.clear() + pol.set_blocked_domains([".acme.com"]) +@@ -917,7 +911,7 @@ + self.assertEqual(len(c), 2) + # ... and check is doesn't get returned + c.add_cookie_header(req) +- self.assertTrue(not req.has_header("Cookie")) ++ self.assertFalse(req.has_header("Cookie")) + + def test_secure(self): + for ns in True, False: +@@ -935,8 +929,8 @@ + url = "http://www.acme.com/" + int(c, url, "foo1=bar%s%s" % (vs, whitespace)) + int(c, url, "foo2=bar%s; secure%s" % (vs, whitespace)) +- self.assertTrue( +- not c._cookies["www.acme.com"]["/"]["foo1"].secure, ++ self.assertFalse( ++ c._cookies["www.acme.com"]["/"]["foo1"].secure, + "non-secure cookie registered secure") + self.assertTrue( + c._cookies["www.acme.com"]["/"]["foo2"].secure, +@@ -1009,8 +1003,8 @@ + url = "http://foo.bar.com/" + interact_2965(c, url, "spam=eggs; Version=1; Port") + h = interact_2965(c, url) +- self.assertTrue(re.search("\$Port([^=]|$)", h), +- "port with no value not returned with no value") ++ self.assertRegex(h, "\$Port([^=]|$)", ++ "port with no value not returned with no value") + + c = CookieJar(pol) + url = "http://foo.bar.com/" +@@ -1034,8 +1028,7 @@ + 'Comment="does anybody read these?"; ' + 'CommentURL="http://foo.bar.net/comment.html"') + h = interact_2965(c, url) +- self.assertTrue( +- "Comment" not in h, ++ self.assertNotIn("Comment", h, + "Comment or CommentURL cookie-attributes returned to server") + + def test_Cookie_iterator(self): +@@ -1063,7 +1056,7 @@ + for i in range(4): + i = 0 + for c in cs: +- self.assertTrue(isinstance(c, Cookie)) ++ self.assertIsInstance(c, Cookie) + self.assertEqual(c.version, versions[i]) + self.assertEqual(c.name, names[i]) + self.assertEqual(c.domain, domains[i]) +@@ -1118,7 +1111,7 @@ + headers = ["Set-Cookie: c=foo; expires=Foo Bar 12 33:22:11 2000"] + c = cookiejar_from_cookie_headers(headers) + cookie = c._cookies["www.example.com"]["/"]["c"] +- self.assertTrue(cookie.expires is None) ++ self.assertIsNone(cookie.expires) + + + class LWPCookieTests(unittest.TestCase): +@@ -1262,9 +1255,9 @@ + req = urllib.request.Request("http://www.acme.com/ammo") + c.add_cookie_header(req) + +- self.assertTrue(re.search(r"PART_NUMBER=RIDING_ROCKET_0023;\s*" +- "PART_NUMBER=ROCKET_LAUNCHER_0001", +- req.get_header("Cookie"))) ++ self.assertRegex(req.get_header("Cookie"), ++ r"PART_NUMBER=RIDING_ROCKET_0023;\s*" ++ "PART_NUMBER=ROCKET_LAUNCHER_0001") + + def test_ietf_example_1(self): + #------------------------------------------------------------------- +@@ -1297,7 +1290,7 @@ + cookie = interact_2965( + c, 'http://www.acme.com/acme/login', + 'Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"') +- self.assertTrue(not cookie) ++ self.assertFalse(cookie) + + # + # 3. User Agent -> Server +@@ -1319,9 +1312,8 @@ + cookie = interact_2965(c, 'http://www.acme.com/acme/pickitem', + 'Part_Number="Rocket_Launcher_0001"; ' + 'Version="1"; Path="/acme"'); +- self.assertTrue(re.search( +- r'^\$Version="?1"?; Customer="?WILE_E_COYOTE"?; \$Path="/acme"$', +- cookie)) ++ self.assertRegex(cookie, ++ r'^\$Version="?1"?; Customer="?WILE_E_COYOTE"?; \$Path="/acme"$') + + # + # 5. User Agent -> Server +@@ -1344,11 +1336,11 @@ + cookie = interact_2965(c, "http://www.acme.com/acme/shipping", + 'Shipping="FedEx"; Version="1"; Path="/acme"') + +- self.assertTrue(re.search(r'^\$Version="?1"?;', cookie)) +- self.assertTrue(re.search(r'Part_Number="?Rocket_Launcher_0001"?;' +- '\s*\$Path="\/acme"', cookie)) +- self.assertTrue(re.search(r'Customer="?WILE_E_COYOTE"?;\s*\$Path="\/acme"', +- cookie)) ++ self.assertRegex(cookie, r'^\$Version="?1"?;') ++ self.assertRegex(cookie, r'Part_Number="?Rocket_Launcher_0001"?;' ++ '\s*\$Path="\/acme"') ++ self.assertRegex(cookie, r'Customer="?WILE_E_COYOTE"?;' ++ '\s*\$Path="\/acme"') + + # + # 7. User Agent -> Server +@@ -1369,9 +1361,8 @@ + # Transaction is complete. + + cookie = interact_2965(c, "http://www.acme.com/acme/process") +- self.assertTrue( +- re.search(r'Shipping="?FedEx"?;\s*\$Path="\/acme"', cookie) and +- "WILE_E_COYOTE" in cookie) ++ self.assertRegex(cookie, r'Shipping="?FedEx"?;\s*\$Path="\/acme"') ++ self.assertIn("WILE_E_COYOTE", cookie) + + # + # The user agent makes a series of requests on the origin server, after +@@ -1418,8 +1409,7 @@ + # than once. + + cookie = interact_2965(c, "http://www.acme.com/acme/ammo/...") +- self.assertTrue( +- re.search(r"Riding_Rocket_0023.*Rocket_Launcher_0001", cookie)) ++ self.assertRegex(cookie, r"Riding_Rocket_0023.*Rocket_Launcher_0001") + + # A subsequent request by the user agent to the (same) server for a URL of + # the form /acme/parts/ would include the following request header: +@@ -1445,7 +1435,7 @@ + # illegal domain (no embedded dots) + cookie = interact_2965(c, "http://www.acme.com", + 'foo=bar; domain=".com"; version=1') +- self.assertTrue(not c) ++ self.assertFalse(c) + + # legal domain + cookie = interact_2965(c, "http://www.acme.com", +@@ -1538,11 +1528,11 @@ + 'bar=baz; path="/foo/"; version=1'); + version_re = re.compile(r'^\$version=\"?1\"?', re.I) + self.assertIn("foo=bar", cookie) +- self.assertTrue(version_re.search(cookie)) ++ self.assertRegex(cookie, version_re) + + cookie = interact_2965( + c, "http://www.acme.com/foo/%25/<<%0anew\345/\346\370\345") +- self.assertTrue(not cookie) ++ self.assertFalse(cookie) + + # unicode URL doesn't raise exception + cookie = interact_2965(c, "http://www.acme.com/\xfc") +@@ -1703,13 +1693,12 @@ + key = "%s_after" % cookie.value + counter[key] = counter[key] + 1 + +- self.assertTrue(not ( + # a permanent cookie got lost accidently +- counter["perm_after"] != counter["perm_before"] or ++ self.assertEqual(counter["perm_after"], counter["perm_before"]) + # a session cookie hasn't been cleared +- counter["session_after"] != 0 or ++ self.assertEqual(counter["session_after"], 0) + # we didn't have session cookies in the first place +- counter["session_before"] == 0)) ++ self.assertNotEqual(counter["session_before"], 0) + + + def test_main(verbose=None): +diff -r c3896275c0f6 Lib/test/test_imaplib.py +--- a/Lib/test/test_imaplib.py ++++ b/Lib/test/test_imaplib.py +@@ -210,13 +210,12 @@ + + @contextmanager + def reaped_pair(self, hdlr): +- server, thread = self.make_server((support.HOST, 0), hdlr) +- client = self.imap_class(*server.server_address) +- try: +- yield server, client +- finally: +- client.logout() +- self.reap_server(server, thread) ++ with self.reaped_server(hdlr) as server: ++ client = self.imap_class(*server.server_address) ++ try: ++ yield server, client ++ finally: ++ client.logout() + + @reap_threads + def test_connect(self): +diff -r c3896275c0f6 Lib/test/test_imp.py +--- a/Lib/test/test_imp.py ++++ b/Lib/test/test_imp.py +@@ -245,7 +245,7 @@ + if found[0] is not None: + found[0].close() + if found[2][2] != imp.C_EXTENSION: +- return ++ self.skipTest("found module doesn't appear to be a C extension") + imp.load_module(name, None, *found[1:]) + + def test_multiple_calls_to_get_data(self): +diff -r c3896275c0f6 Lib/test/test_importlib/builtin/test_finder.py +--- a/Lib/test/test_importlib/builtin/test_finder.py ++++ b/Lib/test/test_importlib/builtin/test_finder.py +@@ -16,21 +16,11 @@ + found = machinery.BuiltinImporter.find_module(builtin_util.NAME) + self.assertTrue(found) + +- def test_package(self): +- # Built-in modules cannot be a package. +- pass ++ # Built-in modules cannot be a package. ++ test_package = test_package_in_package = test_package_over_module = None + +- def test_module_in_package(self): +- # Built-in modules cannobt be in a package. +- pass +- +- def test_package_in_package(self): +- # Built-in modules cannot be a package. +- pass +- +- def test_package_over_module(self): +- # Built-in modules cannot be a package. +- pass ++ # Built-in modules cannot be in a package. ++ test_module_in_package = None + + def test_failure(self): + assert 'importlib' not in sys.builtin_module_names +diff -r c3896275c0f6 Lib/test/test_importlib/builtin/test_loader.py +--- a/Lib/test/test_importlib/builtin/test_loader.py ++++ b/Lib/test/test_importlib/builtin/test_loader.py +@@ -32,17 +32,11 @@ + module = self.load_module(builtin_util.NAME) + self.verify(module) + +- def test_package(self): +- # Built-in modules cannot be a package. +- pass ++ # Built-in modules cannot be a package. ++ test_package = test_lacking_parent = None + +- def test_lacking_parent(self): +- # Built-in modules cannot be a package. +- pass +- +- def test_state_after_failure(self): +- # Not way to force an imoprt failure. +- pass ++ # No way to force an import failure. ++ test_state_after_failure = None + + def test_module_reuse(self): + # Test that the same module is used in a reload. +diff -r c3896275c0f6 Lib/test/test_importlib/extension/test_finder.py +--- a/Lib/test/test_importlib/extension/test_finder.py ++++ b/Lib/test/test_importlib/extension/test_finder.py +@@ -17,21 +17,14 @@ + def test_module(self): + self.assertTrue(self.find_module(util.NAME)) + +- def test_package(self): +- # No extension module as an __init__ available for testing. +- pass ++ # No extension module as an __init__ available for testing. ++ test_package = test_package_in_package = None + +- def test_module_in_package(self): +- # No extension module in a package available for testing. +- pass ++ # No extension module in a package available for testing. ++ test_module_in_package = None + +- def test_package_in_package(self): +- # No extension module as an __init__ available for testing. +- pass +- +- def test_package_over_module(self): +- # Extension modules cannot be an __init__ for a package. +- pass ++ # Extension modules cannot be an __init__ for a package. ++ test_package_over_module = None + + def test_failure(self): + self.assertIsNone(self.find_module('asdfjkl;')) +diff -r c3896275c0f6 Lib/test/test_importlib/extension/test_loader.py +--- a/Lib/test/test_importlib/extension/test_loader.py ++++ b/Lib/test/test_importlib/extension/test_loader.py +@@ -38,13 +38,11 @@ + self.assertIsInstance(module.__loader__, + machinery.ExtensionFileLoader) + +- def test_package(self): +- # No extension module as __init__ available for testing. +- pass ++ # No extension module as __init__ available for testing. ++ test_package = None + +- def test_lacking_parent(self): +- # No extension module in a package available for testing. +- pass ++ # No extension module in a package available for testing. ++ test_lacking_parent = None + + def test_module_reuse(self): + with util.uncache(ext_util.NAME): +@@ -52,9 +50,8 @@ + module2 = self.load_module(ext_util.NAME) + self.assertIs(module1, module2) + +- def test_state_after_failure(self): +- # No easy way to trigger a failure after a successful import. +- pass ++ # No easy way to trigger a failure after a successful import. ++ test_state_after_failure = None + + def test_unloadable(self): + name = 'asdfjkl;' +diff -r c3896275c0f6 Lib/test/test_importlib/frozen/test_finder.py +--- a/Lib/test/test_importlib/frozen/test_finder.py ++++ b/Lib/test/test_importlib/frozen/test_finder.py +@@ -25,13 +25,11 @@ + loader = self.find('__phello__.spam', ['__phello__']) + self.assertTrue(hasattr(loader, 'load_module')) + +- def test_package_in_package(self): +- # No frozen package within another package to test with. +- pass ++ # No frozen package within another package to test with. ++ test_package_in_package = None + +- def test_package_over_module(self): +- # No easy way to test. +- pass ++ # No easy way to test. ++ test_package_over_module = None + + def test_failure(self): + loader = self.find('') +diff -r c3896275c0f6 Lib/test/test_importlib/frozen/test_loader.py +--- a/Lib/test/test_importlib/frozen/test_loader.py ++++ b/Lib/test/test_importlib/frozen/test_loader.py +@@ -65,9 +65,8 @@ + self.assertEqual(repr(module), + "") + +- def test_state_after_failure(self): +- # No way to trigger an error in a frozen module. +- pass ++ # No way to trigger an error in a frozen module. ++ test_state_after_failure = None + + def test_unloadable(self): + assert machinery.FrozenImporter.find_module('_not_real') is None +diff -r c3896275c0f6 Lib/test/test_io.py +--- a/Lib/test/test_io.py ++++ b/Lib/test/test_io.py +@@ -421,14 +421,9 @@ + # a long time to build the >2GB file and takes >2GB of disk space + # therefore the resource must be enabled to run this test. + if sys.platform[:3] == 'win' or sys.platform == 'darwin': +- if not support.is_resource_enabled("largefile"): +- print("\nTesting large file ops skipped on %s." % sys.platform, +- file=sys.stderr) +- print("It requires %d bytes and a long time." % self.LARGE, +- file=sys.stderr) +- print("Use 'regrtest.py -u largefile test_io' to run it.", +- file=sys.stderr) +- return ++ support.requires( ++ 'largefile', ++ 'test requires %s bytes and a long time to run' % self.LARGE) + with self.open(support.TESTFN, "w+b", 0) as f: + self.large_file_ops(f) + with self.open(support.TESTFN, "w+b") as f: +@@ -698,6 +693,7 @@ + + self.assertEqual(42, bufio.fileno()) + ++ @unittest.skip('test having existential crisis') + def test_no_fileno(self): + # XXX will we always have fileno() function? If so, kill + # this test. Else, write it. +diff -r c3896275c0f6 Lib/test/test_json/test_scanstring.py +--- a/Lib/test/test_json/test_scanstring.py ++++ b/Lib/test/test_json/test_scanstring.py +@@ -6,10 +6,6 @@ + def test_scanstring(self): + scanstring = self.json.decoder.scanstring + self.assertEqual( +- scanstring('"z\\ud834\\udd20x"', 1, True), +- ('z\U0001d120x', 16)) +- +- self.assertEqual( + scanstring('"z\U0001d120x"', 1, True), + ('z\U0001d120x', 5)) + +@@ -89,6 +85,53 @@ + scanstring('["Bad value", truth]', 2, True), + ('Bad value', 12)) + ++ def test_surrogates(self): ++ scanstring = self.json.decoder.scanstring ++ def assertScan(given, expect): ++ self.assertEqual(scanstring(given, 1, True), ++ (expect, len(given))) ++ ++ assertScan('"z\\ud834\\u0079x"', 'z\ud834yx') ++ assertScan('"z\\ud834\\udd20x"', 'z\U0001d120x') ++ assertScan('"z\\ud834\\ud834\\udd20x"', 'z\ud834\U0001d120x') ++ assertScan('"z\\ud834x"', 'z\ud834x') ++ assertScan('"z\\ud834\udd20x12345"', 'z\ud834\udd20x12345') ++ assertScan('"z\\udd20x"', 'z\udd20x') ++ assertScan('"z\ud834\udd20x"', 'z\ud834\udd20x') ++ assertScan('"z\ud834\\udd20x"', 'z\ud834\udd20x') ++ assertScan('"z\ud834x"', 'z\ud834x') ++ ++ def test_bad_escapes(self): ++ scanstring = self.json.decoder.scanstring ++ bad_escapes = [ ++ '"\\"', ++ '"\\x"', ++ '"\\u"', ++ '"\\u0"', ++ '"\\u01"', ++ '"\\u012"', ++ '"\\uz012"', ++ '"\\u0z12"', ++ '"\\u01z2"', ++ '"\\u012z"', ++ '"\\u0x12"', ++ '"\\u0X12"', ++ '"\\ud834\\"', ++ '"\\ud834\\u"', ++ '"\\ud834\\ud"', ++ '"\\ud834\\udd"', ++ '"\\ud834\\udd2"', ++ '"\\ud834\\uzdd2"', ++ '"\\ud834\\udzd2"', ++ '"\\ud834\\uddz2"', ++ '"\\ud834\\udd2z"', ++ '"\\ud834\\u0x20"', ++ '"\\ud834\\u0X20"', ++ ] ++ for s in bad_escapes: ++ with self.assertRaises(ValueError, msg=s): ++ scanstring(s, 1, True) ++ + def test_overflow(self): + with self.assertRaises(OverflowError): + self.json.decoder.scanstring(b"xxx", sys.maxsize+1) +diff -r c3896275c0f6 Lib/test/test_logging.py +--- a/Lib/test/test_logging.py ++++ b/Lib/test/test_logging.py +@@ -959,19 +959,21 @@ + + @unittest.skipUnless(threading, 'Threading required for this test.') + class SMTPHandlerTest(BaseTest): ++ TIMEOUT = 8.0 + def test_basic(self): + sockmap = {} + server = TestSMTPServer(('localhost', 0), self.process_message, 0.001, + sockmap) + server.start() + addr = ('localhost', server.port) +- h = logging.handlers.SMTPHandler(addr, 'me', 'you', 'Log', timeout=5.0) ++ h = logging.handlers.SMTPHandler(addr, 'me', 'you', 'Log', ++ timeout=self.TIMEOUT) + self.assertEqual(h.toaddrs, ['you']) + self.messages = [] + r = logging.makeLogRecord({'msg': 'Hello'}) + self.handled = threading.Event() + h.handle(r) +- self.handled.wait(5.0) # 14314: don't wait forever ++ self.handled.wait(self.TIMEOUT) # 14314: don't wait forever + server.stop() + self.assertTrue(self.handled.is_set()) + self.assertEqual(len(self.messages), 1) +diff -r c3896275c0f6 Lib/test/test_lzma.py +--- a/Lib/test/test_lzma.py ++++ b/Lib/test/test_lzma.py +@@ -1,5 +1,6 @@ + from io import BytesIO, UnsupportedOperation + import os ++import pickle + import random + import unittest + +@@ -216,6 +217,14 @@ + finally: + input = cdata = ddata = None + ++ # Pickling raises an exception; there's no way to serialize an lzma_stream. ++ ++ def test_pickle(self): ++ with self.assertRaises(TypeError): ++ pickle.dumps(LZMACompressor()) ++ with self.assertRaises(TypeError): ++ pickle.dumps(LZMADecompressor()) ++ + + class CompressDecompressFunctionTestCase(unittest.TestCase): + +@@ -305,6 +314,8 @@ + + def test_decompress_bad_input(self): + with self.assertRaises(LZMAError): ++ lzma.decompress(COMPRESSED_BOGUS) ++ with self.assertRaises(LZMAError): + lzma.decompress(COMPRESSED_RAW_1) + with self.assertRaises(LZMAError): + lzma.decompress(COMPRESSED_ALONE, format=lzma.FORMAT_XZ) +@@ -339,6 +350,16 @@ + ddata = lzma.decompress(COMPRESSED_XZ + COMPRESSED_ALONE) + self.assertEqual(ddata, INPUT * 2) + ++ # Test robust handling of non-LZMA data following the compressed stream(s). ++ ++ def test_decompress_trailing_junk(self): ++ ddata = lzma.decompress(COMPRESSED_XZ + COMPRESSED_BOGUS) ++ self.assertEqual(ddata, INPUT) ++ ++ def test_decompress_multistream_trailing_junk(self): ++ ddata = lzma.decompress(COMPRESSED_XZ * 3 + COMPRESSED_BOGUS) ++ self.assertEqual(ddata, INPUT * 3) ++ + + class TempFile: + """Context manager - creates a file, and deletes it on __exit__.""" +@@ -649,6 +670,14 @@ + finally: + lzma._BUFFER_SIZE = saved_buffer_size + ++ def test_read_trailing_junk(self): ++ with LZMAFile(BytesIO(COMPRESSED_XZ + COMPRESSED_BOGUS)) as f: ++ self.assertEqual(f.read(), INPUT) ++ ++ def test_read_multistream_trailing_junk(self): ++ with LZMAFile(BytesIO(COMPRESSED_XZ * 5 + COMPRESSED_BOGUS)) as f: ++ self.assertEqual(f.read(), INPUT * 5) ++ + def test_read_from_file(self): + with TempFile(TESTFN, COMPRESSED_XZ): + with LZMAFile(TESTFN) as f: +@@ -678,6 +707,10 @@ + with LZMAFile(BytesIO(COMPRESSED_XZ)) as f: + self.assertRaises(TypeError, f.read, None) + ++ def test_read_bad_data(self): ++ with LZMAFile(BytesIO(COMPRESSED_BOGUS)) as f: ++ self.assertRaises(LZMAError, f.read) ++ + def test_read1(self): + with LZMAFile(BytesIO(COMPRESSED_XZ)) as f: + blocks = [] +@@ -1183,6 +1216,8 @@ + Farewell. + """ + ++COMPRESSED_BOGUS = b"this is not a valid lzma stream" ++ + COMPRESSED_XZ = ( + b"\xfd7zXZ\x00\x00\x04\xe6\xd6\xb4F\x02\x00!\x01\x16\x00\x00\x00t/\xe5\xa3" + b"\xe0\x07\x80\x03\xdf]\x00\x05\x14\x07bX\x19\xcd\xddn\x98\x15\xe4\xb4\x9d" +diff -r c3896275c0f6 Lib/test/test_mailbox.py +--- a/Lib/test/test_mailbox.py ++++ b/Lib/test/test_mailbox.py +@@ -868,10 +868,10 @@ + for msg in self._box: + pass + ++ @unittest.skipUnless(hasattr(os, 'umask'), 'test needs os.umask()') ++ @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()') + def test_file_permissions(self): + # Verify that message files are created without execute permissions +- if not hasattr(os, "stat") or not hasattr(os, "umask"): +- return + msg = mailbox.MaildirMessage(self._template % 0) + orig_umask = os.umask(0) + try: +@@ -882,12 +882,11 @@ + mode = os.stat(path).st_mode + self.assertFalse(mode & 0o111) + ++ @unittest.skipUnless(hasattr(os, 'umask'), 'test needs os.umask()') ++ @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()') + def test_folder_file_perms(self): + # From bug #3228, we want to verify that the file created inside a Maildir + # subfolder isn't marked as executable. +- if not hasattr(os, "stat") or not hasattr(os, "umask"): +- return +- + orig_umask = os.umask(0) + try: + subfolder = self._box.add_folder('subfolder') +@@ -1097,24 +1096,25 @@ + + _factory = lambda self, path, factory=None: mailbox.mbox(path, factory) + ++ @unittest.skipUnless(hasattr(os, 'umask'), 'test needs os.umask()') ++ @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()') + def test_file_perms(self): + # From bug #3228, we want to verify that the mailbox file isn't executable, + # even if the umask is set to something that would leave executable bits set. + # We only run this test on platforms that support umask. +- if hasattr(os, 'umask') and hasattr(os, 'stat'): +- try: +- old_umask = os.umask(0o077) +- self._box.close() +- os.unlink(self._path) +- self._box = mailbox.mbox(self._path, create=True) +- self._box.add('') +- self._box.close() +- finally: +- os.umask(old_umask) ++ try: ++ old_umask = os.umask(0o077) ++ self._box.close() ++ os.unlink(self._path) ++ self._box = mailbox.mbox(self._path, create=True) ++ self._box.add('') ++ self._box.close() ++ finally: ++ os.umask(old_umask) + +- st = os.stat(self._path) +- perms = st.st_mode +- self.assertFalse((perms & 0o111)) # Execute bits should all be off. ++ st = os.stat(self._path) ++ perms = st.st_mode ++ self.assertFalse((perms & 0o111)) # Execute bits should all be off. + + def test_terminating_newline(self): + message = email.message.Message() +diff -r c3896275c0f6 Lib/test/test_math.py +--- a/Lib/test/test_math.py ++++ b/Lib/test/test_math.py +@@ -980,38 +980,37 @@ + # still fails this part of the test on some platforms. For now, we only + # *run* test_exceptions() in verbose mode, so that this isn't normally + # tested. ++ @unittest.skipUnless(verbose, 'requires verbose mode') ++ def test_exceptions(self): ++ try: ++ x = math.exp(-1000000000) ++ except: ++ # mathmodule.c is failing to weed out underflows from libm, or ++ # we've got an fp format with huge dynamic range ++ self.fail("underflowing exp() should not have raised " ++ "an exception") ++ if x != 0: ++ self.fail("underflowing exp() should have returned 0") + +- if verbose: +- def test_exceptions(self): +- try: +- x = math.exp(-1000000000) +- except: +- # mathmodule.c is failing to weed out underflows from libm, or +- # we've got an fp format with huge dynamic range +- self.fail("underflowing exp() should not have raised " +- "an exception") +- if x != 0: +- self.fail("underflowing exp() should have returned 0") ++ # If this fails, probably using a strict IEEE-754 conforming libm, and x ++ # is +Inf afterwards. But Python wants overflows detected by default. ++ try: ++ x = math.exp(1000000000) ++ except OverflowError: ++ pass ++ else: ++ self.fail("overflowing exp() didn't trigger OverflowError") + +- # If this fails, probably using a strict IEEE-754 conforming libm, and x +- # is +Inf afterwards. But Python wants overflows detected by default. +- try: +- x = math.exp(1000000000) +- except OverflowError: +- pass +- else: +- self.fail("overflowing exp() didn't trigger OverflowError") +- +- # If this fails, it could be a puzzle. One odd possibility is that +- # mathmodule.c's macros are getting confused while comparing +- # Inf (HUGE_VAL) to a NaN, and artificially setting errno to ERANGE +- # as a result (and so raising OverflowError instead). +- try: +- x = math.sqrt(-1.0) +- except ValueError: +- pass +- else: +- self.fail("sqrt(-1) didn't raise ValueError") ++ # If this fails, it could be a puzzle. One odd possibility is that ++ # mathmodule.c's macros are getting confused while comparing ++ # Inf (HUGE_VAL) to a NaN, and artificially setting errno to ERANGE ++ # as a result (and so raising OverflowError instead). ++ try: ++ x = math.sqrt(-1.0) ++ except ValueError: ++ pass ++ else: ++ self.fail("sqrt(-1) didn't raise ValueError") + + @requires_IEEE_754 + def test_testfile(self): +diff -r c3896275c0f6 Lib/test/test_memoryview.py +--- a/Lib/test/test_memoryview.py ++++ b/Lib/test/test_memoryview.py +@@ -57,7 +57,7 @@ + + def test_setitem_readonly(self): + if not self.ro_type: +- return ++ self.skipTest("no read-only type to test") + b = self.ro_type(self._source) + oldrefcount = sys.getrefcount(b) + m = self._view(b) +@@ -71,7 +71,7 @@ + + def test_setitem_writable(self): + if not self.rw_type: +- return ++ self.skipTest("no writable type to test") + tp = self.rw_type + b = self.rw_type(self._source) + oldrefcount = sys.getrefcount(b) +@@ -189,13 +189,13 @@ + + def test_attributes_readonly(self): + if not self.ro_type: +- return ++ self.skipTest("no read-only type to test") + m = self.check_attributes_with_type(self.ro_type) + self.assertEqual(m.readonly, True) + + def test_attributes_writable(self): + if not self.rw_type: +- return ++ self.skipTest("no writable type to test") + m = self.check_attributes_with_type(self.rw_type) + self.assertEqual(m.readonly, False) + +@@ -301,7 +301,7 @@ + # buffer as writable causing a segfault if using mmap + tp = self.ro_type + if tp is None: +- return ++ self.skipTest("no read-only type to test") + b = tp(self._source) + m = self._view(b) + i = io.BytesIO(b'ZZZZ') +@@ -370,12 +370,12 @@ + itemsize = array.array('i').itemsize + format = 'i' + ++ @unittest.skip('XXX test should be adapted for non-byte buffers') + def test_getbuffer(self): +- # XXX Test should be adapted for non-byte buffers + pass + ++ @unittest.skip('XXX NotImplementedError: tolist() only supports byte views') + def test_tolist(self): +- # XXX NotImplementedError: tolist() only supports byte views + pass + + +diff -r c3896275c0f6 Lib/test/test_mmap.py +--- a/Lib/test/test_mmap.py ++++ b/Lib/test/test_mmap.py +@@ -314,26 +314,25 @@ + mf.close() + f.close() + ++ @unittest.skipUnless(hasattr(os, "stat"), "needs os.stat()") + def test_entire_file(self): + # test mapping of entire file by passing 0 for map length +- if hasattr(os, "stat"): +- f = open(TESTFN, "wb+") ++ f = open(TESTFN, "wb+") + +- f.write(2**16 * b'm') # Arbitrary character +- f.close() ++ f.write(2**16 * b'm') # Arbitrary character ++ f.close() + +- f = open(TESTFN, "rb+") +- mf = mmap.mmap(f.fileno(), 0) +- self.assertEqual(len(mf), 2**16, "Map size should equal file size.") +- self.assertEqual(mf.read(2**16), 2**16 * b"m") +- mf.close() +- f.close() ++ f = open(TESTFN, "rb+") ++ mf = mmap.mmap(f.fileno(), 0) ++ self.assertEqual(len(mf), 2**16, "Map size should equal file size.") ++ self.assertEqual(mf.read(2**16), 2**16 * b"m") ++ mf.close() ++ f.close() + ++ @unittest.skipUnless(hasattr(os, "stat"), "needs os.stat()") + def test_length_0_offset(self): + # Issue #10916: test mapping of remainder of file by passing 0 for + # map length with an offset doesn't cause a segfault. +- if not hasattr(os, "stat"): +- self.skipTest("needs os.stat") + # NOTE: allocation granularity is currently 65536 under Win64, + # and therefore the minimum offset alignment. + with open(TESTFN, "wb") as f: +@@ -343,12 +342,10 @@ + with mmap.mmap(f.fileno(), 0, offset=65536, access=mmap.ACCESS_READ) as mf: + self.assertRaises(IndexError, mf.__getitem__, 80000) + ++ @unittest.skipUnless(hasattr(os, "stat"), "needs os.stat()") + def test_length_0_large_offset(self): + # Issue #10959: test mapping of a file by passing 0 for + # map length with a large offset doesn't cause a segfault. +- if not hasattr(os, "stat"): +- self.skipTest("needs os.stat") +- + with open(TESTFN, "wb") as f: + f.write(115699 * b'm') # Arbitrary character + +@@ -560,9 +557,8 @@ + return mmap.mmap.__new__(klass, -1, *args, **kwargs) + anon_mmap(PAGESIZE) + ++ @unittest.skipUnless(hasattr(mmap, 'PROT_READ'), "needs mmap.PROT_READ") + def test_prot_readonly(self): +- if not hasattr(mmap, 'PROT_READ'): +- return + mapsize = 10 + with open(TESTFN, "wb") as fp: + fp.write(b"a"*mapsize) +@@ -616,67 +612,69 @@ + self.assertEqual(m.read_byte(), b) + m.close() + +- if os.name == 'nt': +- def test_tagname(self): +- data1 = b"0123456789" +- data2 = b"abcdefghij" +- assert len(data1) == len(data2) ++ @unittest.skipUnless(os.name == 'nt', 'requires Windows') ++ def test_tagname(self): ++ data1 = b"0123456789" ++ data2 = b"abcdefghij" ++ assert len(data1) == len(data2) + +- # Test same tag +- m1 = mmap.mmap(-1, len(data1), tagname="foo") +- m1[:] = data1 +- m2 = mmap.mmap(-1, len(data2), tagname="foo") +- m2[:] = data2 +- self.assertEqual(m1[:], data2) +- self.assertEqual(m2[:], data2) +- m2.close() +- m1.close() ++ # Test same tag ++ m1 = mmap.mmap(-1, len(data1), tagname="foo") ++ m1[:] = data1 ++ m2 = mmap.mmap(-1, len(data2), tagname="foo") ++ m2[:] = data2 ++ self.assertEqual(m1[:], data2) ++ self.assertEqual(m2[:], data2) ++ m2.close() ++ m1.close() + +- # Test different tag +- m1 = mmap.mmap(-1, len(data1), tagname="foo") +- m1[:] = data1 +- m2 = mmap.mmap(-1, len(data2), tagname="boo") +- m2[:] = data2 +- self.assertEqual(m1[:], data1) +- self.assertEqual(m2[:], data2) +- m2.close() +- m1.close() ++ # Test different tag ++ m1 = mmap.mmap(-1, len(data1), tagname="foo") ++ m1[:] = data1 ++ m2 = mmap.mmap(-1, len(data2), tagname="boo") ++ m2[:] = data2 ++ self.assertEqual(m1[:], data1) ++ self.assertEqual(m2[:], data2) ++ m2.close() ++ m1.close() + +- def test_crasher_on_windows(self): +- # Should not crash (Issue 1733986) +- m = mmap.mmap(-1, 1000, tagname="foo") +- try: +- mmap.mmap(-1, 5000, tagname="foo")[:] # same tagname, but larger size +- except: +- pass +- m.close() ++ @unittest.skipUnless(os.name == 'nt', 'requires Windows') ++ def test_crasher_on_windows(self): ++ # Should not crash (Issue 1733986) ++ m = mmap.mmap(-1, 1000, tagname="foo") ++ try: ++ mmap.mmap(-1, 5000, tagname="foo")[:] # same tagname, but larger size ++ except: ++ pass ++ m.close() + +- # Should not crash (Issue 5385) +- with open(TESTFN, "wb") as fp: +- fp.write(b"x"*10) +- f = open(TESTFN, "r+b") +- m = mmap.mmap(f.fileno(), 0) +- f.close() +- try: +- m.resize(0) # will raise WindowsError +- except: +- pass +- try: +- m[:] +- except: +- pass +- m.close() ++ # Should not crash (Issue 5385) ++ with open(TESTFN, "wb") as fp: ++ fp.write(b"x"*10) ++ f = open(TESTFN, "r+b") ++ m = mmap.mmap(f.fileno(), 0) ++ f.close() ++ try: ++ m.resize(0) # will raise WindowsError ++ except: ++ pass ++ try: ++ m[:] ++ except: ++ pass ++ m.close() + +- def test_invalid_descriptor(self): +- # socket file descriptors are valid, but out of range +- # for _get_osfhandle, causing a crash when validating the +- # parameters to _get_osfhandle. +- s = socket.socket() +- try: +- with self.assertRaises(mmap.error): +- m = mmap.mmap(s.fileno(), 10) +- finally: +- s.close() ++ @unittest.skipUnless(os.name == 'nt', 'requires Windows') ++ def test_invalid_descriptor(self): ++ # socket file descriptors are valid, but out of range ++ # for _get_osfhandle, causing a crash when validating the ++ # parameters to _get_osfhandle. ++ s = socket.socket() ++ try: ++ with self.assertRaises(mmap.error): ++ m = mmap.mmap(s.fileno(), 10) ++ finally: ++ s.close() + + def test_context_manager(self): + with mmap.mmap(-1, 10) as m: +diff -r c3896275c0f6 Lib/test/test_multiprocessing.py +--- a/Lib/test/test_multiprocessing.py ++++ b/Lib/test/test_multiprocessing.py +@@ -195,7 +195,7 @@ + + def test_current(self): + if self.TYPE == 'threads': +- return ++ self.skipTest('test not appropriate for {}'.format(self.TYPE)) + + current = self.current_process() + authkey = current.authkey +@@ -209,7 +209,7 @@ + + def test_daemon_argument(self): + if self.TYPE == "threads": +- return ++ self.skipTest('test not appropriate for {}'.format(self.TYPE)) + + # By default uses the current process's daemon flag. + proc0 = self.Process(target=self._test) +@@ -274,7 +274,7 @@ + + def test_terminate(self): + if self.TYPE == 'threads': +- return ++ self.skipTest('test not appropriate for {}'.format(self.TYPE)) + + p = self.Process(target=self._test_terminate) + p.daemon = True +@@ -378,7 +378,7 @@ + + def test_sentinel(self): + if self.TYPE == "threads": +- return ++ self.skipTest('test not appropriate for {}'.format(self.TYPE)) + event = self.Event() + p = self.Process(target=self._test_sentinel, args=(event,)) + with self.assertRaises(ValueError): +@@ -434,7 +434,7 @@ + def test_stderr_flush(self): + # sys.stderr is flushed at process shutdown (issue #13812) + if self.TYPE == "threads": +- return ++ self.skipTest('test not appropriate for {}'.format(self.TYPE)) + + testfn = test.support.TESTFN + self.addCleanup(test.support.unlink, testfn) +@@ -462,12 +462,12 @@ + def test_sys_exit(self): + # See Issue 13854 + if self.TYPE == 'threads': +- return ++ self.skipTest('test not appropriate for {}'.format(self.TYPE)) + + testfn = test.support.TESTFN + self.addCleanup(test.support.unlink, testfn) + +- for reason, code in (([1, 2, 3], 1), ('ignore this', 0)): ++ for reason, code in (([1, 2, 3], 1), ('ignore this', 1)): + p = self.Process(target=self._test_sys_exit, args=(reason, testfn)) + p.daemon = True + p.start() +@@ -671,7 +671,7 @@ + try: + self.assertEqual(q.qsize(), 0) + except NotImplementedError: +- return ++ self.skipTest('qsize method not implemented') + q.put(1) + self.assertEqual(q.qsize(), 1) + q.put(5) +@@ -716,7 +716,7 @@ + start = time.time() + self.assertRaises(pyqueue.Empty, q.get, True, 0.2) + delta = time.time() - start +- self.assertGreaterEqual(delta, 0.19) ++ self.assertGreaterEqual(delta, 0.18) + + # + # +@@ -779,7 +779,7 @@ + + def test_timeout(self): + if self.TYPE != 'processes': +- return ++ self.skipTest('test not appropriate for {}'.format(self.TYPE)) + + sem = self.Semaphore(0) + acquire = TimingWrapper(sem.acquire) +@@ -1399,7 +1399,7 @@ + + def test_thousand(self): + if self.TYPE == 'manager': +- return ++ self.skipTest('test not appropriate for {}'.format(self.TYPE)) + passes = 1000 + lock = self.Lock() + conn, child_conn = self.Pipe(False) +@@ -1691,6 +1691,16 @@ + self.assertEqual(2, len(call_args)) + self.assertIsInstance(call_args[1], ValueError) + ++ def test_map_unplicklable(self): ++ # Issue #19425 -- failure to pickle should not cause a hang ++ if self.TYPE == 'threads': ++ self.skipTest('test not appropriate for {}'.format(self.TYPE)) ++ class A(object): ++ def __reduce__(self): ++ raise RuntimeError('cannot pickle') ++ with self.assertRaises(RuntimeError): ++ self.pool.map(sqr, [A()]*10) ++ + def test_map_chunksize(self): + try: + self.pool.map_async(sqr, [], chunksize=1).get(timeout=TIMEOUT1) +@@ -1704,7 +1714,7 @@ + self.assertTimingAlmostEqual(get.elapsed, TIMEOUT1) + + def test_async_timeout(self): +- res = self.pool.apply_async(sqr, (6, TIMEOUT2 + 0.2)) ++ res = self.pool.apply_async(sqr, (6, TIMEOUT2 + 1.0)) + get = TimingWrapper(res.get) + self.assertRaises(multiprocessing.TimeoutError, get, timeout=TIMEOUT2) + self.assertTimingAlmostEqual(get.elapsed, TIMEOUT2) +@@ -2178,7 +2188,7 @@ + + def test_sendbytes(self): + if self.TYPE != 'processes': +- return ++ self.skipTest('test not appropriate for {}'.format(self.TYPE)) + + msg = latin('abcdefghijklmnopqrstuvwxyz') + a, b = self.Pipe() +diff -r c3896275c0f6 Lib/test/test_nis.py +--- a/Lib/test/test_nis.py ++++ b/Lib/test/test_nis.py +@@ -12,11 +12,7 @@ + maps = nis.maps() + except nis.error as msg: + # NIS is probably not active, so this test isn't useful +- if support.verbose: +- print("Test Skipped:", msg) +- # Can't raise SkipTest as regrtest only recognizes the exception +- # import time. +- return ++ self.skipTest(str(msg)) + try: + # On some systems, this map is only accessible to the + # super user +diff -r c3896275c0f6 Lib/test/test_nntplib.py +--- a/Lib/test/test_nntplib.py ++++ b/Lib/test/test_nntplib.py +@@ -6,10 +6,12 @@ + import functools + import contextlib + from test import support +-from nntplib import NNTP, GroupInfo, _have_ssl ++from nntplib import NNTP, GroupInfo + import nntplib +-if _have_ssl: ++try: + import ssl ++except ImportError: ++ ssl = None + + TIMEOUT = 30 + +@@ -199,23 +201,23 @@ + resp, caps = self.server.capabilities() + _check_caps(caps) + +- if _have_ssl: +- def test_starttls(self): +- file = self.server.file +- sock = self.server.sock +- try: +- self.server.starttls() +- except nntplib.NNTPPermanentError: +- self.skipTest("STARTTLS not supported by server.") +- else: +- # Check that the socket and internal pseudo-file really were +- # changed. +- self.assertNotEqual(file, self.server.file) +- self.assertNotEqual(sock, self.server.sock) +- # Check that the new socket really is an SSL one +- self.assertIsInstance(self.server.sock, ssl.SSLSocket) +- # Check that trying starttls when it's already active fails. +- self.assertRaises(ValueError, self.server.starttls) ++ @unittest.skipUnless(ssl, 'requires SSL support') ++ def test_starttls(self): ++ file = self.server.file ++ sock = self.server.sock ++ try: ++ self.server.starttls() ++ except nntplib.NNTPPermanentError: ++ self.skipTest("STARTTLS not supported by server.") ++ else: ++ # Check that the socket and internal pseudo-file really were ++ # changed. ++ self.assertNotEqual(file, self.server.file) ++ self.assertNotEqual(sock, self.server.sock) ++ # Check that the new socket really is an SSL one ++ self.assertIsInstance(self.server.sock, ssl.SSLSocket) ++ # Check that trying starttls when it's already active fails. ++ self.assertRaises(ValueError, self.server.starttls) + + def test_zlogin(self): + # This test must be the penultimate because further commands will be +@@ -300,25 +302,24 @@ + if cls.server is not None: + cls.server.quit() + ++@unittest.skipUnless(ssl, 'requires SSL support') ++class NetworkedNNTP_SSLTests(NetworkedNNTPTests): + +-if _have_ssl: +- class NetworkedNNTP_SSLTests(NetworkedNNTPTests): ++ # Technical limits for this public NNTP server (see http://www.aioe.org): ++ # "Only two concurrent connections per IP address are allowed and ++ # 400 connections per day are accepted from each IP address." + +- # Technical limits for this public NNTP server (see http://www.aioe.org): +- # "Only two concurrent connections per IP address are allowed and +- # 400 connections per day are accepted from each IP address." ++ NNTP_HOST = 'nntp.aioe.org' ++ GROUP_NAME = 'comp.lang.python' ++ GROUP_PAT = 'comp.lang.*' + +- NNTP_HOST = 'nntp.aioe.org' +- GROUP_NAME = 'comp.lang.python' +- GROUP_PAT = 'comp.lang.*' ++ NNTP_CLASS = getattr(nntplib, 'NNTP_SSL', None) + +- NNTP_CLASS = nntplib.NNTP_SSL ++ # Disabled as it produces too much data ++ test_list = None + +- # Disabled as it produces too much data +- test_list = None +- +- # Disabled as the connection will already be encrypted. +- test_starttls = None ++ # Disabled as the connection will already be encrypted. ++ test_starttls = None + + + # +@@ -1407,12 +1408,13 @@ + gives(2000, 6, 23, "000623", "000000") + gives(2010, 6, 5, "100605", "000000") + ++ @unittest.skipUnless(ssl, 'requires SSL support') ++ def test_ssl_support(self): ++ self.assertTrue(hasattr(nntplib, 'NNTP_SSL')) + + def test_main(): + tests = [MiscTests, NNTPv1Tests, NNTPv2Tests, CapsAfterLoginNNTPv2Tests, +- SendReaderNNTPv2Tests, NetworkedNNTPTests] +- if _have_ssl: +- tests.append(NetworkedNNTP_SSLTests) ++ SendReaderNNTPv2Tests, NetworkedNNTPTests, NetworkedNNTP_SSLTests] + support.run_unittest(*tests) + + +diff -r c3896275c0f6 Lib/test/test_ntpath.py +--- a/Lib/test/test_ntpath.py ++++ b/Lib/test/test_ntpath.py +@@ -218,7 +218,7 @@ + import nt + tester('ntpath.abspath("C:\\")', "C:\\") + except ImportError: +- pass ++ self.skipTest('nt module not available') + + def test_relpath(self): + currentdir = os.path.split(os.getcwd())[-1] +diff -r c3896275c0f6 Lib/test/test_os.py +--- a/Lib/test/test_os.py ++++ b/Lib/test/test_os.py +@@ -178,10 +178,8 @@ + os.unlink(self.fname) + os.rmdir(support.TESTFN) + ++ @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()') + def check_stat_attributes(self, fname): +- if not hasattr(os, "stat"): +- return +- + result = os.stat(fname) + + # Make sure direct access works +@@ -258,16 +256,14 @@ + warnings.simplefilter("ignore", DeprecationWarning) + self.check_stat_attributes(fname) + ++ @unittest.skipUnless(hasattr(os, 'statvfs'), 'test needs os.statvfs()') + def test_statvfs_attributes(self): +- if not hasattr(os, "statvfs"): +- return +- + try: + result = os.statvfs(self.fname) + except OSError as e: + # On AtheOS, glibc always returns ENOSYS + if e.errno == errno.ENOSYS: +- return ++ self.skipTest('glibc always returns ENOSYS on AtheOS') + + # Make sure direct access works + self.assertEqual(result.f_bfree, result[3]) +@@ -450,10 +446,10 @@ + os.close(dirfd) + self._test_utime_subsecond(set_time) + +- # Restrict test to Win32, since there is no guarantee other ++ # Restrict tests to Win32, since there is no guarantee other + # systems support centiseconds +- if sys.platform == 'win32': +- def get_file_system(path): ++ def get_file_system(path): ++ if sys.platform == 'win32': + root = os.path.splitdrive(os.path.abspath(path))[0] + '\\' + import ctypes + kernel32 = ctypes.windll.kernel32 +@@ -461,38 +457,45 @@ + if kernel32.GetVolumeInformationW(root, None, 0, None, None, None, buf, len(buf)): + return buf.value + +- if get_file_system(support.TESTFN) == "NTFS": +- def test_1565150(self): +- t1 = 1159195039.25 +- os.utime(self.fname, (t1, t1)) +- self.assertEqual(os.stat(self.fname).st_mtime, t1) ++ @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") ++ @unittest.skipUnless(get_file_system(support.TESTFN) == "NTFS", ++ "requires NTFS") ++ def test_1565150(self): ++ t1 = 1159195039.25 ++ os.utime(self.fname, (t1, t1)) ++ self.assertEqual(os.stat(self.fname).st_mtime, t1) + +- def test_large_time(self): +- t1 = 5000000000 # some day in 2128 +- os.utime(self.fname, (t1, t1)) +- self.assertEqual(os.stat(self.fname).st_mtime, t1) ++ @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") ++ @unittest.skipUnless(get_file_system(support.TESTFN) == "NTFS", ++ "requires NTFS") ++ def test_large_time(self): ++ t1 = 5000000000 # some day in 2128 ++ os.utime(self.fname, (t1, t1)) ++ self.assertEqual(os.stat(self.fname).st_mtime, t1) + +- def test_1686475(self): +- # Verify that an open file can be stat'ed +- try: +- os.stat(r"c:\pagefile.sys") +- except WindowsError as e: +- if e.errno == 2: # file does not exist; cannot run test +- return +- self.fail("Could not stat pagefile.sys") ++ @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") ++ def test_1686475(self): ++ # Verify that an open file can be stat'ed ++ try: ++ os.stat(r"c:\pagefile.sys") ++ except WindowsError as e: ++ if e.errno == 2: # file does not exist; cannot run test ++ self.skipTest(r'c:\pagefile.sys does not exist') ++ self.fail("Could not stat pagefile.sys") + +- @unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()") +- def test_15261(self): +- # Verify that stat'ing a closed fd does not cause crash +- r, w = os.pipe() +- try: +- os.stat(r) # should not raise error +- finally: +- os.close(r) +- os.close(w) +- with self.assertRaises(OSError) as ctx: +- os.stat(r) +- self.assertEqual(ctx.exception.errno, errno.EBADF) ++ @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") ++ @unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()") ++ def test_15261(self): ++ # Verify that stat'ing a closed fd does not cause crash ++ r, w = os.pipe() ++ try: ++ os.stat(r) # should not raise error ++ finally: ++ os.close(r) ++ os.close(w) ++ with self.assertRaises(OSError) as ctx: ++ os.stat(r) ++ self.assertEqual(ctx.exception.errno, errno.EBADF) + + from test import mapping_tests + +@@ -1127,6 +1130,7 @@ + self._test_internal_execvpe(bytes) + + ++@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") + class Win32ErrorTests(unittest.TestCase): + def test_rename(self): + self.assertRaises(WindowsError, os.rename, support.TESTFN, support.TESTFN+".bak") +@@ -1173,63 +1177,63 @@ + self.fail("%r didn't raise a OSError with a bad file descriptor" + % f) + ++ @unittest.skipUnless(hasattr(os, 'isatty'), 'test needs os.isatty()') + def test_isatty(self): +- if hasattr(os, "isatty"): +- self.assertEqual(os.isatty(support.make_bad_fd()), False) ++ self.assertEqual(os.isatty(support.make_bad_fd()), False) + ++ @unittest.skipUnless(hasattr(os, 'closerange'), 'test needs os.closerange()') + def test_closerange(self): +- if hasattr(os, "closerange"): +- fd = support.make_bad_fd() +- # Make sure none of the descriptors we are about to close are +- # currently valid (issue 6542). +- for i in range(10): +- try: os.fstat(fd+i) +- except OSError: +- pass +- else: +- break +- if i < 2: +- raise unittest.SkipTest( +- "Unable to acquire a range of invalid file descriptors") +- self.assertEqual(os.closerange(fd, fd + i-1), None) ++ fd = support.make_bad_fd() ++ # Make sure none of the descriptors we are about to close are ++ # currently valid (issue 6542). ++ for i in range(10): ++ try: os.fstat(fd+i) ++ except OSError: ++ pass ++ else: ++ break ++ if i < 2: ++ raise unittest.SkipTest( ++ "Unable to acquire a range of invalid file descriptors") ++ self.assertEqual(os.closerange(fd, fd + i-1), None) + ++ @unittest.skipUnless(hasattr(os, 'dup2'), 'test needs os.dup2()') + def test_dup2(self): +- if hasattr(os, "dup2"): +- self.check(os.dup2, 20) ++ self.check(os.dup2, 20) + ++ @unittest.skipUnless(hasattr(os, 'fchmod'), 'test needs os.fchmod()') + def test_fchmod(self): +- if hasattr(os, "fchmod"): +- self.check(os.fchmod, 0) ++ self.check(os.fchmod, 0) + ++ @unittest.skipUnless(hasattr(os, 'fchown'), 'test needs os.fchown()') + def test_fchown(self): +- if hasattr(os, "fchown"): +- self.check(os.fchown, -1, -1) ++ self.check(os.fchown, -1, -1) + ++ @unittest.skipUnless(hasattr(os, 'fpathconf'), 'test needs os.fpathconf()') + def test_fpathconf(self): +- if hasattr(os, "fpathconf"): +- self.check(os.pathconf, "PC_NAME_MAX") +- self.check(os.fpathconf, "PC_NAME_MAX") ++ self.check(os.pathconf, "PC_NAME_MAX") ++ self.check(os.fpathconf, "PC_NAME_MAX") + ++ @unittest.skipUnless(hasattr(os, 'ftruncate'), 'test needs os.ftruncate()') + def test_ftruncate(self): +- if hasattr(os, "ftruncate"): +- self.check(os.truncate, 0) +- self.check(os.ftruncate, 0) ++ self.check(os.truncate, 0) ++ self.check(os.ftruncate, 0) + ++ @unittest.skipUnless(hasattr(os, 'lseek'), 'test needs os.lseek()') + def test_lseek(self): +- if hasattr(os, "lseek"): +- self.check(os.lseek, 0, 0) ++ self.check(os.lseek, 0, 0) + ++ @unittest.skipUnless(hasattr(os, 'read'), 'test needs os.read()') + def test_read(self): +- if hasattr(os, "read"): +- self.check(os.read, 1) ++ self.check(os.read, 1) + ++ @unittest.skipUnless(hasattr(os, 'tcsetpgrp'), 'test needs os.tcsetpgrp()') + def test_tcsetpgrpt(self): +- if hasattr(os, "tcsetpgrp"): +- self.check(os.tcsetpgrp, 0) ++ self.check(os.tcsetpgrp, 0) + ++ @unittest.skipUnless(hasattr(os, 'write'), 'test needs os.write()') + def test_write(self): +- if hasattr(os, "write"): +- self.check(os.write, b" ") ++ self.check(os.write, b" ") + + + class LinkTests(unittest.TestCase): +@@ -1269,138 +1273,117 @@ + self.file2 = self.file1 + "2" + self._test_link(self.file1, self.file2) + +-if sys.platform != 'win32': +- class Win32ErrorTests(unittest.TestCase): +- pass ++@unittest.skipIf(sys.platform == "win32", "Posix specific tests") ++class PosixUidGidTests(unittest.TestCase): ++ @unittest.skipUnless(hasattr(os, 'setuid'), 'test needs os.setuid()') ++ def test_setuid(self): ++ if os.getuid() != 0: ++ self.assertRaises(os.error, os.setuid, 0) ++ self.assertRaises(OverflowError, os.setuid, 1<<32) + +- class PosixUidGidTests(unittest.TestCase): +- if hasattr(os, 'setuid'): +- def test_setuid(self): +- if os.getuid() != 0: +- self.assertRaises(os.error, os.setuid, 0) +- self.assertRaises(OverflowError, os.setuid, 1<<32) ++ @unittest.skipUnless(hasattr(os, 'setgid'), 'test needs os.setgid()') ++ def test_setgid(self): ++ if os.getuid() != 0 and not HAVE_WHEEL_GROUP: ++ self.assertRaises(os.error, os.setgid, 0) ++ self.assertRaises(OverflowError, os.setgid, 1<<32) + +- if hasattr(os, 'setgid'): +- def test_setgid(self): +- if os.getuid() != 0 and not HAVE_WHEEL_GROUP: +- self.assertRaises(os.error, os.setgid, 0) +- self.assertRaises(OverflowError, os.setgid, 1<<32) ++ @unittest.skipUnless(hasattr(os, 'seteuid'), 'test needs os.seteuid()') ++ def test_seteuid(self): ++ if os.getuid() != 0: ++ self.assertRaises(os.error, os.seteuid, 0) ++ self.assertRaises(OverflowError, os.seteuid, 1<<32) + +- if hasattr(os, 'seteuid'): +- def test_seteuid(self): +- if os.getuid() != 0: +- self.assertRaises(os.error, os.seteuid, 0) +- self.assertRaises(OverflowError, os.seteuid, 1<<32) ++ @unittest.skipUnless(hasattr(os, 'setegid'), 'test needs os.setegid()') ++ def test_setegid(self): ++ if os.getuid() != 0 and not HAVE_WHEEL_GROUP: ++ self.assertRaises(os.error, os.setegid, 0) ++ self.assertRaises(OverflowError, os.setegid, 1<<32) + +- if hasattr(os, 'setegid'): +- def test_setegid(self): +- if os.getuid() != 0 and not HAVE_WHEEL_GROUP: +- self.assertRaises(os.error, os.setegid, 0) +- self.assertRaises(OverflowError, os.setegid, 1<<32) ++ @unittest.skipUnless(hasattr(os, 'setreuid'), 'test needs os.setreuid()') ++ def test_setreuid(self): ++ if os.getuid() != 0: ++ self.assertRaises(os.error, os.setreuid, 0, 0) ++ self.assertRaises(OverflowError, os.setreuid, 1<<32, 0) ++ self.assertRaises(OverflowError, os.setreuid, 0, 1<<32) + +- if hasattr(os, 'setreuid'): +- def test_setreuid(self): +- if os.getuid() != 0: +- self.assertRaises(os.error, os.setreuid, 0, 0) +- self.assertRaises(OverflowError, os.setreuid, 1<<32, 0) +- self.assertRaises(OverflowError, os.setreuid, 0, 1<<32) ++ @unittest.skipUnless(hasattr(os, 'setregid'), 'test needs os.setregid()') ++ def test_setregid(self): ++ if os.getuid() != 0 and not HAVE_WHEEL_GROUP: ++ self.assertRaises(os.error, os.setregid, 0, 0) ++ self.assertRaises(OverflowError, os.setregid, 1<<32, 0) ++ self.assertRaises(OverflowError, os.setregid, 0, 1<<32) + +- def test_setreuid_neg1(self): +- # Needs to accept -1. We run this in a subprocess to avoid +- # altering the test runner's process state (issue8045). +- subprocess.check_call([ +- sys.executable, '-c', +- 'import os,sys;os.setreuid(-1,-1);sys.exit(0)']) ++@unittest.skipIf(sys.platform == "win32", "Posix specific tests") ++class Pep383Tests(unittest.TestCase): ++ def setUp(self): ++ if support.TESTFN_UNENCODABLE: ++ self.dir = support.TESTFN_UNENCODABLE ++ elif support.TESTFN_NONASCII: ++ self.dir = support.TESTFN_NONASCII ++ else: ++ self.dir = support.TESTFN ++ self.bdir = os.fsencode(self.dir) + +- if hasattr(os, 'setregid'): +- def test_setregid(self): +- if os.getuid() != 0 and not HAVE_WHEEL_GROUP: +- self.assertRaises(os.error, os.setregid, 0, 0) +- self.assertRaises(OverflowError, os.setregid, 1<<32, 0) +- self.assertRaises(OverflowError, os.setregid, 0, 1<<32) ++ bytesfn = [] ++ def add_filename(fn): ++ try: ++ fn = os.fsencode(fn) ++ except UnicodeEncodeError: ++ return ++ bytesfn.append(fn) ++ add_filename(support.TESTFN_UNICODE) ++ if support.TESTFN_UNENCODABLE: ++ add_filename(support.TESTFN_UNENCODABLE) ++ if support.TESTFN_NONASCII: ++ add_filename(support.TESTFN_NONASCII) ++ if not bytesfn: ++ self.skipTest("couldn't create any non-ascii filename") + +- def test_setregid_neg1(self): +- # Needs to accept -1. We run this in a subprocess to avoid +- # altering the test runner's process state (issue8045). +- subprocess.check_call([ +- sys.executable, '-c', +- 'import os,sys;os.setregid(-1,-1);sys.exit(0)']) ++ self.unicodefn = set() ++ os.mkdir(self.dir) ++ try: ++ for fn in bytesfn: ++ support.create_empty_file(os.path.join(self.bdir, fn)) ++ fn = os.fsdecode(fn) ++ if fn in self.unicodefn: ++ raise ValueError("duplicate filename") ++ self.unicodefn.add(fn) ++ except: ++ shutil.rmtree(self.dir) ++ raise + +- class Pep383Tests(unittest.TestCase): +- def setUp(self): +- if support.TESTFN_UNENCODABLE: +- self.dir = support.TESTFN_UNENCODABLE +- elif support.TESTFN_NONASCII: +- self.dir = support.TESTFN_NONASCII +- else: +- self.dir = support.TESTFN +- self.bdir = os.fsencode(self.dir) ++ def tearDown(self): ++ shutil.rmtree(self.dir) + +- bytesfn = [] +- def add_filename(fn): +- try: +- fn = os.fsencode(fn) +- except UnicodeEncodeError: +- return +- bytesfn.append(fn) +- add_filename(support.TESTFN_UNICODE) +- if support.TESTFN_UNENCODABLE: +- add_filename(support.TESTFN_UNENCODABLE) +- if support.TESTFN_NONASCII: +- add_filename(support.TESTFN_NONASCII) +- if not bytesfn: +- self.skipTest("couldn't create any non-ascii filename") ++ def test_listdir(self): ++ expected = self.unicodefn ++ found = set(os.listdir(self.dir)) ++ self.assertEqual(found, expected) ++ # test listdir without arguments ++ current_directory = os.getcwd() ++ try: ++ os.chdir(os.sep) ++ self.assertEqual(set(os.listdir()), set(os.listdir(os.sep))) ++ finally: ++ os.chdir(current_directory) + +- self.unicodefn = set() +- os.mkdir(self.dir) +- try: +- for fn in bytesfn: +- support.create_empty_file(os.path.join(self.bdir, fn)) +- fn = os.fsdecode(fn) +- if fn in self.unicodefn: +- raise ValueError("duplicate filename") +- self.unicodefn.add(fn) +- except: +- shutil.rmtree(self.dir) +- raise ++ def test_open(self): ++ for fn in self.unicodefn: ++ f = open(os.path.join(self.dir, fn), 'rb') ++ f.close() + +- def tearDown(self): +- shutil.rmtree(self.dir) ++ @unittest.skipUnless(hasattr(os, 'statvfs'), ++ "need os.statvfs()") ++ def test_statvfs(self): ++ # issue #9645 ++ for fn in self.unicodefn: ++ # should not fail with file not found error ++ fullname = os.path.join(self.dir, fn) ++ os.statvfs(fullname) + +- def test_listdir(self): +- expected = self.unicodefn +- found = set(os.listdir(self.dir)) +- self.assertEqual(found, expected) +- # test listdir without arguments +- current_directory = os.getcwd() +- try: +- os.chdir(os.sep) +- self.assertEqual(set(os.listdir()), set(os.listdir(os.sep))) +- finally: +- os.chdir(current_directory) +- +- def test_open(self): +- for fn in self.unicodefn: +- f = open(os.path.join(self.dir, fn), 'rb') +- f.close() +- +- @unittest.skipUnless(hasattr(os, 'statvfs'), +- "need os.statvfs()") +- def test_statvfs(self): +- # issue #9645 +- for fn in self.unicodefn: +- # should not fail with file not found error +- fullname = os.path.join(self.dir, fn) +- os.statvfs(fullname) +- +- def test_stat(self): +- for fn in self.unicodefn: +- os.stat(os.path.join(self.dir, fn)) +-else: +- class PosixUidGidTests(unittest.TestCase): +- pass +- class Pep383Tests(unittest.TestCase): +- pass ++ def test_stat(self): ++ for fn in self.unicodefn: ++ os.stat(os.path.join(self.dir, fn)) + + @unittest.skipUnless(sys.platform == "win32", "Win32 specific tests") + class Win32KillTests(unittest.TestCase): +@@ -1838,6 +1821,8 @@ + SUPPORT_HEADERS_TRAILERS = not sys.platform.startswith("linux") and \ + not sys.platform.startswith("solaris") and \ + not sys.platform.startswith("sunos") ++ requires_headers_trailers = unittest.skipUnless(SUPPORT_HEADERS_TRAILERS, ++ 'requires headers and trailers support') + + @classmethod + def setUpClass(cls): +@@ -1956,52 +1941,54 @@ + + # --- headers / trailers tests + +- if SUPPORT_HEADERS_TRAILERS: ++ @requires_headers_trailers ++ def test_headers(self): ++ total_sent = 0 ++ sent = os.sendfile(self.sockno, self.fileno, 0, 4096, ++ headers=[b"x" * 512]) ++ total_sent += sent ++ offset = 4096 ++ nbytes = 4096 ++ while 1: ++ sent = self.sendfile_wrapper(self.sockno, self.fileno, ++ offset, nbytes) ++ if sent == 0: ++ break ++ total_sent += sent ++ offset += sent + +- def test_headers(self): +- total_sent = 0 +- sent = os.sendfile(self.sockno, self.fileno, 0, 4096, +- headers=[b"x" * 512]) +- total_sent += sent +- offset = 4096 +- nbytes = 4096 +- while 1: +- sent = self.sendfile_wrapper(self.sockno, self.fileno, +- offset, nbytes) +- if sent == 0: +- break +- total_sent += sent +- offset += sent ++ expected_data = b"x" * 512 + self.DATA ++ self.assertEqual(total_sent, len(expected_data)) ++ self.client.close() ++ self.server.wait() ++ data = self.server.handler_instance.get_data() ++ self.assertEqual(hash(data), hash(expected_data)) + +- expected_data = b"x" * 512 + self.DATA +- self.assertEqual(total_sent, len(expected_data)) ++ @requires_headers_trailers ++ def test_trailers(self): ++ TESTFN2 = support.TESTFN + "2" ++ file_data = b"abcdef" ++ with open(TESTFN2, 'wb') as f: ++ f.write(file_data) ++ with open(TESTFN2, 'rb')as f: ++ self.addCleanup(os.remove, TESTFN2) ++ os.sendfile(self.sockno, f.fileno(), 0, len(file_data), ++ trailers=[b"1234"]) + self.client.close() + self.server.wait() + data = self.server.handler_instance.get_data() +- self.assertEqual(hash(data), hash(expected_data)) ++ self.assertEqual(data, b"abcdef1234") + +- def test_trailers(self): +- TESTFN2 = support.TESTFN + "2" +- file_data = b"abcdef" +- with open(TESTFN2, 'wb') as f: +- f.write(file_data) +- with open(TESTFN2, 'rb')as f: +- self.addCleanup(os.remove, TESTFN2) +- os.sendfile(self.sockno, f.fileno(), 0, len(file_data), +- trailers=[b"1234"]) +- self.client.close() +- self.server.wait() +- data = self.server.handler_instance.get_data() +- self.assertEqual(data, b"abcdef1234") +- +- if hasattr(os, "SF_NODISKIO"): +- def test_flags(self): +- try: +- os.sendfile(self.sockno, self.fileno, 0, 4096, +- flags=os.SF_NODISKIO) +- except OSError as err: +- if err.errno not in (errno.EBUSY, errno.EAGAIN): +- raise ++ @requires_headers_trailers ++ @unittest.skipUnless(hasattr(os, 'SF_NODISKIO'), ++ 'test needs os.SF_NODISKIO') ++ def test_flags(self): ++ try: ++ os.sendfile(self.sockno, self.fileno, 0, 4096, ++ flags=os.SF_NODISKIO) ++ except OSError as err: ++ if err.errno not in (errno.EBUSY, errno.EAGAIN): ++ raise + + + def supports_extended_attributes(): +diff -r c3896275c0f6 Lib/test/test_poplib.py +--- a/Lib/test/test_poplib.py ++++ b/Lib/test/test_poplib.py +@@ -11,7 +11,7 @@ + import time + import errno + +-from unittest import TestCase ++from unittest import TestCase, skipUnless + from test import support as test_support + threading = test_support.import_module('threading') + +@@ -288,35 +288,37 @@ + else: + DummyPOP3Handler.handle_read(self) + ++requires_ssl = skipUnless(SUPPORTS_SSL, 'SSL not supported') + +- class TestPOP3_SSLClass(TestPOP3Class): +- # repeat previous tests by using poplib.POP3_SSL ++@requires_ssl ++class TestPOP3_SSLClass(TestPOP3Class): ++ # repeat previous tests by using poplib.POP3_SSL + +- def setUp(self): +- self.server = DummyPOP3Server((HOST, PORT)) +- self.server.handler = DummyPOP3_SSLHandler +- self.server.start() +- self.client = poplib.POP3_SSL(self.server.host, self.server.port) ++ def setUp(self): ++ self.server = DummyPOP3Server((HOST, PORT)) ++ self.server.handler = DummyPOP3_SSLHandler ++ self.server.start() ++ self.client = poplib.POP3_SSL(self.server.host, self.server.port) + +- def test__all__(self): +- self.assertIn('POP3_SSL', poplib.__all__) ++ def test__all__(self): ++ self.assertIn('POP3_SSL', poplib.__all__) + +- def test_context(self): +- ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) +- self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host, +- self.server.port, keyfile=CERTFILE, context=ctx) +- self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host, +- self.server.port, certfile=CERTFILE, context=ctx) +- self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host, +- self.server.port, keyfile=CERTFILE, +- certfile=CERTFILE, context=ctx) ++ def test_context(self): ++ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ++ self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host, ++ self.server.port, keyfile=CERTFILE, context=ctx) ++ self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host, ++ self.server.port, certfile=CERTFILE, context=ctx) ++ self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host, ++ self.server.port, keyfile=CERTFILE, ++ certfile=CERTFILE, context=ctx) + +- self.client.quit() +- self.client = poplib.POP3_SSL(self.server.host, self.server.port, +- context=ctx) +- self.assertIsInstance(self.client.sock, ssl.SSLSocket) +- self.assertIs(self.client.sock.context, ctx) +- self.assertTrue(self.client.noop().startswith(b'+OK')) ++ self.client.quit() ++ self.client = poplib.POP3_SSL(self.server.host, self.server.port, ++ context=ctx) ++ self.assertIsInstance(self.client.sock, ssl.SSLSocket) ++ self.assertIs(self.client.sock.context, ctx) ++ self.assertTrue(self.client.noop().startswith(b'+OK')) + + + class TestTimeouts(TestCase): +@@ -374,9 +376,8 @@ + + + def test_main(): +- tests = [TestPOP3Class, TestTimeouts] +- if SUPPORTS_SSL: +- tests.append(TestPOP3_SSLClass) ++ tests = [TestPOP3Class, TestTimeouts, ++ TestPOP3_SSLClass] + thread_info = test_support.threading_setup() + try: + test_support.run_unittest(*tests) +diff -r c3896275c0f6 Lib/test/test_posix.py +--- a/Lib/test/test_posix.py ++++ b/Lib/test/test_posix.py +@@ -54,47 +54,55 @@ + posix_func() + self.assertRaises(TypeError, posix_func, 1) + +- if hasattr(posix, 'getresuid'): +- def test_getresuid(self): +- user_ids = posix.getresuid() +- self.assertEqual(len(user_ids), 3) +- for val in user_ids: +- self.assertGreaterEqual(val, 0) ++ @unittest.skipUnless(hasattr(posix, 'getresuid'), ++ 'test needs posix.getresuid()') ++ def test_getresuid(self): ++ user_ids = posix.getresuid() ++ self.assertEqual(len(user_ids), 3) ++ for val in user_ids: ++ self.assertGreaterEqual(val, 0) + +- if hasattr(posix, 'getresgid'): +- def test_getresgid(self): +- group_ids = posix.getresgid() +- self.assertEqual(len(group_ids), 3) +- for val in group_ids: +- self.assertGreaterEqual(val, 0) ++ @unittest.skipUnless(hasattr(posix, 'getresgid'), ++ 'test needs posix.getresgid()') ++ def test_getresgid(self): ++ group_ids = posix.getresgid() ++ self.assertEqual(len(group_ids), 3) ++ for val in group_ids: ++ self.assertGreaterEqual(val, 0) + +- if hasattr(posix, 'setresuid'): +- def test_setresuid(self): +- current_user_ids = posix.getresuid() +- self.assertIsNone(posix.setresuid(*current_user_ids)) +- # -1 means don't change that value. +- self.assertIsNone(posix.setresuid(-1, -1, -1)) ++ @unittest.skipUnless(hasattr(posix, 'setresuid'), ++ 'test needs posix.setresuid()') ++ def test_setresuid(self): ++ current_user_ids = posix.getresuid() ++ self.assertIsNone(posix.setresuid(*current_user_ids)) ++ # -1 means don't change that value. ++ self.assertIsNone(posix.setresuid(-1, -1, -1)) + +- def test_setresuid_exception(self): +- # Don't do this test if someone is silly enough to run us as root. +- current_user_ids = posix.getresuid() +- if 0 not in current_user_ids: +- new_user_ids = (current_user_ids[0]+1, -1, -1) +- self.assertRaises(OSError, posix.setresuid, *new_user_ids) ++ @unittest.skipUnless(hasattr(posix, 'setresuid'), ++ 'test needs posix.setresuid()') ++ def test_setresuid_exception(self): ++ # Don't do this test if someone is silly enough to run us as root. ++ current_user_ids = posix.getresuid() ++ if 0 not in current_user_ids: ++ new_user_ids = (current_user_ids[0]+1, -1, -1) ++ self.assertRaises(OSError, posix.setresuid, *new_user_ids) + +- if hasattr(posix, 'setresgid'): +- def test_setresgid(self): +- current_group_ids = posix.getresgid() +- self.assertIsNone(posix.setresgid(*current_group_ids)) +- # -1 means don't change that value. +- self.assertIsNone(posix.setresgid(-1, -1, -1)) ++ @unittest.skipUnless(hasattr(posix, 'setresgid'), ++ 'test needs posix.setresgid()') ++ def test_setresgid(self): ++ current_group_ids = posix.getresgid() ++ self.assertIsNone(posix.setresgid(*current_group_ids)) ++ # -1 means don't change that value. ++ self.assertIsNone(posix.setresgid(-1, -1, -1)) + +- def test_setresgid_exception(self): +- # Don't do this test if someone is silly enough to run us as root. +- current_group_ids = posix.getresgid() +- if 0 not in current_group_ids: +- new_group_ids = (current_group_ids[0]+1, -1, -1) +- self.assertRaises(OSError, posix.setresgid, *new_group_ids) ++ @unittest.skipUnless(hasattr(posix, 'setresgid'), ++ 'test needs posix.setresgid()') ++ def test_setresgid_exception(self): ++ # Don't do this test if someone is silly enough to run us as root. ++ current_group_ids = posix.getresgid() ++ if 0 not in current_group_ids: ++ new_group_ids = (current_group_ids[0]+1, -1, -1) ++ self.assertRaises(OSError, posix.setresgid, *new_group_ids) + + @unittest.skipUnless(hasattr(posix, 'initgroups'), + "test needs os.initgroups()") +@@ -121,29 +129,32 @@ + else: + self.fail("Expected OSError to be raised by initgroups") + ++ @unittest.skipUnless(hasattr(posix, 'statvfs'), ++ 'test needs posix.statvfs()') + def test_statvfs(self): +- if hasattr(posix, 'statvfs'): +- self.assertTrue(posix.statvfs(os.curdir)) ++ self.assertTrue(posix.statvfs(os.curdir)) + ++ @unittest.skipUnless(hasattr(posix, 'fstatvfs'), ++ 'test needs posix.fstatvfs()') + def test_fstatvfs(self): +- if hasattr(posix, 'fstatvfs'): +- fp = open(support.TESTFN) +- try: +- self.assertTrue(posix.fstatvfs(fp.fileno())) +- self.assertTrue(posix.statvfs(fp.fileno())) +- finally: +- fp.close() ++ fp = open(support.TESTFN) ++ try: ++ self.assertTrue(posix.fstatvfs(fp.fileno())) ++ self.assertTrue(posix.statvfs(fp.fileno())) ++ finally: ++ fp.close() + ++ @unittest.skipUnless(hasattr(posix, 'ftruncate'), ++ 'test needs posix.ftruncate()') + def test_ftruncate(self): +- if hasattr(posix, 'ftruncate'): +- fp = open(support.TESTFN, 'w+') +- try: +- # we need to have some data to truncate +- fp.write('test') +- fp.flush() +- posix.ftruncate(fp.fileno(), 0) +- finally: +- fp.close() ++ fp = open(support.TESTFN, 'w+') ++ try: ++ # we need to have some data to truncate ++ fp.write('test') ++ fp.flush() ++ posix.ftruncate(fp.fileno(), 0) ++ finally: ++ fp.close() + + @unittest.skipUnless(hasattr(posix, 'truncate'), "test needs posix.truncate()") + def test_truncate(self): +@@ -290,30 +301,33 @@ + finally: + os.close(fd) + ++ @unittest.skipUnless(hasattr(posix, 'dup'), ++ 'test needs posix.dup()') + def test_dup(self): +- if hasattr(posix, 'dup'): +- fp = open(support.TESTFN) +- try: +- fd = posix.dup(fp.fileno()) +- self.assertIsInstance(fd, int) +- os.close(fd) +- finally: +- fp.close() ++ fp = open(support.TESTFN) ++ try: ++ fd = posix.dup(fp.fileno()) ++ self.assertIsInstance(fd, int) ++ os.close(fd) ++ finally: ++ fp.close() + ++ @unittest.skipUnless(hasattr(posix, 'confstr'), ++ 'test needs posix.confstr()') + def test_confstr(self): +- if hasattr(posix, 'confstr'): +- self.assertRaises(ValueError, posix.confstr, "CS_garbage") +- self.assertEqual(len(posix.confstr("CS_PATH")) > 0, True) ++ self.assertRaises(ValueError, posix.confstr, "CS_garbage") ++ self.assertEqual(len(posix.confstr("CS_PATH")) > 0, True) + ++ @unittest.skipUnless(hasattr(posix, 'dup2'), ++ 'test needs posix.dup2()') + def test_dup2(self): +- if hasattr(posix, 'dup2'): +- fp1 = open(support.TESTFN) +- fp2 = open(support.TESTFN) +- try: +- posix.dup2(fp1.fileno(), fp2.fileno()) +- finally: +- fp1.close() +- fp2.close() ++ fp1 = open(support.TESTFN) ++ fp2 = open(support.TESTFN) ++ try: ++ posix.dup2(fp1.fileno(), fp2.fileno()) ++ finally: ++ fp1.close() ++ fp2.close() + + @unittest.skipUnless(hasattr(os, 'O_CLOEXEC'), "needs os.O_CLOEXEC") + @support.requires_linux_version(2, 6, 23) +@@ -322,65 +336,69 @@ + self.addCleanup(os.close, fd) + self.assertTrue(fcntl.fcntl(fd, fcntl.F_GETFD) & fcntl.FD_CLOEXEC) + ++ @unittest.skipUnless(hasattr(posix, 'O_EXLOCK'), ++ 'test needs posix.O_EXLOCK') + def test_osexlock(self): +- if hasattr(posix, "O_EXLOCK"): ++ fd = os.open(support.TESTFN, ++ os.O_WRONLY|os.O_EXLOCK|os.O_CREAT) ++ self.assertRaises(OSError, os.open, support.TESTFN, ++ os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK) ++ os.close(fd) ++ ++ if hasattr(posix, "O_SHLOCK"): + fd = os.open(support.TESTFN, +- os.O_WRONLY|os.O_EXLOCK|os.O_CREAT) ++ os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) + self.assertRaises(OSError, os.open, support.TESTFN, + os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK) + os.close(fd) + +- if hasattr(posix, "O_SHLOCK"): +- fd = os.open(support.TESTFN, +- os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) +- self.assertRaises(OSError, os.open, support.TESTFN, +- os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK) +- os.close(fd) ++ @unittest.skipUnless(hasattr(posix, 'O_SHLOCK'), ++ 'test needs posix.O_SHLOCK') ++ def test_osshlock(self): ++ fd1 = os.open(support.TESTFN, ++ os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) ++ fd2 = os.open(support.TESTFN, ++ os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) ++ os.close(fd2) ++ os.close(fd1) + +- def test_osshlock(self): +- if hasattr(posix, "O_SHLOCK"): +- fd1 = os.open(support.TESTFN, ++ if hasattr(posix, "O_EXLOCK"): ++ fd = os.open(support.TESTFN, + os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) +- fd2 = os.open(support.TESTFN, +- os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) +- os.close(fd2) +- os.close(fd1) ++ self.assertRaises(OSError, os.open, support.TESTFN, ++ os.O_RDONLY|os.O_EXLOCK|os.O_NONBLOCK) ++ os.close(fd) + +- if hasattr(posix, "O_EXLOCK"): +- fd = os.open(support.TESTFN, +- os.O_WRONLY|os.O_SHLOCK|os.O_CREAT) +- self.assertRaises(OSError, os.open, support.TESTFN, +- os.O_RDONLY|os.O_EXLOCK|os.O_NONBLOCK) +- os.close(fd) +- ++ @unittest.skipUnless(hasattr(posix, 'fstat'), ++ 'test needs posix.fstat()') + def test_fstat(self): +- if hasattr(posix, 'fstat'): +- fp = open(support.TESTFN) +- try: +- self.assertTrue(posix.fstat(fp.fileno())) +- self.assertTrue(posix.stat(fp.fileno())) +- +- self.assertRaisesRegex(TypeError, +- 'should be string, bytes or integer, not', +- posix.stat, float(fp.fileno())) +- finally: +- fp.close() +- +- def test_stat(self): +- if hasattr(posix, 'stat'): +- self.assertTrue(posix.stat(support.TESTFN)) +- self.assertTrue(posix.stat(os.fsencode(support.TESTFN))) +- self.assertTrue(posix.stat(bytearray(os.fsencode(support.TESTFN)))) ++ fp = open(support.TESTFN) ++ try: ++ self.assertTrue(posix.fstat(fp.fileno())) ++ self.assertTrue(posix.stat(fp.fileno())) + + self.assertRaisesRegex(TypeError, +- 'can\'t specify None for path argument', +- posix.stat, None) +- self.assertRaisesRegex(TypeError, + 'should be string, bytes or integer, not', +- posix.stat, list(support.TESTFN)) +- self.assertRaisesRegex(TypeError, +- 'should be string, bytes or integer, not', +- posix.stat, list(os.fsencode(support.TESTFN))) ++ posix.stat, float(fp.fileno())) ++ finally: ++ fp.close() ++ ++ @unittest.skipUnless(hasattr(posix, 'stat'), ++ 'test needs posix.stat()') ++ def test_stat(self): ++ self.assertTrue(posix.stat(support.TESTFN)) ++ self.assertTrue(posix.stat(os.fsencode(support.TESTFN))) ++ self.assertTrue(posix.stat(bytearray(os.fsencode(support.TESTFN)))) ++ ++ self.assertRaisesRegex(TypeError, ++ 'can\'t specify None for path argument', ++ posix.stat, None) ++ self.assertRaisesRegex(TypeError, ++ 'should be string, bytes or integer, not', ++ posix.stat, list(support.TESTFN)) ++ self.assertRaisesRegex(TypeError, ++ 'should be string, bytes or integer, not', ++ posix.stat, list(os.fsencode(support.TESTFN))) + + @unittest.skipUnless(hasattr(posix, 'mkfifo'), "don't have mkfifo()") + def test_mkfifo(self): +@@ -495,10 +513,10 @@ + self._test_all_chown_common(posix.lchown, support.TESTFN, + getattr(posix, 'lstat', None)) + ++ @unittest.skipUnless(hasattr(posix, 'chdir'), 'test needs posix.chdir()') + def test_chdir(self): +- if hasattr(posix, 'chdir'): +- posix.chdir(os.curdir) +- self.assertRaises(OSError, posix.chdir, support.TESTFN) ++ posix.chdir(os.curdir) ++ self.assertRaises(OSError, posix.chdir, support.TESTFN) + + def test_listdir(self): + self.assertTrue(support.TESTFN in posix.listdir(os.curdir)) +@@ -528,25 +546,26 @@ + sorted(posix.listdir(f)) + ) + ++ @unittest.skipUnless(hasattr(posix, 'access'), 'test needs posix.access()') + def test_access(self): +- if hasattr(posix, 'access'): +- self.assertTrue(posix.access(support.TESTFN, os.R_OK)) ++ self.assertTrue(posix.access(support.TESTFN, os.R_OK)) + ++ @unittest.skipUnless(hasattr(posix, 'umask'), 'test needs posix.umask()') + def test_umask(self): +- if hasattr(posix, 'umask'): +- old_mask = posix.umask(0) +- self.assertIsInstance(old_mask, int) +- posix.umask(old_mask) ++ old_mask = posix.umask(0) ++ self.assertIsInstance(old_mask, int) ++ posix.umask(old_mask) + ++ @unittest.skipUnless(hasattr(posix, 'strerror'), ++ 'test needs posix.strerror()') + def test_strerror(self): +- if hasattr(posix, 'strerror'): +- self.assertTrue(posix.strerror(0)) ++ self.assertTrue(posix.strerror(0)) + ++ @unittest.skipUnless(hasattr(posix, 'pipe'), 'test needs posix.pipe()') + def test_pipe(self): +- if hasattr(posix, 'pipe'): +- reader, writer = posix.pipe() +- os.close(reader) +- os.close(writer) ++ reader, writer = posix.pipe() ++ os.close(reader) ++ os.close(writer) + + @unittest.skipUnless(hasattr(os, 'pipe2'), "test needs os.pipe2()") + @support.requires_linux_version(2, 6, 27) +@@ -578,15 +597,15 @@ + self.assertRaises(OverflowError, os.pipe2, _testcapi.INT_MAX + 1) + self.assertRaises(OverflowError, os.pipe2, _testcapi.UINT_MAX + 1) + ++ @unittest.skipUnless(hasattr(posix, 'utime'), 'test needs posix.utime()') + def test_utime(self): +- if hasattr(posix, 'utime'): +- now = time.time() +- posix.utime(support.TESTFN, None) +- self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, None)) +- self.assertRaises(TypeError, posix.utime, support.TESTFN, (now, None)) +- self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, now)) +- posix.utime(support.TESTFN, (int(now), int(now))) +- posix.utime(support.TESTFN, (now, now)) ++ now = time.time() ++ posix.utime(support.TESTFN, None) ++ self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, None)) ++ self.assertRaises(TypeError, posix.utime, support.TESTFN, (now, None)) ++ self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, now)) ++ posix.utime(support.TESTFN, (int(now), int(now))) ++ posix.utime(support.TESTFN, (now, now)) + + def _test_chflags_regular_file(self, chflags_func, target_file, **kwargs): + st = os.stat(target_file) +@@ -663,6 +682,7 @@ + self.assertEqual(type(k), item_type) + self.assertEqual(type(v), item_type) + ++ @unittest.skipUnless(hasattr(posix, 'getcwd'), 'test needs posix.getcwd()') + def test_getcwd_long_pathnames(self): + if hasattr(posix, 'getcwd'): + dirname = 'getcwd-test-directory-0123456789abcdef-01234567890abcdef' +diff -r c3896275c0f6 Lib/test/test_pwd.py +--- a/Lib/test/test_pwd.py ++++ b/Lib/test/test_pwd.py +@@ -8,8 +8,6 @@ + + def test_values(self): + entries = pwd.getpwall() +- entriesbyname = {} +- entriesbyuid = {} + + for e in entries: + self.assertEqual(len(e), 7) +@@ -32,13 +30,20 @@ + # for one uid + # self.assertEqual(pwd.getpwuid(e.pw_uid), e) + # instead of this collect all entries for one uid +- # and check afterwards ++ # and check afterwards (done in test_values_extended) ++ ++ def test_values_extended(self): ++ entries = pwd.getpwall() ++ entriesbyname = {} ++ entriesbyuid = {} ++ ++ if len(entries) > 1000: # Huge passwd file (NIS?) -- skip this test ++ self.skipTest('passwd file is huge; extended test skipped') ++ ++ for e in entries: + entriesbyname.setdefault(e.pw_name, []).append(e) + entriesbyuid.setdefault(e.pw_uid, []).append(e) + +- if len(entries) > 1000: # Huge passwd file (NIS?) -- skip the rest +- return +- + # check whether the entry returned by getpwuid() + # for each uid is among those from getpwall() for this uid + for e in entries: +diff -r c3896275c0f6 Lib/test/test_pydoc.py +--- a/Lib/test/test_pydoc.py ++++ b/Lib/test/test_pydoc.py +@@ -404,7 +404,7 @@ + def test_namedtuple_public_underscore(self): + NT = namedtuple('NT', ['abc', 'def'], rename=True) + with captured_stdout() as help_io: +- help(NT) ++ pydoc.help(NT) + helptext = help_io.getvalue() + self.assertIn('_1', helptext) + self.assertIn('_replace', helptext) +diff -r c3896275c0f6 Lib/test/test_random.py +--- a/Lib/test/test_random.py ++++ b/Lib/test/test_random.py +@@ -194,10 +194,10 @@ + + def test_bigrand_ranges(self): + for i in [40,80, 160, 200, 211, 250, 375, 512, 550]: +- start = self.gen.randrange(2 ** i) +- stop = self.gen.randrange(2 ** (i-2)) ++ start = self.gen.randrange(2 ** (i-2)) ++ stop = self.gen.randrange(2 ** i) + if stop <= start: +- return ++ continue + self.assertTrue(start <= self.gen.randrange(start, stop) < stop) + + def test_rangelimits(self): +@@ -357,10 +357,10 @@ + + def test_bigrand_ranges(self): + for i in [40,80, 160, 200, 211, 250, 375, 512, 550]: +- start = self.gen.randrange(2 ** i) +- stop = self.gen.randrange(2 ** (i-2)) ++ start = self.gen.randrange(2 ** (i-2)) ++ stop = self.gen.randrange(2 ** i) + if stop <= start: +- return ++ continue + self.assertTrue(start <= self.gen.randrange(start, stop) < stop) + + def test_rangelimits(self): +diff -r c3896275c0f6 Lib/test/test_reprlib.py +--- a/Lib/test/test_reprlib.py ++++ b/Lib/test/test_reprlib.py +@@ -166,6 +166,7 @@ + eq(r([[[[[[{}]]]]]]), "[[[[[[{}]]]]]]") + eq(r([[[[[[[{}]]]]]]]), "[[[[[[[...]]]]]]]") + ++ @unittest.skip('hard to catch a cell object') + def test_cell(self): + # XXX Hmm? How to get at a cell object? + pass +@@ -272,6 +273,7 @@ + eq(repr(foo.foo), + "" % foo.__name__) + ++ @unittest.skip('need a suitable object') + def test_object(self): + # XXX Test the repr of a type with a really long tp_name but with no + # tp_repr. WIBNI we had ::Inline? :) +@@ -319,6 +321,7 @@ + '= myobj + self.assertTrue(myobj.le_called) + +- # C API test only available in a debug build +- if hasattr(set, "test_c_api"): +- def test_c_api(self): +- self.assertEqual(set().test_c_api(), True) ++ @unittest.skipUnless(hasattr(set, "test_c_api"), ++ 'C API test only available in a debug build') ++ def test_c_api(self): ++ self.assertEqual(set().test_c_api(), True) + + class SetSubclass(set): + pass +diff -r c3896275c0f6 Lib/test/test_shutil.py +--- a/Lib/test/test_shutil.py ++++ b/Lib/test/test_shutil.py +@@ -194,37 +194,37 @@ + self.assertIn(errors[1][2][1].filename, possible_args) + + +- # See bug #1071513 for why we don't run this on cygwin +- # and bug #1076467 for why we don't run this as root. +- if (hasattr(os, 'chmod') and sys.platform[:6] != 'cygwin' +- and not (hasattr(os, 'geteuid') and os.geteuid() == 0)): +- def test_on_error(self): +- self.errorState = 0 +- os.mkdir(TESTFN) +- self.addCleanup(shutil.rmtree, TESTFN) ++ @unittest.skipUnless(hasattr(os, 'chmod'), 'requires os.chmod()') ++ @unittest.skipIf(sys.platform[:6] == 'cygwin', ++ "This test can't be run on Cygwin (issue #1071513).") ++ @unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0, ++ "This test can't be run reliably as root (issue #1076467).") ++ def test_on_error(self): ++ self.errorState = 0 ++ os.mkdir(TESTFN) ++ self.addCleanup(shutil.rmtree, TESTFN) + +- self.child_file_path = os.path.join(TESTFN, 'a') +- self.child_dir_path = os.path.join(TESTFN, 'b') +- support.create_empty_file(self.child_file_path) +- os.mkdir(self.child_dir_path) +- old_dir_mode = os.stat(TESTFN).st_mode +- old_child_file_mode = os.stat(self.child_file_path).st_mode +- old_child_dir_mode = os.stat(self.child_dir_path).st_mode +- # Make unwritable. +- new_mode = stat.S_IREAD|stat.S_IEXEC +- os.chmod(self.child_file_path, new_mode) +- os.chmod(self.child_dir_path, new_mode) +- os.chmod(TESTFN, new_mode) ++ self.child_file_path = os.path.join(TESTFN, 'a') ++ self.child_dir_path = os.path.join(TESTFN, 'b') ++ support.create_empty_file(self.child_file_path) ++ os.mkdir(self.child_dir_path) ++ old_dir_mode = os.stat(TESTFN).st_mode ++ old_child_file_mode = os.stat(self.child_file_path).st_mode ++ old_child_dir_mode = os.stat(self.child_dir_path).st_mode ++ # Make unwritable. ++ new_mode = stat.S_IREAD|stat.S_IEXEC ++ os.chmod(self.child_file_path, new_mode) ++ os.chmod(self.child_dir_path, new_mode) ++ os.chmod(TESTFN, new_mode) + +- self.addCleanup(os.chmod, TESTFN, old_dir_mode) +- self.addCleanup(os.chmod, self.child_file_path, old_child_file_mode) +- self.addCleanup(os.chmod, self.child_dir_path, old_child_dir_mode) ++ self.addCleanup(os.chmod, TESTFN, old_dir_mode) ++ self.addCleanup(os.chmod, self.child_file_path, old_child_file_mode) ++ self.addCleanup(os.chmod, self.child_dir_path, old_child_dir_mode) + +- shutil.rmtree(TESTFN, onerror=self.check_args_to_onerror) +- # Test whether onerror has actually been called. +- self.assertEqual(self.errorState, 3, +- "Expected call to onerror function did not " +- "happen.") ++ shutil.rmtree(TESTFN, onerror=self.check_args_to_onerror) ++ # Test whether onerror has actually been called. ++ self.assertEqual(self.errorState, 3, ++ "Expected call to onerror function did not happen.") + + def check_args_to_onerror(self, func, arg, exc): + # test_rmtree_errors deliberately runs rmtree +@@ -752,11 +752,9 @@ + self.assertEquals(os.stat(restrictive_subdir).st_mode, + os.stat(restrictive_subdir_dst).st_mode) + ++ @unittest.skipIf(os.name == 'nt', 'temporarily disabled on Windows') + @unittest.skipUnless(hasattr(os, 'link'), 'requires os.link') + def test_dont_copy_file_onto_link_to_itself(self): +- # Temporarily disable test on Windows. +- if os.name == 'nt': +- return + # bug 851123. + os.mkdir(TESTFN) + src = os.path.join(TESTFN, 'cheese') +@@ -806,38 +804,39 @@ + finally: + shutil.rmtree(TESTFN, ignore_errors=True) + +- if hasattr(os, "mkfifo"): +- # Issue #3002: copyfile and copytree block indefinitely on named pipes +- def test_copyfile_named_pipe(self): +- os.mkfifo(TESTFN) ++ # Issue #3002: copyfile and copytree block indefinitely on named pipes ++ @unittest.skipUnless(hasattr(os, "mkfifo"), 'requires os.mkfifo()') ++ def test_copyfile_named_pipe(self): ++ os.mkfifo(TESTFN) ++ try: ++ self.assertRaises(shutil.SpecialFileError, ++ shutil.copyfile, TESTFN, TESTFN2) ++ self.assertRaises(shutil.SpecialFileError, ++ shutil.copyfile, __file__, TESTFN) ++ finally: ++ os.remove(TESTFN) ++ ++ @unittest.skipUnless(hasattr(os, "mkfifo"), 'requires os.mkfifo()') ++ @support.skip_unless_symlink ++ def test_copytree_named_pipe(self): ++ os.mkdir(TESTFN) ++ try: ++ subdir = os.path.join(TESTFN, "subdir") ++ os.mkdir(subdir) ++ pipe = os.path.join(subdir, "mypipe") ++ os.mkfifo(pipe) + try: +- self.assertRaises(shutil.SpecialFileError, +- shutil.copyfile, TESTFN, TESTFN2) +- self.assertRaises(shutil.SpecialFileError, +- shutil.copyfile, __file__, TESTFN) +- finally: +- os.remove(TESTFN) +- +- @support.skip_unless_symlink +- def test_copytree_named_pipe(self): +- os.mkdir(TESTFN) +- try: +- subdir = os.path.join(TESTFN, "subdir") +- os.mkdir(subdir) +- pipe = os.path.join(subdir, "mypipe") +- os.mkfifo(pipe) +- try: +- shutil.copytree(TESTFN, TESTFN2) +- except shutil.Error as e: +- errors = e.args[0] +- self.assertEqual(len(errors), 1) +- src, dst, error_msg = errors[0] +- self.assertEqual("`%s` is a named pipe" % pipe, error_msg) +- else: +- self.fail("shutil.Error should have been raised") +- finally: +- shutil.rmtree(TESTFN, ignore_errors=True) +- shutil.rmtree(TESTFN2, ignore_errors=True) ++ shutil.copytree(TESTFN, TESTFN2) ++ except shutil.Error as e: ++ errors = e.args[0] ++ self.assertEqual(len(errors), 1) ++ src, dst, error_msg = errors[0] ++ self.assertEqual("`%s` is a named pipe" % pipe, error_msg) ++ else: ++ self.fail("shutil.Error should have been raised") ++ finally: ++ shutil.rmtree(TESTFN, ignore_errors=True) ++ shutil.rmtree(TESTFN2, ignore_errors=True) + + def test_copytree_special_func(self): + +diff -r c3896275c0f6 Lib/test/test_site.py +--- a/Lib/test/test_site.py ++++ b/Lib/test/test_site.py +@@ -374,6 +374,7 @@ + self.assertNotIn(path, seen_paths) + seen_paths.add(path) + ++ @unittest.skip('test not implemented') + def test_add_build_dir(self): + # Test that the build directory's Modules directory is used when it + # should be. +diff -r c3896275c0f6 Lib/test/test_socket.py +--- a/Lib/test/test_socket.py ++++ b/Lib/test/test_socket.py +@@ -714,13 +714,13 @@ + ip = socket.gethostbyname(hostname) + except socket.error: + # Probably name lookup wasn't set up right; skip this test +- return ++ self.skipTest('name lookup failure') + self.assertTrue(ip.find('.') >= 0, "Error resolving host to ip.") + try: + hname, aliases, ipaddrs = socket.gethostbyaddr(ip) + except socket.error: + # Probably a similar problem as above; skip this test +- return ++ self.skipTest('name lookup failure') + all_host_names = [hostname, hname] + aliases + fqhn = socket.getfqdn(ip) + if not fqhn in all_host_names: +@@ -772,16 +772,17 @@ + self.assertRaises(TypeError, socket.if_nametoindex, 0) + self.assertRaises(TypeError, socket.if_indextoname, '_DEADBEEF') + ++ @unittest.skipUnless(hasattr(sys, 'getrefcount'), ++ 'test needs sys.getrefcount()') + def testRefCountGetNameInfo(self): + # Testing reference count for getnameinfo +- if hasattr(sys, "getrefcount"): +- try: +- # On some versions, this loses a reference +- orig = sys.getrefcount(__name__) +- socket.getnameinfo(__name__,0) +- except TypeError: +- if sys.getrefcount(__name__) != orig: +- self.fail("socket.getnameinfo loses a reference") ++ try: ++ # On some versions, this loses a reference ++ orig = sys.getrefcount(__name__) ++ socket.getnameinfo(__name__,0) ++ except TypeError: ++ if sys.getrefcount(__name__) != orig: ++ self.fail("socket.getnameinfo loses a reference") + + def testInterpreterCrash(self): + # Making sure getnameinfo doesn't crash the interpreter +@@ -886,17 +887,17 @@ + # Check that setting it to an invalid type raises TypeError + self.assertRaises(TypeError, socket.setdefaulttimeout, "spam") + ++ @unittest.skipUnless(hasattr(socket, 'inet_aton'), ++ 'test needs socket.inet_aton()') + def testIPv4_inet_aton_fourbytes(self): +- if not hasattr(socket, 'inet_aton'): +- return # No inet_aton, nothing to check + # Test that issue1008086 and issue767150 are fixed. + # It must return 4 bytes. + self.assertEqual(b'\x00'*4, socket.inet_aton('0.0.0.0')) + self.assertEqual(b'\xff'*4, socket.inet_aton('255.255.255.255')) + ++ @unittest.skipUnless(hasattr(socket, 'inet_pton'), ++ 'test needs socket.inet_pton()') + def testIPv4toString(self): +- if not hasattr(socket, 'inet_pton'): +- return # No inet_pton() on this platform + from socket import inet_aton as f, inet_pton, AF_INET + g = lambda a: inet_pton(AF_INET, a) + +@@ -925,15 +926,15 @@ + assertInvalid(g, '1.2.3.4.5') + assertInvalid(g, '::1') + ++ @unittest.skipUnless(hasattr(socket, 'inet_pton'), ++ 'test needs socket.inet_pton()') + def testIPv6toString(self): +- if not hasattr(socket, 'inet_pton'): +- return # No inet_pton() on this platform + try: + from socket import inet_pton, AF_INET6, has_ipv6 + if not has_ipv6: +- return ++ self.skipTest('IPv6 not available') + except ImportError: +- return ++ self.skipTest('could not import needed symbols from socket') + f = lambda a: inet_pton(AF_INET6, a) + assertInvalid = lambda a: self.assertRaises( + (socket.error, ValueError), f, a +@@ -979,9 +980,9 @@ + assertInvalid('::1.2.3.4:0') + assertInvalid('0.100.200.0:3:4:5:6:7:8') + ++ @unittest.skipUnless(hasattr(socket, 'inet_ntop'), ++ 'test needs socket.inet_ntop()') + def testStringToIPv4(self): +- if not hasattr(socket, 'inet_ntop'): +- return # No inet_ntop() on this platform + from socket import inet_ntoa as f, inet_ntop, AF_INET + g = lambda a: inet_ntop(AF_INET, a) + assertInvalid = lambda func,a: self.assertRaises( +@@ -1003,15 +1004,15 @@ + assertInvalid(g, b'\x00' * 5) + assertInvalid(g, b'\x00' * 16) + ++ @unittest.skipUnless(hasattr(socket, 'inet_ntop'), ++ 'test needs socket.inet_ntop()') + def testStringToIPv6(self): +- if not hasattr(socket, 'inet_ntop'): +- return # No inet_ntop() on this platform + try: + from socket import inet_ntop, AF_INET6, has_ipv6 + if not has_ipv6: +- return ++ self.skipTest('IPv6 not available') + except ImportError: +- return ++ self.skipTest('could not import needed symbols from socket') + f = lambda a: inet_ntop(AF_INET6, a) + assertInvalid = lambda a: self.assertRaises( + (socket.error, ValueError), f, a +@@ -1044,7 +1045,7 @@ + my_ip_addr = socket.gethostbyname(socket.gethostname()) + except socket.error: + # Probably name lookup wasn't set up right; skip this test +- return ++ self.skipTest('name lookup failure') + self.assertIn(name[0], ("0.0.0.0", my_ip_addr), '%s invalid' % name[0]) + self.assertEqual(name[1], port) + +@@ -3531,6 +3532,8 @@ + self.cli.connect((HOST, self.port)) + time.sleep(1.0) + ++@unittest.skipUnless(hasattr(socket, 'socketpair'), ++ 'test needs socket.socketpair()') + @unittest.skipUnless(thread, 'Threading required for this test.') + class BasicSocketPairTest(SocketPairTest): + +@@ -3593,26 +3596,27 @@ + def _testSetBlocking(self): + pass + +- if hasattr(socket, "SOCK_NONBLOCK"): +- @support.requires_linux_version(2, 6, 28) +- def testInitNonBlocking(self): +- # reinit server socket +- self.serv.close() +- self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM | +- socket.SOCK_NONBLOCK) +- self.port = support.bind_port(self.serv) +- self.serv.listen(1) +- # actual testing +- start = time.time() +- try: +- self.serv.accept() +- except socket.error: +- pass +- end = time.time() +- self.assertTrue((end - start) < 1.0, "Error creating with non-blocking mode.") +- +- def _testInitNonBlocking(self): ++ @unittest.skipUnless(hasattr(socket, 'SOCK_NONBLOCK'), ++ 'test needs socket.SOCK_NONBLOCK') ++ @support.requires_linux_version(2, 6, 28) ++ def testInitNonBlocking(self): ++ # reinit server socket ++ self.serv.close() ++ self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM | ++ socket.SOCK_NONBLOCK) ++ self.port = support.bind_port(self.serv) ++ self.serv.listen(1) ++ # actual testing ++ start = time.time() ++ try: ++ self.serv.accept() ++ except socket.error: + pass ++ end = time.time() ++ self.assertTrue((end - start) < 1.0, "Error creating with non-blocking mode.") ++ ++ def _testInitNonBlocking(self): ++ pass + + def testInheritFlags(self): + # Issue #7995: when calling accept() on a listening socket with a +@@ -4302,12 +4306,12 @@ + if not ok: + self.fail("accept() returned success when we did not expect it") + ++ @unittest.skipUnless(hasattr(signal, 'alarm'), ++ 'test needs signal.alarm()') + def testInterruptedTimeout(self): + # XXX I don't know how to do this test on MSWindows or any other + # plaform that doesn't support signal.alarm() or os.kill(), though + # the bug should have existed on all platforms. +- if not hasattr(signal, "alarm"): +- return # can only test on *nix + self.serv.settimeout(5.0) # must be longer than alarm + class Alarm(Exception): + pass +@@ -4367,6 +4371,7 @@ + self.assertTrue(issubclass(socket.gaierror, socket.error)) + self.assertTrue(issubclass(socket.timeout, socket.error)) + ++@unittest.skipUnless(sys.platform == 'linux', 'Linux specific test') + class TestLinuxAbstractNamespace(unittest.TestCase): + + UNIX_PATH_MAX = 108 +@@ -4402,6 +4407,7 @@ + finally: + s.close() + ++@unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'test needs socket.AF_UNIX') + class TestUnixDomain(unittest.TestCase): + + def setUp(self): +@@ -4551,10 +4557,10 @@ + for line in f: + if line.startswith("tipc "): + return True +- if support.verbose: +- print("TIPC module is not loaded, please 'sudo modprobe tipc'") + return False + ++@unittest.skipUnless(isTipcAvailable(), ++ "TIPC module is not loaded, please 'sudo modprobe tipc'") + class TIPCTest(unittest.TestCase): + def testRDM(self): + srv = socket.socket(socket.AF_TIPC, socket.SOCK_RDM) +@@ -4577,6 +4583,8 @@ + self.assertEqual(msg, MSG) + + ++@unittest.skipUnless(isTipcAvailable(), ++ "TIPC module is not loaded, please 'sudo modprobe tipc'") + class TIPCThreadableTest(unittest.TestCase, ThreadableTest): + def __init__(self, methodName = 'runTest'): + unittest.TestCase.__init__(self, methodName = methodName) +@@ -4842,15 +4850,10 @@ + CloexecConstantTest, + NonblockConstantTest + ]) +- if hasattr(socket, "socketpair"): +- tests.append(BasicSocketPairTest) +- if hasattr(socket, "AF_UNIX"): +- tests.append(TestUnixDomain) +- if sys.platform == 'linux': +- tests.append(TestLinuxAbstractNamespace) +- if isTipcAvailable(): +- tests.append(TIPCTest) +- tests.append(TIPCThreadableTest) ++ tests.append(BasicSocketPairTest) ++ tests.append(TestUnixDomain) ++ tests.append(TestLinuxAbstractNamespace) ++ tests.extend([TIPCTest, TIPCThreadableTest]) + tests.extend([BasicCANTest, CANTest]) + tests.extend([BasicRDSTest, RDSTest]) + tests.extend([ +diff -r c3896275c0f6 Lib/test/test_socketserver.py +--- a/Lib/test/test_socketserver.py ++++ b/Lib/test/test_socketserver.py +@@ -27,7 +27,10 @@ + HOST = test.support.HOST + + HAVE_UNIX_SOCKETS = hasattr(socket, "AF_UNIX") ++requires_unix_sockets = unittest.skipUnless(HAVE_UNIX_SOCKETS, ++ 'requires Unix sockets') + HAVE_FORKING = hasattr(os, "fork") and os.name != "os2" ++requires_forking = unittest.skipUnless(HAVE_FORKING, 'requires forking') + + def signal_alarm(n): + """Call signal.alarm when it exists (i.e. not on Windows).""" +@@ -189,31 +192,33 @@ + socketserver.StreamRequestHandler, + self.stream_examine) + +- if HAVE_FORKING: +- def test_ForkingTCPServer(self): +- with simple_subprocess(self): +- self.run_server(socketserver.ForkingTCPServer, +- socketserver.StreamRequestHandler, +- self.stream_examine) +- +- if HAVE_UNIX_SOCKETS: +- def test_UnixStreamServer(self): +- self.run_server(socketserver.UnixStreamServer, ++ @requires_forking ++ def test_ForkingTCPServer(self): ++ with simple_subprocess(self): ++ self.run_server(socketserver.ForkingTCPServer, + socketserver.StreamRequestHandler, + self.stream_examine) + +- def test_ThreadingUnixStreamServer(self): +- self.run_server(socketserver.ThreadingUnixStreamServer, ++ @requires_unix_sockets ++ def test_UnixStreamServer(self): ++ self.run_server(socketserver.UnixStreamServer, ++ socketserver.StreamRequestHandler, ++ self.stream_examine) ++ ++ @requires_unix_sockets ++ def test_ThreadingUnixStreamServer(self): ++ self.run_server(socketserver.ThreadingUnixStreamServer, ++ socketserver.StreamRequestHandler, ++ self.stream_examine) ++ ++ @requires_unix_sockets ++ @requires_forking ++ def test_ForkingUnixStreamServer(self): ++ with simple_subprocess(self): ++ self.run_server(ForkingUnixStreamServer, + socketserver.StreamRequestHandler, + self.stream_examine) + +- if HAVE_FORKING: +- def test_ForkingUnixStreamServer(self): +- with simple_subprocess(self): +- self.run_server(ForkingUnixStreamServer, +- socketserver.StreamRequestHandler, +- self.stream_examine) +- + def test_UDPServer(self): + self.run_server(socketserver.UDPServer, + socketserver.DatagramRequestHandler, +@@ -224,12 +229,12 @@ + socketserver.DatagramRequestHandler, + self.dgram_examine) + +- if HAVE_FORKING: +- def test_ForkingUDPServer(self): +- with simple_subprocess(self): +- self.run_server(socketserver.ForkingUDPServer, +- socketserver.DatagramRequestHandler, +- self.dgram_examine) ++ @requires_forking ++ def test_ForkingUDPServer(self): ++ with simple_subprocess(self): ++ self.run_server(socketserver.ForkingUDPServer, ++ socketserver.DatagramRequestHandler, ++ self.dgram_examine) + + @contextlib.contextmanager + def mocked_select_module(self): +@@ -266,22 +271,24 @@ + # Alas, on Linux (at least) recvfrom() doesn't return a meaningful + # client address so this cannot work: + +- # if HAVE_UNIX_SOCKETS: +- # def test_UnixDatagramServer(self): +- # self.run_server(socketserver.UnixDatagramServer, +- # socketserver.DatagramRequestHandler, +- # self.dgram_examine) ++ # @requires_unix_sockets ++ # def test_UnixDatagramServer(self): ++ # self.run_server(socketserver.UnixDatagramServer, ++ # socketserver.DatagramRequestHandler, ++ # self.dgram_examine) + # +- # def test_ThreadingUnixDatagramServer(self): +- # self.run_server(socketserver.ThreadingUnixDatagramServer, +- # socketserver.DatagramRequestHandler, +- # self.dgram_examine) ++ # @requires_unix_sockets ++ # def test_ThreadingUnixDatagramServer(self): ++ # self.run_server(socketserver.ThreadingUnixDatagramServer, ++ # socketserver.DatagramRequestHandler, ++ # self.dgram_examine) + # +- # if HAVE_FORKING: +- # def test_ForkingUnixDatagramServer(self): +- # self.run_server(socketserver.ForkingUnixDatagramServer, +- # socketserver.DatagramRequestHandler, +- # self.dgram_examine) ++ # @requires_unix_sockets ++ # @requires_forking ++ # def test_ForkingUnixDatagramServer(self): ++ # self.run_server(socketserver.ForkingUnixDatagramServer, ++ # socketserver.DatagramRequestHandler, ++ # self.dgram_examine) + + @reap_threads + def test_shutdown(self): +diff -r c3896275c0f6 Lib/test/test_strftime.py +--- a/Lib/test/test_strftime.py ++++ b/Lib/test/test_strftime.py +@@ -176,8 +176,32 @@ + (e[0], e[2])) + print(" Expected %s, but got %s" % (e[1], result)) + ++ ++class Y1900Tests(unittest.TestCase): ++ """A limitation of the MS C runtime library is that it crashes if ++ a date before 1900 is passed with a format string containing "%y" ++ """ ++ ++ @unittest.skipUnless(sys.platform == "win32", "Only applies to Windows") ++ def test_y_before_1900_win(self): ++ with self.assertRaises(ValueError): ++ time.strftime("%y", (1899, 1, 1, 0, 0, 0, 0, 0, 0)) ++ ++ @unittest.skipIf(sys.platform == "win32", "Doesn't apply on Windows") ++ def test_y_before_1900_nonwin(self): ++ self.assertEquals( ++ time.strftime("%y", (1899, 1, 1, 0, 0, 0, 0, 0, 0)), "99") ++ ++ def test_y_1900(self): ++ self.assertEquals( ++ time.strftime("%y", (1900, 1, 1, 0, 0, 0, 0, 0, 0)), "00") ++ ++ def test_y_after_1900(self): ++ self.assertEquals( ++ time.strftime("%y", (2013, 1, 1, 0, 0, 0, 0, 0, 0)), "13") ++ + def test_main(): +- support.run_unittest(StrftimeTest) ++ support.run_unittest(StrftimeTest, Y1900Tests) + + if __name__ == '__main__': + test_main() +diff -r c3896275c0f6 Lib/test/test_strptime.py +--- a/Lib/test/test_strptime.py ++++ b/Lib/test/test_strptime.py +@@ -223,6 +223,10 @@ + with self.assertRaises(ValueError) as e: + _strptime._strptime_time('', '%D') + self.assertIs(e.exception.__suppress_context__, True) ++ # additional check for IndexError branch (issue #19545) ++ with self.assertRaises(ValueError) as e: ++ _strptime._strptime_time('19', '%Y %') ++ self.assertIs(e.exception.__suppress_context__, True) + + def test_unconverteddata(self): + # Check ValueError is raised when there is unconverted data +@@ -319,7 +323,7 @@ + # when time.tzname[0] == time.tzname[1] and time.daylight + tz_name = time.tzname[0] + if tz_name.upper() in ("UTC", "GMT"): +- return ++ self.skipTest('need non-UTC/GMT timezone') + try: + original_tzname = time.tzname + original_daylight = time.daylight +@@ -532,7 +536,7 @@ + try: + locale.setlocale(locale.LC_TIME, ('en_US', 'UTF8')) + except locale.Error: +- return ++ self.skipTest('test needs en_US.UTF8 locale') + try: + _strptime._strptime_time('10', '%d') + # Get id of current cache object. +@@ -549,7 +553,7 @@ + # If this is the case just suppress the exception and fall-through + # to the resetting to the original locale. + except locale.Error: +- pass ++ self.skipTest('test needs de_DE.UTF8 locale') + # Make sure we don't trample on the locale setting once we leave the + # test. + finally: +diff -r c3896275c0f6 Lib/test/test_strtod.py +--- a/Lib/test/test_strtod.py ++++ b/Lib/test/test_strtod.py +@@ -248,6 +248,37 @@ + else: + assert False, "expected ValueError" + ++ @test.support.bigmemtest(size=test.support._2G+10, memuse=4, dry_run=False) ++ def test_oversized_digit_strings(self, maxsize): ++ # Input string whose length doesn't fit in an INT. ++ s = "1." + "1" * maxsize ++ with self.assertRaises(ValueError): ++ float(s) ++ del s ++ ++ s = "0." + "0" * maxsize + "1" ++ with self.assertRaises(ValueError): ++ float(s) ++ del s ++ ++ def test_large_exponents(self): ++ # Verify that the clipping of the exponent in strtod doesn't affect the ++ # output values. ++ def positive_exp(n): ++ """ Long string with value 1.0 and exponent n""" ++ return '0.{}1e+{}'.format('0'*(n-1), n) ++ ++ def negative_exp(n): ++ """ Long string with value 1.0 and exponent -n""" ++ return '1{}e-{}'.format('0'*n, n) ++ ++ self.assertEqual(float(positive_exp(10000)), 1.0) ++ self.assertEqual(float(positive_exp(20000)), 1.0) ++ self.assertEqual(float(positive_exp(30000)), 1.0) ++ self.assertEqual(float(negative_exp(10000)), 1.0) ++ self.assertEqual(float(negative_exp(20000)), 1.0) ++ self.assertEqual(float(negative_exp(30000)), 1.0) ++ + def test_particular(self): + # inputs that produced crashes or incorrectly rounded results with + # previous versions of dtoa.c, for various reasons +diff -r c3896275c0f6 Lib/test/test_subprocess.py +--- a/Lib/test/test_subprocess.py ++++ b/Lib/test/test_subprocess.py +@@ -1559,6 +1559,27 @@ + # all standard fds closed. + self.check_close_std_fds([0, 1, 2]) + ++ def test_small_errpipe_write_fd(self): ++ """Issue #15798: Popen should work when stdio fds are available.""" ++ new_stdin = os.dup(0) ++ new_stdout = os.dup(1) ++ try: ++ os.close(0) ++ os.close(1) ++ ++ # Side test: if errpipe_write fails to have its CLOEXEC ++ # flag set this should cause the parent to think the exec ++ # failed. Extremely unlikely: everyone supports CLOEXEC. ++ subprocess.Popen([ ++ sys.executable, "-c", ++ "print('AssertionError:0:CLOEXEC failure.')"]).wait() ++ finally: ++ # Restore original stdin and stdout ++ os.dup2(new_stdin, 0) ++ os.dup2(new_stdout, 1) ++ os.close(new_stdin) ++ os.close(new_stdout) ++ + def test_remapping_std_fds(self): + # open up some temporary files + temps = [mkstemp() for i in range(3)] +@@ -2133,13 +2154,6 @@ + def test_terminate_dead(self): + self._kill_dead_process('terminate') + +- +-# The module says: +-# "NB This only works (and is only relevant) for UNIX." +-# +-# Actually, getoutput should work on any platform with an os.popen, but +-# I'll take the comment as given, and skip this suite. +-@unittest.skipUnless(os.name == 'posix', "only relevant for UNIX") + class CommandTests(unittest.TestCase): + def test_getoutput(self): + self.assertEqual(subprocess.getoutput('echo xyzzy'), 'xyzzy') +@@ -2153,8 +2167,8 @@ + try: + dir = tempfile.mkdtemp() + name = os.path.join(dir, "foo") +- +- status, output = subprocess.getstatusoutput('cat ' + name) ++ status, output = subprocess.getstatusoutput( ++ ("type " if mswindows else "cat ") + name) + self.assertNotEqual(status, 0) + finally: + if dir is not None: +diff -r c3896275c0f6 Lib/test/test_sys.py +--- a/Lib/test/test_sys.py ++++ b/Lib/test/test_sys.py +@@ -291,15 +291,16 @@ + def test_call_tracing(self): + self.assertRaises(TypeError, sys.call_tracing, type, 2) + ++ @unittest.skipUnless(hasattr(sys, "setdlopenflags"), ++ 'test needs sys.setdlopenflags()') + def test_dlopenflags(self): +- if hasattr(sys, "setdlopenflags"): +- self.assertTrue(hasattr(sys, "getdlopenflags")) +- self.assertRaises(TypeError, sys.getdlopenflags, 42) +- oldflags = sys.getdlopenflags() +- self.assertRaises(TypeError, sys.setdlopenflags) +- sys.setdlopenflags(oldflags+1) +- self.assertEqual(sys.getdlopenflags(), oldflags+1) +- sys.setdlopenflags(oldflags) ++ self.assertTrue(hasattr(sys, "getdlopenflags")) ++ self.assertRaises(TypeError, sys.getdlopenflags, 42) ++ oldflags = sys.getdlopenflags() ++ self.assertRaises(TypeError, sys.setdlopenflags) ++ sys.setdlopenflags(oldflags+1) ++ self.assertEqual(sys.getdlopenflags(), oldflags+1) ++ sys.setdlopenflags(oldflags) + + @test.support.refcount_test + def test_refcount(self): +diff -r c3896275c0f6 Lib/test/test_tcl.py +--- a/Lib/test/test_tcl.py ++++ b/Lib/test/test_tcl.py +@@ -302,6 +302,12 @@ + self.assertRaises(OverflowError, self.interp.call, 'set', '_', value) + + ++def setUpModule(): ++ if support.verbose: ++ tcl = Tcl() ++ print('patchlevel =', tcl.call('info', 'patchlevel')) ++ ++ + def test_main(): + support.run_unittest(TclTest, TkinterTest, BigmemTclTest) + +diff -r c3896275c0f6 Lib/test/test_tempfile.py +--- a/Lib/test/test_tempfile.py ++++ b/Lib/test/test_tempfile.py +@@ -324,10 +324,9 @@ + finally: + os.rmdir(dir) + ++ @unittest.skipUnless(has_stat, 'os.stat not available') + def test_file_mode(self): + # _mkstemp_inner creates files with the proper mode +- if not has_stat: +- return # ugh, can't use SkipTest. + + file = self.do_create() + mode = stat.S_IMODE(os.stat(file.name).st_mode) +@@ -339,10 +338,9 @@ + expected = user * (1 + 8 + 64) + self.assertEqual(mode, expected) + ++ @unittest.skipUnless(has_spawnl, 'os.spawnl not available') + def test_noinherit(self): + # _mkstemp_inner file handles are not inherited by child processes +- if not has_spawnl: +- return # ugh, can't use SkipTest. + + if support.verbose: + v="v" +@@ -377,10 +375,9 @@ + "child process caught fatal signal %d" % -retval) + self.assertFalse(retval > 0, "child process reports failure %d"%retval) + ++ @unittest.skipUnless(has_textmode, "text mode not available") + def test_textmode(self): + # _mkstemp_inner can create files in text mode +- if not has_textmode: +- return # ugh, can't use SkipTest. + + # A text file is truncated at the first Ctrl+Z byte + f = self.do_create(bin=0) +@@ -556,10 +553,9 @@ + finally: + os.rmdir(dir) + ++ @unittest.skipUnless(has_stat, 'os.stat not available') + def test_mode(self): + # mkdtemp creates directories with the proper mode +- if not has_stat: +- return # ugh, can't use SkipTest. + + dir = self.do_create() + try: +diff -r c3896275c0f6 Lib/test/test_thread.py +--- a/Lib/test/test_thread.py ++++ b/Lib/test/test_thread.py +@@ -68,39 +68,35 @@ + thread.stack_size(0) + self.assertEqual(thread.stack_size(), 0, "stack_size not reset to default") + +- if os.name not in ("nt", "os2", "posix"): +- return +- +- tss_supported = True ++ @unittest.skipIf(os.name not in ("nt", "os2", "posix"), 'test meant for nt, os2, and posix') ++ def test_nt_and_posix_stack_size(self): + try: + thread.stack_size(4096) + except ValueError: + verbose_print("caught expected ValueError setting " + "stack_size(4096)") + except thread.error: +- tss_supported = False +- verbose_print("platform does not support changing thread stack " +- "size") ++ self.skipTest("platform does not support changing thread stack " ++ "size") + +- if tss_supported: +- fail_msg = "stack_size(%d) failed - should succeed" +- for tss in (262144, 0x100000, 0): +- thread.stack_size(tss) +- self.assertEqual(thread.stack_size(), tss, fail_msg % tss) +- verbose_print("successfully set stack_size(%d)" % tss) ++ fail_msg = "stack_size(%d) failed - should succeed" ++ for tss in (262144, 0x100000, 0): ++ thread.stack_size(tss) ++ self.assertEqual(thread.stack_size(), tss, fail_msg % tss) ++ verbose_print("successfully set stack_size(%d)" % tss) + +- for tss in (262144, 0x100000): +- verbose_print("trying stack_size = (%d)" % tss) +- self.next_ident = 0 +- self.created = 0 +- for i in range(NUMTASKS): +- self.newtask() ++ for tss in (262144, 0x100000): ++ verbose_print("trying stack_size = (%d)" % tss) ++ self.next_ident = 0 ++ self.created = 0 ++ for i in range(NUMTASKS): ++ self.newtask() + +- verbose_print("waiting for all tasks to complete") +- self.done_mutex.acquire() +- verbose_print("all tasks done") ++ verbose_print("waiting for all tasks to complete") ++ self.done_mutex.acquire() ++ verbose_print("all tasks done") + +- thread.stack_size(0) ++ thread.stack_size(0) + + def test__count(self): + # Test the _count() function. +diff -r c3896275c0f6 Lib/test/test_time.py +--- a/Lib/test/test_time.py ++++ b/Lib/test/test_time.py +@@ -198,6 +198,10 @@ + with self.assertRaises(ValueError) as e: + time.strptime('', '%D') + self.assertIs(e.exception.__suppress_context__, True) ++ # additional check for IndexError branch (issue #19545) ++ with self.assertRaises(ValueError) as e: ++ time.strptime('19', '%Y %') ++ self.assertIs(e.exception.__suppress_context__, True) + + def test_asctime(self): + time.asctime(time.gmtime(self.t)) +@@ -459,8 +463,7 @@ + try: + tmp = locale.setlocale(locale.LC_ALL, "fr_FR") + except locale.Error: +- # skip this test +- return ++ self.skipTest('could not set locale.LC_ALL to fr_FR') + # This should not cause an exception + time.strftime("%B", (2009,2,1,0,0,0,0,0,0)) + +diff -r c3896275c0f6 Lib/test/test_unicode.py +--- a/Lib/test/test_unicode.py ++++ b/Lib/test/test_unicode.py +@@ -955,6 +955,7 @@ + '') + + self.assertEqual("{[{}]}".format({"{}": 5}), "5") ++ self.assertEqual("0x{:0{:d}X}".format(0x0,16), "0x0000000000000000") + + def test_format_map(self): + self.assertEqual(''.format_map({}), '') +@@ -1951,12 +1952,12 @@ + self.assertEqual(repr('\U00010000'), "'%c'" % (0x10000,)) # printable + self.assertEqual(repr('\U00014000'), "'\\U00014000'") # nonprintable + ++ # This test only affects 32-bit platforms because expandtabs can only take ++ # an int as the max value, not a 64-bit C long. If expandtabs is changed ++ # to take a 64-bit long, this test should apply to all platforms. ++ @unittest.skipIf(sys.maxsize > (1 << 32) or struct.calcsize('P') != 4, ++ 'only applies to 32-bit platforms') + def test_expandtabs_overflows_gracefully(self): +- # This test only affects 32-bit platforms because expandtabs can only take +- # an int as the max value, not a 64-bit C long. If expandtabs is changed +- # to take a 64-bit long, this test should apply to all platforms. +- if sys.maxsize > (1 << 32) or struct.calcsize('P') != 4: +- return + self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxsize) + + @support.cpython_only +diff -r c3896275c0f6 Lib/test/test_urllib2_localnet.py +--- a/Lib/test/test_urllib2_localnet.py ++++ b/Lib/test/test_urllib2_localnet.py +@@ -353,12 +353,15 @@ + def setUp(self): + super(TestUrlopen, self).setUp() + # Ignore proxies for localhost tests. ++ self.old_environ = os.environ.copy() + os.environ['NO_PROXY'] = '*' + self.server = None + + def tearDown(self): + if self.server is not None: + self.server.stop() ++ os.environ.clear() ++ os.environ.update(self.old_environ) + super(TestUrlopen, self).tearDown() + + def urlopen(self, url, data=None, **kwargs): +diff -r c3896275c0f6 Lib/test/test_urllibnet.py +--- a/Lib/test/test_urllibnet.py ++++ b/Lib/test/test_urllibnet.py +@@ -98,11 +98,10 @@ + open_url.close() + self.assertEqual(code, 404) + ++ # On Windows, socket handles are not file descriptors; this ++ # test can't pass on Windows. ++ @unittest.skipIf(sys.platform in ('win32',), 'not appropriate for Windows') + def test_fileno(self): +- if sys.platform in ('win32',): +- # On Windows, socket handles are not file descriptors; this +- # test can't pass on Windows. +- return + # Make sure fd returned by fileno is valid. + with self.urlopen("http://www.python.org/", timeout=None) as open_url: + fd = open_url.fileno() +diff -r c3896275c0f6 Lib/test/test_uuid.py +--- a/Lib/test/test_uuid.py ++++ b/Lib/test/test_uuid.py +@@ -1,5 +1,7 @@ + import unittest ++from test import support + import builtins ++import io + import os + import uuid + +@@ -356,6 +358,26 @@ + + self.assertEqual(node1, node2) + ++ @unittest.skipUnless(os.name == 'posix', 'requires Posix') ++ def test_find_mac(self): ++ data = '''\ ++ ++fake hwaddr ++cscotun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 ++eth0 Link encap:Ethernet HWaddr 12:34:56:78:90:ab ++''' ++ def mock_popen(cmd): ++ return io.StringIO(data) ++ ++ with support.swap_attr(os, 'popen', mock_popen): ++ mac = uuid._find_mac( ++ command='ifconfig', ++ args='', ++ hw_identifiers=['hwaddr'], ++ get_index=lambda x: x + 1, ++ ) ++ self.assertEqual(mac, 0x1234567890ab) ++ + @unittest.skipUnless(importable('ctypes'), 'requires ctypes') + def test_uuid1(self): + equal = self.assertEqual +diff -r c3896275c0f6 Lib/test/test_warnings.py +--- a/Lib/test/test_warnings.py ++++ b/Lib/test/test_warnings.py +@@ -271,11 +271,10 @@ + finally: + warning_tests.__file__ = filename + ++ @unittest.skipUnless(hasattr(sys, 'argv'), 'test needs sys.argv') + def test_missing_filename_main_with_argv(self): + # If __file__ is not specified and the caller is __main__ and sys.argv + # exists, then use sys.argv[0] as the file. +- if not hasattr(sys, 'argv'): +- return + filename = warning_tests.__file__ + module_name = warning_tests.__name__ + try: +@@ -683,7 +682,7 @@ + # Explicit tests for the test.support convenience wrapper + wmod = self.module + if wmod is not sys.modules['warnings']: +- return ++ self.skipTest('module to test is not loaded warnings module') + with support.check_warnings(quiet=False) as w: + self.assertEqual(w.warnings, []) + wmod.simplefilter("always") +diff -r c3896275c0f6 Lib/test/test_wave.py +--- a/Lib/test/test_wave.py ++++ b/Lib/test/test_wave.py +@@ -48,10 +48,13 @@ + if sys.byteorder != 'big': + frames = audiotests.byteswap2(frames) + ++ if sys.byteorder == 'big': ++ @unittest.expectedFailure ++ def test_unseekable_incompleted_write(self): ++ super().test_unseekable_incompleted_write() + +-@unittest.skipIf(sys.byteorder == 'big', +- '24-bit wave files are supported only on little-endian ' +- 'platforms') ++ ++ + class WavePCM24Test(audiotests.AudioWriteTests, + audiotests.AudioTestsWithSourceFile, + unittest.TestCase): +@@ -111,6 +114,11 @@ + if sys.byteorder != 'big': + frames = audiotests.byteswap4(frames) + ++ if sys.byteorder == 'big': ++ @unittest.expectedFailure ++ def test_unseekable_incompleted_write(self): ++ super().test_unseekable_incompleted_write() ++ + + if __name__ == '__main__': + unittest.main() +diff -r c3896275c0f6 Lib/test/test_weakref.py +--- a/Lib/test/test_weakref.py ++++ b/Lib/test/test_weakref.py +@@ -88,11 +88,9 @@ + ref1 = weakref.ref(o, self.callback) + ref2 = weakref.ref(o, self.callback) + del o +- self.assertTrue(ref1() is None, +- "expected reference to be invalidated") +- self.assertTrue(ref2() is None, +- "expected reference to be invalidated") +- self.assertTrue(self.cbcalled == 2, ++ self.assertIsNone(ref1(), "expected reference to be invalidated") ++ self.assertIsNone(ref2(), "expected reference to be invalidated") ++ self.assertEqual(self.cbcalled, 2, + "callback not called the right number of times") + + def test_multiple_selfref_callbacks(self): +@@ -131,10 +129,10 @@ + def check_basic_ref(self, factory): + o = factory() + ref = weakref.ref(o) +- self.assertTrue(ref() is not None, ++ self.assertIsNotNone(ref(), + "weak reference to live object should be live") + o2 = ref() +- self.assertTrue(o is o2, ++ self.assertIs(o, o2, + "() should return original object if live") + + def check_basic_callback(self, factory): +@@ -142,9 +140,9 @@ + o = factory() + ref = weakref.ref(o, self.callback) + del o +- self.assertTrue(self.cbcalled == 1, ++ self.assertEqual(self.cbcalled, 1, + "callback did not properly set 'cbcalled'") +- self.assertTrue(ref() is None, ++ self.assertIsNone(ref(), + "ref2 should be dead after deleting object reference") + + def test_ref_reuse(self): +@@ -154,19 +152,19 @@ + # between these two; it should make no difference + proxy = weakref.proxy(o) + ref2 = weakref.ref(o) +- self.assertTrue(ref1 is ref2, ++ self.assertIs(ref1, ref2, + "reference object w/out callback should be re-used") + + o = C() + proxy = weakref.proxy(o) + ref1 = weakref.ref(o) + ref2 = weakref.ref(o) +- self.assertTrue(ref1 is ref2, ++ self.assertIs(ref1, ref2, + "reference object w/out callback should be re-used") +- self.assertTrue(weakref.getweakrefcount(o) == 2, ++ self.assertEqual(weakref.getweakrefcount(o), 2, + "wrong weak ref count for object") + del proxy +- self.assertTrue(weakref.getweakrefcount(o) == 1, ++ self.assertEqual(weakref.getweakrefcount(o), 1, + "wrong weak ref count for object after deleting proxy") + + def test_proxy_reuse(self): +@@ -174,7 +172,7 @@ + proxy1 = weakref.proxy(o) + ref = weakref.ref(o) + proxy2 = weakref.proxy(o) +- self.assertTrue(proxy1 is proxy2, ++ self.assertIs(proxy1, proxy2, + "proxy object w/out callback should have been re-used") + + def test_basic_proxy(self): +@@ -254,19 +252,19 @@ + o = Object(1) + p1 = makeref(o, None) + p2 = makeref(o, None) +- self.assertTrue(p1 is p2, "both callbacks were None in the C API") ++ self.assertIs(p1, p2, "both callbacks were None in the C API") + del p1, p2 + p1 = makeref(o) + p2 = makeref(o, None) +- self.assertTrue(p1 is p2, "callbacks were NULL, None in the C API") ++ self.assertIs(p1, p2, "callbacks were NULL, None in the C API") + del p1, p2 + p1 = makeref(o) + p2 = makeref(o) +- self.assertTrue(p1 is p2, "both callbacks were NULL in the C API") ++ self.assertIs(p1, p2, "both callbacks were NULL in the C API") + del p1, p2 + p1 = makeref(o, None) + p2 = makeref(o) +- self.assertTrue(p1 is p2, "callbacks were None, NULL in the C API") ++ self.assertIs(p1, p2, "callbacks were None, NULL in the C API") + + def test_callable_proxy(self): + o = Callable() +@@ -274,13 +272,13 @@ + + self.check_proxy(o, ref1) + +- self.assertTrue(type(ref1) is weakref.CallableProxyType, ++ self.assertIs(type(ref1), weakref.CallableProxyType, + "proxy is not of callable type") + ref1('twinkies!') +- self.assertTrue(o.bar == 'twinkies!', ++ self.assertEqual(o.bar, 'twinkies!', + "call through proxy not passed through to original") + ref1(x='Splat.') +- self.assertTrue(o.bar == 'Splat.', ++ self.assertEqual(o.bar, 'Splat.', + "call through proxy not passed through to original") + + # expect due to too few args +@@ -291,24 +289,23 @@ + + def check_proxy(self, o, proxy): + o.foo = 1 +- self.assertTrue(proxy.foo == 1, ++ self.assertEqual(proxy.foo, 1, + "proxy does not reflect attribute addition") + o.foo = 2 +- self.assertTrue(proxy.foo == 2, ++ self.assertEqual(proxy.foo, 2, + "proxy does not reflect attribute modification") + del o.foo +- self.assertTrue(not hasattr(proxy, 'foo'), ++ self.assertFalse(hasattr(proxy, 'foo'), + "proxy does not reflect attribute removal") + + proxy.foo = 1 +- self.assertTrue(o.foo == 1, ++ self.assertEqual(o.foo, 1, + "object does not reflect attribute addition via proxy") + proxy.foo = 2 +- self.assertTrue( +- o.foo == 2, ++ self.assertEqual(o.foo, 2, + "object does not reflect attribute modification via proxy") + del proxy.foo +- self.assertTrue(not hasattr(o, 'foo'), ++ self.assertFalse(hasattr(o, 'foo'), + "object does not reflect attribute removal via proxy") + + def test_proxy_deletion(self): +@@ -332,21 +329,21 @@ + o = C() + ref1 = weakref.ref(o) + ref2 = weakref.ref(o, self.callback) +- self.assertTrue(weakref.getweakrefcount(o) == 2, ++ self.assertEqual(weakref.getweakrefcount(o), 2, + "got wrong number of weak reference objects") + + proxy1 = weakref.proxy(o) + proxy2 = weakref.proxy(o, self.callback) +- self.assertTrue(weakref.getweakrefcount(o) == 4, ++ self.assertEqual(weakref.getweakrefcount(o), 4, + "got wrong number of weak reference objects") + + del ref1, ref2, proxy1, proxy2 +- self.assertTrue(weakref.getweakrefcount(o) == 0, ++ self.assertEqual(weakref.getweakrefcount(o), 0, + "weak reference objects not unlinked from" + " referent when discarded.") + + # assumes ints do not support weakrefs +- self.assertTrue(weakref.getweakrefcount(1) == 0, ++ self.assertEqual(weakref.getweakrefcount(1), 0, + "got wrong number of weak reference objects for int") + + def test_getweakrefs(self): +@@ -354,22 +351,22 @@ + ref1 = weakref.ref(o, self.callback) + ref2 = weakref.ref(o, self.callback) + del ref1 +- self.assertTrue(weakref.getweakrefs(o) == [ref2], ++ self.assertEqual(weakref.getweakrefs(o), [ref2], + "list of refs does not match") + + o = C() + ref1 = weakref.ref(o, self.callback) + ref2 = weakref.ref(o, self.callback) + del ref2 +- self.assertTrue(weakref.getweakrefs(o) == [ref1], ++ self.assertEqual(weakref.getweakrefs(o), [ref1], + "list of refs does not match") + + del ref1 +- self.assertTrue(weakref.getweakrefs(o) == [], ++ self.assertEqual(weakref.getweakrefs(o), [], + "list of refs not cleared") + + # assumes ints do not support weakrefs +- self.assertTrue(weakref.getweakrefs(1) == [], ++ self.assertEqual(weakref.getweakrefs(1), [], + "list of refs does not match for int") + + def test_newstyle_number_ops(self): +@@ -377,8 +374,8 @@ + pass + f = F(2.0) + p = weakref.proxy(f) +- self.assertTrue(p + 1.0 == 3.0) +- self.assertTrue(1.0 + p == 3.0) # this used to SEGV ++ self.assertEqual(p + 1.0, 3.0) ++ self.assertEqual(1.0 + p, 3.0) # this used to SEGV + + def test_callbacks_protected(self): + # Callbacks protected from already-set exceptions? +@@ -631,7 +628,7 @@ + c.wr = weakref.ref(d, callback) # this won't trigger + d.wr = weakref.ref(callback, d.cb) # ditto + external_wr = weakref.ref(callback, safe_callback) # but this will +- self.assertTrue(external_wr() is callback) ++ self.assertIs(external_wr(), callback) + + # The weakrefs attached to c and d should get cleared, so that + # C.cb is never called. But external_wr isn't part of the cyclic +@@ -810,11 +807,11 @@ + return super().__call__() + o = Object("foo") + mr = MyRef(o, value=24) +- self.assertTrue(mr() is o) ++ self.assertIs(mr(), o) + self.assertTrue(mr.called) + self.assertEqual(mr.value, 24) + del o +- self.assertTrue(mr() is None) ++ self.assertIsNone(mr()) + self.assertTrue(mr.called) + + def test_subclass_refs_dont_replace_standard_refs(self): +@@ -823,14 +820,14 @@ + o = Object(42) + r1 = MyRef(o) + r2 = weakref.ref(o) +- self.assertTrue(r1 is not r2) ++ self.assertIsNot(r1, r2) + self.assertEqual(weakref.getweakrefs(o), [r2, r1]) + self.assertEqual(weakref.getweakrefcount(o), 2) + r3 = MyRef(o) + self.assertEqual(weakref.getweakrefcount(o), 3) + refs = weakref.getweakrefs(o) + self.assertEqual(len(refs), 3) +- self.assertTrue(r2 is refs[0]) ++ self.assertIs(r2, refs[0]) + self.assertIn(r1, refs[1:]) + self.assertIn(r3, refs[1:]) + +@@ -840,7 +837,7 @@ + o = Object(42) + r1 = MyRef(o, id) + r2 = MyRef(o, str) +- self.assertTrue(r1 is not r2) ++ self.assertIsNot(r1, r2) + refs = weakref.getweakrefs(o) + self.assertIn(r1, refs) + self.assertIn(r2, refs) +@@ -968,7 +965,7 @@ + dict, objects = self.make_weak_valued_dict() + for o in objects: + self.assertEqual(weakref.getweakrefcount(o), 1) +- self.assertTrue(o is dict[o.arg], ++ self.assertIs(o, dict[o.arg], + "wrong object returned by weak dict!") + items1 = list(dict.items()) + items2 = list(dict.copy().items()) +@@ -997,9 +994,9 @@ + # + dict, objects = self.make_weak_keyed_dict() + for o in objects: +- self.assertTrue(weakref.getweakrefcount(o) == 1, ++ self.assertEqual(weakref.getweakrefcount(o), 1, + "wrong number of weak references to %r!" % o) +- self.assertTrue(o.arg is dict[o], ++ self.assertIs(o.arg, dict[o], + "wrong object returned by weak dict!") + items1 = dict.items() + items2 = dict.copy().items() +@@ -1008,10 +1005,10 @@ + del items1, items2 + self.assertEqual(len(dict), self.COUNT) + del objects[0] +- self.assertTrue(len(dict) == (self.COUNT - 1), ++ self.assertEqual(len(dict), (self.COUNT - 1), + "deleting object did not cause dictionary update") + del objects, o +- self.assertTrue(len(dict) == 0, ++ self.assertEqual(len(dict), 0, + "deleting the keys did not clear the dictionary") + o = Object(42) + dict[o] = "What is the meaning of the universe?" +@@ -1221,15 +1218,15 @@ + k, v = weakdict.popitem() + self.assertEqual(len(weakdict), 1) + if k is key1: +- self.assertTrue(v is value1) ++ self.assertIs(v, value1) + else: +- self.assertTrue(v is value2) ++ self.assertIs(v, value2) + k, v = weakdict.popitem() + self.assertEqual(len(weakdict), 0) + if k is key1: +- self.assertTrue(v is value1) ++ self.assertIs(v, value1) + else: +- self.assertTrue(v is value2) ++ self.assertIs(v, value2) + + def test_weak_valued_dict_popitem(self): + self.check_popitem(weakref.WeakValueDictionary, +@@ -1240,21 +1237,21 @@ + C(), "value 1", C(), "value 2") + + def check_setdefault(self, klass, key, value1, value2): +- self.assertTrue(value1 is not value2, ++ self.assertIsNot(value1, value2, + "invalid test" + " -- value parameters must be distinct objects") + weakdict = klass() + o = weakdict.setdefault(key, value1) +- self.assertTrue(o is value1) ++ self.assertIs(o, value1) + self.assertIn(key, weakdict) +- self.assertTrue(weakdict.get(key) is value1) +- self.assertTrue(weakdict[key] is value1) ++ self.assertIs(weakdict.get(key), value1) ++ self.assertIs(weakdict[key], value1) + + o = weakdict.setdefault(key, value2) +- self.assertTrue(o is value1) ++ self.assertIs(o, value1) + self.assertIn(key, weakdict) +- self.assertTrue(weakdict.get(key) is value1) +- self.assertTrue(weakdict[key] is value1) ++ self.assertIs(weakdict.get(key), value1) ++ self.assertIs(weakdict[key], value1) + + def test_weak_valued_dict_setdefault(self): + self.check_setdefault(weakref.WeakValueDictionary, +@@ -1275,13 +1272,13 @@ + for k in weakdict.keys(): + self.assertIn(k, dict, "mysterious new key appeared in weak dict") + v = dict.get(k) +- self.assertTrue(v is weakdict[k]) +- self.assertTrue(v is weakdict.get(k)) ++ self.assertIs(v, weakdict[k]) ++ self.assertIs(v, weakdict.get(k)) + for k in dict.keys(): + self.assertIn(k, weakdict, "original key disappeared in weak dict") + v = dict[k] +- self.assertTrue(v is weakdict[k]) +- self.assertTrue(v is weakdict.get(k)) ++ self.assertIs(v, weakdict[k]) ++ self.assertIs(v, weakdict.get(k)) + + def test_weak_valued_dict_update(self): + self.check_update(weakref.WeakValueDictionary, +@@ -1311,7 +1308,7 @@ + self.assertEqual(len(d), 2) + del d['something'] + self.assertEqual(len(d), 1) +- self.assertTrue(list(d.items()) == [('something else', o2)]) ++ self.assertEqual(list(d.items()), [('something else', o2)]) + + def test_weak_keyed_bad_delitem(self): + d = weakref.WeakKeyDictionary() +diff -r c3896275c0f6 Lib/test/test_winsound.py +--- a/Lib/test/test_winsound.py ++++ b/Lib/test/test_winsound.py +@@ -158,18 +158,14 @@ + ) + + def test_alias_fallback(self): +- # This test can't be expected to work on all systems. The MS +- # PlaySound() docs say: +- # +- # If it cannot find the specified sound, PlaySound uses the +- # default system event sound entry instead. If the function +- # can find neither the system default entry nor the default +- # sound, it makes no sound and returns FALSE. +- # +- # It's known to return FALSE on some real systems. +- +- # winsound.PlaySound('!"$%&/(#+*', winsound.SND_ALIAS) +- return ++ if _have_soundcard(): ++ winsound.PlaySound('!"$%&/(#+*', winsound.SND_ALIAS) ++ else: ++ self.assertRaises( ++ RuntimeError, ++ winsound.PlaySound, ++ '!"$%&/(#+*', winsound.SND_ALIAS ++ ) + + def test_alias_nofallback(self): + if _have_soundcard(): +diff -r c3896275c0f6 Lib/test/test_xml_etree.py +--- a/Lib/test/test_xml_etree.py ++++ b/Lib/test/test_xml_etree.py +@@ -535,6 +535,11 @@ + ('end-ns', None), + ]) + ++ events = ('start-ns', 'end-ns') ++ context = iterparse(io.StringIO(r""), events) ++ res = [action for action, elem in context] ++ self.assertEqual(res, ['start-ns', 'end-ns']) ++ + events = ("start", "end", "bogus") + with self.assertRaises(ValueError) as cm: + with open(SIMPLE_XMLFILE, "rb") as f: +diff -r c3896275c0f6 Lib/test/test_xmlrpc_net.py +--- a/Lib/test/test_xmlrpc_net.py ++++ b/Lib/test/test_xmlrpc_net.py +@@ -20,7 +20,6 @@ + t0 = server.currentTime.getCurrentTime() + except socket.error as e: + self.skipTest("network error: %s" % e) +- return + + # Perform a minimal sanity check on the result, just to be sure + # the request means what we think it means. +@@ -44,7 +43,6 @@ + builders = server.getAllBuilders() + except socket.error as e: + self.skipTest("network error: %s" % e) +- return + self.addCleanup(lambda: server('close')()) + + # Perform a minimal sanity check on the result, just to be sure +diff -r c3896275c0f6 Lib/test/test_zipimport.py +--- a/Lib/test/test_zipimport.py ++++ b/Lib/test/test_zipimport.py +@@ -111,7 +111,7 @@ + # so we'll simply skip it then. Bug #765456. + # + if "zlib" in sys.builtin_module_names: +- return ++ self.skipTest('zlib is a builtin module') + if "zlib" in sys.modules: + del sys.modules["zlib"] + files = {"zlib.py": (NOW, test_src)} +diff -r c3896275c0f6 Lib/test/test_zlib.py +--- a/Lib/test/test_zlib.py ++++ b/Lib/test/test_zlib.py +@@ -7,6 +7,13 @@ + + zlib = support.import_module('zlib') + ++requires_Compress_copy = unittest.skipUnless( ++ hasattr(zlib.compressobj(), "copy"), ++ 'requires Compress.copy()') ++requires_Decompress_copy = unittest.skipUnless( ++ hasattr(zlib.decompressobj(), "copy"), ++ 'requires Decompress.copy()') ++ + + class VersionTestCase(unittest.TestCase): + +@@ -381,39 +388,39 @@ + "mode=%i, level=%i") % (sync, level)) + del obj + ++ @unittest.skipUnless(hasattr(zlib, 'Z_SYNC_FLUSH'), ++ 'requires zlib.Z_SYNC_FLUSH') + def test_odd_flush(self): + # Test for odd flushing bugs noted in 2.0, and hopefully fixed in 2.1 + import random ++ # Testing on 17K of "random" data + +- if hasattr(zlib, 'Z_SYNC_FLUSH'): +- # Testing on 17K of "random" data ++ # Create compressor and decompressor objects ++ co = zlib.compressobj(zlib.Z_BEST_COMPRESSION) ++ dco = zlib.decompressobj() + +- # Create compressor and decompressor objects +- co = zlib.compressobj(zlib.Z_BEST_COMPRESSION) +- dco = zlib.decompressobj() ++ # Try 17K of data ++ # generate random data stream ++ try: ++ # In 2.3 and later, WichmannHill is the RNG of the bug report ++ gen = random.WichmannHill() ++ except AttributeError: ++ try: ++ # 2.2 called it Random ++ gen = random.Random() ++ except AttributeError: ++ # others might simply have a single RNG ++ gen = random ++ gen.seed(1) ++ data = genblock(1, 17 * 1024, generator=gen) + +- # Try 17K of data +- # generate random data stream +- try: +- # In 2.3 and later, WichmannHill is the RNG of the bug report +- gen = random.WichmannHill() +- except AttributeError: +- try: +- # 2.2 called it Random +- gen = random.Random() +- except AttributeError: +- # others might simply have a single RNG +- gen = random +- gen.seed(1) +- data = genblock(1, 17 * 1024, generator=gen) ++ # compress, sync-flush, and decompress ++ first = co.compress(data) ++ second = co.flush(zlib.Z_SYNC_FLUSH) ++ expanded = dco.decompress(first + second) + +- # compress, sync-flush, and decompress +- first = co.compress(data) +- second = co.flush(zlib.Z_SYNC_FLUSH) +- expanded = dco.decompress(first + second) +- +- # if decompressed data is different from the input data, choke. +- self.assertEqual(expanded, data, "17K random source doesn't match") ++ # if decompressed data is different from the input data, choke. ++ self.assertEqual(expanded, data, "17K random source doesn't match") + + def test_empty_flush(self): + # Test that calling .flush() on unused objects works. +@@ -525,67 +532,69 @@ + data = zlib.compress(input2) + self.assertEqual(dco.flush(), input1[1:]) + +- if hasattr(zlib.compressobj(), "copy"): +- def test_compresscopy(self): +- # Test copying a compression object +- data0 = HAMLET_SCENE +- data1 = bytes(str(HAMLET_SCENE, "ascii").swapcase(), "ascii") +- c0 = zlib.compressobj(zlib.Z_BEST_COMPRESSION) +- bufs0 = [] +- bufs0.append(c0.compress(data0)) ++ @requires_Compress_copy ++ def test_compresscopy(self): ++ # Test copying a compression object ++ data0 = HAMLET_SCENE ++ data1 = bytes(str(HAMLET_SCENE, "ascii").swapcase(), "ascii") ++ c0 = zlib.compressobj(zlib.Z_BEST_COMPRESSION) ++ bufs0 = [] ++ bufs0.append(c0.compress(data0)) + +- c1 = c0.copy() +- bufs1 = bufs0[:] ++ c1 = c0.copy() ++ bufs1 = bufs0[:] + +- bufs0.append(c0.compress(data0)) +- bufs0.append(c0.flush()) +- s0 = b''.join(bufs0) ++ bufs0.append(c0.compress(data0)) ++ bufs0.append(c0.flush()) ++ s0 = b''.join(bufs0) + +- bufs1.append(c1.compress(data1)) +- bufs1.append(c1.flush()) +- s1 = b''.join(bufs1) ++ bufs1.append(c1.compress(data1)) ++ bufs1.append(c1.flush()) ++ s1 = b''.join(bufs1) + +- self.assertEqual(zlib.decompress(s0),data0+data0) +- self.assertEqual(zlib.decompress(s1),data0+data1) ++ self.assertEqual(zlib.decompress(s0),data0+data0) ++ self.assertEqual(zlib.decompress(s1),data0+data1) + +- def test_badcompresscopy(self): +- # Test copying a compression object in an inconsistent state +- c = zlib.compressobj() +- c.compress(HAMLET_SCENE) +- c.flush() +- self.assertRaises(ValueError, c.copy) ++ @requires_Compress_copy ++ def test_badcompresscopy(self): ++ # Test copying a compression object in an inconsistent state ++ c = zlib.compressobj() ++ c.compress(HAMLET_SCENE) ++ c.flush() ++ self.assertRaises(ValueError, c.copy) + +- if hasattr(zlib.decompressobj(), "copy"): +- def test_decompresscopy(self): +- # Test copying a decompression object +- data = HAMLET_SCENE +- comp = zlib.compress(data) +- # Test type of return value +- self.assertIsInstance(comp, bytes) ++ @requires_Decompress_copy ++ def test_decompresscopy(self): ++ # Test copying a decompression object ++ data = HAMLET_SCENE ++ comp = zlib.compress(data) ++ # Test type of return value ++ self.assertIsInstance(comp, bytes) + +- d0 = zlib.decompressobj() +- bufs0 = [] +- bufs0.append(d0.decompress(comp[:32])) ++ d0 = zlib.decompressobj() ++ bufs0 = [] ++ bufs0.append(d0.decompress(comp[:32])) + +- d1 = d0.copy() +- bufs1 = bufs0[:] ++ d1 = d0.copy() ++ bufs1 = bufs0[:] + +- bufs0.append(d0.decompress(comp[32:])) +- s0 = b''.join(bufs0) ++ bufs0.append(d0.decompress(comp[32:])) ++ s0 = b''.join(bufs0) + +- bufs1.append(d1.decompress(comp[32:])) +- s1 = b''.join(bufs1) ++ bufs1.append(d1.decompress(comp[32:])) ++ s1 = b''.join(bufs1) + +- self.assertEqual(s0,s1) +- self.assertEqual(s0,data) ++ self.assertEqual(s0,s1) ++ self.assertEqual(s0,data) + +- def test_baddecompresscopy(self): +- # Test copying a compression object in an inconsistent state +- data = zlib.compress(HAMLET_SCENE) +- d = zlib.decompressobj() +- d.decompress(data) +- d.flush() +- self.assertRaises(ValueError, d.copy) ++ @requires_Decompress_copy ++ def test_baddecompresscopy(self): ++ # Test copying a compression object in an inconsistent state ++ data = zlib.compress(HAMLET_SCENE) ++ d = zlib.decompressobj() ++ d.decompress(data) ++ d.flush() ++ self.assertRaises(ValueError, d.copy) + + # Memory use of the following functions takes into account overallocation + +diff -r c3896275c0f6 Lib/tkinter/__init__.py +--- a/Lib/tkinter/__init__.py ++++ b/Lib/tkinter/__init__.py +@@ -2990,8 +2990,9 @@ + def debug(self, boolean=None): + """Turn on the internal consistency checks of the B-Tree inside the text + widget according to BOOLEAN.""" +- return self.tk.getboolean(self.tk.call( +- self._w, 'debug', boolean)) ++ if boolean is None: ++ return self.tk.call(self._w, 'debug') ++ self.tk.call(self._w, 'debug', boolean) + def delete(self, index1, index2=None): + """Delete the characters between INDEX1 and INDEX2 (not included).""" + self.tk.call(self._w, 'delete', index1, index2) +@@ -3511,7 +3512,7 @@ + bounding box may refer to a region outside the + visible area of the window. + """ +- return self.tk.call(self._w, 'bbox', index) ++ return self._getints(self.tk.call(self._w, 'bbox', index)) or None + + def delete(self, first, last=None): + """Delete one or more elements of the spinbox. +diff -r c3896275c0f6 Lib/tkinter/test/support.py +--- a/Lib/tkinter/test/support.py ++++ b/Lib/tkinter/test/support.py +@@ -77,3 +77,57 @@ + widget.event_generate('', x=x, y=y) + widget.event_generate('', x=x, y=y) + widget.event_generate('', x=x, y=y) ++ ++ ++import _tkinter ++tcl_version = tuple(map(int, _tkinter.TCL_VERSION.split('.'))) ++ ++def requires_tcl(*version): ++ return unittest.skipUnless(tcl_version >= version, ++ 'requires Tcl version >= ' + '.'.join(map(str, version))) ++ ++_tk_patchlevel = None ++def get_tk_patchlevel(): ++ global _tk_patchlevel ++ if _tk_patchlevel is None: ++ tcl = tkinter.Tcl() ++ patchlevel = [] ++ for x in tcl.call('info', 'patchlevel').split('.'): ++ try: ++ x = int(x, 10) ++ except ValueError: ++ x = -1 ++ patchlevel.append(x) ++ _tk_patchlevel = tuple(patchlevel) ++ return _tk_patchlevel ++ ++units = { ++ 'c': 72 / 2.54, # centimeters ++ 'i': 72, # inches ++ 'm': 72 / 25.4, # millimeters ++ 'p': 1, # points ++} ++ ++def pixels_conv(value): ++ return float(value[:-1]) * units[value[-1:]] ++ ++def tcl_obj_eq(actual, expected): ++ if actual == expected: ++ return True ++ if isinstance(actual, _tkinter.Tcl_Obj): ++ if isinstance(expected, str): ++ return str(actual) == expected ++ if isinstance(actual, tuple): ++ if isinstance(expected, tuple): ++ return (len(actual) == len(expected) and ++ all(tcl_obj_eq(act, exp) ++ for act, exp in zip(actual, expected))) ++ return False ++ ++def widget_eq(actual, expected): ++ if actual == expected: ++ return True ++ if isinstance(actual, (str, tkinter.Widget)): ++ if isinstance(expected, (str, tkinter.Widget)): ++ return str(actual) == str(expected) ++ return False +diff -r c3896275c0f6 Lib/tkinter/test/test_tkinter/test_text.py +--- a/Lib/tkinter/test/test_tkinter/test_text.py ++++ b/Lib/tkinter/test/test_tkinter/test_text.py +@@ -14,6 +14,17 @@ + def tearDown(self): + self.text.destroy() + ++ def test_debug(self): ++ text = self.text ++ olddebug = text.debug() ++ try: ++ text.debug(0) ++ self.assertEqual(text.debug(), 0) ++ text.debug(1) ++ self.assertEqual(text.debug(), 1) ++ finally: ++ text.debug(olddebug) ++ self.assertEqual(text.debug(), olddebug) + + def test_search(self): + text = self.text +diff -r c3896275c0f6 Lib/tkinter/test/test_tkinter/test_widgets.py +--- /dev/null ++++ b/Lib/tkinter/test/test_tkinter/test_widgets.py +@@ -0,0 +1,954 @@ ++import unittest ++import tkinter ++import os ++import sys ++from test.support import requires ++ ++from tkinter.test.support import (tcl_version, requires_tcl, ++ get_tk_patchlevel, widget_eq) ++from tkinter.test.widget_tests import ( ++ add_standard_options, noconv, pixels_round, ++ AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests, ++ setUpModule) ++ ++requires('gui') ++ ++ ++def float_round(x): ++ return float(round(x)) ++ ++ ++class AbstractToplevelTest(AbstractWidgetTest, PixelSizeTests): ++ _conv_pad_pixels = noconv ++ ++ def test_class(self): ++ widget = self.create() ++ self.assertEqual(widget['class'], ++ widget.__class__.__name__.title()) ++ self.checkInvalidParam(widget, 'class', 'Foo', ++ errmsg="can't modify -class option after widget is created") ++ widget2 = self.create(class_='Foo') ++ self.assertEqual(widget2['class'], 'Foo') ++ ++ def test_colormap(self): ++ widget = self.create() ++ self.assertEqual(widget['colormap'], '') ++ self.checkInvalidParam(widget, 'colormap', 'new', ++ errmsg="can't modify -colormap option after widget is created") ++ widget2 = self.create(colormap='new') ++ self.assertEqual(widget2['colormap'], 'new') ++ ++ def test_container(self): ++ widget = self.create() ++ self.assertEqual(widget['container'], 0 if self.wantobjects else '0') ++ self.checkInvalidParam(widget, 'container', 1, ++ errmsg="can't modify -container option after widget is created") ++ widget2 = self.create(container=True) ++ self.assertEqual(widget2['container'], 1 if self.wantobjects else '1') ++ ++ def test_visual(self): ++ widget = self.create() ++ self.assertEqual(widget['visual'], '') ++ self.checkInvalidParam(widget, 'visual', 'default', ++ errmsg="can't modify -visual option after widget is created") ++ widget2 = self.create(visual='default') ++ self.assertEqual(widget2['visual'], 'default') ++ ++ ++@add_standard_options(StandardOptionsTests) ++class ToplevelTest(AbstractToplevelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'background', 'borderwidth', ++ 'class', 'colormap', 'container', 'cursor', 'height', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'menu', 'padx', 'pady', 'relief', 'screen', ++ 'takefocus', 'use', 'visual', 'width', ++ ) ++ ++ def _create(self, **kwargs): ++ return tkinter.Toplevel(self.root, **kwargs) ++ ++ def test_menu(self): ++ widget = self.create() ++ menu = tkinter.Menu(self.root) ++ self.checkParam(widget, 'menu', menu, eq=widget_eq) ++ self.checkParam(widget, 'menu', '') ++ ++ def test_screen(self): ++ widget = self.create() ++ self.assertEqual(widget['screen'], '') ++ try: ++ display = os.environ['DISPLAY'] ++ except KeyError: ++ self.skipTest('No $DISPLAY set.') ++ self.checkInvalidParam(widget, 'screen', display, ++ errmsg="can't modify -screen option after widget is created") ++ widget2 = self.create(screen=display) ++ self.assertEqual(widget2['screen'], display) ++ ++ def test_use(self): ++ widget = self.create() ++ self.assertEqual(widget['use'], '') ++ parent = self.create(container=True) ++ wid = parent.winfo_id() ++ widget2 = self.create(use=wid) ++ self.assertEqual(int(widget2['use']), wid) ++ ++ ++@add_standard_options(StandardOptionsTests) ++class FrameTest(AbstractToplevelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'background', 'borderwidth', ++ 'class', 'colormap', 'container', 'cursor', 'height', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'relief', 'takefocus', 'visual', 'width', ++ ) ++ ++ def _create(self, **kwargs): ++ return tkinter.Frame(self.root, **kwargs) ++ ++ ++@add_standard_options(StandardOptionsTests) ++class LabelFrameTest(AbstractToplevelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'background', 'borderwidth', ++ 'class', 'colormap', 'container', 'cursor', ++ 'font', 'foreground', 'height', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'labelanchor', 'labelwidget', 'padx', 'pady', 'relief', ++ 'takefocus', 'text', 'visual', 'width', ++ ) ++ ++ def _create(self, **kwargs): ++ return tkinter.LabelFrame(self.root, **kwargs) ++ ++ def test_labelanchor(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'labelanchor', ++ 'e', 'en', 'es', 'n', 'ne', 'nw', ++ 's', 'se', 'sw', 'w', 'wn', 'ws') ++ self.checkInvalidParam(widget, 'labelanchor', 'center') ++ ++ def test_labelwidget(self): ++ widget = self.create() ++ label = tkinter.Label(self.root, text='Mupp', name='foo') ++ self.checkParam(widget, 'labelwidget', label, expected='.foo') ++ label.destroy() ++ ++ ++class AbstractLabelTest(AbstractWidgetTest, IntegerSizeTests): ++ _conv_pixels = noconv ++ ++ def test_highlightthickness(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'highlightthickness', ++ 0, 1.3, 2.6, 6, -2, '10p') ++ ++ ++@add_standard_options(StandardOptionsTests) ++class LabelTest(AbstractLabelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'activebackground', 'activeforeground', 'anchor', ++ 'background', 'bitmap', 'borderwidth', 'compound', 'cursor', ++ 'disabledforeground', 'font', 'foreground', 'height', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'image', 'justify', 'padx', 'pady', 'relief', 'state', ++ 'takefocus', 'text', 'textvariable', ++ 'underline', 'width', 'wraplength', ++ ) ++ ++ def _create(self, **kwargs): ++ return tkinter.Label(self.root, **kwargs) ++ ++ ++@add_standard_options(StandardOptionsTests) ++class ButtonTest(AbstractLabelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'activebackground', 'activeforeground', 'anchor', ++ 'background', 'bitmap', 'borderwidth', ++ 'command', 'compound', 'cursor', 'default', ++ 'disabledforeground', 'font', 'foreground', 'height', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'image', 'justify', 'overrelief', 'padx', 'pady', 'relief', ++ 'repeatdelay', 'repeatinterval', ++ 'state', 'takefocus', 'text', 'textvariable', ++ 'underline', 'width', 'wraplength') ++ ++ def _create(self, **kwargs): ++ return tkinter.Button(self.root, **kwargs) ++ ++ def test_default(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'default', 'active', 'disabled', 'normal') ++ ++ ++@add_standard_options(StandardOptionsTests) ++class CheckbuttonTest(AbstractLabelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'activebackground', 'activeforeground', 'anchor', ++ 'background', 'bitmap', 'borderwidth', ++ 'command', 'compound', 'cursor', ++ 'disabledforeground', 'font', 'foreground', 'height', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'image', 'indicatoron', 'justify', ++ 'offrelief', 'offvalue', 'onvalue', 'overrelief', ++ 'padx', 'pady', 'relief', 'selectcolor', 'selectimage', 'state', ++ 'takefocus', 'text', 'textvariable', ++ 'tristateimage', 'tristatevalue', ++ 'underline', 'variable', 'width', 'wraplength', ++ ) ++ ++ def _create(self, **kwargs): ++ return tkinter.Checkbutton(self.root, **kwargs) ++ ++ ++ def test_offvalue(self): ++ widget = self.create() ++ self.checkParams(widget, 'offvalue', 1, 2.3, '', 'any string') ++ ++ def test_onvalue(self): ++ widget = self.create() ++ self.checkParams(widget, 'onvalue', 1, 2.3, '', 'any string') ++ ++ ++@add_standard_options(StandardOptionsTests) ++class RadiobuttonTest(AbstractLabelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'activebackground', 'activeforeground', 'anchor', ++ 'background', 'bitmap', 'borderwidth', ++ 'command', 'compound', 'cursor', ++ 'disabledforeground', 'font', 'foreground', 'height', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'image', 'indicatoron', 'justify', 'offrelief', 'overrelief', ++ 'padx', 'pady', 'relief', 'selectcolor', 'selectimage', 'state', ++ 'takefocus', 'text', 'textvariable', ++ 'tristateimage', 'tristatevalue', ++ 'underline', 'value', 'variable', 'width', 'wraplength', ++ ) ++ ++ def _create(self, **kwargs): ++ return tkinter.Radiobutton(self.root, **kwargs) ++ ++ def test_value(self): ++ widget = self.create() ++ self.checkParams(widget, 'value', 1, 2.3, '', 'any string') ++ ++ ++@add_standard_options(StandardOptionsTests) ++class MenubuttonTest(AbstractLabelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'activebackground', 'activeforeground', 'anchor', ++ 'background', 'bitmap', 'borderwidth', ++ 'compound', 'cursor', 'direction', ++ 'disabledforeground', 'font', 'foreground', 'height', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'image', 'indicatoron', 'justify', 'menu', ++ 'padx', 'pady', 'relief', 'state', ++ 'takefocus', 'text', 'textvariable', ++ 'underline', 'width', 'wraplength', ++ ) ++ _conv_pixels = staticmethod(pixels_round) ++ ++ def _create(self, **kwargs): ++ return tkinter.Menubutton(self.root, **kwargs) ++ ++ def test_direction(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'direction', ++ 'above', 'below', 'flush', 'left', 'right') ++ ++ def test_height(self): ++ widget = self.create() ++ self.checkIntegerParam(widget, 'height', 100, -100, 0, conv=str) ++ ++ test_highlightthickness = StandardOptionsTests.test_highlightthickness ++ ++ @unittest.skipIf(sys.platform == 'darwin', ++ 'crashes with Cocoa Tk (issue19733)') ++ def test_image(self): ++ widget = self.create() ++ image = tkinter.PhotoImage('image1') ++ self.checkParam(widget, 'image', image, conv=str) ++ errmsg = 'image "spam" doesn\'t exist' ++ with self.assertRaises(tkinter.TclError) as cm: ++ widget['image'] = 'spam' ++ if errmsg is not None: ++ self.assertEqual(str(cm.exception), errmsg) ++ with self.assertRaises(tkinter.TclError) as cm: ++ widget.configure({'image': 'spam'}) ++ if errmsg is not None: ++ self.assertEqual(str(cm.exception), errmsg) ++ ++ def test_menu(self): ++ widget = self.create() ++ menu = tkinter.Menu(widget, name='menu') ++ self.checkParam(widget, 'menu', menu, eq=widget_eq) ++ menu.destroy() ++ ++ def test_padx(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'padx', 3, 4.4, 5.6, '12m') ++ self.checkParam(widget, 'padx', -2, expected=0) ++ ++ def test_pady(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'pady', 3, 4.4, 5.6, '12m') ++ self.checkParam(widget, 'pady', -2, expected=0) ++ ++ def test_width(self): ++ widget = self.create() ++ self.checkIntegerParam(widget, 'width', 402, -402, 0, conv=str) ++ ++ ++class OptionMenuTest(MenubuttonTest, unittest.TestCase): ++ ++ def _create(self, default='b', values=('a', 'b', 'c'), **kwargs): ++ return tkinter.OptionMenu(self.root, None, default, *values, **kwargs) ++ ++ ++@add_standard_options(IntegerSizeTests, StandardOptionsTests) ++class EntryTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'background', 'borderwidth', 'cursor', ++ 'disabledbackground', 'disabledforeground', ++ 'exportselection', 'font', 'foreground', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'insertbackground', 'insertborderwidth', ++ 'insertofftime', 'insertontime', 'insertwidth', ++ 'invalidcommand', 'justify', 'readonlybackground', 'relief', ++ 'selectbackground', 'selectborderwidth', 'selectforeground', ++ 'show', 'state', 'takefocus', 'textvariable', ++ 'validate', 'validatecommand', 'width', 'xscrollcommand', ++ ) ++ ++ def _create(self, **kwargs): ++ return tkinter.Entry(self.root, **kwargs) ++ ++ def test_disabledbackground(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'disabledbackground') ++ ++ def test_insertborderwidth(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'insertborderwidth', 0, 1.3, -2) ++ self.checkParam(widget, 'insertborderwidth', 2, expected=1) ++ self.checkParam(widget, 'insertborderwidth', '10p', expected=1) ++ ++ def test_insertwidth(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'insertwidth', 1.3, 3.6, '10p') ++ self.checkParam(widget, 'insertwidth', 0.1, expected=2) ++ self.checkParam(widget, 'insertwidth', -2, expected=2) ++ if pixels_round(0.9) <= 0: ++ self.checkParam(widget, 'insertwidth', 0.9, expected=2) ++ else: ++ self.checkParam(widget, 'insertwidth', 0.9, expected=1) ++ ++ def test_invalidcommand(self): ++ widget = self.create() ++ self.checkCommandParam(widget, 'invalidcommand') ++ self.checkCommandParam(widget, 'invcmd') ++ ++ def test_readonlybackground(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'readonlybackground') ++ ++ def test_show(self): ++ widget = self.create() ++ self.checkParam(widget, 'show', '*') ++ self.checkParam(widget, 'show', '') ++ self.checkParam(widget, 'show', ' ') ++ ++ def test_state(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'state', ++ 'disabled', 'normal', 'readonly') ++ ++ def test_validate(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'validate', ++ 'all', 'key', 'focus', 'focusin', 'focusout', 'none') ++ ++ def test_validatecommand(self): ++ widget = self.create() ++ self.checkCommandParam(widget, 'validatecommand') ++ self.checkCommandParam(widget, 'vcmd') ++ ++ ++@add_standard_options(StandardOptionsTests) ++class SpinboxTest(EntryTest, unittest.TestCase): ++ OPTIONS = ( ++ 'activebackground', 'background', 'borderwidth', ++ 'buttonbackground', 'buttoncursor', 'buttondownrelief', 'buttonuprelief', ++ 'command', 'cursor', 'disabledbackground', 'disabledforeground', ++ 'exportselection', 'font', 'foreground', 'format', 'from', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'increment', ++ 'insertbackground', 'insertborderwidth', ++ 'insertofftime', 'insertontime', 'insertwidth', ++ 'invalidcommand', 'justify', 'relief', 'readonlybackground', ++ 'repeatdelay', 'repeatinterval', ++ 'selectbackground', 'selectborderwidth', 'selectforeground', ++ 'state', 'takefocus', 'textvariable', 'to', ++ 'validate', 'validatecommand', 'values', ++ 'width', 'wrap', 'xscrollcommand', ++ ) ++ ++ def _create(self, **kwargs): ++ return tkinter.Spinbox(self.root, **kwargs) ++ ++ test_show = None ++ ++ def test_buttonbackground(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'buttonbackground') ++ ++ def test_buttoncursor(self): ++ widget = self.create() ++ self.checkCursorParam(widget, 'buttoncursor') ++ ++ def test_buttondownrelief(self): ++ widget = self.create() ++ self.checkReliefParam(widget, 'buttondownrelief') ++ ++ def test_buttonuprelief(self): ++ widget = self.create() ++ self.checkReliefParam(widget, 'buttonuprelief') ++ ++ def test_format(self): ++ widget = self.create() ++ self.checkParam(widget, 'format', '%2f') ++ self.checkParam(widget, 'format', '%2.2f') ++ self.checkParam(widget, 'format', '%.2f') ++ self.checkParam(widget, 'format', '%2.f') ++ self.checkInvalidParam(widget, 'format', '%2e-1f') ++ self.checkInvalidParam(widget, 'format', '2.2') ++ self.checkInvalidParam(widget, 'format', '%2.-2f') ++ self.checkParam(widget, 'format', '%-2.02f') ++ self.checkParam(widget, 'format', '% 2.02f') ++ self.checkParam(widget, 'format', '% -2.200f') ++ self.checkParam(widget, 'format', '%09.200f') ++ self.checkInvalidParam(widget, 'format', '%d') ++ ++ def test_from(self): ++ widget = self.create() ++ self.checkParam(widget, 'to', 100.0) ++ self.checkFloatParam(widget, 'from', -10, 10.2, 11.7) ++ self.checkInvalidParam(widget, 'from', 200, ++ errmsg='-to value must be greater than -from value') ++ ++ def test_increment(self): ++ widget = self.create() ++ self.checkFloatParam(widget, 'increment', -1, 1, 10.2, 12.8, 0) ++ ++ def test_to(self): ++ widget = self.create() ++ self.checkParam(widget, 'from', -100.0) ++ self.checkFloatParam(widget, 'to', -10, 10.2, 11.7) ++ self.checkInvalidParam(widget, 'to', -200, ++ errmsg='-to value must be greater than -from value') ++ ++ def test_values(self): ++ # XXX ++ widget = self.create() ++ self.assertEqual(widget['values'], '') ++ self.checkParam(widget, 'values', 'mon tue wed thur') ++ self.checkParam(widget, 'values', ('mon', 'tue', 'wed', 'thur'), ++ expected='mon tue wed thur') ++ self.checkParam(widget, 'values', (42, 3.14, '', 'any string'), ++ expected='42 3.14 {} {any string}') ++ self.checkParam(widget, 'values', '') ++ ++ def test_wrap(self): ++ widget = self.create() ++ self.checkBooleanParam(widget, 'wrap') ++ ++ def test_bbox(self): ++ widget = self.create() ++ bbox = widget.bbox(0) ++ self.assertEqual(len(bbox), 4) ++ for item in bbox: ++ self.assertIsInstance(item, int) ++ ++ self.assertRaises(tkinter.TclError, widget.bbox, 'noindex') ++ self.assertRaises(tkinter.TclError, widget.bbox, None) ++ self.assertRaises(TypeError, widget.bbox) ++ self.assertRaises(TypeError, widget.bbox, 0, 1) ++ ++ ++@add_standard_options(StandardOptionsTests) ++class TextTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'autoseparators', 'background', 'blockcursor', 'borderwidth', ++ 'cursor', 'endline', 'exportselection', ++ 'font', 'foreground', 'height', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'inactiveselectbackground', 'insertbackground', 'insertborderwidth', ++ 'insertofftime', 'insertontime', 'insertunfocussed', 'insertwidth', ++ 'maxundo', 'padx', 'pady', 'relief', ++ 'selectbackground', 'selectborderwidth', 'selectforeground', ++ 'setgrid', 'spacing1', 'spacing2', 'spacing3', 'startline', 'state', ++ 'tabs', 'tabstyle', 'takefocus', 'undo', 'width', 'wrap', ++ 'xscrollcommand', 'yscrollcommand', ++ ) ++ if tcl_version < (8, 5): ++ wantobjects = False ++ ++ def _create(self, **kwargs): ++ return tkinter.Text(self.root, **kwargs) ++ ++ def test_autoseparators(self): ++ widget = self.create() ++ self.checkBooleanParam(widget, 'autoseparators') ++ ++ @requires_tcl(8, 5) ++ def test_blockcursor(self): ++ widget = self.create() ++ self.checkBooleanParam(widget, 'blockcursor') ++ ++ @requires_tcl(8, 5) ++ def test_endline(self): ++ widget = self.create() ++ text = '\n'.join('Line %d' for i in range(100)) ++ widget.insert('end', text) ++ self.checkParam(widget, 'endline', 200, expected='') ++ self.checkParam(widget, 'endline', -10, expected='') ++ self.checkInvalidParam(widget, 'endline', 'spam', ++ errmsg='expected integer but got "spam"') ++ self.checkParam(widget, 'endline', 50) ++ self.checkParam(widget, 'startline', 15) ++ self.checkInvalidParam(widget, 'endline', 10, ++ errmsg='-startline must be less than or equal to -endline') ++ ++ def test_height(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'height', 100, 101.2, 102.6, '3c') ++ self.checkParam(widget, 'height', -100, expected=1) ++ self.checkParam(widget, 'height', 0, expected=1) ++ ++ def test_maxundo(self): ++ widget = self.create() ++ self.checkIntegerParam(widget, 'maxundo', 0, 5, -1) ++ ++ @requires_tcl(8, 5) ++ def test_inactiveselectbackground(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'inactiveselectbackground') ++ ++ @requires_tcl(8, 6) ++ def test_insertunfocussed(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'insertunfocussed', ++ 'hollow', 'none', 'solid') ++ ++ def test_selectborderwidth(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'selectborderwidth', ++ 1.3, 2.6, -2, '10p', conv=noconv, ++ keep_orig=tcl_version >= (8, 5)) ++ ++ def test_spacing1(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'spacing1', 20, 21.4, 22.6, '0.5c') ++ self.checkParam(widget, 'spacing1', -5, expected=0) ++ ++ def test_spacing2(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'spacing2', 5, 6.4, 7.6, '0.1c') ++ self.checkParam(widget, 'spacing2', -1, expected=0) ++ ++ def test_spacing3(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'spacing3', 20, 21.4, 22.6, '0.5c') ++ self.checkParam(widget, 'spacing3', -10, expected=0) ++ ++ @requires_tcl(8, 5) ++ def test_startline(self): ++ widget = self.create() ++ text = '\n'.join('Line %d' for i in range(100)) ++ widget.insert('end', text) ++ self.checkParam(widget, 'startline', 200, expected='') ++ self.checkParam(widget, 'startline', -10, expected='') ++ self.checkInvalidParam(widget, 'startline', 'spam', ++ errmsg='expected integer but got "spam"') ++ self.checkParam(widget, 'startline', 10) ++ self.checkParam(widget, 'endline', 50) ++ self.checkInvalidParam(widget, 'startline', 70, ++ errmsg='-startline must be less than or equal to -endline') ++ ++ def test_state(self): ++ widget = self.create() ++ if tcl_version < (8, 5): ++ self.checkParams(widget, 'state', 'disabled', 'normal') ++ else: ++ self.checkEnumParam(widget, 'state', 'disabled', 'normal') ++ ++ def test_tabs(self): ++ widget = self.create() ++ if get_tk_patchlevel() < (8, 5, 11): ++ self.checkParam(widget, 'tabs', (10.2, 20.7, '1i', '2i'), ++ expected=('10.2', '20.7', '1i', '2i')) ++ else: ++ self.checkParam(widget, 'tabs', (10.2, 20.7, '1i', '2i')) ++ self.checkParam(widget, 'tabs', '10.2 20.7 1i 2i', ++ expected=('10.2', '20.7', '1i', '2i')) ++ self.checkParam(widget, 'tabs', '2c left 4c 6c center', ++ expected=('2c', 'left', '4c', '6c', 'center')) ++ self.checkInvalidParam(widget, 'tabs', 'spam', ++ errmsg='bad screen distance "spam"', ++ keep_orig=tcl_version >= (8, 5)) ++ ++ @requires_tcl(8, 5) ++ def test_tabstyle(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'tabstyle', 'tabular', 'wordprocessor') ++ ++ def test_undo(self): ++ widget = self.create() ++ self.checkBooleanParam(widget, 'undo') ++ ++ def test_width(self): ++ widget = self.create() ++ self.checkIntegerParam(widget, 'width', 402) ++ self.checkParam(widget, 'width', -402, expected=1) ++ self.checkParam(widget, 'width', 0, expected=1) ++ ++ def test_wrap(self): ++ widget = self.create() ++ if tcl_version < (8, 5): ++ self.checkParams(widget, 'wrap', 'char', 'none', 'word') ++ else: ++ self.checkEnumParam(widget, 'wrap', 'char', 'none', 'word') ++ ++ def test_bbox(self): ++ widget = self.create() ++ bbox = widget.bbox('1.1') ++ self.assertEqual(len(bbox), 4) ++ for item in bbox: ++ self.assertIsInstance(item, int) ++ ++ self.assertIsNone(widget.bbox('end')) ++ self.assertRaises(tkinter.TclError, widget.bbox, 'noindex') ++ self.assertRaises(tkinter.TclError, widget.bbox, None) ++ self.assertRaises(tkinter.TclError, widget.bbox) ++ self.assertRaises(tkinter.TclError, widget.bbox, '1.1', 'end') ++ ++ ++@add_standard_options(PixelSizeTests, StandardOptionsTests) ++class CanvasTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'background', 'borderwidth', ++ 'closeenough', 'confine', 'cursor', 'height', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'insertbackground', 'insertborderwidth', ++ 'insertofftime', 'insertontime', 'insertwidth', ++ 'relief', 'scrollregion', ++ 'selectbackground', 'selectborderwidth', 'selectforeground', ++ 'state', 'takefocus', ++ 'xscrollcommand', 'xscrollincrement', ++ 'yscrollcommand', 'yscrollincrement', 'width', ++ ) ++ ++ _conv_pixels = round ++ wantobjects = False ++ ++ def _create(self, **kwargs): ++ return tkinter.Canvas(self.root, **kwargs) ++ ++ def test_closeenough(self): ++ widget = self.create() ++ self.checkFloatParam(widget, 'closeenough', 24, 2.4, 3.6, -3, ++ conv=float) ++ ++ def test_confine(self): ++ widget = self.create() ++ self.checkBooleanParam(widget, 'confine') ++ ++ def test_scrollregion(self): ++ widget = self.create() ++ self.checkParam(widget, 'scrollregion', '0 0 200 150') ++ self.checkParam(widget, 'scrollregion', (0, 0, 200, 150), ++ expected='0 0 200 150') ++ self.checkParam(widget, 'scrollregion', '') ++ self.checkInvalidParam(widget, 'scrollregion', 'spam', ++ errmsg='bad scrollRegion "spam"') ++ self.checkInvalidParam(widget, 'scrollregion', (0, 0, 200, 'spam')) ++ self.checkInvalidParam(widget, 'scrollregion', (0, 0, 200)) ++ self.checkInvalidParam(widget, 'scrollregion', (0, 0, 200, 150, 0)) ++ ++ def test_state(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'state', 'disabled', 'normal', ++ errmsg='bad state value "{}": must be normal or disabled') ++ ++ def test_xscrollincrement(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'xscrollincrement', ++ 40, 0, 41.2, 43.6, -40, '0.5i') ++ ++ def test_yscrollincrement(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'yscrollincrement', ++ 10, 0, 11.2, 13.6, -10, '0.1i') ++ ++ ++@add_standard_options(IntegerSizeTests, StandardOptionsTests) ++class ListboxTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'activestyle', 'background', 'borderwidth', 'cursor', ++ 'disabledforeground', 'exportselection', ++ 'font', 'foreground', 'height', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'listvariable', 'relief', ++ 'selectbackground', 'selectborderwidth', 'selectforeground', ++ 'selectmode', 'setgrid', 'state', ++ 'takefocus', 'width', 'xscrollcommand', 'yscrollcommand', ++ ) ++ ++ def _create(self, **kwargs): ++ return tkinter.Listbox(self.root, **kwargs) ++ ++ def test_activestyle(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'activestyle', ++ 'dotbox', 'none', 'underline') ++ ++ def test_listvariable(self): ++ widget = self.create() ++ var = tkinter.DoubleVar() ++ self.checkVariableParam(widget, 'listvariable', var) ++ ++ def test_selectmode(self): ++ widget = self.create() ++ self.checkParam(widget, 'selectmode', 'single') ++ self.checkParam(widget, 'selectmode', 'browse') ++ self.checkParam(widget, 'selectmode', 'multiple') ++ self.checkParam(widget, 'selectmode', 'extended') ++ ++ def test_state(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'state', 'disabled', 'normal') ++ ++@add_standard_options(PixelSizeTests, StandardOptionsTests) ++class ScaleTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'activebackground', 'background', 'bigincrement', 'borderwidth', ++ 'command', 'cursor', 'digits', 'font', 'foreground', 'from', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'label', 'length', 'orient', 'relief', ++ 'repeatdelay', 'repeatinterval', ++ 'resolution', 'showvalue', 'sliderlength', 'sliderrelief', 'state', ++ 'takefocus', 'tickinterval', 'to', 'troughcolor', 'variable', 'width', ++ ) ++ default_orient = 'vertical' ++ ++ def _create(self, **kwargs): ++ return tkinter.Scale(self.root, **kwargs) ++ ++ def test_bigincrement(self): ++ widget = self.create() ++ self.checkFloatParam(widget, 'bigincrement', 12.4, 23.6, -5) ++ ++ def test_digits(self): ++ widget = self.create() ++ self.checkIntegerParam(widget, 'digits', 5, 0) ++ ++ def test_from(self): ++ widget = self.create() ++ self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=float_round) ++ ++ def test_label(self): ++ widget = self.create() ++ self.checkParam(widget, 'label', 'any string') ++ self.checkParam(widget, 'label', '') ++ ++ def test_length(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'length', 130, 131.2, 135.6, '5i') ++ ++ def test_resolution(self): ++ widget = self.create() ++ self.checkFloatParam(widget, 'resolution', 4.2, 0, 6.7, -2) ++ ++ def test_showvalue(self): ++ widget = self.create() ++ self.checkBooleanParam(widget, 'showvalue') ++ ++ def test_sliderlength(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'sliderlength', ++ 10, 11.2, 15.6, -3, '3m') ++ ++ def test_sliderrelief(self): ++ widget = self.create() ++ self.checkReliefParam(widget, 'sliderrelief') ++ ++ def test_tickinterval(self): ++ widget = self.create() ++ self.checkFloatParam(widget, 'tickinterval', 1, 4.3, 7.6, 0, ++ conv=float_round) ++ self.checkParam(widget, 'tickinterval', -2, expected=2, ++ conv=float_round) ++ ++ def test_to(self): ++ widget = self.create() ++ self.checkFloatParam(widget, 'to', 300, 14.9, 15.1, -10, ++ conv=float_round) ++ ++ ++@add_standard_options(PixelSizeTests, StandardOptionsTests) ++class ScrollbarTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'activebackground', 'activerelief', ++ 'background', 'borderwidth', ++ 'command', 'cursor', 'elementborderwidth', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'jump', 'orient', 'relief', ++ 'repeatdelay', 'repeatinterval', ++ 'takefocus', 'troughcolor', 'width', ++ ) ++ _conv_pixels = round ++ wantobjects = False ++ default_orient = 'vertical' ++ ++ def _create(self, **kwargs): ++ return tkinter.Scrollbar(self.root, **kwargs) ++ ++ def test_activerelief(self): ++ widget = self.create() ++ self.checkReliefParam(widget, 'activerelief') ++ ++ def test_elementborderwidth(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'elementborderwidth', 4.3, 5.6, -2, '1m') ++ ++ def test_orient(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'orient', 'vertical', 'horizontal', ++ errmsg='bad orientation "{}": must be vertical or horizontal') ++ ++ ++@add_standard_options(StandardOptionsTests) ++class PanedWindowTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'background', 'borderwidth', 'cursor', ++ 'handlepad', 'handlesize', 'height', ++ 'opaqueresize', 'orient', 'relief', ++ 'sashcursor', 'sashpad', 'sashrelief', 'sashwidth', ++ 'showhandle', 'width', ++ ) ++ default_orient = 'horizontal' ++ ++ def _create(self, **kwargs): ++ return tkinter.PanedWindow(self.root, **kwargs) ++ ++ def test_handlepad(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'handlepad', 5, 6.4, 7.6, -3, '1m') ++ ++ def test_handlesize(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'handlesize', 8, 9.4, 10.6, -3, '2m', ++ conv=noconv) ++ ++ def test_height(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'height', 100, 101.2, 102.6, -100, 0, '1i', ++ conv=noconv) ++ ++ def test_opaqueresize(self): ++ widget = self.create() ++ self.checkBooleanParam(widget, 'opaqueresize') ++ ++ def test_sashcursor(self): ++ widget = self.create() ++ self.checkCursorParam(widget, 'sashcursor') ++ ++ def test_sashpad(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'sashpad', 8, 1.3, 2.6, -2, '2m') ++ ++ def test_sashrelief(self): ++ widget = self.create() ++ self.checkReliefParam(widget, 'sashrelief') ++ ++ def test_sashwidth(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'sashwidth', 10, 11.1, 15.6, -3, '1m', ++ conv=noconv) ++ ++ def test_showhandle(self): ++ widget = self.create() ++ self.checkBooleanParam(widget, 'showhandle') ++ ++ def test_width(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'width', 402, 403.4, 404.6, -402, 0, '5i', ++ conv=noconv) ++ ++ ++@add_standard_options(StandardOptionsTests) ++class MenuTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'activebackground', 'activeborderwidth', 'activeforeground', ++ 'background', 'borderwidth', 'cursor', ++ 'disabledforeground', 'font', 'foreground', ++ 'postcommand', 'relief', 'selectcolor', 'takefocus', ++ 'tearoff', 'tearoffcommand', 'title', 'type', ++ ) ++ _conv_pixels = noconv ++ ++ def _create(self, **kwargs): ++ return tkinter.Menu(self.root, **kwargs) ++ ++ def test_postcommand(self): ++ widget = self.create() ++ self.checkCommandParam(widget, 'postcommand') ++ ++ def test_tearoff(self): ++ widget = self.create() ++ self.checkBooleanParam(widget, 'tearoff') ++ ++ def test_tearoffcommand(self): ++ widget = self.create() ++ self.checkCommandParam(widget, 'tearoffcommand') ++ ++ def test_title(self): ++ widget = self.create() ++ self.checkParam(widget, 'title', 'any string') ++ ++ def test_type(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'type', ++ 'normal', 'tearoff', 'menubar') ++ ++ ++@add_standard_options(PixelSizeTests, StandardOptionsTests) ++class MessageTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'anchor', 'aspect', 'background', 'borderwidth', ++ 'cursor', 'font', 'foreground', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'justify', 'padx', 'pady', 'relief', ++ 'takefocus', 'text', 'textvariable', 'width', ++ ) ++ _conv_pad_pixels = noconv ++ ++ def _create(self, **kwargs): ++ return tkinter.Message(self.root, **kwargs) ++ ++ def test_aspect(self): ++ widget = self.create() ++ self.checkIntegerParam(widget, 'aspect', 250, 0, -300) ++ ++ ++tests_gui = ( ++ ButtonTest, CanvasTest, CheckbuttonTest, EntryTest, ++ FrameTest, LabelFrameTest,LabelTest, ListboxTest, ++ MenubuttonTest, MenuTest, MessageTest, OptionMenuTest, ++ PanedWindowTest, RadiobuttonTest, ScaleTest, ScrollbarTest, ++ SpinboxTest, TextTest, ToplevelTest, ++) ++ ++if __name__ == '__main__': ++ unittest.main() +diff -r c3896275c0f6 Lib/tkinter/test/test_ttk/test_extensions.py +--- a/Lib/tkinter/test/test_ttk/test_extensions.py ++++ b/Lib/tkinter/test/test_ttk/test_extensions.py +@@ -45,7 +45,7 @@ + # it tries calling instance attributes not yet defined. + ttk.LabeledScale(variable=myvar) + if hasattr(sys, 'last_type'): +- self.assertFalse(sys.last_type == tkinter.TclError) ++ self.assertNotEqual(sys.last_type, tkinter.TclError) + + + def test_initialization(self): +@@ -120,14 +120,14 @@ + # at the same time this shouldn't affect test outcome + lscale.update() + curr_xcoord = lscale.scale.coords()[0] +- self.assertTrue(prev_xcoord != curr_xcoord) ++ self.assertNotEqual(prev_xcoord, curr_xcoord) + # the label widget should have been repositioned too + linfo_2 = lscale.label.place_info() + self.assertEqual(lscale.label['text'], 0) + self.assertEqual(curr_xcoord, int(linfo_2['x'])) + # change the range back + lscale.scale.configure(from_=0, to=10) +- self.assertTrue(prev_xcoord != curr_xcoord) ++ self.assertNotEqual(prev_xcoord, curr_xcoord) + self.assertEqual(prev_xcoord, int(linfo_1['x'])) + + lscale.destroy() +@@ -146,7 +146,7 @@ + # at the same time this shouldn't affect test outcome + x.update() + self.assertEqual(x.label['text'], newval) +- self.assertTrue(x.scale.coords()[0] > curr_xcoord) ++ self.assertGreater(x.scale.coords()[0], curr_xcoord) + self.assertEqual(x.scale.coords()[0], + int(x.label.place_info()['x'])) + +@@ -238,7 +238,7 @@ + if last == curr: + # no more menu entries + break +- self.assertFalse(curr == default) ++ self.assertNotEqual(curr, default) + i += 1 + self.assertEqual(i, len(items)) + +diff -r c3896275c0f6 Lib/tkinter/test/test_ttk/test_style.py +--- a/Lib/tkinter/test/test_ttk/test_style.py ++++ b/Lib/tkinter/test/test_ttk/test_style.py +@@ -18,7 +18,7 @@ + style.configure('TButton', background='yellow') + self.assertEqual(style.configure('TButton', 'background'), + 'yellow') +- self.assertTrue(isinstance(style.configure('TButton'), dict)) ++ self.assertIsInstance(style.configure('TButton'), dict) + + + def test_map(self): +@@ -26,7 +26,7 @@ + style.map('TButton', background=[('active', 'background', 'blue')]) + self.assertEqual(style.map('TButton', 'background'), + [('active', 'background', 'blue')]) +- self.assertTrue(isinstance(style.map('TButton'), dict)) ++ self.assertIsInstance(style.map('TButton'), dict) + + + def test_lookup(self): +@@ -57,7 +57,7 @@ + self.assertEqual(style.layout('Treeview'), tv_style) + + # should return a list +- self.assertTrue(isinstance(style.layout('TButton'), list)) ++ self.assertIsInstance(style.layout('TButton'), list) + + # correct layout, but "option" doesn't exist as option + self.assertRaises(tkinter.TclError, style.layout, 'Treeview', +diff -r c3896275c0f6 Lib/tkinter/test/test_ttk/test_widgets.py +--- a/Lib/tkinter/test/test_ttk/test_widgets.py ++++ b/Lib/tkinter/test/test_ttk/test_widgets.py +@@ -1,15 +1,58 @@ + import unittest + import tkinter +-import os + from tkinter import ttk +-from test.support import requires, run_unittest ++from test.support import requires + import sys + + import tkinter.test.support as support +-from tkinter.test.test_ttk.test_functions import MockTclObj, MockStateSpec ++from tkinter.test.test_ttk.test_functions import MockTclObj ++from tkinter.test.support import tcl_version ++from tkinter.test.widget_tests import (add_standard_options, noconv, ++ AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests, ++ setUpModule) + + requires('gui') + ++ ++class StandardTtkOptionsTests(StandardOptionsTests): ++ ++ def test_class(self): ++ widget = self.create() ++ self.assertEqual(widget['class'], '') ++ errmsg='attempt to change read-only option' ++ if tcl_version < (8, 6): ++ errmsg='Attempt to change read-only option' ++ self.checkInvalidParam(widget, 'class', 'Foo', errmsg=errmsg) ++ widget2 = self.create(class_='Foo') ++ self.assertEqual(widget2['class'], 'Foo') ++ ++ def test_padding(self): ++ widget = self.create() ++ self.checkParam(widget, 'padding', 0, expected=('0',)) ++ self.checkParam(widget, 'padding', 5, expected=('5',)) ++ self.checkParam(widget, 'padding', (5, 6), expected=('5', '6')) ++ self.checkParam(widget, 'padding', (5, 6, 7), ++ expected=('5', '6', '7')) ++ self.checkParam(widget, 'padding', (5, 6, 7, 8), ++ expected=('5', '6', '7', '8')) ++ self.checkParam(widget, 'padding', ('5p', '6p', '7p', '8p')) ++ self.checkParam(widget, 'padding', (), expected='') ++ ++ def test_style(self): ++ widget = self.create() ++ self.assertEqual(widget['style'], '') ++ errmsg = 'Layout Foo not found' ++ if hasattr(self, 'default_orient'): ++ errmsg = ('Layout %s.Foo not found' % ++ getattr(self, 'default_orient').title()) ++ self.checkInvalidParam(widget, 'style', 'Foo', ++ errmsg=errmsg) ++ widget2 = self.create(class_='Foo') ++ self.assertEqual(widget2['class'], 'Foo') ++ # XXX ++ pass ++ ++ + class WidgetTest(unittest.TestCase): + """Tests methods available in every ttk widget.""" + +@@ -73,7 +116,112 @@ + self.assertEqual(self.widget.state(), ('active', )) + + +-class ButtonTest(unittest.TestCase): ++class AbstractToplevelTest(AbstractWidgetTest, PixelSizeTests): ++ _conv_pixels = noconv ++ ++ ++@add_standard_options(StandardTtkOptionsTests) ++class FrameTest(AbstractToplevelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'borderwidth', 'class', 'cursor', 'height', ++ 'padding', 'relief', 'style', 'takefocus', ++ 'width', ++ ) ++ ++ def _create(self, **kwargs): ++ return ttk.Frame(self.root, **kwargs) ++ ++ ++@add_standard_options(StandardTtkOptionsTests) ++class LabelFrameTest(AbstractToplevelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'borderwidth', 'class', 'cursor', 'height', ++ 'labelanchor', 'labelwidget', ++ 'padding', 'relief', 'style', 'takefocus', ++ 'text', 'underline', 'width', ++ ) ++ ++ def _create(self, **kwargs): ++ return ttk.LabelFrame(self.root, **kwargs) ++ ++ def test_labelanchor(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'labelanchor', ++ 'e', 'en', 'es', 'n', 'ne', 'nw', 's', 'se', 'sw', 'w', 'wn', 'ws', ++ errmsg='Bad label anchor specification {}') ++ self.checkInvalidParam(widget, 'labelanchor', 'center') ++ ++ def test_labelwidget(self): ++ widget = self.create() ++ label = ttk.Label(self.root, text='Mupp', name='foo') ++ self.checkParam(widget, 'labelwidget', label, expected='.foo') ++ label.destroy() ++ ++ ++class AbstractLabelTest(AbstractWidgetTest): ++ ++ def checkImageParam(self, widget, name): ++ image = tkinter.PhotoImage('image1') ++ image2 = tkinter.PhotoImage('image2') ++ self.checkParam(widget, name, image, expected=('image1',)) ++ self.checkParam(widget, name, 'image1', expected=('image1',)) ++ self.checkParam(widget, name, (image,), expected=('image1',)) ++ self.checkParam(widget, name, (image, 'active', image2), ++ expected=('image1', 'active', 'image2')) ++ self.checkParam(widget, name, 'image1 active image2', ++ expected=('image1', 'active', 'image2')) ++ self.checkInvalidParam(widget, name, 'spam', ++ errmsg='image "spam" doesn\'t exist') ++ ++ def test_compound(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'compound', ++ 'none', 'text', 'image', 'center', ++ 'top', 'bottom', 'left', 'right') ++ ++ def test_state(self): ++ widget = self.create() ++ self.checkParams(widget, 'state', 'active', 'disabled', 'normal') ++ ++ def test_width(self): ++ widget = self.create() ++ self.checkParams(widget, 'width', 402, -402, 0) ++ ++ ++@add_standard_options(StandardTtkOptionsTests) ++class LabelTest(AbstractLabelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'anchor', 'background', ++ 'class', 'compound', 'cursor', 'font', 'foreground', ++ 'image', 'justify', 'padding', 'relief', 'state', 'style', ++ 'takefocus', 'text', 'textvariable', ++ 'underline', 'width', 'wraplength', ++ ) ++ _conv_pixels = noconv ++ ++ def _create(self, **kwargs): ++ return ttk.Label(self.root, **kwargs) ++ ++ def test_font(self): ++ widget = self.create() ++ self.checkParam(widget, 'font', ++ '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') ++ ++ ++@add_standard_options(StandardTtkOptionsTests) ++class ButtonTest(AbstractLabelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'class', 'command', 'compound', 'cursor', 'default', ++ 'image', 'state', 'style', 'takefocus', 'text', 'textvariable', ++ 'underline', 'width', ++ ) ++ ++ def _create(self, **kwargs): ++ return ttk.Button(self.root, **kwargs) ++ ++ def test_default(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'default', 'normal', 'active', 'disabled') + + def test_invoke(self): + success = [] +@@ -82,7 +230,27 @@ + self.assertTrue(success) + + +-class CheckbuttonTest(unittest.TestCase): ++@add_standard_options(StandardTtkOptionsTests) ++class CheckbuttonTest(AbstractLabelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'class', 'command', 'compound', 'cursor', ++ 'image', ++ 'offvalue', 'onvalue', ++ 'state', 'style', ++ 'takefocus', 'text', 'textvariable', ++ 'underline', 'variable', 'width', ++ ) ++ ++ def _create(self, **kwargs): ++ return ttk.Checkbutton(self.root, **kwargs) ++ ++ def test_offvalue(self): ++ widget = self.create() ++ self.checkParams(widget, 'offvalue', 1, 2.3, '', 'any string') ++ ++ def test_onvalue(self): ++ widget = self.create() ++ self.checkParams(widget, 'onvalue', 1, 2.3, '', 'any string') + + def test_invoke(self): + success = [] +@@ -105,21 +273,40 @@ + + cbtn['command'] = '' + res = cbtn.invoke() +- self.assertEqual(str(res), '') +- self.assertFalse(len(success) > 1) ++ self.assertFalse(str(res)) ++ self.assertLessEqual(len(success), 1) + self.assertEqual(cbtn['offvalue'], + cbtn.tk.globalgetvar(cbtn['variable'])) + + +-class ComboboxTest(unittest.TestCase): ++@add_standard_options(IntegerSizeTests, StandardTtkOptionsTests) ++class ComboboxTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'class', 'cursor', 'exportselection', 'height', ++ 'justify', 'postcommand', 'state', 'style', ++ 'takefocus', 'textvariable', 'values', 'width', ++ ) + + def setUp(self): ++ super().setUp() + support.root_deiconify() +- self.combo = ttk.Combobox() ++ self.combo = self.create() + + def tearDown(self): + self.combo.destroy() + support.root_withdraw() ++ super().tearDown() ++ ++ def _create(self, **kwargs): ++ return ttk.Combobox(self.root, **kwargs) ++ ++ def test_height(self): ++ widget = self.create() ++ self.checkParams(widget, 'height', 100, 101.2, 102.6, -100, 0, '1i') ++ ++ def test_state(self): ++ widget = self.create() ++ self.checkParams(widget, 'state', 'active', 'disabled', 'normal') + + def _show_drop_down_listbox(self): + width = self.combo.winfo_width() +@@ -167,8 +354,16 @@ + self.assertEqual(self.combo.get(), getval) + self.assertEqual(self.combo.current(), currval) + ++ self.assertEqual(self.combo['values'], ++ () if tcl_version < (8, 5) else '') + check_get_current('', -1) + ++ self.checkParam(self.combo, 'values', 'mon tue wed thur', ++ expected=('mon', 'tue', 'wed', 'thur')) ++ self.checkParam(self.combo, 'values', ('mon', 'tue', 'wed', 'thur')) ++ self.checkParam(self.combo, 'values', (42, 3.14, '', 'any string')) ++ self.checkParam(self.combo, 'values', '', expected=()) ++ + self.combo['values'] = ['a', 1, 'c'] + + self.combo.set('c') +@@ -209,21 +404,58 @@ + combo2.destroy() + + +-class EntryTest(unittest.TestCase): ++@add_standard_options(IntegerSizeTests, StandardTtkOptionsTests) ++class EntryTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'background', 'class', 'cursor', ++ 'exportselection', 'font', ++ 'invalidcommand', 'justify', ++ 'show', 'state', 'style', 'takefocus', 'textvariable', ++ 'validate', 'validatecommand', 'width', 'xscrollcommand', ++ ) + + def setUp(self): ++ super().setUp() + support.root_deiconify() +- self.entry = ttk.Entry() ++ self.entry = self.create() + + def tearDown(self): + self.entry.destroy() + support.root_withdraw() ++ super().tearDown() ++ ++ def _create(self, **kwargs): ++ return ttk.Entry(self.root, **kwargs) ++ ++ def test_invalidcommand(self): ++ widget = self.create() ++ self.checkCommandParam(widget, 'invalidcommand') ++ ++ def test_show(self): ++ widget = self.create() ++ self.checkParam(widget, 'show', '*') ++ self.checkParam(widget, 'show', '') ++ self.checkParam(widget, 'show', ' ') ++ ++ def test_state(self): ++ widget = self.create() ++ self.checkParams(widget, 'state', ++ 'disabled', 'normal', 'readonly') ++ ++ def test_validate(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'validate', ++ 'all', 'key', 'focus', 'focusin', 'focusout', 'none') ++ ++ def test_validatecommand(self): ++ widget = self.create() ++ self.checkCommandParam(widget, 'validatecommand') + + + def test_bbox(self): + self.assertEqual(len(self.entry.bbox(0)), 4) + for item in self.entry.bbox(0): +- self.assertTrue(isinstance(item, int)) ++ self.assertIsInstance(item, int) + + self.assertRaises(tkinter.TclError, self.entry.bbox, 'noindex') + self.assertRaises(tkinter.TclError, self.entry.bbox, None) +@@ -313,16 +545,36 @@ + self.assertEqual(self.entry.state(), ()) + + +-class PanedwindowTest(unittest.TestCase): ++@add_standard_options(IntegerSizeTests, StandardTtkOptionsTests) ++class PanedWindowTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'class', 'cursor', 'height', ++ 'orient', 'style', 'takefocus', 'width', ++ ) + + def setUp(self): ++ super().setUp() + support.root_deiconify() +- self.paned = ttk.Panedwindow() ++ self.paned = self.create() + + def tearDown(self): + self.paned.destroy() + support.root_withdraw() ++ super().tearDown() + ++ def _create(self, **kwargs): ++ return ttk.PanedWindow(self.root, **kwargs) ++ ++ def test_orient(self): ++ widget = self.create() ++ self.assertEqual(str(widget['orient']), 'vertical') ++ errmsg='attempt to change read-only option' ++ if tcl_version < (8, 6): ++ errmsg='Attempt to change read-only option' ++ self.checkInvalidParam(widget, 'orient', 'horizontal', ++ errmsg=errmsg) ++ widget2 = self.create(orient='horizontal') ++ self.assertEqual(str(widget2['orient']), 'horizontal') + + def test_add(self): + # attempt to add a child that is not a direct child of the paned window +@@ -401,7 +653,7 @@ + + child = ttk.Label() + self.paned.add(child) +- self.assertTrue(isinstance(self.paned.pane(0), dict)) ++ self.assertIsInstance(self.paned.pane(0), dict) + self.assertEqual(self.paned.pane(0, weight=None), 0) + # newer form for querying a single option + self.assertEqual(self.paned.pane(0, 'weight'), 0) +@@ -428,11 +680,26 @@ + + curr_pos = self.paned.sashpos(0) + self.paned.sashpos(0, 1000) +- self.assertTrue(curr_pos != self.paned.sashpos(0)) +- self.assertTrue(isinstance(self.paned.sashpos(0), int)) ++ self.assertNotEqual(curr_pos, self.paned.sashpos(0)) ++ self.assertIsInstance(self.paned.sashpos(0), int) + + +-class RadiobuttonTest(unittest.TestCase): ++@add_standard_options(StandardTtkOptionsTests) ++class RadiobuttonTest(AbstractLabelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'class', 'command', 'compound', 'cursor', ++ 'image', ++ 'state', 'style', ++ 'takefocus', 'text', 'textvariable', ++ 'underline', 'value', 'variable', 'width', ++ ) ++ ++ def _create(self, **kwargs): ++ return ttk.Radiobutton(self.root, **kwargs) ++ ++ def test_value(self): ++ widget = self.create() ++ self.checkParams(widget, 'value', 1, 2.3, '', 'any string') + + def test_invoke(self): + success = [] +@@ -454,7 +721,7 @@ + cbtn2['command'] = '' + res = cbtn2.invoke() + self.assertEqual(str(res), '') +- self.assertFalse(len(success) > 1) ++ self.assertLessEqual(len(success), 1) + self.assertEqual(cbtn2['value'], myvar.get()) + self.assertEqual(myvar.get(), + cbtn.tk.globalgetvar(cbtn['variable'])) +@@ -462,19 +729,68 @@ + self.assertEqual(str(cbtn['variable']), str(cbtn2['variable'])) + + ++class MenubuttonTest(AbstractLabelTest, unittest.TestCase): ++ OPTIONS = ( ++ 'class', 'compound', 'cursor', 'direction', ++ 'image', 'menu', 'state', 'style', ++ 'takefocus', 'text', 'textvariable', ++ 'underline', 'width', ++ ) + +-class ScaleTest(unittest.TestCase): ++ def _create(self, **kwargs): ++ return ttk.Menubutton(self.root, **kwargs) ++ ++ def test_direction(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'direction', ++ 'above', 'below', 'left', 'right', 'flush') ++ ++ def test_menu(self): ++ widget = self.create() ++ menu = tkinter.Menu(widget, name='menu') ++ self.checkParam(widget, 'menu', menu, conv=str) ++ menu.destroy() ++ ++ ++@add_standard_options(StandardTtkOptionsTests) ++class ScaleTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'class', 'command', 'cursor', 'from', 'length', ++ 'orient', 'style', 'takefocus', 'to', 'value', 'variable', ++ ) ++ _conv_pixels = noconv ++ default_orient = 'horizontal' + + def setUp(self): ++ super().setUp() + support.root_deiconify() +- self.scale = ttk.Scale() ++ self.scale = self.create() + self.scale.pack() + self.scale.update() + + def tearDown(self): + self.scale.destroy() + support.root_withdraw() ++ super().tearDown() + ++ def _create(self, **kwargs): ++ return ttk.Scale(self.root, **kwargs) ++ ++ def test_from(self): ++ widget = self.create() ++ self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=False) ++ ++ def test_length(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'length', 130, 131.2, 135.6, '5i') ++ ++ def test_to(self): ++ widget = self.create() ++ self.checkFloatParam(widget, 'to', 300, 14.9, 15.1, -10, conv=False) ++ ++ def test_value(self): ++ widget = self.create() ++ self.checkFloatParam(widget, 'value', 300, 14.9, 15.1, -10, conv=False) + + def test_custom_event(self): + failure = [1, 1, 1] # will need to be empty +@@ -539,11 +855,64 @@ + self.assertRaises(tkinter.TclError, self.scale.set, None) + + +-class NotebookTest(unittest.TestCase): ++@add_standard_options(StandardTtkOptionsTests) ++class ProgressbarTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'class', 'cursor', 'orient', 'length', ++ 'mode', 'maximum', 'phase', ++ 'style', 'takefocus', 'value', 'variable', ++ ) ++ _conv_pixels = noconv ++ default_orient = 'horizontal' ++ ++ def _create(self, **kwargs): ++ return ttk.Progressbar(self.root, **kwargs) ++ ++ def test_length(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'length', 100.1, 56.7, '2i') ++ ++ def test_maximum(self): ++ widget = self.create() ++ self.checkFloatParam(widget, 'maximum', 150.2, 77.7, 0, -10, conv=False) ++ ++ def test_mode(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'mode', 'determinate', 'indeterminate') ++ ++ def test_phase(self): ++ # XXX ++ pass ++ ++ def test_value(self): ++ widget = self.create() ++ self.checkFloatParam(widget, 'value', 150.2, 77.7, 0, -10, ++ conv=False) ++ ++ ++@unittest.skipIf(sys.platform == 'darwin', ++ 'ttk.Scrollbar is special on MacOSX') ++@add_standard_options(StandardTtkOptionsTests) ++class ScrollbarTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'class', 'command', 'cursor', 'orient', 'style', 'takefocus', ++ ) ++ default_orient = 'vertical' ++ ++ def _create(self, **kwargs): ++ return ttk.Scrollbar(self.root, **kwargs) ++ ++ ++@add_standard_options(IntegerSizeTests, StandardTtkOptionsTests) ++class NotebookTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'class', 'cursor', 'height', 'padding', 'style', 'takefocus', ++ ) + + def setUp(self): ++ super().setUp() + support.root_deiconify() +- self.nb = ttk.Notebook(padding=0) ++ self.nb = self.create(padding=0) + self.child1 = ttk.Label() + self.child2 = ttk.Label() + self.nb.add(self.child1, text='a') +@@ -554,7 +923,10 @@ + self.child2.destroy() + self.nb.destroy() + support.root_withdraw() ++ super().tearDown() + ++ def _create(self, **kwargs): ++ return ttk.Notebook(self.root, **kwargs) + + def test_tab_identifiers(self): + self.nb.forget(0) +@@ -611,7 +983,7 @@ + self.nb.add(self.child2) + self.assertEqual(self.nb.tabs(), tabs) + self.assertEqual(self.nb.index(self.child2), child2_index) +- self.assertTrue(str(self.child2) == self.nb.tabs()[child2_index]) ++ self.assertEqual(str(self.child2), self.nb.tabs()[child2_index]) + # but the tab next to it (not hidden) is the one selected now + self.assertEqual(self.nb.index('current'), curr + 1) + +@@ -624,19 +996,19 @@ + tabs = self.nb.tabs() + child1_index = self.nb.index(self.child1) + self.nb.forget(self.child1) +- self.assertFalse(str(self.child1) in self.nb.tabs()) ++ self.assertNotIn(str(self.child1), self.nb.tabs()) + self.assertEqual(len(tabs) - 1, len(self.nb.tabs())) + + self.nb.add(self.child1) + self.assertEqual(self.nb.index(self.child1), 1) +- self.assertFalse(child1_index == self.nb.index(self.child1)) ++ self.assertNotEqual(child1_index, self.nb.index(self.child1)) + + + def test_index(self): + self.assertRaises(tkinter.TclError, self.nb.index, -1) + self.assertRaises(tkinter.TclError, self.nb.index, None) + +- self.assertTrue(isinstance(self.nb.index('end'), int)) ++ self.assertIsInstance(self.nb.index('end'), int) + self.assertEqual(self.nb.index(self.child1), 0) + self.assertEqual(self.nb.index(self.child2), 1) + self.assertEqual(self.nb.index('end'), 2) +@@ -700,7 +1072,7 @@ + self.assertRaises(tkinter.TclError, self.nb.tab, 'notab') + self.assertRaises(tkinter.TclError, self.nb.tab, None) + +- self.assertTrue(isinstance(self.nb.tab(self.child1), dict)) ++ self.assertIsInstance(self.nb.tab(self.child1), dict) + self.assertEqual(self.nb.tab(self.child1, text=None), 'a') + # newer form for querying a single option + self.assertEqual(self.nb.tab(self.child1, 'text'), 'a') +@@ -746,16 +1118,68 @@ + self.assertEqual(self.nb.select(), str(self.child1)) + + +-class TreeviewTest(unittest.TestCase): ++@add_standard_options(StandardTtkOptionsTests) ++class TreeviewTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'class', 'columns', 'cursor', 'displaycolumns', ++ 'height', 'padding', 'selectmode', 'show', ++ 'style', 'takefocus', 'xscrollcommand', 'yscrollcommand', ++ ) + + def setUp(self): ++ super().setUp() + support.root_deiconify() +- self.tv = ttk.Treeview(padding=0) ++ self.tv = self.create(padding=0) + + def tearDown(self): + self.tv.destroy() + support.root_withdraw() ++ super().tearDown() + ++ def _create(self, **kwargs): ++ return ttk.Treeview(self.root, **kwargs) ++ ++ def test_columns(self): ++ widget = self.create() ++ self.checkParam(widget, 'columns', 'a b c', ++ expected=('a', 'b', 'c')) ++ self.checkParam(widget, 'columns', ('a', 'b', 'c')) ++ self.checkParam(widget, 'columns', ()) ++ ++ def test_displaycolumns(self): ++ widget = self.create() ++ widget['columns'] = ('a', 'b', 'c') ++ self.checkParam(widget, 'displaycolumns', 'b a c', ++ expected=('b', 'a', 'c')) ++ self.checkParam(widget, 'displaycolumns', ('b', 'a', 'c')) ++ self.checkParam(widget, 'displaycolumns', '#all', ++ expected=('#all',)) ++ self.checkParam(widget, 'displaycolumns', (2, 1, 0)) ++ self.checkInvalidParam(widget, 'displaycolumns', ('a', 'b', 'd'), ++ errmsg='Invalid column index d') ++ self.checkInvalidParam(widget, 'displaycolumns', (1, 2, 3), ++ errmsg='Column index 3 out of bounds') ++ self.checkInvalidParam(widget, 'displaycolumns', (1, -2), ++ errmsg='Column index -2 out of bounds') ++ ++ def test_height(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'height', 100, -100, 0, '3c', conv=False) ++ self.checkPixelsParam(widget, 'height', 101.2, 102.6, conv=noconv) ++ ++ def test_selectmode(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'selectmode', ++ 'none', 'browse', 'extended') ++ ++ def test_show(self): ++ widget = self.create() ++ self.checkParam(widget, 'show', 'tree headings', ++ expected=('tree', 'headings')) ++ self.checkParam(widget, 'show', ('tree', 'headings')) ++ self.checkParam(widget, 'show', ('headings', 'tree')) ++ self.checkParam(widget, 'show', 'tree', expected=('tree',)) ++ self.checkParam(widget, 'show', 'headings', expected=('headings',)) + + def test_bbox(self): + self.tv.pack() +@@ -769,7 +1193,7 @@ + + bbox = self.tv.bbox(children[0]) + self.assertEqual(len(bbox), 4) +- self.assertTrue(isinstance(bbox, tuple)) ++ self.assertIsInstance(bbox, tuple) + for item in bbox: + if not isinstance(item, int): + self.fail("Invalid bounding box: %s" % bbox) +@@ -792,7 +1216,7 @@ + self.assertEqual(self.tv.get_children(), ()) + + item_id = self.tv.insert('', 'end') +- self.assertTrue(isinstance(self.tv.get_children(), tuple)) ++ self.assertIsInstance(self.tv.get_children(), tuple) + self.assertEqual(self.tv.get_children()[0], item_id) + + # add item_id and child3 as children of child2 +@@ -817,9 +1241,9 @@ + + def test_column(self): + # return a dict with all options/values +- self.assertTrue(isinstance(self.tv.column('#0'), dict)) ++ self.assertIsInstance(self.tv.column('#0'), dict) + # return a single value of the given option +- self.assertTrue(isinstance(self.tv.column('#0', width=None), int)) ++ self.assertIsInstance(self.tv.column('#0', width=None), int) + # set a new value for an option + self.tv.column('#0', width=10) + # testing new way to get option value +@@ -932,7 +1356,7 @@ + + def test_heading(self): + # check a dict is returned +- self.assertTrue(isinstance(self.tv.heading('#0'), dict)) ++ self.assertIsInstance(self.tv.heading('#0'), dict) + + # check a value is returned + self.tv.heading('#0', text='hi') +@@ -946,12 +1370,10 @@ + self.assertRaises(tkinter.TclError, self.tv.heading, '#0', + anchor=1) + +- # XXX skipping for now; should be fixed to work with newer ttk +- @unittest.skip("skipping pending resolution of Issue #10734") + def test_heading_callback(self): + def simulate_heading_click(x, y): + support.simulate_mouse_click(self.tv, x, y) +- self.tv.update_idletasks() ++ self.tv.update() + + success = [] # no success for now + +@@ -1045,7 +1467,7 @@ + self.tv.item(item, values=list(self.tv.item(item, values=None))) + self.assertEqual(self.tv.item(item, values=None), (value, )) + +- self.assertTrue(isinstance(self.tv.item(item), dict)) ++ self.assertIsInstance(self.tv.item(item), dict) + + # erase item values + self.tv.item(item, values='') +@@ -1146,14 +1568,38 @@ + 'blue') + self.assertEqual(str(self.tv.tag_configure('test', foreground=None)), + 'blue') +- self.assertTrue(isinstance(self.tv.tag_configure('test'), dict)) ++ self.assertIsInstance(self.tv.tag_configure('test'), dict) + + ++@add_standard_options(StandardTtkOptionsTests) ++class SeparatorTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'class', 'cursor', 'orient', 'style', 'takefocus', ++ # 'state'? ++ ) ++ default_orient = 'horizontal' ++ ++ def _create(self, **kwargs): ++ return ttk.Separator(self.root, **kwargs) ++ ++ ++@add_standard_options(StandardTtkOptionsTests) ++class SizegripTest(AbstractWidgetTest, unittest.TestCase): ++ OPTIONS = ( ++ 'class', 'cursor', 'style', 'takefocus', ++ # 'state'? ++ ) ++ ++ def _create(self, **kwargs): ++ return ttk.Sizegrip(self.root, **kwargs) ++ + tests_gui = ( +- WidgetTest, ButtonTest, CheckbuttonTest, RadiobuttonTest, +- ComboboxTest, EntryTest, PanedwindowTest, ScaleTest, NotebookTest, +- TreeviewTest ++ ButtonTest, CheckbuttonTest, ComboboxTest, EntryTest, ++ FrameTest, LabelFrameTest, LabelTest, MenubuttonTest, ++ NotebookTest, PanedWindowTest, ProgressbarTest, ++ RadiobuttonTest, ScaleTest, ScrollbarTest, SeparatorTest, ++ SizegripTest, TreeviewTest, WidgetTest, + ) + + if __name__ == "__main__": +- run_unittest(*tests_gui) ++ unittest.main() +diff -r c3896275c0f6 Lib/tkinter/test/widget_tests.py +--- /dev/null ++++ b/Lib/tkinter/test/widget_tests.py +@@ -0,0 +1,503 @@ ++# Common tests for test_tkinter/test_widgets.py and test_ttk/test_widgets.py ++ ++import unittest ++import sys ++import tkinter ++from tkinter.ttk import setup_master, Scale ++from tkinter.test.support import (tcl_version, requires_tcl, get_tk_patchlevel, ++ pixels_conv, tcl_obj_eq) ++ ++ ++noconv = False ++if get_tk_patchlevel() < (8, 5, 11): ++ noconv = str ++ ++pixels_round = round ++if get_tk_patchlevel()[:3] == (8, 5, 11): ++ # Issue #19085: Workaround a bug in Tk ++ # http://core.tcl.tk/tk/info/3497848 ++ pixels_round = int ++ ++ ++_sentinel = object() ++ ++class AbstractWidgetTest: ++ _conv_pixels = staticmethod(pixels_round) ++ _conv_pad_pixels = None ++ wantobjects = True ++ ++ def setUp(self): ++ self.root = setup_master() ++ self.scaling = float(self.root.call('tk', 'scaling')) ++ if not self.root.wantobjects(): ++ self.wantobjects = False ++ ++ def create(self, **kwargs): ++ widget = self._create(**kwargs) ++ self.addCleanup(widget.destroy) ++ return widget ++ ++ def assertEqual2(self, actual, expected, msg=None, eq=object.__eq__): ++ if eq(actual, expected): ++ return ++ self.assertEqual(actual, expected, msg) ++ ++ def checkParam(self, widget, name, value, *, expected=_sentinel, ++ conv=False, eq=None): ++ widget[name] = value ++ if expected is _sentinel: ++ expected = value ++ if conv: ++ expected = conv(expected) ++ if not self.wantobjects: ++ if isinstance(expected, tuple): ++ expected = tkinter._join(expected) ++ else: ++ expected = str(expected) ++ if eq is None: ++ eq = tcl_obj_eq ++ self.assertEqual2(widget[name], expected, eq=eq) ++ self.assertEqual2(widget.cget(name), expected, eq=eq) ++ # XXX ++ if not isinstance(widget, Scale): ++ t = widget.configure(name) ++ self.assertEqual(len(t), 5) ++ ## XXX ++ if not isinstance(t[4], tuple): ++ self.assertEqual2(t[4], expected, eq=eq) ++ ++ def checkInvalidParam(self, widget, name, value, errmsg=None, *, ++ keep_orig=True): ++ orig = widget[name] ++ if errmsg is not None: ++ errmsg = errmsg.format(value) ++ with self.assertRaises(tkinter.TclError) as cm: ++ widget[name] = value ++ if errmsg is not None: ++ self.assertEqual(str(cm.exception), errmsg) ++ if keep_orig: ++ self.assertEqual(widget[name], orig) ++ else: ++ widget[name] = orig ++ with self.assertRaises(tkinter.TclError) as cm: ++ widget.configure({name: value}) ++ if errmsg is not None: ++ self.assertEqual(str(cm.exception), errmsg) ++ if keep_orig: ++ self.assertEqual(widget[name], orig) ++ else: ++ widget[name] = orig ++ ++ def checkParams(self, widget, name, *values, **kwargs): ++ for value in values: ++ self.checkParam(widget, name, value, **kwargs) ++ ++ def checkIntegerParam(self, widget, name, *values, **kwargs): ++ self.checkParams(widget, name, *values, **kwargs) ++ self.checkInvalidParam(widget, name, '', ++ errmsg='expected integer but got ""') ++ self.checkInvalidParam(widget, name, '10p', ++ errmsg='expected integer but got "10p"') ++ self.checkInvalidParam(widget, name, 3.2, ++ errmsg='expected integer but got "3.2"') ++ ++ def checkFloatParam(self, widget, name, *values, conv=float, **kwargs): ++ for value in values: ++ self.checkParam(widget, name, value, conv=conv, **kwargs) ++ self.checkInvalidParam(widget, name, '', ++ errmsg='expected floating-point number but got ""') ++ self.checkInvalidParam(widget, name, 'spam', ++ errmsg='expected floating-point number but got "spam"') ++ ++ def checkBooleanParam(self, widget, name): ++ for value in (False, 0, 'false', 'no', 'off'): ++ self.checkParam(widget, name, value, expected=0) ++ for value in (True, 1, 'true', 'yes', 'on'): ++ self.checkParam(widget, name, value, expected=1) ++ self.checkInvalidParam(widget, name, '', ++ errmsg='expected boolean value but got ""') ++ self.checkInvalidParam(widget, name, 'spam', ++ errmsg='expected boolean value but got "spam"') ++ ++ def checkColorParam(self, widget, name, *, allow_empty=None, **kwargs): ++ self.checkParams(widget, name, ++ '#ff0000', '#00ff00', '#0000ff', '#123456', ++ 'red', 'green', 'blue', 'white', 'black', 'grey', ++ **kwargs) ++ self.checkInvalidParam(widget, name, 'spam', ++ errmsg='unknown color name "spam"') ++ ++ def checkCursorParam(self, widget, name, **kwargs): ++ self.checkParams(widget, name, 'arrow', 'watch', 'cross', '',**kwargs) ++ if tcl_version >= (8, 5): ++ self.checkParam(widget, name, 'none') ++ self.checkInvalidParam(widget, name, 'spam', ++ errmsg='bad cursor spec "spam"') ++ ++ def checkCommandParam(self, widget, name): ++ def command(*args): ++ pass ++ widget[name] = command ++ self.assertTrue(widget[name]) ++ self.checkParams(widget, name, '') ++ ++ def checkEnumParam(self, widget, name, *values, errmsg=None, **kwargs): ++ self.checkParams(widget, name, *values, **kwargs) ++ if errmsg is None: ++ errmsg2 = ' %s "{}": must be %s%s or %s' % ( ++ name, ++ ', '.join(values[:-1]), ++ ',' if len(values) > 2 else '', ++ values[-1]) ++ self.checkInvalidParam(widget, name, '', ++ errmsg='ambiguous' + errmsg2) ++ errmsg = 'bad' + errmsg2 ++ self.checkInvalidParam(widget, name, 'spam', errmsg=errmsg) ++ ++ def checkPixelsParam(self, widget, name, *values, ++ conv=None, keep_orig=True, **kwargs): ++ if conv is None: ++ conv = self._conv_pixels ++ for value in values: ++ expected = _sentinel ++ conv1 = conv ++ if isinstance(value, str): ++ if conv1 and conv1 is not str: ++ expected = pixels_conv(value) * self.scaling ++ conv1 = round ++ self.checkParam(widget, name, value, expected=expected, ++ conv=conv1, **kwargs) ++ self.checkInvalidParam(widget, name, '6x', ++ errmsg='bad screen distance "6x"', keep_orig=keep_orig) ++ self.checkInvalidParam(widget, name, 'spam', ++ errmsg='bad screen distance "spam"', keep_orig=keep_orig) ++ ++ def checkReliefParam(self, widget, name): ++ self.checkParams(widget, name, ++ 'flat', 'groove', 'raised', 'ridge', 'solid', 'sunken') ++ errmsg='bad relief "spam": must be '\ ++ 'flat, groove, raised, ridge, solid, or sunken' ++ if tcl_version < (8, 6): ++ errmsg = None ++ self.checkInvalidParam(widget, name, 'spam', ++ errmsg=errmsg) ++ ++ def checkImageParam(self, widget, name): ++ image = tkinter.PhotoImage('image1') ++ self.checkParam(widget, name, image, conv=str) ++ self.checkInvalidParam(widget, name, 'spam', ++ errmsg='image "spam" doesn\'t exist') ++ widget[name] = '' ++ ++ def checkVariableParam(self, widget, name, var): ++ self.checkParam(widget, name, var, conv=str) ++ ++ ++class StandardOptionsTests: ++ STANDARD_OPTIONS = ( ++ 'activebackground', 'activeborderwidth', 'activeforeground', 'anchor', ++ 'background', 'bitmap', 'borderwidth', 'compound', 'cursor', ++ 'disabledforeground', 'exportselection', 'font', 'foreground', ++ 'highlightbackground', 'highlightcolor', 'highlightthickness', ++ 'image', 'insertbackground', 'insertborderwidth', ++ 'insertofftime', 'insertontime', 'insertwidth', ++ 'jump', 'justify', 'orient', 'padx', 'pady', 'relief', ++ 'repeatdelay', 'repeatinterval', ++ 'selectbackground', 'selectborderwidth', 'selectforeground', ++ 'setgrid', 'takefocus', 'text', 'textvariable', 'troughcolor', ++ 'underline', 'wraplength', 'xscrollcommand', 'yscrollcommand', ++ ) ++ ++ def test_activebackground(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'activebackground') ++ ++ def test_activeborderwidth(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'activeborderwidth', ++ 0, 1.3, 2.9, 6, -2, '10p') ++ ++ def test_activeforeground(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'activeforeground') ++ ++ def test_anchor(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'anchor', ++ 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'center') ++ ++ def test_background(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'background') ++ if 'bg' in self.OPTIONS: ++ self.checkColorParam(widget, 'bg') ++ ++ def test_bitmap(self): ++ widget = self.create() ++ self.checkParam(widget, 'bitmap', 'questhead') ++ self.checkParam(widget, 'bitmap', 'gray50') ++ self.checkInvalidParam(widget, 'bitmap', 'spam', ++ errmsg='bitmap "spam" not defined') ++ ++ def test_borderwidth(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'borderwidth', ++ 0, 1.3, 2.6, 6, -2, '10p') ++ if 'bd' in self.OPTIONS: ++ self.checkPixelsParam(widget, 'bd', 0, 1.3, 2.6, 6, -2, '10p') ++ ++ def test_compound(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'compound', ++ 'bottom', 'center', 'left', 'none', 'right', 'top') ++ ++ def test_cursor(self): ++ widget = self.create() ++ self.checkCursorParam(widget, 'cursor') ++ ++ def test_disabledforeground(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'disabledforeground') ++ ++ def test_exportselection(self): ++ widget = self.create() ++ self.checkBooleanParam(widget, 'exportselection') ++ ++ def test_font(self): ++ widget = self.create() ++ self.checkParam(widget, 'font', ++ '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*') ++ self.checkInvalidParam(widget, 'font', '', ++ errmsg='font "" doesn\'t exist') ++ ++ def test_foreground(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'foreground') ++ if 'fg' in self.OPTIONS: ++ self.checkColorParam(widget, 'fg') ++ ++ def test_highlightbackground(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'highlightbackground') ++ ++ def test_highlightcolor(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'highlightcolor') ++ ++ def test_highlightthickness(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'highlightthickness', ++ 0, 1.3, 2.6, 6, '10p') ++ self.checkParam(widget, 'highlightthickness', -2, expected=0, ++ conv=self._conv_pixels) ++ ++ @unittest.skipIf(sys.platform == 'darwin', ++ 'crashes with Cocoa Tk (issue19733)') ++ def test_image(self): ++ widget = self.create() ++ self.checkImageParam(widget, 'image') ++ ++ def test_insertbackground(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'insertbackground') ++ ++ def test_insertborderwidth(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'insertborderwidth', ++ 0, 1.3, 2.6, 6, -2, '10p') ++ ++ def test_insertofftime(self): ++ widget = self.create() ++ self.checkIntegerParam(widget, 'insertofftime', 100) ++ ++ def test_insertontime(self): ++ widget = self.create() ++ self.checkIntegerParam(widget, 'insertontime', 100) ++ ++ def test_insertwidth(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'insertwidth', 1.3, 2.6, -2, '10p') ++ ++ def test_jump(self): ++ widget = self.create() ++ self.checkBooleanParam(widget, 'jump') ++ ++ def test_justify(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'justify', 'left', 'right', 'center', ++ errmsg='bad justification "{}": must be ' ++ 'left, right, or center') ++ self.checkInvalidParam(widget, 'justify', '', ++ errmsg='ambiguous justification "": must be ' ++ 'left, right, or center') ++ ++ def test_orient(self): ++ widget = self.create() ++ self.assertEqual(str(widget['orient']), self.default_orient) ++ self.checkEnumParam(widget, 'orient', 'horizontal', 'vertical') ++ ++ def test_padx(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'padx', 3, 4.4, 5.6, -2, '12m', ++ conv=self._conv_pad_pixels) ++ ++ def test_pady(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'pady', 3, 4.4, 5.6, -2, '12m', ++ conv=self._conv_pad_pixels) ++ ++ def test_relief(self): ++ widget = self.create() ++ self.checkReliefParam(widget, 'relief') ++ ++ def test_repeatdelay(self): ++ widget = self.create() ++ self.checkIntegerParam(widget, 'repeatdelay', -500, 500) ++ ++ def test_repeatinterval(self): ++ widget = self.create() ++ self.checkIntegerParam(widget, 'repeatinterval', -500, 500) ++ ++ def test_selectbackground(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'selectbackground') ++ ++ def test_selectborderwidth(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'selectborderwidth', 1.3, 2.6, -2, '10p') ++ ++ def test_selectforeground(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'selectforeground') ++ ++ def test_setgrid(self): ++ widget = self.create() ++ self.checkBooleanParam(widget, 'setgrid') ++ ++ def test_state(self): ++ widget = self.create() ++ self.checkEnumParam(widget, 'state', 'active', 'disabled', 'normal') ++ ++ def test_takefocus(self): ++ widget = self.create() ++ self.checkParams(widget, 'takefocus', '0', '1', '') ++ ++ def test_text(self): ++ widget = self.create() ++ self.checkParams(widget, 'text', '', 'any string') ++ ++ def test_textvariable(self): ++ widget = self.create() ++ var = tkinter.StringVar() ++ self.checkVariableParam(widget, 'textvariable', var) ++ ++ def test_troughcolor(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'troughcolor') ++ ++ def test_underline(self): ++ widget = self.create() ++ self.checkIntegerParam(widget, 'underline', 0, 1, 10) ++ ++ def test_wraplength(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'wraplength', 100) ++ ++ def test_xscrollcommand(self): ++ widget = self.create() ++ self.checkCommandParam(widget, 'xscrollcommand') ++ ++ def test_yscrollcommand(self): ++ widget = self.create() ++ self.checkCommandParam(widget, 'yscrollcommand') ++ ++ # non-standard but common options ++ ++ def test_command(self): ++ widget = self.create() ++ self.checkCommandParam(widget, 'command') ++ ++ def test_indicatoron(self): ++ widget = self.create() ++ self.checkBooleanParam(widget, 'indicatoron') ++ ++ def test_offrelief(self): ++ widget = self.create() ++ self.checkReliefParam(widget, 'offrelief') ++ ++ def test_overrelief(self): ++ widget = self.create() ++ self.checkReliefParam(widget, 'overrelief') ++ ++ def test_selectcolor(self): ++ widget = self.create() ++ self.checkColorParam(widget, 'selectcolor') ++ ++ def test_selectimage(self): ++ widget = self.create() ++ self.checkImageParam(widget, 'selectimage') ++ ++ @requires_tcl(8, 5) ++ def test_tristateimage(self): ++ widget = self.create() ++ self.checkImageParam(widget, 'tristateimage') ++ ++ @requires_tcl(8, 5) ++ def test_tristatevalue(self): ++ widget = self.create() ++ self.checkParam(widget, 'tristatevalue', 'unknowable') ++ ++ def test_variable(self): ++ widget = self.create() ++ var = tkinter.DoubleVar() ++ self.checkVariableParam(widget, 'variable', var) ++ ++ ++class IntegerSizeTests: ++ def test_height(self): ++ widget = self.create() ++ self.checkIntegerParam(widget, 'height', 100, -100, 0) ++ ++ def test_width(self): ++ widget = self.create() ++ self.checkIntegerParam(widget, 'width', 402, -402, 0) ++ ++ ++class PixelSizeTests: ++ def test_height(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'height', 100, 101.2, 102.6, -100, 0, '3c') ++ ++ def test_width(self): ++ widget = self.create() ++ self.checkPixelsParam(widget, 'width', 402, 403.4, 404.6, -402, 0, '5i') ++ ++ ++def add_standard_options(*source_classes): ++ # This decorator adds test_xxx methods from source classes for every xxx ++ # option in the OPTIONS class attribute if they are not defined explicitly. ++ def decorator(cls): ++ for option in cls.OPTIONS: ++ methodname = 'test_' + option ++ if not hasattr(cls, methodname): ++ for source_class in source_classes: ++ if hasattr(source_class, methodname): ++ setattr(cls, methodname, ++ getattr(source_class, methodname)) ++ break ++ else: ++ def test(self, option=option): ++ widget = self.create() ++ widget[option] ++ raise AssertionError('Option "%s" is not tested in %s' % ++ (option, cls.__name__)) ++ test.__name__ = methodname ++ setattr(cls, methodname, test) ++ return cls ++ return decorator ++ ++def setUpModule(): ++ import test.support ++ if test.support.verbose: ++ tcl = tkinter.Tcl() ++ print('patchlevel =', tcl.call('info', 'patchlevel')) +diff -r c3896275c0f6 Lib/tokenize.py +--- a/Lib/tokenize.py ++++ b/Lib/tokenize.py +@@ -333,7 +333,7 @@ + def detect_encoding(readline): + """ + The detect_encoding() function is used to detect the encoding that should +- be used to decode a Python source file. It requires one argment, readline, ++ be used to decode a Python source file. It requires one argument, readline, + in the same way as the tokenize() generator. + + It will call readline a maximum of twice, and return the encoding used +diff -r c3896275c0f6 Lib/unittest/test/test_case.py +--- a/Lib/unittest/test/test_case.py ++++ b/Lib/unittest/test/test_case.py +@@ -307,7 +307,7 @@ + def test(self): + pass + +- self.assertTrue(Foo('test').failureException is AssertionError) ++ self.assertIs(Foo('test').failureException, AssertionError) + + # "This class attribute gives the exception raised by the test() method. + # If a test framework needs to use a specialized exception, possibly to +@@ -325,7 +325,7 @@ + + failureException = RuntimeError + +- self.assertTrue(Foo('test').failureException is RuntimeError) ++ self.assertIs(Foo('test').failureException, RuntimeError) + + + Foo('test').run(result) +@@ -348,7 +348,7 @@ + + failureException = RuntimeError + +- self.assertTrue(Foo('test').failureException is RuntimeError) ++ self.assertIs(Foo('test').failureException, RuntimeError) + + + Foo('test').run(result) +@@ -660,7 +660,7 @@ + msg = e.args[0] + else: + self.fail('assertSequenceEqual did not fail.') +- self.assertTrue(len(msg) < len(diff)) ++ self.assertLess(len(msg), len(diff)) + self.assertIn(omitted, msg) + + self.maxDiff = len(diff) * 2 +@@ -670,7 +670,7 @@ + msg = e.args[0] + else: + self.fail('assertSequenceEqual did not fail.') +- self.assertTrue(len(msg) > len(diff)) ++ self.assertGreater(len(msg), len(diff)) + self.assertNotIn(omitted, msg) + + self.maxDiff = None +@@ -680,7 +680,7 @@ + msg = e.args[0] + else: + self.fail('assertSequenceEqual did not fail.') +- self.assertTrue(len(msg) > len(diff)) ++ self.assertGreater(len(msg), len(diff)) + self.assertNotIn(omitted, msg) + + def testTruncateMessage(self): +diff -r c3896275c0f6 Lib/unittest/test/test_loader.py +--- a/Lib/unittest/test/test_loader.py ++++ b/Lib/unittest/test/test_loader.py +@@ -1305,4 +1305,4 @@ + # "The default value is the TestSuite class" + def test_suiteClass__default_value(self): + loader = unittest.TestLoader() +- self.assertTrue(loader.suiteClass is unittest.TestSuite) ++ self.assertIs(loader.suiteClass, unittest.TestSuite) +diff -r c3896275c0f6 Lib/unittest/test/test_result.py +--- a/Lib/unittest/test/test_result.py ++++ b/Lib/unittest/test/test_result.py +@@ -176,7 +176,7 @@ + self.assertEqual(result.shouldStop, False) + + test_case, formatted_exc = result.failures[0] +- self.assertTrue(test_case is test) ++ self.assertIs(test_case, test) + self.assertIsInstance(formatted_exc, str) + + # "addError(test, err)" +@@ -224,7 +224,7 @@ + self.assertEqual(result.shouldStop, False) + + test_case, formatted_exc = result.errors[0] +- self.assertTrue(test_case is test) ++ self.assertIs(test_case, test) + self.assertIsInstance(formatted_exc, str) + + def testGetDescriptionWithoutDocstring(self): +diff -r c3896275c0f6 Lib/unittest/test/testmock/testhelpers.py +--- a/Lib/unittest/test/testmock/testhelpers.py ++++ b/Lib/unittest/test/testmock/testhelpers.py +@@ -177,7 +177,7 @@ + args = _Call(((1, 2, 3), {})) + self.assertEqual(args, call(1, 2, 3)) + self.assertEqual(call(1, 2, 3), args) +- self.assertTrue(call(1, 2, 3) in [args]) ++ self.assertIn(call(1, 2, 3), [args]) + + + def test_call_ne(self): +@@ -793,7 +793,7 @@ + mock_property = foo.foo + + # no spec on properties +- self.assertTrue(isinstance(mock_property, MagicMock)) ++ self.assertIsInstance(mock_property, MagicMock) + mock_property(1, 2, 3) + mock_property.abc(4, 5, 6) + mock_property.assert_called_once_with(1, 2, 3) +@@ -826,19 +826,19 @@ + mock(b=6) + + for kall in call(1, 2), call(a=3), call(3, 4), call(b=6): +- self.assertTrue(kall in mock.call_args_list) ++ self.assertIn(kall, mock.call_args_list) + + calls = [call(a=3), call(3, 4)] +- self.assertTrue(calls in mock.call_args_list) ++ self.assertIn(calls, mock.call_args_list) + calls = [call(1, 2), call(a=3)] +- self.assertTrue(calls in mock.call_args_list) ++ self.assertIn(calls, mock.call_args_list) + calls = [call(3, 4), call(b=6)] +- self.assertTrue(calls in mock.call_args_list) ++ self.assertIn(calls, mock.call_args_list) + calls = [call(3, 4)] +- self.assertTrue(calls in mock.call_args_list) ++ self.assertIn(calls, mock.call_args_list) + +- self.assertFalse(call('fish') in mock.call_args_list) +- self.assertFalse([call('fish')] in mock.call_args_list) ++ self.assertNotIn(call('fish'), mock.call_args_list) ++ self.assertNotIn([call('fish')], mock.call_args_list) + + + def test_call_list_str(self): +diff -r c3896275c0f6 Lib/unittest/test/testmock/testmagicmethods.py +--- a/Lib/unittest/test/testmock/testmagicmethods.py ++++ b/Lib/unittest/test/testmock/testmagicmethods.py +@@ -37,12 +37,12 @@ + return self, 'fish' + + mock.__getitem__ = f +- self.assertFalse(mock.__getitem__ is f) ++ self.assertIsNot(mock.__getitem__, f) + self.assertEqual(mock['foo'], (mock, 'fish')) + self.assertEqual(mock.__getitem__('foo'), (mock, 'fish')) + + mock.__getitem__ = mock +- self.assertTrue(mock.__getitem__ is mock) ++ self.assertIs(mock.__getitem__, mock) + + + def test_magic_methods_isolated_between_mocks(self): +@@ -212,8 +212,8 @@ + self.assertEqual(len(mock), 6) + + mock.__contains__ = lambda s, o: o == 3 +- self.assertTrue(3 in mock) +- self.assertFalse(6 in mock) ++ self.assertIn(3, mock) ++ self.assertNotIn(6, mock) + + mock.__iter__ = lambda s: iter('foobarbaz') + self.assertEqual(list(mock), list('foobarbaz')) +diff -r c3896275c0f6 Lib/unittest/test/testmock/testmock.py +--- a/Lib/unittest/test/testmock/testmock.py ++++ b/Lib/unittest/test/testmock/testmock.py +@@ -52,7 +52,7 @@ + "method_calls not initialised correctly") + + # Can't use hasattr for this test as it always returns True on a mock +- self.assertFalse('_items' in mock.__dict__, ++ self.assertNotIn('_items', mock.__dict__, + "default mock should not have '_items' attribute") + + self.assertIsNone(mock._mock_parent, +@@ -493,19 +493,19 @@ + pass + + mock = Mock(spec=X) +- self.assertTrue(isinstance(mock, X)) ++ self.assertIsInstance(mock, X) + + mock = Mock(spec=X()) +- self.assertTrue(isinstance(mock, X)) ++ self.assertIsInstance(mock, X) + + self.assertIs(mock.__class__, X) + self.assertEqual(Mock().__class__.__name__, 'Mock') + + mock = Mock(spec_set=X) +- self.assertTrue(isinstance(mock, X)) ++ self.assertIsInstance(mock, X) + + mock = Mock(spec_set=X()) +- self.assertTrue(isinstance(mock, X)) ++ self.assertIsInstance(mock, X) + + + def test_setting_attribute_with_spec_set(self): +diff -r c3896275c0f6 Lib/unittest/test/testmock/testsentinel.py +--- a/Lib/unittest/test/testmock/testsentinel.py ++++ b/Lib/unittest/test/testmock/testsentinel.py +@@ -17,7 +17,7 @@ + + + def testDEFAULT(self): +- self.assertTrue(DEFAULT is sentinel.DEFAULT) ++ self.assertIs(DEFAULT, sentinel.DEFAULT) + + def testBases(self): + # If this doesn't raise an AttributeError then help(mock) is broken +diff -r c3896275c0f6 Lib/uuid.py +--- a/Lib/uuid.py ++++ b/Lib/uuid.py +@@ -327,8 +327,16 @@ + words = line.lower().split() + for i in range(len(words)): + if words[i] in hw_identifiers: +- return int( +- words[get_index(i)].replace(':', ''), 16) ++ try: ++ return int( ++ words[get_index(i)].replace(':', ''), 16) ++ except (ValueError, IndexError): ++ # Virtual interfaces, such as those provided by ++ # VPNs, do not have a colon-delimited MAC address ++ # as expected, but a 16-byte HWAddr separated by ++ # dashes. These should be ignored in favor of a ++ # real MAC address ++ pass + except IOError: + continue + return None +diff -r c3896275c0f6 Lib/venv/__init__.py +--- a/Lib/venv/__init__.py ++++ b/Lib/venv/__init__.py +@@ -38,7 +38,7 @@ + class EnvBuilder: + """ + This class exists to allow virtual environment creation to be +- customised. The constructor parameters determine the builder's ++ customized. The constructor parameters determine the builder's + behaviour when called upon to create a virtual environment. + + By default, the builder makes the system (global) site-packages dir +@@ -336,7 +336,7 @@ + elif not hasattr(sys, 'base_prefix'): + compatible = False + if not compatible: +- raise ValueError('This script is only for use with Python 3.3') ++ raise ValueError('This script is only for use with Python >= 3.3') + else: + import argparse + +diff -r c3896275c0f6 Lib/wave.py +--- a/Lib/wave.py ++++ b/Lib/wave.py +@@ -82,14 +82,15 @@ + + _array_fmts = None, 'b', 'h', None, 'i' + +-# Determine endian-ness + import struct +-if struct.pack("h", 1) == b"\000\001": +- big_endian = 1 +-else: +- big_endian = 0 ++import sys ++from chunk import Chunk + +-from chunk import Chunk ++def _byteswap3(data): ++ ba = bytearray(data) ++ ba[::3] = data[2::3] ++ ba[2::3] = data[::3] ++ return bytes(ba) + + class Wave_read: + """Variables used in this class: +@@ -231,7 +232,7 @@ + self._data_seek_needed = 0 + if nframes == 0: + return b'' +- if self._sampwidth > 1 and big_endian: ++ if self._sampwidth in (2, 4) and sys.byteorder == 'big': + # unfortunately the fromfile() method does not take + # something that only looks like a file object, so + # we have to reach into the innards of the chunk object +@@ -252,6 +253,8 @@ + data = data.tobytes() + else: + data = self._data_chunk.read(nframes * self._framesize) ++ if self._sampwidth == 3 and sys.byteorder == 'big': ++ data = _byteswap3(data) + if self._convert and data: + data = self._convert(data) + self._soundpos = self._soundpos + len(data) // (self._nchannels * self._sampwidth) +@@ -419,14 +422,18 @@ + nframes = len(data) // (self._sampwidth * self._nchannels) + if self._convert: + data = self._convert(data) +- if self._sampwidth > 1 and big_endian: ++ if self._sampwidth in (2, 4) and sys.byteorder == 'big': + import array +- data = array.array(_array_fmts[self._sampwidth], data) ++ a = array.array(_array_fmts[self._sampwidth]) ++ a.frombytes(data) ++ data = a + assert data.itemsize == self._sampwidth + data.byteswap() + data.tofile(self._file) + self._datawritten = self._datawritten + len(data) * self._sampwidth + else: ++ if self._sampwidth == 3 and sys.byteorder == 'big': ++ data = _byteswap3(data) + self._file.write(data) + self._datawritten = self._datawritten + len(data) + self._nframeswritten = self._nframeswritten + nframes +diff -r c3896275c0f6 Lib/xml/dom/minicompat.py +--- a/Lib/xml/dom/minicompat.py ++++ b/Lib/xml/dom/minicompat.py +@@ -1,4 +1,8 @@ +-"""Python version compatibility support for minidom.""" ++"""Python version compatibility support for minidom. ++ ++This module contains internal implementation details and ++should not be imported; use xml.dom.minidom instead. ++""" + + # This module should only be imported using "import *". + # +diff -r c3896275c0f6 Makefile.pre.in +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -1048,7 +1048,8 @@ + lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \ + lib2to3/tests/data lib2to3/tests/data/fixers \ + lib2to3/tests/data/fixers/myfixes \ +- ctypes ctypes/test ctypes/macholib idlelib idlelib/Icons \ ++ ctypes ctypes/test ctypes/macholib \ ++ idlelib idlelib/Icons idlelib/idle_test \ + distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \ + importlib test/test_importlib test/test_importlib/builtin \ + test/test_importlib/extension test/test_importlib/frozen \ +@@ -1412,8 +1413,8 @@ + # remove all generated files, even Makefile[.pre] + # Keep configure and Python-ast.[ch], it's possible they can't be generated + distclean: clobber +- for file in Lib/test/data/* ; do \ +- if test "$$file" != "Lib/test/data/README"; then rm "$$file"; fi; \ ++ for file in $(srcdir)/Lib/test/data/* ; do \ ++ if test "$$file" != "$(srcdir)/Lib/test/data/README"; then rm "$$file"; fi; \ + done + -rm -f core Makefile Makefile.pre config.status \ + Modules/Setup Modules/Setup.local Modules/Setup.config \ +diff -r c3896275c0f6 Misc/ACKS +--- a/Misc/ACKS ++++ b/Misc/ACKS +@@ -394,6 +394,7 @@ + Andrew Francis + Stefan Franke + Martin Franklin ++Kent Frazier + Bruce Frederiksen + Robin Friedrich + Bradley Froehle +@@ -435,6 +436,7 @@ + Jonathan Giddy + Johannes Gijsbers + Michael Gilfix ++Julian Gindi + Yannick Gingras + Matt Giuca + Wim Glenn +@@ -1138,7 +1140,6 @@ + Michael Shiplett + John W. Shipman + Joel Shprentz +-Itamar Shtull-Trauring + Yue Shuaijie + Terrel Shumway + Eric Siegerman +@@ -1263,6 +1264,7 @@ + Erno Tukia + David Turner + Stephen Turner ++Itamar Turner-Trauring + Theodore Turocy + Bill Tutt + Fraser Tweedale +diff -r c3896275c0f6 Misc/NEWS +--- a/Misc/NEWS ++++ b/Misc/NEWS +@@ -2,6 +2,145 @@ + Python News + +++++++++++ + ++What's New in Python 3.3.4 release candidate 1? ++=============================================== ++ ++*Not yet released, see sections below for changes released in 3.3.3* ++ ++Core and Builtins ++----------------- ++ ++- Issue #19729: In str.format(), fix recursive expansion in format spec. ++ ++- Issue #19638: Fix possible crash / undefined behaviour from huge (more than 2 ++ billion characters) input strings in _Py_dg_strtod. ++ ++Library ++------- ++ ++- Issue #19506: Use a memoryview to avoid a data copy when piping data ++ to stdin within subprocess.Popen.communicate. 5-10% less cpu usage. ++ ++- Issue #19839: Fix regression in bz2 module's handling of non-bzip2 data at ++ EOF, and analogous bug in lzma module. ++ ++- Issue #19138: doctest's IGNORE_EXCEPTION_DETAIL now allows a match when ++ no exception detail exists (no colon following the exception's name, or ++ a colon does follow but no text follows the colon). ++ ++- Issue #19834: Support unpickling of exceptions pickled by Python 2. ++ ++- Issue #15798: Fixed subprocess.Popen() to no longer fail if file ++ descriptor 0, 1 or 2 is closed. ++ ++- Issue #19088: Fixed incorrect caching of the copyreg module in ++ object.__reduce__() and object.__reduce_ex__(). ++ ++- Fixed _pickle.Unpickler to not fail when loading empty strings as ++ persistent IDs. ++ ++- Issue #11480: Fixed copy.copy to work with classes with custom metaclasses. ++ Patch by Daniel Urban. ++ ++- Issue #6477: Added support for pickling the types of built-in singletons ++ (i.e., Ellipsis, NotImplemented, None). ++ ++- Issue #11508: Fixed uuid.getnode() and uuid.uuid1() on environment with ++ virtual interface. Original patch by Kent Frazier. ++ ++- Issue #11489: JSON decoder now accepts lone surrogates. ++ ++- Issue #19545: Avoid chained exceptions while passing stray % to ++ time.strptime(). Initial patch by Claudiu Popa. ++ ++- Issue #19633: Fixed writing not compressed 16- and 32-bit wave files on ++ big-endian platforms. ++ ++- Issue #19449: in csv's writerow, handle non-string keys when generating the ++ error message that certain keys are not in the 'fieldnames' list. ++ ++- Fix test.support.bind_port() to not cause an error when Python was compiled ++ on a system with SO_REUSEPORT defined in the headers but run on a system ++ with an OS kernel that does not support that reasonably new socket option. ++ ++- Fix compilation error under gcc of the ctypes module bundled libffi for arm. ++ ++- Issue #19523: Closed FileHandler leak which occurred when delay was set. ++ ++- Issue #13674: Prevented time.strftime from crashing on Windows when given ++ a year before 1900 and a format of %y. ++ ++- Issue #19544 and Issue #6286: Restore use of urllib over http allowing use ++ of http_proxy for Distutils upload command, a feature accidentally lost ++ in the rollback of distutils2. ++ ++- Issue #19544 and Issue #7457: Restore the read_pkg_file method to ++ distutils.dist.DistributionMetadata accidentally removed in the undo of ++ distutils2. ++ ++- Issue #1575020: Fixed support of 24-bit wave files on big-endian platforms. ++ ++- Issue #19480: HTMLParser now accepts all valid start-tag names as defined ++ by the HTML5 standard. ++ ++- Issue #6157: Fixed tkinter.Text.debug(). Original patch by Guilherme Polo. ++ ++- Issue #6160: The bbox() method of tkinter.Spinbox now returns a tuple of ++ integers instead of a string. Based on patch by Guilherme Polo. ++ ++- Issue #10197: Rework subprocess.get[status]output to use subprocess ++ functionality and thus to work on Windows. Patch by Nick Coghlan. ++ ++- Issue #19286: Directories in ``package_data`` are no longer added to ++ the filelist, preventing failure outlined in the ticket. ++ ++Tests ++----- ++ ++- Issue #19926: Removed unneeded test_main from test_abstract_numbers. ++ Patch by Vajrasky Kok. ++ ++- Issue #19595: Re-enabled a long-disabled test in test_winsound. ++ ++- Issue #19588: Fixed tests in test_random that were silently skipped most ++ of the time. Patch by Julian Gindi. ++ ++- Issue #19596: Set untestable tests in test_importlib to None to avoid ++ reporting success on empty tests. ++ ++- Issue #19440: Clean up test_capi by removing an unnecessary __future__ ++ import, converting from test_main to unittest.main, and running the ++ _testcapi module tests within a unittest TestCase. ++ ++- Issue #18702, 19572: All skipped tests now reported as skipped. ++ ++- Issue #19085: Added basic tests for all tkinter widget options. ++ ++Documentation ++------------- ++ ++- Issue #18840: Introduce the json module in the tutorial, and deemphasize ++ the pickle module. ++ ++- Issue #19845: Updated the Compiling Python on Windows section. ++ ++- Issue #19795: Improved markup of True/False constants. ++ ++- Issue #18326: Clarify that list.sort's arguments are keyword-only. Also, ++ attempt to reduce confusion in the glossary by not saying there are ++ different "types" of arguments and parameters. ++ ++Build ++----- ++ ++- Issue #19788: kill_python(_d).exe is now run as a PreBuildEvent on the ++ pythoncore sub-project. This should prevent build errors due a previous ++ build's python(_d).exe still running. ++ ++- Add workaround for VS 2010 nmake clean issue. VS 2010 doesn't set up PATH ++ for nmake.exe correctly. ++ ++ + What's New in Python 3.3.3? + =========================== + +@@ -114,6 +253,10 @@ + Library + ------- + ++- Issue #19395: Raise an exception when attempting to pickle a bz2 or lzma ++ compressor/decompressor object, rather than creating a pickle that would ++ cause a segfault when loaded and used. ++ + - Issue #19227: Try to fix deadlocks caused by re-seeding then OpenSSL + pseudo-random number generator on fork(). + +diff -r c3896275c0f6 Misc/valgrind-python.supp +--- a/Misc/valgrind-python.supp ++++ b/Misc/valgrind-python.supp +@@ -456,6 +456,15 @@ + fun:PyUnicode_FSConverter + } + ++{ ++ wcscmp_false_positive ++ Memcheck:Addr8 ++ fun:wcscmp ++ fun:_PyOS_GetOpt ++ fun:Py_Main ++ fun:main ++} ++ + # Additional suppressions for the unified decimal tests: + { + test_decimal +diff -r c3896275c0f6 Modules/_bz2module.c +--- a/Modules/_bz2module.c ++++ b/Modules/_bz2module.c +@@ -250,6 +250,14 @@ + return result; + } + ++static PyObject * ++BZ2Compressor_getstate(BZ2Compressor *self, PyObject *noargs) ++{ ++ PyErr_Format(PyExc_TypeError, "cannot serialize '%s' object", ++ Py_TYPE(self)->tp_name); ++ return NULL; ++} ++ + static int + BZ2Compressor_init(BZ2Compressor *self, PyObject *args, PyObject *kwargs) + { +@@ -298,10 +306,11 @@ + } + + static PyMethodDef BZ2Compressor_methods[] = { +- {"compress", (PyCFunction)BZ2Compressor_compress, METH_VARARGS, ++ {"compress", (PyCFunction)BZ2Compressor_compress, METH_VARARGS, + BZ2Compressor_compress__doc__}, +- {"flush", (PyCFunction)BZ2Compressor_flush, METH_NOARGS, ++ {"flush", (PyCFunction)BZ2Compressor_flush, METH_NOARGS, + BZ2Compressor_flush__doc__}, ++ {"__getstate__", (PyCFunction)BZ2Compressor_getstate, METH_NOARGS}, + {NULL} + }; + +@@ -452,6 +461,14 @@ + return result; + } + ++static PyObject * ++BZ2Decompressor_getstate(BZ2Decompressor *self, PyObject *noargs) ++{ ++ PyErr_Format(PyExc_TypeError, "cannot serialize '%s' object", ++ Py_TYPE(self)->tp_name); ++ return NULL; ++} ++ + static int + BZ2Decompressor_init(BZ2Decompressor *self, PyObject *args, PyObject *kwargs) + { +@@ -502,6 +519,7 @@ + static PyMethodDef BZ2Decompressor_methods[] = { + {"decompress", (PyCFunction)BZ2Decompressor_decompress, METH_VARARGS, + BZ2Decompressor_decompress__doc__}, ++ {"__getstate__", (PyCFunction)BZ2Decompressor_getstate, METH_NOARGS}, + {NULL} + }; + +diff -r c3896275c0f6 Modules/_ctypes/libffi/src/arm/ffi.c +--- a/Modules/_ctypes/libffi/src/arm/ffi.c ++++ b/Modules/_ctypes/libffi/src/arm/ffi.c +@@ -221,11 +221,11 @@ + int vfp_struct = (cif->flags == FFI_TYPE_STRUCT_VFP_FLOAT + || cif->flags == FFI_TYPE_STRUCT_VFP_DOUBLE); + ++ unsigned int temp; ++ + ecif.cif = cif; + ecif.avalue = avalue; + +- unsigned int temp; +- + /* If the return value is a struct and we don't have a return */ + /* value address then we need to make one */ + +@@ -278,11 +278,11 @@ + /* This function is jumped to by the trampoline */ + + unsigned int +-ffi_closure_SYSV_inner (closure, respp, args, vfp_args) +- ffi_closure *closure; +- void **respp; +- void *args; +- void *vfp_args; ++ffi_closure_SYSV_inner( ++ ffi_closure *closure, ++ void **respp, ++ void *args, ++ void *vfp_args) + { + // our various things... + ffi_cif *cif; +diff -r c3896275c0f6 Modules/_cursesmodule.c +--- a/Modules/_cursesmodule.c ++++ b/Modules/_cursesmodule.c +@@ -1342,7 +1342,8 @@ + static PyObject * + PyCursesWindow_InCh(PyCursesWindowObject *self, PyObject *args) + { +- int x, y, rtn; ++ int x, y; ++ unsigned long rtn; + + switch (PyTuple_Size(args)) { + case 0: +@@ -1357,7 +1358,7 @@ + PyErr_SetString(PyExc_TypeError, "inch requires 0 or 2 arguments"); + return NULL; + } +- return PyLong_FromLong((long) rtn); ++ return PyLong_FromUnsignedLong(rtn); + } + + static PyObject * +diff -r c3896275c0f6 Modules/_decimal/_decimal.c +--- a/Modules/_decimal/_decimal.c ++++ b/Modules/_decimal/_decimal.c +@@ -39,6 +39,11 @@ + #include "memory.h" + + ++#if MPD_MAJOR_VERSION != 2 ++ #error "libmpdec major version 2 required" ++#endif ++ ++ + /* + * Type sizes with assertions in mpdecimal.h and pyport.h: + * sizeof(size_t) == sizeof(Py_ssize_t) +@@ -3009,18 +3014,24 @@ + *wcmp = Py_NotImplemented; + } + } +- else if (PyObject_IsInstance(w, Rational)) { +- *wcmp = numerator_as_decimal(w, context); +- if (*wcmp && !mpd_isspecial(MPD(v))) { +- *vcmp = multiply_by_denominator(v, w, context); +- if (*vcmp == NULL) { +- Py_CLEAR(*wcmp); ++ else { ++ int is_rational = PyObject_IsInstance(w, Rational); ++ if (is_rational < 0) { ++ *wcmp = NULL; ++ } ++ else if (is_rational > 0) { ++ *wcmp = numerator_as_decimal(w, context); ++ if (*wcmp && !mpd_isspecial(MPD(v))) { ++ *vcmp = multiply_by_denominator(v, w, context); ++ if (*vcmp == NULL) { ++ Py_CLEAR(*wcmp); ++ } + } + } +- } +- else { +- Py_INCREF(Py_NotImplemented); +- *wcmp = Py_NotImplemented; ++ else { ++ Py_INCREF(Py_NotImplemented); ++ *wcmp = Py_NotImplemented; ++ } + } + + if (*wcmp == NULL || *wcmp == Py_NotImplemented) { +@@ -3102,6 +3113,7 @@ + { + char *dest = PyMem_Malloc(size+1); + if (dest == NULL) { ++ PyErr_NoMemory(); + return NULL; + } + +@@ -5723,7 +5735,8 @@ + } + + /* Add specification version number */ +- CHECK_INT(PyModule_AddStringConstant(m, "__version__", " 1.70")); ++ CHECK_INT(PyModule_AddStringConstant(m, "__version__", "1.70")); ++ CHECK_INT(PyModule_AddStringConstant(m, "__libmpdec_version__", mpd_version())); + + + return m; +diff -r c3896275c0f6 Modules/_decimal/libmpdec/mpdecimal.c +--- a/Modules/_decimal/libmpdec/mpdecimal.c ++++ b/Modules/_decimal/libmpdec/mpdecimal.c +@@ -97,6 +97,8 @@ + mpd_ssize_t exp); + static inline mpd_ssize_t _mpd_real_size(mpd_uint_t *data, mpd_ssize_t size); + ++static int _mpd_cmp_abs(const mpd_t *a, const mpd_t *b); ++ + static void _mpd_qadd(mpd_t *result, const mpd_t *a, const mpd_t *b, + const mpd_context_t *ctx, uint32_t *status); + static inline void _mpd_qmul(mpd_t *result, const mpd_t *a, const mpd_t *b, +@@ -111,6 +113,17 @@ + + + /******************************************************************************/ ++/* Version */ ++/******************************************************************************/ ++ ++const char * ++mpd_version(void) ++{ ++ return MPD_VERSION; ++} ++ ++ ++/******************************************************************************/ + /* Performance critical inline functions */ + /******************************************************************************/ + +@@ -379,42 +392,42 @@ + + /* Dynamic decimal */ + ALWAYS_INLINE int +-mpd_isdynamic(mpd_t *dec) ++mpd_isdynamic(const mpd_t *dec) + { + return !(dec->flags & MPD_STATIC); + } + + /* Static decimal */ + ALWAYS_INLINE int +-mpd_isstatic(mpd_t *dec) ++mpd_isstatic(const mpd_t *dec) + { + return dec->flags & MPD_STATIC; + } + + /* Data of decimal is dynamic */ + ALWAYS_INLINE int +-mpd_isdynamic_data(mpd_t *dec) ++mpd_isdynamic_data(const mpd_t *dec) + { + return !(dec->flags & MPD_DATAFLAGS); + } + + /* Data of decimal is static */ + ALWAYS_INLINE int +-mpd_isstatic_data(mpd_t *dec) ++mpd_isstatic_data(const mpd_t *dec) + { + return dec->flags & MPD_STATIC_DATA; + } + + /* Data of decimal is shared */ + ALWAYS_INLINE int +-mpd_isshared_data(mpd_t *dec) ++mpd_isshared_data(const mpd_t *dec) + { + return dec->flags & MPD_SHARED_DATA; + } + + /* Data of decimal is const */ + ALWAYS_INLINE int +-mpd_isconst_data(mpd_t *dec) ++mpd_isconst_data(const mpd_t *dec) + { + return dec->flags & MPD_CONST_DATA; + } +@@ -584,7 +597,7 @@ + + /* Copy sign from another decimal */ + ALWAYS_INLINE void +-mpd_signcpy(mpd_t *result, mpd_t *a) ++mpd_signcpy(mpd_t *result, const mpd_t *a) + { + uint8_t sign = a->flags&MPD_NEG; + +@@ -1345,6 +1358,91 @@ + return MPD_SSIZE_MAX; + } + ++#if defined(CONFIG_32) && !defined(LEGACY_COMPILER) ++/* ++ * Quietly get a uint64_t from a decimal. If the operation is impossible, ++ * MPD_Invalid_operation is set. ++ */ ++static uint64_t ++_c32_qget_u64(int use_sign, const mpd_t *a, uint32_t *status) ++{ ++ MPD_NEW_STATIC(tmp,0,0,20,3); ++ mpd_context_t maxcontext; ++ uint64_t ret; ++ ++ tmp_data[0] = 709551615; ++ tmp_data[1] = 446744073; ++ tmp_data[2] = 18; ++ ++ if (mpd_isspecial(a)) { ++ *status |= MPD_Invalid_operation; ++ return UINT64_MAX; ++ } ++ if (mpd_iszero(a)) { ++ return 0; ++ } ++ if (use_sign && mpd_isnegative(a)) { ++ *status |= MPD_Invalid_operation; ++ return UINT64_MAX; ++ } ++ if (!_mpd_isint(a)) { ++ *status |= MPD_Invalid_operation; ++ return UINT64_MAX; ++ } ++ ++ if (_mpd_cmp_abs(a, &tmp) > 0) { ++ *status |= MPD_Invalid_operation; ++ return UINT64_MAX; ++ } ++ ++ mpd_maxcontext(&maxcontext); ++ mpd_qrescale(&tmp, a, 0, &maxcontext, &maxcontext.status); ++ maxcontext.status &= ~MPD_Rounded; ++ if (maxcontext.status != 0) { ++ *status |= (maxcontext.status|MPD_Invalid_operation); /* GCOV_NOT_REACHED */ ++ return UINT64_MAX; /* GCOV_NOT_REACHED */ ++ } ++ ++ ret = 0; ++ switch (tmp.len) { ++ case 3: ++ ret += (uint64_t)tmp_data[2] * 1000000000000000000ULL; ++ case 2: ++ ret += (uint64_t)tmp_data[1] * 1000000000ULL; ++ case 1: ++ ret += tmp_data[0]; ++ break; ++ default: ++ abort(); /* GCOV_NOT_REACHED */ ++ } ++ ++ return ret; ++} ++ ++static int64_t ++_c32_qget_i64(const mpd_t *a, uint32_t *status) ++{ ++ uint64_t u; ++ int isneg; ++ ++ u = _c32_qget_u64(0, a, status); ++ if (*status&MPD_Invalid_operation) { ++ return INT64_MAX; ++ } ++ ++ isneg = mpd_isnegative(a); ++ if (u <= INT64_MAX) { ++ return isneg ? -((int64_t)u) : (int64_t)u; ++ } ++ else if (isneg && u+(INT64_MIN+INT64_MAX) == INT64_MAX) { ++ return INT64_MIN; ++ } ++ ++ *status |= MPD_Invalid_operation; ++ return INT64_MAX; ++} ++#endif /* CONFIG_32 && !LEGACY_COMPILER */ ++ + #ifdef CONFIG_64 + /* quietly get a uint64_t from a decimal */ + uint64_t +@@ -1359,7 +1457,57 @@ + { + return mpd_qget_ssize(a, status); + } ++ ++/* quietly get a uint32_t from a decimal */ ++uint32_t ++mpd_qget_u32(const mpd_t *a, uint32_t *status) ++{ ++ uint64_t x = mpd_qget_uint(a, status); ++ ++ if (*status&MPD_Invalid_operation) { ++ return UINT32_MAX; ++ } ++ if (x > UINT32_MAX) { ++ *status |= MPD_Invalid_operation; ++ return UINT32_MAX; ++ } ++ ++ return (uint32_t)x; ++} ++ ++/* quietly get an int32_t from a decimal */ ++int32_t ++mpd_qget_i32(const mpd_t *a, uint32_t *status) ++{ ++ int64_t x = mpd_qget_ssize(a, status); ++ ++ if (*status&MPD_Invalid_operation) { ++ return INT32_MAX; ++ } ++ if (x < INT32_MIN || x > INT32_MAX) { ++ *status |= MPD_Invalid_operation; ++ return INT32_MAX; ++ } ++ ++ return (int32_t)x; ++} + #else ++#ifndef LEGACY_COMPILER ++/* quietly get a uint64_t from a decimal */ ++uint64_t ++mpd_qget_u64(const mpd_t *a, uint32_t *status) ++{ ++ return _c32_qget_u64(1, a, status); ++} ++ ++/* quietly get an int64_t from a decimal */ ++int64_t ++mpd_qget_i64(const mpd_t *a, uint32_t *status) ++{ ++ return _c32_qget_i64(a, status); ++} ++#endif ++ + /* quietly get a uint32_t from a decimal */ + uint32_t + mpd_qget_u32(const mpd_t *a, uint32_t *status) +@@ -3386,6 +3534,34 @@ + { + mpd_qadd_uint(result, a, b, ctx, status); + } ++#elif !defined(LEGACY_COMPILER) ++/* Add decimal and int64_t. */ ++void ++mpd_qadd_i64(mpd_t *result, const mpd_t *a, int64_t b, ++ const mpd_context_t *ctx, uint32_t *status) ++{ ++ mpd_context_t maxcontext; ++ MPD_NEW_STATIC(bb,0,0,0,0); ++ ++ mpd_maxcontext(&maxcontext); ++ mpd_qset_i64(&bb, b, &maxcontext, status); ++ mpd_qadd(result, a, &bb, ctx, status); ++ mpd_del(&bb); ++} ++ ++/* Add decimal and uint64_t. */ ++void ++mpd_qadd_u64(mpd_t *result, const mpd_t *a, uint64_t b, ++ const mpd_context_t *ctx, uint32_t *status) ++{ ++ mpd_context_t maxcontext; ++ MPD_NEW_STATIC(bb,0,0,0,0); ++ ++ mpd_maxcontext(&maxcontext); ++ mpd_qset_u64(&bb, b, &maxcontext, status); ++ mpd_qadd(result, a, &bb, ctx, status); ++ mpd_del(&bb); ++} + #endif + + /* Subtract int32_t from decimal. */ +@@ -3420,6 +3596,34 @@ + { + mpd_qsub_uint(result, a, b, ctx, status); + } ++#elif !defined(LEGACY_COMPILER) ++/* Subtract int64_t from decimal. */ ++void ++mpd_qsub_i64(mpd_t *result, const mpd_t *a, int64_t b, ++ const mpd_context_t *ctx, uint32_t *status) ++{ ++ mpd_context_t maxcontext; ++ MPD_NEW_STATIC(bb,0,0,0,0); ++ ++ mpd_maxcontext(&maxcontext); ++ mpd_qset_i64(&bb, b, &maxcontext, status); ++ mpd_qsub(result, a, &bb, ctx, status); ++ mpd_del(&bb); ++} ++ ++/* Subtract uint64_t from decimal. */ ++void ++mpd_qsub_u64(mpd_t *result, const mpd_t *a, uint64_t b, ++ const mpd_context_t *ctx, uint32_t *status) ++{ ++ mpd_context_t maxcontext; ++ MPD_NEW_STATIC(bb,0,0,0,0); ++ ++ mpd_maxcontext(&maxcontext); ++ mpd_qset_u64(&bb, b, &maxcontext, status); ++ mpd_qsub(result, a, &bb, ctx, status); ++ mpd_del(&bb); ++} + #endif + + +@@ -3871,6 +4075,34 @@ + { + mpd_qdiv_uint(result, a, b, ctx, status); + } ++#elif !defined(LEGACY_COMPILER) ++/* Divide decimal by int64_t. */ ++void ++mpd_qdiv_i64(mpd_t *result, const mpd_t *a, int64_t b, ++ const mpd_context_t *ctx, uint32_t *status) ++{ ++ mpd_context_t maxcontext; ++ MPD_NEW_STATIC(bb,0,0,0,0); ++ ++ mpd_maxcontext(&maxcontext); ++ mpd_qset_i64(&bb, b, &maxcontext, status); ++ mpd_qdiv(result, a, &bb, ctx, status); ++ mpd_del(&bb); ++} ++ ++/* Divide decimal by uint64_t. */ ++void ++mpd_qdiv_u64(mpd_t *result, const mpd_t *a, uint64_t b, ++ const mpd_context_t *ctx, uint32_t *status) ++{ ++ mpd_context_t maxcontext; ++ MPD_NEW_STATIC(bb,0,0,0,0); ++ ++ mpd_maxcontext(&maxcontext); ++ mpd_qset_u64(&bb, b, &maxcontext, status); ++ mpd_qdiv(result, a, &bb, ctx, status); ++ mpd_del(&bb); ++} + #endif + + /* Pad the result with trailing zeros if it has fewer digits than prec. */ +@@ -5664,6 +5896,34 @@ + { + mpd_qmul_uint(result, a, b, ctx, status); + } ++#elif !defined(LEGACY_COMPILER) ++/* Multiply decimal and int64_t. */ ++void ++mpd_qmul_i64(mpd_t *result, const mpd_t *a, int64_t b, ++ const mpd_context_t *ctx, uint32_t *status) ++{ ++ mpd_context_t maxcontext; ++ MPD_NEW_STATIC(bb,0,0,0,0); ++ ++ mpd_maxcontext(&maxcontext); ++ mpd_qset_i64(&bb, b, &maxcontext, status); ++ mpd_qmul(result, a, &bb, ctx, status); ++ mpd_del(&bb); ++} ++ ++/* Multiply decimal and uint64_t. */ ++void ++mpd_qmul_u64(mpd_t *result, const mpd_t *a, uint64_t b, ++ const mpd_context_t *ctx, uint32_t *status) ++{ ++ mpd_context_t maxcontext; ++ MPD_NEW_STATIC(bb,0,0,0,0); ++ ++ mpd_maxcontext(&maxcontext); ++ mpd_qset_u64(&bb, b, &maxcontext, status); ++ mpd_qmul(result, a, &bb, ctx, status); ++ mpd_del(&bb); ++} + #endif + + /* Like the minus operator. */ +diff -r c3896275c0f6 Modules/_decimal/libmpdec/mpdecimal.h +--- a/Modules/_decimal/libmpdec/mpdecimal.h ++++ b/Modules/_decimal/libmpdec/mpdecimal.h +@@ -32,7 +32,6 @@ + + #ifdef __cplusplus + extern "C" { +-#define __STDC_LIMIT_MACROS + #endif + + +@@ -56,12 +55,18 @@ + #define MPD_HIDE_SYMBOLS_END + #define EXTINLINE extern inline + #else +- #ifdef HAVE_STDINT_H +- #include +- #endif + #ifdef HAVE_INTTYPES_H + #include + #endif ++ #ifdef HAVE_STDINT_H ++ #if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS) ++ #define __STDC_LIMIT_MACROS ++ #include ++ #undef __STDC_LIMIT_MACROS ++ #else ++ #include ++ #endif ++ #endif + #ifndef __GNUC_STDC_INLINE__ + #define __GNUC_STDC_INLINE__ 1 + #endif +@@ -100,6 +105,19 @@ + + + /******************************************************************************/ ++/* Version */ ++/******************************************************************************/ ++ ++#define MPD_MAJOR_VERSION 2 ++#define MPD_MINOR_VERSION 4 ++#define MPD_MICRO_VERSION 0 ++ ++#define MPD_VERSION "2.4.0" ++ ++const char *mpd_version(void); ++ ++ ++/******************************************************************************/ + /* Configuration */ + /******************************************************************************/ + +@@ -241,7 +259,7 @@ + extern const char *mpd_clamp_string[MPD_CLAMP_GUARD]; + + +-typedef struct { ++typedef struct mpd_context_t { + mpd_ssize_t prec; /* precision */ + mpd_ssize_t emax; /* max positive exp */ + mpd_ssize_t emin; /* min negative exp */ +@@ -353,7 +371,7 @@ + #define MPD_DATAFLAGS (MPD_STATIC_DATA|MPD_SHARED_DATA|MPD_CONST_DATA) + + /* mpd_t */ +-typedef struct { ++typedef struct mpd_t { + uint8_t flags; + mpd_ssize_t exp; + mpd_ssize_t digits; +@@ -371,7 +389,7 @@ + /******************************************************************************/ + + /* format specification */ +-typedef struct { ++typedef struct mpd_spec_t { + mpd_ssize_t min_width; /* minimum field width */ + mpd_ssize_t prec; /* fraction digits or significant digits */ + char type; /* conversion specifier */ +@@ -437,6 +455,12 @@ + mpd_uint_t mpd_qget_uint(const mpd_t *dec, uint32_t *status); + mpd_uint_t mpd_qabs_uint(const mpd_t *dec, uint32_t *status); + ++int32_t mpd_qget_i32(const mpd_t *dec, uint32_t *status); ++uint32_t mpd_qget_u32(const mpd_t *dec, uint32_t *status); ++#ifndef LEGACY_COMPILER ++int64_t mpd_qget_i64(const mpd_t *dec, uint32_t *status); ++uint64_t mpd_qget_u64(const mpd_t *dec, uint32_t *status); ++#endif + + /* quiet functions */ + int mpd_qcheck_nan(mpd_t *nanresult, const mpd_t *a, const mpd_context_t *ctx, uint32_t *status); +@@ -528,6 +552,17 @@ + void mpd_qsqrt(mpd_t *result, const mpd_t *a, const mpd_context_t *ctx, uint32_t *status); + void mpd_qinvroot(mpd_t *result, const mpd_t *a, const mpd_context_t *ctx, uint32_t *status); + ++#ifndef LEGACY_COMPILER ++void mpd_qadd_i64(mpd_t *result, const mpd_t *a, int64_t b, const mpd_context_t *ctx, uint32_t *status); ++void mpd_qadd_u64(mpd_t *result, const mpd_t *a, uint64_t b, const mpd_context_t *ctx, uint32_t *status); ++void mpd_qsub_i64(mpd_t *result, const mpd_t *a, int64_t b, const mpd_context_t *ctx, uint32_t *status); ++void mpd_qsub_u64(mpd_t *result, const mpd_t *a, uint64_t b, const mpd_context_t *ctx, uint32_t *status); ++void mpd_qmul_i64(mpd_t *result, const mpd_t *a, int64_t b, const mpd_context_t *ctx, uint32_t *status); ++void mpd_qmul_u64(mpd_t *result, const mpd_t *a, uint64_t b, const mpd_context_t *ctx, uint32_t *status); ++void mpd_qdiv_i64(mpd_t *result, const mpd_t *a, int64_t b, const mpd_context_t *ctx, uint32_t *status); ++void mpd_qdiv_u64(mpd_t *result, const mpd_t *a, uint64_t b, const mpd_context_t *ctx, uint32_t *status); ++#endif ++ + + size_t mpd_sizeinbase(const mpd_t *a, uint32_t base); + void mpd_qimport_u16(mpd_t *result, const uint16_t *srcdata, size_t srclen, +@@ -571,6 +606,12 @@ + mpd_ssize_t mpd_get_ssize(const mpd_t *a, mpd_context_t *ctx); + mpd_uint_t mpd_get_uint(const mpd_t *a, mpd_context_t *ctx); + mpd_uint_t mpd_abs_uint(const mpd_t *a, mpd_context_t *ctx); ++int32_t mpd_get_i32(const mpd_t *a, mpd_context_t *ctx); ++uint32_t mpd_get_u32(const mpd_t *a, mpd_context_t *ctx); ++#ifndef LEGACY_COMPILER ++int64_t mpd_get_i64(const mpd_t *a, mpd_context_t *ctx); ++uint64_t mpd_get_u64(const mpd_t *a, mpd_context_t *ctx); ++#endif + void mpd_and(mpd_t *result, const mpd_t *a, const mpd_t *b, mpd_context_t *ctx); + void mpd_copy(mpd_t *result, const mpd_t *a, mpd_context_t *ctx); + void mpd_canonical(mpd_t *result, const mpd_t *a, mpd_context_t *ctx); +@@ -641,6 +682,17 @@ + void mpd_sqrt(mpd_t *result, const mpd_t *a, mpd_context_t *ctx); + void mpd_invroot(mpd_t *result, const mpd_t *a, mpd_context_t *ctx); + ++#ifndef LEGACY_COMPILER ++void mpd_add_i64(mpd_t *result, const mpd_t *a, int64_t b, mpd_context_t *ctx); ++void mpd_add_u64(mpd_t *result, const mpd_t *a, uint64_t b, mpd_context_t *ctx); ++void mpd_sub_i64(mpd_t *result, const mpd_t *a, int64_t b, mpd_context_t *ctx); ++void mpd_sub_u64(mpd_t *result, const mpd_t *a, uint64_t b, mpd_context_t *ctx); ++void mpd_div_i64(mpd_t *result, const mpd_t *a, int64_t b, mpd_context_t *ctx); ++void mpd_div_u64(mpd_t *result, const mpd_t *a, uint64_t b, mpd_context_t *ctx); ++void mpd_mul_i64(mpd_t *result, const mpd_t *a, int64_t b, mpd_context_t *ctx); ++void mpd_mul_u64(mpd_t *result, const mpd_t *a, uint64_t b, mpd_context_t *ctx); ++#endif ++ + + /******************************************************************************/ + /* Configuration specific */ +@@ -649,36 +701,8 @@ + #ifdef CONFIG_64 + void mpd_qsset_i64(mpd_t *result, int64_t a, const mpd_context_t *ctx, uint32_t *status); + void mpd_qsset_u64(mpd_t *result, uint64_t a, const mpd_context_t *ctx, uint32_t *status); +-int64_t mpd_qget_i64(const mpd_t *dec, uint32_t *status); +-uint64_t mpd_qget_u64(const mpd_t *dec, uint32_t *status); +- +-void mpd_qadd_i64(mpd_t *result, const mpd_t *a, int64_t b, const mpd_context_t *ctx, uint32_t *status); +-void mpd_qadd_u64(mpd_t *result, const mpd_t *a, uint64_t b, const mpd_context_t *ctx, uint32_t *status); +-void mpd_qsub_i64(mpd_t *result, const mpd_t *a, int64_t b, const mpd_context_t *ctx, uint32_t *status); +-void mpd_qsub_u64(mpd_t *result, const mpd_t *a, uint64_t b, const mpd_context_t *ctx, uint32_t *status); +-void mpd_qmul_i64(mpd_t *result, const mpd_t *a, int64_t b, const mpd_context_t *ctx, uint32_t *status); +-void mpd_qmul_u64(mpd_t *result, const mpd_t *a, uint64_t b, const mpd_context_t *ctx, uint32_t *status); +-void mpd_qdiv_i64(mpd_t *result, const mpd_t *a, int64_t b, const mpd_context_t *ctx, uint32_t *status); +-void mpd_qdiv_u64(mpd_t *result, const mpd_t *a, uint64_t b, const mpd_context_t *ctx, uint32_t *status); +- + void mpd_sset_i64(mpd_t *result, int64_t a, mpd_context_t *ctx); + void mpd_sset_u64(mpd_t *result, uint64_t a, mpd_context_t *ctx); +-int64_t mpd_get_i64(const mpd_t *a, mpd_context_t *ctx); +-uint64_t mpd_get_u64(const mpd_t *a, mpd_context_t *ctx); +- +-void mpd_add_i64(mpd_t *result, const mpd_t *a, int64_t b, mpd_context_t *ctx); +-void mpd_add_u64(mpd_t *result, const mpd_t *a, uint64_t b, mpd_context_t *ctx); +-void mpd_sub_i64(mpd_t *result, const mpd_t *a, int64_t b, mpd_context_t *ctx); +-void mpd_sub_u64(mpd_t *result, const mpd_t *a, uint64_t b, mpd_context_t *ctx); +-void mpd_div_i64(mpd_t *result, const mpd_t *a, int64_t b, mpd_context_t *ctx); +-void mpd_div_u64(mpd_t *result, const mpd_t *a, uint64_t b, mpd_context_t *ctx); +-void mpd_mul_i64(mpd_t *result, const mpd_t *a, int64_t b, mpd_context_t *ctx); +-void mpd_mul_u64(mpd_t *result, const mpd_t *a, uint64_t b, mpd_context_t *ctx); +-#else +-int32_t mpd_qget_i32(const mpd_t *dec, uint32_t *status); +-uint32_t mpd_qget_u32(const mpd_t *dec, uint32_t *status); +-int32_t mpd_get_i32(const mpd_t *a, mpd_context_t *ctx); +-uint32_t mpd_get_u32(const mpd_t *a, mpd_context_t *ctx); + #endif + + +@@ -728,12 +752,12 @@ + /* 1 if dec is positive, -1 if dec is negative */ + EXTINLINE int mpd_arith_sign(const mpd_t *dec); + EXTINLINE long mpd_radix(void); +-EXTINLINE int mpd_isdynamic(mpd_t *dec); +-EXTINLINE int mpd_isstatic(mpd_t *dec); +-EXTINLINE int mpd_isdynamic_data(mpd_t *dec); +-EXTINLINE int mpd_isstatic_data(mpd_t *dec); +-EXTINLINE int mpd_isshared_data(mpd_t *dec); +-EXTINLINE int mpd_isconst_data(mpd_t *dec); ++EXTINLINE int mpd_isdynamic(const mpd_t *dec); ++EXTINLINE int mpd_isstatic(const mpd_t *dec); ++EXTINLINE int mpd_isdynamic_data(const mpd_t *dec); ++EXTINLINE int mpd_isstatic_data(const mpd_t *dec); ++EXTINLINE int mpd_isshared_data(const mpd_t *dec); ++EXTINLINE int mpd_isconst_data(const mpd_t *dec); + EXTINLINE mpd_ssize_t mpd_trail_zeros(const mpd_t *dec); + + +@@ -745,7 +769,7 @@ + EXTINLINE void mpd_setdigits(mpd_t *result); + EXTINLINE void mpd_set_sign(mpd_t *result, uint8_t sign); + /* copy sign from another decimal */ +-EXTINLINE void mpd_signcpy(mpd_t *result, mpd_t *a); ++EXTINLINE void mpd_signcpy(mpd_t *result, const mpd_t *a); + EXTINLINE void mpd_set_infinity(mpd_t *result); + EXTINLINE void mpd_set_qnan(mpd_t *result); + EXTINLINE void mpd_set_snan(mpd_t *result); +diff -r c3896275c0f6 Modules/_elementtree.c +--- a/Modules/_elementtree.c ++++ b/Modules/_elementtree.c +@@ -2997,7 +2997,10 @@ + PyObject* sprefix = NULL; + PyObject* suri = NULL; + +- suri = PyUnicode_DecodeUTF8(uri, strlen(uri), "strict"); ++ if (uri) ++ suri = PyUnicode_DecodeUTF8(uri, strlen(uri), "strict"); ++ else ++ suri = PyUnicode_FromString(""); + if (!suri) + return; + +diff -r c3896275c0f6 Modules/_json.c +--- a/Modules/_json.c ++++ b/Modules/_json.c +@@ -433,17 +433,10 @@ + } + } + /* Surrogate pair */ +- if ((c & 0xfc00) == 0xd800) { ++ if (Py_UNICODE_IS_HIGH_SURROGATE(c) && end + 6 < len && ++ PyUnicode_READ(kind, buf, next++) == '\\' && ++ PyUnicode_READ(kind, buf, next++) == 'u') { + Py_UCS4 c2 = 0; +- if (end + 6 >= len) { +- raise_errmsg("Unpaired high surrogate", pystr, end - 5); +- goto bail; +- } +- if (PyUnicode_READ(kind, buf, next++) != '\\' || +- PyUnicode_READ(kind, buf, next++) != 'u') { +- raise_errmsg("Unpaired high surrogate", pystr, end - 5); +- goto bail; +- } + end += 6; + /* Decode 4 hex digits */ + for (; next < end; next++) { +@@ -464,15 +457,10 @@ + goto bail; + } + } +- if ((c2 & 0xfc00) != 0xdc00) { +- raise_errmsg("Unpaired high surrogate", pystr, end - 5); +- goto bail; +- } +- c = 0x10000 + (((c - 0xd800) << 10) | (c2 - 0xdc00)); +- } +- else if ((c & 0xfc00) == 0xdc00) { +- raise_errmsg("Unpaired low surrogate", pystr, end - 5); +- goto bail; ++ if (Py_UNICODE_IS_LOW_SURROGATE(c2)) ++ c = Py_UNICODE_JOIN_SURROGATES(c, c2); ++ else ++ end -= 6; + } + } + APPEND_OLD_CHUNK +diff -r c3896275c0f6 Modules/_lzmamodule.c +--- a/Modules/_lzmamodule.c ++++ b/Modules/_lzmamodule.c +@@ -546,6 +546,14 @@ + return result; + } + ++static PyObject * ++Compressor_getstate(Compressor *self, PyObject *noargs) ++{ ++ PyErr_Format(PyExc_TypeError, "cannot serialize '%s' object", ++ Py_TYPE(self)->tp_name); ++ return NULL; ++} ++ + static int + Compressor_init_xz(lzma_stream *lzs, int check, uint32_t preset, + PyObject *filterspecs) +@@ -712,6 +720,7 @@ + Compressor_compress_doc}, + {"flush", (PyCFunction)Compressor_flush, METH_NOARGS, + Compressor_flush_doc}, ++ {"__getstate__", (PyCFunction)Compressor_getstate, METH_NOARGS}, + {NULL} + }; + +@@ -869,6 +878,14 @@ + return result; + } + ++static PyObject * ++Decompressor_getstate(Decompressor *self, PyObject *noargs) ++{ ++ PyErr_Format(PyExc_TypeError, "cannot serialize '%s' object", ++ Py_TYPE(self)->tp_name); ++ return NULL; ++} ++ + static int + Decompressor_init_raw(lzma_stream *lzs, PyObject *filterspecs) + { +@@ -991,6 +1008,7 @@ + static PyMethodDef Decompressor_methods[] = { + {"decompress", (PyCFunction)Decompressor_decompress, METH_VARARGS, + Decompressor_decompress_doc}, ++ {"__getstate__", (PyCFunction)Decompressor_getstate, METH_NOARGS}, + {NULL} + }; + +diff -r c3896275c0f6 Modules/_pickle.c +--- a/Modules/_pickle.c ++++ b/Modules/_pickle.c +@@ -2836,6 +2836,36 @@ + } + + static int ++save_singleton_type(PicklerObject *self, PyObject *obj, PyObject *singleton) ++{ ++ PyObject *reduce_value; ++ int status; ++ ++ reduce_value = Py_BuildValue("O(O)", &PyType_Type, singleton); ++ if (reduce_value == NULL) { ++ return -1; ++ } ++ status = save_reduce(self, reduce_value, obj); ++ Py_DECREF(reduce_value); ++ return status; ++} ++ ++static int ++save_type(PicklerObject *self, PyObject *obj) ++{ ++ if (obj == (PyObject *)&_PyNone_Type) { ++ return save_singleton_type(self, obj, Py_None); ++ } ++ else if (obj == (PyObject *)&PyEllipsis_Type) { ++ return save_singleton_type(self, obj, Py_Ellipsis); ++ } ++ else if (obj == (PyObject *)&_PyNotImplemented_Type) { ++ return save_singleton_type(self, obj, Py_NotImplemented); ++ } ++ return save_global(self, obj, NULL); ++} ++ ++static int + save_pers(PicklerObject *self, PyObject *obj, PyObject *func) + { + PyObject *pid = NULL; +@@ -3189,7 +3219,7 @@ + goto done; + } + else if (type == &PyType_Type) { +- status = save_global(self, obj, NULL); ++ status = save_type(self, obj); + goto done; + } + else if (type == &PyFunction_Type) { +@@ -4665,7 +4695,7 @@ + if (self->pers_func) { + if ((len = _Unpickler_Readline(self, &s)) < 0) + return -1; +- if (len < 2) ++ if (len < 1) + return bad_readline(); + + pid = PyBytes_FromStringAndSize(s, len - 1); +diff -r c3896275c0f6 Modules/_posixsubprocess.c +--- a/Modules/_posixsubprocess.c ++++ b/Modules/_posixsubprocess.c +@@ -723,26 +723,24 @@ + + PyDoc_STRVAR(subprocess_cloexec_pipe_doc, + "cloexec_pipe() -> (read_end, write_end)\n\n\ +-Create a pipe whose ends have the cloexec flag set."); ++Create a pipe whose ends have the cloexec flag set; write_end will be >= 3."); + + static PyObject * + subprocess_cloexec_pipe(PyObject *self, PyObject *noargs) + { + int fds[2]; +- int res; ++ int res, saved_errno; ++ long oldflags; + #ifdef HAVE_PIPE2 + Py_BEGIN_ALLOW_THREADS + res = pipe2(fds, O_CLOEXEC); + Py_END_ALLOW_THREADS + if (res != 0 && errno == ENOSYS) + { +- { + #endif + /* We hold the GIL which offers some protection from other code calling + * fork() before the CLOEXEC flags have been set but we can't guarantee + * anything without pipe2(). */ +- long oldflags; +- + res = pipe(fds); + + if (res == 0) { +@@ -759,9 +757,47 @@ + if (res == 0) + res = fcntl(fds[1], F_SETFD, oldflags | FD_CLOEXEC); + #ifdef HAVE_PIPE2 +- } + } + #endif ++ if (res == 0 && fds[1] < 3) { ++ /* We always want the write end of the pipe to avoid fds 0, 1 and 2 ++ * as our child may claim those for stdio connections. */ ++ int write_fd = fds[1]; ++ int fds_to_close[3] = {-1, -1, -1}; ++ int fds_to_close_idx = 0; ++#ifdef F_DUPFD_CLOEXEC ++ fds_to_close[fds_to_close_idx++] = write_fd; ++ write_fd = fcntl(write_fd, F_DUPFD_CLOEXEC, 3); ++ if (write_fd < 0) /* We don't support F_DUPFD_CLOEXEC / other error */ ++#endif ++ { ++ /* Use dup a few times until we get a desirable fd. */ ++ for (; fds_to_close_idx < 3; ++fds_to_close_idx) { ++ fds_to_close[fds_to_close_idx] = write_fd; ++ write_fd = dup(write_fd); ++ if (write_fd >= 3) ++ break; ++ /* We may dup a few extra times if it returns an error but ++ * that is okay. Repeat calls should return the same error. */ ++ } ++ if (write_fd < 0) res = write_fd; ++ if (res == 0) { ++ oldflags = fcntl(write_fd, F_GETFD, 0); ++ if (oldflags < 0) res = oldflags; ++ if (res == 0) ++ res = fcntl(write_fd, F_SETFD, oldflags | FD_CLOEXEC); ++ } ++ } ++ saved_errno = errno; ++ /* Close fds we tried for the write end that were too low. */ ++ for (fds_to_close_idx=0; fds_to_close_idx < 3; ++fds_to_close_idx) { ++ int temp_fd = fds_to_close[fds_to_close_idx]; ++ while (temp_fd >= 0 && close(temp_fd) < 0 && errno == EINTR); ++ } ++ errno = saved_errno; /* report dup or fcntl errors, not close. */ ++ fds[1] = write_fd; ++ } /* end if write fd was too small */ ++ + if (res != 0) + return PyErr_SetFromErrno(PyExc_OSError); + return Py_BuildValue("(ii)", fds[0], fds[1]); +diff -r c3896275c0f6 Modules/audioop.c +--- a/Modules/audioop.c ++++ b/Modules/audioop.c +@@ -27,7 +27,8 @@ + #endif + + static const int maxvals[] = {0, 0x7F, 0x7FFF, 0x7FFFFF, 0x7FFFFFFF}; +-static const int minvals[] = {0, -0x80, -0x8000, -0x800000, -0x80000000}; ++/* -1 trick is needed on Windows to support -0x80000000 without a warning */ ++static const int minvals[] = {0, -0x80, -0x8000, -0x800000, -0x7FFFFFFF-1}; + static const unsigned int masks[] = {0, 0xFF, 0xFFFF, 0xFFFFFF, 0xFFFFFFFF}; + + static int +@@ -385,7 +386,9 @@ + signed char *cp; + Py_ssize_t len, i; + int size, val = 0; +- int min = 0x7fffffff, max = -0x80000000; ++ /* -1 trick below is needed on Windows to support -0x80000000 without ++ a warning */ ++ int min = 0x7fffffff, max = -0x7FFFFFFF-1; + + if (!PyArg_ParseTuple(args, "s#i:minmax", &cp, &len, &size)) + return NULL; +diff -r c3896275c0f6 Modules/binascii.c +--- a/Modules/binascii.c ++++ b/Modules/binascii.c +@@ -1129,7 +1129,8 @@ + PyDoc_STRVAR(doc_hexlify, + "b2a_hex(data) -> s; Hexadecimal representation of binary data.\n\ + \n\ +-This function is also available as \"hexlify()\"."); ++The return value is a bytes object. This function is also\n\ ++available as \"hexlify()\"."); + + + static int +diff -r c3896275c0f6 Modules/fcntlmodule.c +--- a/Modules/fcntlmodule.c ++++ b/Modules/fcntlmodule.c +@@ -27,7 +27,7 @@ + } + + +-/* fcntl(fd, opt, [arg]) */ ++/* fcntl(fd, op, [arg]) */ + + static PyObject * + fcntl_fcntl(PyObject *self, PyObject *args) +@@ -77,11 +77,12 @@ + } + + PyDoc_STRVAR(fcntl_doc, +-"fcntl(fd, opt, [arg])\n\ ++"fcntl(fd, op, [arg])\n\ + \n\ +-Perform the requested operation on file descriptor fd. The operation\n\ +-is defined by op and is operating system dependent. These constants are\n\ +-available from the fcntl module. The argument arg is optional, and\n\ ++Perform the operation op on file descriptor fd. The values used\n\ ++for op are operating system dependent, and are available\n\ ++as constants in the fcntl module, using the same names as used in\n\ ++the relevant C header files. The argument arg is optional, and\n\ + defaults to 0; it may be an int or a string. If arg is given as a string,\n\ + the return value of fcntl is a string of that length, containing the\n\ + resulting value put in the arg buffer by the operating system. The length\n\ +@@ -90,7 +91,7 @@ + corresponding to the return value of the fcntl call in the C code."); + + +-/* ioctl(fd, opt, [arg]) */ ++/* ioctl(fd, op, [arg]) */ + + static PyObject * + fcntl_ioctl(PyObject *self, PyObject *args) +@@ -104,7 +105,7 @@ + whereas the system expects it to be a 32bit bit field value + regardless of it being passed as an int or unsigned long on + various platforms. See the termios.TIOCSWINSZ constant across +- platforms for an example of thise. ++ platforms for an example of this. + + If any of the 64bit platforms ever decide to use more than 32bits + in their unsigned long ioctl codes this will break and need +@@ -222,11 +223,12 @@ + } + + PyDoc_STRVAR(ioctl_doc, +-"ioctl(fd, opt[, arg[, mutate_flag]])\n\ ++"ioctl(fd, op[, arg[, mutate_flag]])\n\ + \n\ +-Perform the requested operation on file descriptor fd. The operation is\n\ +-defined by opt and is operating system dependent. Typically these codes are\n\ +-retrieved from the fcntl or termios library modules.\n\ ++Perform the operation op on file descriptor fd. The values used for op\n\ ++are operating system dependent, and are available as constants in the\n\ ++fcntl or termios library modules, using the same names as used in the\n\ ++relevant C header files.\n\ + \n\ + The argument arg is optional, and defaults to 0; it may be an int or a\n\ + buffer containing character data (most likely a string or an array). \n\ +diff -r c3896275c0f6 Modules/timemodule.c +--- a/Modules/timemodule.c ++++ b/Modules/timemodule.c +@@ -632,6 +632,13 @@ + Py_DECREF(format); + return NULL; + } ++ if ((outbuf[1] == 'y') && buf.tm_year < 0) ++ { ++ PyErr_SetString(PyExc_ValueError, ++ "format %y requires year >= 1900 on Windows"); ++ Py_DECREF(format); ++ return NULL; ++ } + } + #endif + +diff -r c3896275c0f6 Objects/descrobject.c +--- a/Objects/descrobject.c ++++ b/Objects/descrobject.c +@@ -1512,21 +1512,25 @@ + "\n" + "fget is a function to be used for getting an attribute value, and likewise\n" + "fset is a function for setting, and fdel a function for del'ing, an\n" +-"attribute. Typical use is to define a managed attribute x:\n" ++"attribute. Typical use is to define a managed attribute x:\n\n" + "class C(object):\n" + " def getx(self): return self._x\n" + " def setx(self, value): self._x = value\n" + " def delx(self): del self._x\n" + " x = property(getx, setx, delx, \"I'm the 'x' property.\")\n" + "\n" +-"Decorators make defining new properties or modifying existing ones easy:\n" ++"Decorators make defining new properties or modifying existing ones easy:\n\n" + "class C(object):\n" + " @property\n" +-" def x(self): return self._x\n" ++" def x(self):\n" ++" \"I am the 'x' property.\"\n" ++" return self._x\n" + " @x.setter\n" +-" def x(self, value): self._x = value\n" ++" def x(self, value):\n" ++" self._x = value\n" + " @x.deleter\n" +-" def x(self): del self._x\n" ++" def x(self):\n" ++" del self._x\n" + ); + + static int +diff -r c3896275c0f6 Objects/object.c +--- a/Objects/object.c ++++ b/Objects/object.c +@@ -1459,7 +1459,7 @@ + 0, /* nb_index */ + }; + +-static PyTypeObject PyNone_Type = { ++PyTypeObject _PyNone_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "NoneType", + 0, +@@ -1502,7 +1502,7 @@ + + PyObject _Py_NoneStruct = { + _PyObject_EXTRA_INIT +- 1, &PyNone_Type ++ 1, &_PyNone_Type + }; + + /* NotImplemented is an object that can be used to signal that an +@@ -1524,7 +1524,7 @@ + Py_RETURN_NOTIMPLEMENTED; + } + +-static PyTypeObject PyNotImplemented_Type = { ++PyTypeObject _PyNotImplemented_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "NotImplementedType", + 0, +@@ -1567,7 +1567,7 @@ + + PyObject _Py_NotImplementedStruct = { + _PyObject_EXTRA_INIT +- 1, &PyNotImplemented_Type ++ 1, &_PyNotImplemented_Type + }; + + void +@@ -1597,10 +1597,10 @@ + if (PyType_Ready(&PyList_Type) < 0) + Py_FatalError("Can't initialize list type"); + +- if (PyType_Ready(&PyNone_Type) < 0) ++ if (PyType_Ready(&_PyNone_Type) < 0) + Py_FatalError("Can't initialize None type"); + +- if (PyType_Ready(&PyNotImplemented_Type) < 0) ++ if (PyType_Ready(&_PyNotImplemented_Type) < 0) + Py_FatalError("Can't initialize NotImplemented type"); + + if (PyType_Ready(&PyTraceBack_Type) < 0) +diff -r c3896275c0f6 Objects/stringlib/unicode_format.h +--- a/Objects/stringlib/unicode_format.h ++++ b/Objects/stringlib/unicode_format.h +@@ -727,8 +727,10 @@ + while (self->str.start < self->str.end) { + switch (c = PyUnicode_READ_CHAR(self->str.str, self->str.start++)) { + case ':': +- hit_format_spec = 1; +- count = 1; ++ if (!hit_format_spec) { ++ count = 1; ++ hit_format_spec = 1; ++ } + break; + case '{': + /* the format spec needs to be recursively expanded. +diff -r c3896275c0f6 Objects/typeobject.c +--- a/Objects/typeobject.c ++++ b/Objects/typeobject.c +@@ -7,10 +7,6 @@ + #include + + +-/* Cached lookup of the copyreg module, for faster __reduce__ calls */ +- +-static PyObject *cached_copyreg_module = NULL; +- + /* Support type attribute cache */ + + /* The cache can keep references to the names alive for longer than +@@ -73,9 +69,6 @@ + _PyType_Fini(void) + { + PyType_ClearCache(); +- /* Need to forget our obsolete instance of the copyreg module at +- * interpreter shutdown (issue #17408). */ +- Py_CLEAR(cached_copyreg_module); + } + + void +@@ -3348,19 +3341,29 @@ + static PyObject * + import_copyreg(void) + { +- static PyObject *copyreg_str; +- +- if (!copyreg_str) { +- copyreg_str = PyUnicode_InternFromString("copyreg"); +- if (copyreg_str == NULL) +- return NULL; +- } +- if (!cached_copyreg_module) { +- cached_copyreg_module = PyImport_Import(copyreg_str); +- } +- +- Py_XINCREF(cached_copyreg_module); +- return cached_copyreg_module; ++ PyObject *copyreg_str; ++ PyObject *copyreg_module; ++ PyInterpreterState *interp = PyThreadState_GET()->interp; ++ _Py_IDENTIFIER(copyreg); ++ ++ copyreg_str = _PyUnicode_FromId(&PyId_copyreg); ++ if (copyreg_str == NULL) { ++ return NULL; ++ } ++ /* Try to fetch cached copy of copyreg from sys.modules first in an ++ attempt to avoid the import overhead. Previously this was implemented ++ by storing a reference to the cached module in a static variable, but ++ this broke when multiple embeded interpreters were in use (see issue ++ #17408 and #19088). */ ++ copyreg_module = PyDict_GetItemWithError(interp->modules, copyreg_str); ++ if (copyreg_module != NULL) { ++ Py_INCREF(copyreg_module); ++ return copyreg_module; ++ } ++ if (PyErr_Occurred()) { ++ return NULL; ++ } ++ return PyImport_Import(copyreg_str); + } + + static PyObject * +diff -r c3896275c0f6 PC/VS9.0/x64.vsprops +--- a/PC/VS9.0/x64.vsprops ++++ b/PC/VS9.0/x64.vsprops +@@ -8,7 +8,7 @@ + > + + cd $(ProjectDir)\..\PC + nmake /f python3.mak MACHINE=x86 OutDir=$(OutDir) rebuild + cd $(ProjectDir)\..\PC +-nmake /f python3.mak MACHINE=x86 OutDir=$(OutDir) clean ++"$(VSInstallDir)\VC\bin\nmake.exe" /f python3.mak MACHINE=x86 OutDir=$(OutDir) clean + $(OutDir)python3.dll + $(NMakePreprocessorDefinitions) + $(NMakeIncludeSearchPath) +@@ -111,7 +111,7 @@ + cd $(ProjectDir)\..\PC + nmake /f python3.mak MACHINE=x64 OutDir=$(OutDir) rebuild + cd $(ProjectDir)\..\PC +-nmake /f python3.mak MACHINE=x64 OutDir=$(OutDir) clean ++"$(VSInstallDir)\VC\bin\nmake.exe" /f python3.mak MACHINE=x64 OutDir=$(OutDir) clean + $(OutDir)python3.dll + $(NMakePreprocessorDefinitions) + $(NMakeIncludeSearchPath) +@@ -123,7 +123,7 @@ + cd $(ProjectDir)\..\PC + nmake /f python3.mak MACHINE=x86 OutDir=$(OutDir) rebuild + cd $(ProjectDir)\..\PC +-nmake /f python3.mak MACHINE=x86 OutDir=$(OutDir) clean ++"$(VSInstallDir)\VC\bin\nmake.exe" /f python3.mak MACHINE=x86 OutDir=$(OutDir) clean + $(OutDir)python3.dll + $(NMakePreprocessorDefinitions) + $(NMakeIncludeSearchPath) +@@ -135,7 +135,7 @@ + cd $(ProjectDir)\..\PC + nmake /f python3.mak MACHINE=x64 OutDir=$(OutDir) rebuild + cd $(ProjectDir)\..\PC +-nmake /f python3.mak MACHINE=x64 OutDir=$(OutDir) clean ++"$(VSInstallDir)\VC\bin\nmake.exe" /f python3.mak MACHINE=x64 OutDir=$(OutDir) clean + $(OutDir)python3.dll + $(NMakePreprocessorDefinitions) + $(NMakeIncludeSearchPath) +@@ -147,7 +147,7 @@ + cd $(ProjectDir)\..\PC + nmake /f python3.mak MACHINE=x86 OutDir=$(OutDir) rebuild + cd $(ProjectDir)\..\PC +-nmake /f python3.mak MACHINE=x86 OutDir=$(OutDir) clean ++"$(VSInstallDir)\VC\bin\nmake.exe" /f python3.mak MACHINE=x86 OutDir=$(OutDir) clean + $(OutDir)python3.dll + $(NMakePreprocessorDefinitions) + $(NMakeIncludeSearchPath) +@@ -159,7 +159,7 @@ + cd $(ProjectDir)\..\PC + nmake /f python3.mak MACHINE=x64 OutDir=$(OutDir) rebuild + cd $(ProjectDir)\..\PC +-nmake /f python3.mak MACHINE=x64 OutDir=$(OutDir) clean ++"$(VSInstallDir)\VC\bin\nmake.exe" /f python3.mak MACHINE=x64 OutDir=$(OutDir) clean + $(OutDir)python3.dll + $(NMakePreprocessorDefinitions) + $(NMakeIncludeSearchPath) +diff -r c3896275c0f6 PCbuild/pythoncore.vcxproj +--- a/PCbuild/pythoncore.vcxproj ++++ b/PCbuild/pythoncore.vcxproj +@@ -181,6 +181,12 @@ + libc;%(IgnoreSpecificDefaultLibraries) + 0x1e000000 + ++ ++ $(KillPythonExe) ++ ++ ++ Killing any running $(PythonExe) instances... ++ + + + +@@ -206,6 +212,12 @@ + libc;%(IgnoreSpecificDefaultLibraries) + 0x1e000000 + ++ ++ $(KillPythonExe) ++ ++ ++ Killing any running $(PythonExe) instances... ++ + + + +@@ -231,6 +243,12 @@ + libc;%(IgnoreSpecificDefaultLibraries) + 0x1e000000 + ++ ++ $(KillPythonExe) ++ ++ ++ Killing any running $(PythonExe) instances... ++ + + + +@@ -259,6 +277,12 @@ + libc;%(IgnoreSpecificDefaultLibraries) + 0x1e000000 + ++ ++ $(KillPythonExe) ++ ++ ++ Killing any running $(PythonExe) instances... ++ + + + +@@ -282,6 +306,12 @@ + libc;%(IgnoreSpecificDefaultLibraries) + 0x1e000000 + ++ ++ $(KillPythonExe) ++ ++ ++ Killing any running $(PythonExe) instances... ++ + + + +@@ -308,6 +338,12 @@ + 0x1e000000 + MachineX64 + ++ ++ $(KillPythonExe) ++ ++ ++ Killing any running $(PythonExe) instances... ++ + + + +@@ -331,6 +367,12 @@ + libc;%(IgnoreSpecificDefaultLibraries) + 0x1e000000 + ++ ++ $(KillPythonExe) ++ ++ ++ Killing any running $(PythonExe) instances... ++ + + + +@@ -357,6 +399,12 @@ + 0x1e000000 + MachineX64 + ++ ++ $(KillPythonExe) ++ ++ ++ Killing any running $(PythonExe) instances... ++ + + + +diff -r c3896275c0f6 PCbuild/readme.txt +--- a/PCbuild/readme.txt ++++ b/PCbuild/readme.txt +@@ -1,8 +1,8 @@ + Building Python using VC++ 10.0 + ------------------------------- + +-This directory is used to build Python for Win32 and x64 platforms, e.g. +-Windows 2000, XP, Vista and Windows Server 2008. In order to build 32-bit ++This directory is used to build Python for Win32 and x64 platforms, e.g. ++Windows XP, Vista and Windows Server 2008. In order to build 32-bit + debug and release executables, Microsoft Visual C++ 2010 Express Edition is + required at the very least. In order to build 64-bit debug and release + executables, Visual Studio 2010 Standard Edition is required at the very +@@ -27,7 +27,7 @@ + + The solution is configured to build the projects in the correct order. "Build + Solution" or F7 takes care of dependencies except for x64 builds. To make +-cross compiling x64 builds on a 32bit OS possible the x64 builds require a ++cross compiling x64 builds on a 32bit OS possible the x64 builds require a + 32bit version of Python. + + NOTE: +@@ -47,7 +47,7 @@ + Legacy support + -------------- + +-You can find build directories for older versions of Visual Studio and ++You can find build directories for older versions of Visual Studio and + Visual C++ in the PC directory. The legacy build directories are no longer + actively maintained and may not work out of the box. + +@@ -64,10 +64,10 @@ + C RUNTIME + --------- + +-Visual Studio 2010 uses version 10 of the C runtime (MSVCRT9). The executables ++Visual Studio 2010 uses version 10 of the C runtime (MSVCRT10). The executables + no longer use the "Side by Side" assemblies used in previous versions of the + compiler. This simplifies distribution of applications. +-The run time libraries are avalible under the VC/Redist folder of your visual studio ++The run time libraries are available under the VC/Redist folder of your visual studio + distribution. For more info, see the Readme in the VC/Redist folder. + + SUBPROJECTS +@@ -103,14 +103,14 @@ + + Python-controlled subprojects that wrap external projects: + _sqlite3 +- Wraps SQLite 3.7.4, which is currently built by sqlite3.vcproj (see below). ++ Wraps SQLite 3.7.12, which is currently built by sqlite3.vcxproj. + _tkinter + Wraps the Tk windowing system. Unlike _sqlite3, there's no +- corresponding tcltk.vcproj-type project that builds Tcl/Tk from vcproj's ++ corresponding tcltk.vcxproj-type project that builds Tcl/Tk from vcxproj's + within our pcbuild.sln, which means this module expects to find a + pre-built Tcl/Tk in either ..\..\tcltk for 32-bit or ..\..\tcltk64 for + 64-bit (relative to this directory). See below for instructions to build +- Tcl/Tk. ++ Tcl/Tk. + _bz2 + Python wrapper for the libbzip2 compression library. Homepage + http://www.bzip.org/ +@@ -122,16 +122,6 @@ + ** NOTE: if you use the Tools\buildbot\external(-amd64).bat approach for + obtaining external sources then you don't need to manually get the source + above via subversion. ** +- +- A custom pre-link step in the bz2 project settings should manage to +- build bzip2-1.0.6\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is +- linked in PCbuild\. +- However, the bz2 project is not smart enough to remove anything under +- bzip2-1.0.6\ when you do a clean, so if you want to rebuild bzip2.lib +- you need to clean up bzip2-1.0.6\ by hand. +- +- All of this managed to build libbz2.lib in +- bzip2-1.0.6\$platform-$configuration\, which the Python project links in. + _lzma + Python wrapper for the liblzma compression library. + +@@ -156,21 +146,19 @@ + + You must install the NASM assembler 2.10 or newer from + http://nasm.sf.net +- for x86 builds. Put nasmw.exe anywhere in your PATH. More recent ++ for x86 builds. Put nasm.exe anywhere in your PATH. More recent + versions of OpenSSL may need a later version of NASM. If OpenSSL's self + tests don't pass, you should first try to update NASM and do a full + rebuild of OpenSSL. +- Note: recent releases of nasm only have nasm.exe. Just rename it to +- nasmw.exe. + + You can also install ActivePerl from + http://www.activestate.com/activeperl/ +- if you like to use the official sources instead of the files from ++ if you like to use the official sources instead of the files from + python's subversion repository. The svn version contains pre-build + makefiles and assembly files. + + The build process makes sure that no patented algorithms are included. +- For now RC5, MDC2 and IDEA are excluded from the build. You may have ++ For now RC5, MDC2 and IDEA are excluded from the build. You may have + to manually remove $(OBJ_D)\i_*.obj from ms\nt.mak if the build process + complains about missing files or forbidden IDEA. Again the files provided + in the subversion repository are already fixed. +@@ -191,16 +179,16 @@ + this by hand. + + The subprojects above wrap external projects Python doesn't control, and as +-such, a little more work is required in order to download the relevant source ++such, a little more work is required in order to download the relevant source + files for each project before they can be built. The buildbots do this each +-time they're built, so the easiest approach is to run either external.bat or ++time they're built, so the easiest approach is to run either external.bat or + external-amd64.bat in the ..\Tools\buildbot directory from ..\, i.e.: + + C:\..\svn.python.org\projects\python\trunk\PCbuild>cd .. + C:\..\svn.python.org\projects\python\trunk>Tools\buildbot\external.bat + + This extracts all the external subprojects from http://svn.python.org/external +-via Subversion (so you'll need an svn.exe on your PATH) and places them in ++via Subversion (so you'll need an svn.exe on your PATH) and places them in + ..\.. (relative to this directory). The external(-amd64).bat scripts will + also build a debug build of Tcl/Tk; there aren't any equivalent batch files + for building release versions of Tcl/Tk lying around in the Tools\buildbot +@@ -209,18 +197,18 @@ + two nmake lines, then call each one without the 'DEBUG=1' parameter, i.e.: + + The external-amd64.bat file contains this for tcl: +- nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all install ++ nmake -f makefile.vc DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all install + + So for a release build, you'd call it as: +- nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all install ++ nmake -f makefile.vc MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 clean all install + + XXX Should we compile with OPTS=threads? + XXX Our installer copies a lot of stuff out of the Tcl/Tk install + XXX directory. Is all of that really needed for Python use of Tcl/Tk? + + This will be cleaned up in the future; ideally Tcl/Tk will be brought into our +-pcbuild.sln as custom .vcproj files, just as we've recently done with the +-sqlite3.vcproj file, which will remove the need for Tcl/Tk to be built ++pcbuild.sln as custom .vcxproj files, just as we've recently done with the ++sqlite3.vcxproj file, which will remove the need for Tcl/Tk to be built + separately via a batch file. + + XXX trent.nelson 02-Apr-08: +@@ -243,7 +231,7 @@ + junction as follows (using the directory structure above as an example): + + C:\..\python\trunk\external <- already exists and has built versions +- of the external subprojects ++ of the external subprojects + + C:\..\python\branches\py3k>linkd.exe external ..\..\trunk\external + Link created at: external +@@ -256,19 +244,9 @@ + Building for Itanium + -------------------- + +-NOTE: + Official support for Itanium builds have been dropped from the build. Please + contact us and provide patches if you are interested in Itanium builds. + +-The project files support a ReleaseItanium configuration which creates +-Win64/Itanium binaries. For this to work, you need to install the Platform +-SDK, in particular the 64-bit support. This includes an Itanium compiler +-(future releases of the SDK likely include an AMD64 compiler as well). +-In addition, you need the Visual Studio plugin for external C compilers, +-from http://sf.net/projects/vsextcomp. The plugin will wrap cl.exe, to +-locate the proper target compiler, and convert compiler options +-accordingly. The project files require at least version 0.9. +- + Building for AMD64 + ------------------ + +@@ -288,7 +266,7 @@ + + The solution has two configurations for PGO. The PGInstrument + configuration must be build first. The PGInstrument binaries are +-lniked against a profiling library and contain extra debug ++linked against a profiling library and contain extra debug + information. The PGUpdate configuration takes the profiling data and + generates optimized binaries. + +@@ -296,23 +274,23 @@ + creates the PGI files, runs the unit test suite or PyBench with the PGI + python and finally creates the optimized files. + +-http://msdn2.microsoft.com/en-us/library/e7k32f4k(VS.90).aspx ++http://msdn.microsoft.com/en-us/library/e7k32f4k(VS.100).aspx + + Static library + -------------- + + The solution has no configuration for static libraries. However it is easy +-it build a static library instead of a DLL. You simply have to set the ++it build a static library instead of a DLL. You simply have to set the + "Configuration Type" to "Static Library (.lib)" and alter the preprocessor + macro "Py_ENABLE_SHARED" to "Py_NO_ENABLE_SHARED". You may also have to +-change the "Runtime Library" from "Multi-threaded DLL (/MD)" to ++change the "Runtime Library" from "Multi-threaded DLL (/MD)" to + "Multi-threaded (/MT)". + + Visual Studio properties + ------------------------ + +-The PCbuild solution makes heavy use of Visual Studio property files +-(*.vsprops). The properties can be viewed and altered in the Property ++The PCbuild solution makes heavy use of Visual Studio property files ++(*.props). The properties can be viewed and altered in the Property + Manager (View -> Other Windows -> Property Manager). + + * debug (debug macro: _DEBUG) +diff -r c3896275c0f6 PCbuild/ssl.vcxproj +--- a/PCbuild/ssl.vcxproj ++++ b/PCbuild/ssl.vcxproj +@@ -122,7 +122,7 @@ + "$(PythonExe)" build_ssl.py Release $(Platform) -a + + +- ++ echo OpenSSL must be cleaned manually if you want to rebuild it. + + $(NMakePreprocessorDefinitions) + $(NMakeIncludeSearchPath) +@@ -133,7 +133,7 @@ + "$(PythonExe)" build_ssl.py Release $(Platform) -a + + +- ++ echo OpenSSL must be cleaned manually if you want to rebuild it. + + $(NMakePreprocessorDefinitions) + $(NMakeIncludeSearchPath) +@@ -144,7 +144,7 @@ + "$(PythonExe)" build_ssl.py Release $(Platform) -a + + +- ++ echo OpenSSL must be cleaned manually if you want to rebuild it. + + $(NMakePreprocessorDefinitions) + $(NMakeIncludeSearchPath) +@@ -155,7 +155,7 @@ + "$(PythonExe)" build_ssl.py Release $(Platform) -a + + +- ++ echo OpenSSL must be cleaned manually if you want to rebuild it. + + $(NMakePreprocessorDefinitions) + $(NMakeIncludeSearchPath) +@@ -166,7 +166,7 @@ + "$(PythonExe)" build_ssl.py Release $(Platform) -a + + +- ++ echo OpenSSL must be cleaned manually if you want to rebuild it. + + $(NMakePreprocessorDefinitions) + $(NMakeIncludeSearchPath) +@@ -177,7 +177,7 @@ + "$(PythonExe)" build_ssl.py Release $(Platform) -a + + +- ++ echo OpenSSL must be cleaned manually if you want to rebuild it. + + $(NMakePreprocessorDefinitions) + $(NMakeIncludeSearchPath) +@@ -188,7 +188,7 @@ + "$(PythonExe)" build_ssl.py Release $(Platform) -a + + +- ++ echo OpenSSL must be cleaned manually if you want to rebuild it. + + $(NMakePreprocessorDefinitions) + $(NMakeIncludeSearchPath) +@@ -199,7 +199,7 @@ + "$(PythonExe)" build_ssl.py Release $(Platform) -a + + +- ++ echo OpenSSL must be cleaned manually if you want to rebuild it. + + $(NMakePreprocessorDefinitions) + $(NMakeIncludeSearchPath) +diff -r c3896275c0f6 PCbuild/x64.props +--- a/PCbuild/x64.props ++++ b/PCbuild/x64.props +@@ -5,7 +5,7 @@ + + + +- /USECL:MS_OPTERON /GS- %(AdditionalOptions) ++ false + _WIN64;_M_X64;%(PreprocessorDefinitions) + + +diff -r c3896275c0f6 Python/bltinmodule.c +--- a/Python/bltinmodule.c ++++ b/Python/bltinmodule.c +@@ -676,7 +676,7 @@ + PyDoc_STRVAR(compile_doc, + "compile(source, filename, mode[, flags[, dont_inherit]]) -> code object\n\ + \n\ +-Compile the source string (a Python module, statement or expression)\n\ ++Compile the source (a Python module, statement or expression)\n\ + into a code object that can be executed by exec() or eval().\n\ + The filename will be used for run-time error messages.\n\ + The mode must be 'exec' to compile a module, 'single' to compile a\n\ +diff -r c3896275c0f6 Python/ceval.c +--- a/Python/ceval.c ++++ b/Python/ceval.c +@@ -2573,7 +2573,7 @@ + + TARGET(WITH_CLEANUP) + { +- /* At the top of the stack are 1-3 values indicating ++ /* At the top of the stack are 1-6 values indicating + how/why we entered the finally clause: + - TOP = None + - (TOP, SECOND) = (WHY_{RETURN,CONTINUE}), retval +@@ -2586,9 +2586,9 @@ + otherwise we must call + EXIT(None, None, None) + +- In the first two cases, we remove EXIT from the ++ In the first three cases, we remove EXIT from the + stack, leaving the rest in the same order. In the +- third case, we shift the bottom 3 values of the ++ fourth case, we shift the bottom 3 values of the + stack down, and replace the empty spot with NULL. + + In addition, if the stack represents an exception, +diff -r c3896275c0f6 Python/dtoa.c +--- a/Python/dtoa.c ++++ b/Python/dtoa.c +@@ -204,7 +204,24 @@ + MAX_ABS_EXP in absolute value get truncated to +-MAX_ABS_EXP. MAX_ABS_EXP + should fit into an int. */ + #ifndef MAX_ABS_EXP +-#define MAX_ABS_EXP 19999U ++#define MAX_ABS_EXP 1100000000U ++#endif ++/* Bound on length of pieces of input strings in _Py_dg_strtod; specifically, ++ this is used to bound the total number of digits ignoring leading zeros and ++ the number of digits that follow the decimal point. Ideally, MAX_DIGITS ++ should satisfy MAX_DIGITS + 400 < MAX_ABS_EXP; that ensures that the ++ exponent clipping in _Py_dg_strtod can't affect the value of the output. */ ++#ifndef MAX_DIGITS ++#define MAX_DIGITS 1000000000U ++#endif ++ ++/* Guard against trying to use the above values on unusual platforms with ints ++ * of width less than 32 bits. */ ++#if MAX_ABS_EXP > INT_MAX ++#error "MAX_ABS_EXP should fit in an int" ++#endif ++#if MAX_DIGITS > INT_MAX ++#error "MAX_DIGITS should fit in an int" + #endif + + /* The following definition of Storeinc is appropriate for MIPS processors. +@@ -1538,6 +1555,7 @@ + Long L; + BCinfo bc; + Bigint *bb, *bb1, *bd, *bd0, *bs, *delta; ++ size_t ndigits, fraclen; + + dval(&rv) = 0.; + +@@ -1560,40 +1578,53 @@ + c = *++s; + lz = s != s1; + +- /* Point s0 at the first nonzero digit (if any). nd0 will be the position +- of the point relative to s0. nd will be the total number of digits +- ignoring leading zeros. */ ++ /* Point s0 at the first nonzero digit (if any). fraclen will be the ++ number of digits between the decimal point and the end of the ++ digit string. ndigits will be the total number of digits ignoring ++ leading zeros. */ + s0 = s1 = s; + while ('0' <= c && c <= '9') + c = *++s; +- nd0 = nd = s - s1; ++ ndigits = s - s1; ++ fraclen = 0; + + /* Parse decimal point and following digits. */ + if (c == '.') { + c = *++s; +- if (!nd) { ++ if (!ndigits) { + s1 = s; + while (c == '0') + c = *++s; + lz = lz || s != s1; +- nd0 -= s - s1; ++ fraclen += (s - s1); + s0 = s; + } + s1 = s; + while ('0' <= c && c <= '9') + c = *++s; +- nd += s - s1; ++ ndigits += s - s1; ++ fraclen += s - s1; + } + +- /* Now lz is true if and only if there were leading zero digits, and nd +- gives the total number of digits ignoring leading zeros. A valid input +- must have at least one digit. */ +- if (!nd && !lz) { ++ /* Now lz is true if and only if there were leading zero digits, and ++ ndigits gives the total number of digits ignoring leading zeros. A ++ valid input must have at least one digit. */ ++ if (!ndigits && !lz) { + if (se) + *se = (char *)s00; + goto parse_error; + } + ++ /* Range check ndigits and fraclen to make sure that they, and values ++ computed with them, can safely fit in an int. */ ++ if (ndigits > MAX_DIGITS || fraclen > MAX_DIGITS) { ++ if (se) ++ *se = (char *)s00; ++ goto parse_error; ++ } ++ nd = (int)ndigits; ++ nd0 = (int)ndigits - (int)fraclen; ++ + /* Parse exponent. */ + e = 0; + if (c == 'e' || c == 'E') { +diff -r c3896275c0f6 Python/fileutils.c +--- a/Python/fileutils.c ++++ b/Python/fileutils.c +@@ -623,7 +623,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; +@@ -633,11 +633,11 @@ + errno = EINVAL; + return -1; + } +- res = (int)readlink(cpath, cbuf, PATH_MAX); ++ res = (int)readlink(cpath, cbuf, Py_ARRAY_LENGTH(cbuf)); + PyMem_Free(cpath); + if (res == -1) + return -1; +- if (res == PATH_MAX) { ++ if (res == Py_ARRAY_LENGTH(cbuf)) { + errno = EINVAL; + return -1; + } +@@ -669,7 +669,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; +@@ -709,11 +709,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, Py_ARRAY_LENGTH(fname)) == NULL) + return NULL; + wname = _Py_char2wchar(fname, &len); + if (wname == NULL) +diff -r c3896275c0f6 Python/getcopyright.c +--- a/Python/getcopyright.c ++++ b/Python/getcopyright.c +@@ -2,7 +2,7 @@ + + #include "Python.h" + +-static char cprt[] = ++static const char cprt[] = + "\ + Copyright (c) 2001-2013 Python Software Foundation.\n\ + All Rights Reserved.\n\ +diff -r c3896275c0f6 Python/pythonrun.c +--- a/Python/pythonrun.c ++++ b/Python/pythonrun.c +@@ -817,8 +817,9 @@ + 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 size = Py_ARRAY_LENGTH(env_home); ++ size_t r = mbstowcs(env_home, chome, size); ++ if (r != (size_t)-1 && r < size) + home = env_home; + } + +diff -r c3896275c0f6 Python/sysmodule.c +--- a/Python/sysmodule.c ++++ b/Python/sysmodule.c +@@ -1895,7 +1895,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, Py_ARRAY_LENGTH(fullpath))) { + argv0 = fullpath; + } + #endif +diff -r c3896275c0f6 Tools/buildbot/build-amd64.bat +--- a/Tools/buildbot/build-amd64.bat ++++ b/Tools/buildbot/build-amd64.bat +@@ -2,6 +2,5 @@ + cmd /c Tools\buildbot\external-amd64.bat + call "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64 + cmd /c Tools\buildbot\clean-amd64.bat +-msbuild PCbuild\kill_python.vcxproj /p:Configuration=Debug /p:PlatformTarget=x64 +-PCbuild\amd64\kill_python_d.exe ++ + msbuild PCbuild\pcbuild.sln /p:Configuration=Debug /p:Platform=x64 +diff -r c3896275c0f6 Tools/buildbot/build.bat +--- a/Tools/buildbot/build.bat ++++ b/Tools/buildbot/build.bat +@@ -2,7 +2,6 @@ + cmd /c Tools\buildbot\external.bat + call "%VS100COMNTOOLS%vsvars32.bat" + cmd /c Tools\buildbot\clean.bat +-msbuild PCbuild\kill_python.vcxproj /p:Configuration=Debug /p:PlatformTarget=x86 +-PCbuild\kill_python_d.exe ++ + msbuild PCbuild\pcbuild.sln /p:Configuration=Debug /p:Platform=Win32 + +diff -r c3896275c0f6 Tools/gdb/libpython.py +--- a/Tools/gdb/libpython.py ++++ b/Tools/gdb/libpython.py +@@ -40,11 +40,21 @@ + + The module also extends gdb with some python-specific commands. + ''' +-from __future__ import with_statement ++ ++# NOTE: some gdbs are linked with Python 3, so this file should be dual-syntax ++# compatible (2.6+ and 3.0+). See #19308. ++ ++from __future__ import print_function, with_statement + import gdb ++import os + import locale + import sys + ++if sys.version_info[0] >= 3: ++ unichr = chr ++ xrange = range ++ long = int ++ + # Look up the gdb.Type for some standard types: + _type_char_ptr = gdb.lookup_type('char').pointer() # char* + _type_unsigned_char_ptr = gdb.lookup_type('unsigned char').pointer() # unsigned char* +@@ -58,16 +68,16 @@ + SIZEOF_VOID_P = _type_void_ptr.sizeof + + +-Py_TPFLAGS_HEAPTYPE = (1L << 9) ++Py_TPFLAGS_HEAPTYPE = (1 << 9) + +-Py_TPFLAGS_LONG_SUBCLASS = (1L << 24) +-Py_TPFLAGS_LIST_SUBCLASS = (1L << 25) +-Py_TPFLAGS_TUPLE_SUBCLASS = (1L << 26) +-Py_TPFLAGS_BYTES_SUBCLASS = (1L << 27) +-Py_TPFLAGS_UNICODE_SUBCLASS = (1L << 28) +-Py_TPFLAGS_DICT_SUBCLASS = (1L << 29) +-Py_TPFLAGS_BASE_EXC_SUBCLASS = (1L << 30) +-Py_TPFLAGS_TYPE_SUBCLASS = (1L << 31) ++Py_TPFLAGS_LONG_SUBCLASS = (1 << 24) ++Py_TPFLAGS_LIST_SUBCLASS = (1 << 25) ++Py_TPFLAGS_TUPLE_SUBCLASS = (1 << 26) ++Py_TPFLAGS_BYTES_SUBCLASS = (1 << 27) ++Py_TPFLAGS_UNICODE_SUBCLASS = (1 << 28) ++Py_TPFLAGS_DICT_SUBCLASS = (1 << 29) ++Py_TPFLAGS_BASE_EXC_SUBCLASS = (1 << 30) ++Py_TPFLAGS_TYPE_SUBCLASS = (1 << 31) + + + MAX_OUTPUT_LEN=1024 +@@ -90,32 +100,39 @@ + def safe_range(val): + # As per range, but don't trust the value too much: cap it to a safety + # threshold in case the data was corrupted +- return xrange(safety_limit(val)) ++ return xrange(safety_limit(int(val))) + +-def write_unicode(file, text): +- # Write a byte or unicode string to file. Unicode strings are encoded to +- # ENCODING encoding with 'backslashreplace' error handler to avoid +- # UnicodeEncodeError. +- if isinstance(text, unicode): +- text = text.encode(ENCODING, 'backslashreplace') +- file.write(text) ++if sys.version_info[0] >= 3: ++ def write_unicode(file, text): ++ file.write(text) ++else: ++ def write_unicode(file, text): ++ # Write a byte or unicode string to file. Unicode strings are encoded to ++ # ENCODING encoding with 'backslashreplace' error handler to avoid ++ # UnicodeEncodeError. ++ if isinstance(text, unicode): ++ text = text.encode(ENCODING, 'backslashreplace') ++ file.write(text) + +-def os_fsencode(filename): +- if not isinstance(filename, unicode): +- return filename +- encoding = sys.getfilesystemencoding() +- if encoding == 'mbcs': +- # mbcs doesn't support surrogateescape +- return filename.encode(encoding) +- encoded = [] +- for char in filename: +- # surrogateescape error handler +- if 0xDC80 <= ord(char) <= 0xDCFF: +- byte = chr(ord(char) - 0xDC00) +- else: +- byte = char.encode(encoding) +- encoded.append(byte) +- return ''.join(encoded) ++try: ++ os_fsencode = os.fsencode ++except AttributeError: ++ def os_fsencode(filename): ++ if not isinstance(filename, unicode): ++ return filename ++ encoding = sys.getfilesystemencoding() ++ if encoding == 'mbcs': ++ # mbcs doesn't support surrogateescape ++ return filename.encode(encoding) ++ encoded = [] ++ for char in filename: ++ # surrogateescape error handler ++ if 0xDC80 <= ord(char) <= 0xDCFF: ++ byte = chr(ord(char) - 0xDC00) ++ else: ++ byte = char.encode(encoding) ++ encoded.append(byte) ++ return ''.join(encoded) + + class StringTruncated(RuntimeError): + pass +@@ -322,8 +339,8 @@ + # class + return cls + +- #print 'tp_flags = 0x%08x' % tp_flags +- #print 'tp_name = %r' % tp_name ++ #print('tp_flags = 0x%08x' % tp_flags) ++ #print('tp_name = %r' % tp_name) + + name_map = {'bool': PyBoolObjectPtr, + 'classobj': PyClassObjectPtr, +@@ -733,14 +750,14 @@ + ''' + ob_size = long(self.field('ob_size')) + if ob_size == 0: +- return 0L ++ return 0 + + ob_digit = self.field('ob_digit') + + if gdb.lookup_type('digit').sizeof == 2: +- SHIFT = 15L ++ SHIFT = 15 + else: +- SHIFT = 30L ++ SHIFT = 30 + + digits = [long(ob_digit[i]) * 2**(SHIFT*i) + for i in safe_range(abs(ob_size))] +@@ -1595,12 +1612,12 @@ + # py-list requires an actual PyEval_EvalFrameEx frame: + frame = Frame.get_selected_bytecode_frame() + if not frame: +- print 'Unable to locate gdb frame for python bytecode interpreter' ++ print('Unable to locate gdb frame for python bytecode interpreter') + return + + pyop = frame.get_pyop() + if not pyop or pyop.is_optimized_out(): +- print 'Unable to read information on python frame' ++ print('Unable to read information on python frame') + return + + filename = pyop.filename() +@@ -1656,9 +1673,9 @@ + frame = iter_frame + + if move_up: +- print 'Unable to find an older python frame' ++ print('Unable to find an older python frame') + else: +- print 'Unable to find a newer python frame' ++ print('Unable to find a newer python frame') + + class PyUp(gdb.Command): + 'Select and print the python stack frame that called this one (if any)' +@@ -1740,23 +1757,23 @@ + + frame = Frame.get_selected_python_frame() + if not frame: +- print 'Unable to locate python frame' ++ print('Unable to locate python frame') + return + + pyop_frame = frame.get_pyop() + if not pyop_frame: +- print 'Unable to read information on python frame' ++ print('Unable to read information on python frame') + return + + pyop_var, scope = pyop_frame.get_var_by_name(name) + + if pyop_var: +- print ('%s %r = %s' ++ print('%s %r = %s' + % (scope, + name, + pyop_var.get_truncated_repr(MAX_OUTPUT_LEN))) + else: +- print '%r not found' % name ++ print('%r not found' % name) + + PyPrint() + +@@ -1774,16 +1791,16 @@ + + frame = Frame.get_selected_python_frame() + if not frame: +- print 'Unable to locate python frame' ++ print('Unable to locate python frame') + return + + pyop_frame = frame.get_pyop() + if not pyop_frame: +- print 'Unable to read information on python frame' ++ print('Unable to read information on python frame') + return + + for pyop_name, pyop_value in pyop_frame.iter_locals(): +- print ('%s = %s' ++ print('%s = %s' + % (pyop_name.proxyval(set()), + pyop_value.get_truncated_repr(MAX_OUTPUT_LEN))) + +diff -r c3896275c0f6 config.guess +--- a/config.guess ++++ b/config.guess +@@ -1,10 +1,8 @@ + #! /bin/sh + # Attempt to guess a canonical system name. +-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +-# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +-# 2011, 2012, 2013 Free Software Foundation, Inc. ++# Copyright 1992-2013 Free Software Foundation, Inc. + +-timestamp='2012-12-29' ++timestamp='2013-06-10' + + # This file is free software; you can redistribute it and/or modify it + # under the terms of the GNU General Public License as published by +@@ -26,7 +24,7 @@ + # program. This Exception is an additional permission under section 7 + # of the GNU General Public License, version 3 ("GPLv3"). + # +-# Originally written by Per Bothner. ++# Originally written by Per Bothner. + # + # You can get the latest version of this script from: + # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +@@ -52,9 +50,7 @@ + GNU config.guess ($timestamp) + + Originally written by Per Bothner. +-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, +-2012, 2013 Free Software Foundation, Inc. ++Copyright 1992-2013 Free Software Foundation, Inc. + + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." +@@ -136,6 +132,27 @@ + UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown + UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + ++case "${UNAME_SYSTEM}" in ++Linux|GNU|GNU/*) ++ # If the system lacks a compiler, then just pick glibc. ++ # We could probably try harder. ++ LIBC=gnu ++ ++ eval $set_cc_for_build ++ cat <<-EOF > $dummy.c ++ #include ++ #if defined(__UCLIBC__) ++ LIBC=uclibc ++ #elif defined(__dietlibc__) ++ LIBC=dietlibc ++ #else ++ LIBC=gnu ++ #endif ++ EOF ++ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` ++ ;; ++esac ++ + # Note: order is significant - the case branches are not exclusive. + + case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +@@ -857,21 +874,21 @@ + exit ;; + *:GNU:*:*) + # the GNU system +- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` ++ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland +- echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu ++ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + aarch64:Linux:*:*) +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in +@@ -884,59 +901,54 @@ + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 +- if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi +- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ++ if test "$?" = 0 ; then LIBC="gnulibc1" ; fi ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ arc:Linux:*:* | arceb:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then +- echo ${UNAME_MACHINE}-unknown-linux-gnueabi ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + else +- echo ${UNAME_MACHINE}-unknown-linux-gnueabihf ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + cris:Linux:*:*) +- echo ${UNAME_MACHINE}-axis-linux-gnu ++ echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + crisv32:Linux:*:*) +- echo ${UNAME_MACHINE}-axis-linux-gnu ++ echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + frv:Linux:*:*) +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + hexagon:Linux:*:*) +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:Linux:*:*) +- LIBC=gnu +- eval $set_cc_for_build +- sed 's/^ //' << EOF >$dummy.c +- #ifdef __dietlibc__ +- LIBC=dietlibc +- #endif +-EOF +- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` +- echo "${UNAME_MACHINE}-pc-linux-${LIBC}" ++ echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + ia64:Linux:*:*) +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m32r*:Linux:*:*) +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m68*:Linux:*:*) +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build +@@ -955,54 +967,63 @@ + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` +- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ++ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + ;; ++ or1k:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; + or32:Linux:*:*) +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + padre:Linux:*:*) +- echo sparc-unknown-linux-gnu ++ echo sparc-unknown-linux-${LIBC} + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) +- echo hppa64-unknown-linux-gnu ++ echo hppa64-unknown-linux-${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in +- PA7*) echo hppa1.1-unknown-linux-gnu ;; +- PA8*) echo hppa2.0-unknown-linux-gnu ;; +- *) echo hppa-unknown-linux-gnu ;; ++ PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; ++ PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; ++ *) echo hppa-unknown-linux-${LIBC} ;; + esac + exit ;; + ppc64:Linux:*:*) +- echo powerpc64-unknown-linux-gnu ++ echo powerpc64-unknown-linux-${LIBC} + exit ;; + ppc:Linux:*:*) +- echo powerpc-unknown-linux-gnu ++ echo powerpc-unknown-linux-${LIBC} ++ exit ;; ++ ppc64le:Linux:*:*) ++ echo powerpc64le-unknown-linux-${LIBC} ++ exit ;; ++ ppcle:Linux:*:*) ++ echo powerpcle-unknown-linux-${LIBC} + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) +- echo ${UNAME_MACHINE}-ibm-linux ++ echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + exit ;; + sh64*:Linux:*:*) +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sh*:Linux:*:*) +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + tile*:Linux:*:*) +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + vax:Linux:*:*) +- echo ${UNAME_MACHINE}-dec-linux-gnu ++ echo ${UNAME_MACHINE}-dec-linux-${LIBC} + exit ;; + x86_64:Linux:*:*) +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + xtensa*:Linux:*:*) +- echo ${UNAME_MACHINE}-unknown-linux-gnu ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. +@@ -1235,19 +1256,21 @@ + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown +- case $UNAME_PROCESSOR in +- i386) +- eval $set_cc_for_build +- if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then +- if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ +- (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ +- grep IS_64BIT_ARCH >/dev/null +- then +- UNAME_PROCESSOR="x86_64" +- fi +- fi ;; +- unknown) UNAME_PROCESSOR=powerpc ;; +- esac ++ eval $set_cc_for_build ++ if test "$UNAME_PROCESSOR" = unknown ; then ++ UNAME_PROCESSOR=powerpc ++ fi ++ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then ++ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ ++ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ ++ grep IS_64BIT_ARCH >/dev/null ++ then ++ case $UNAME_PROCESSOR in ++ i386) UNAME_PROCESSOR=x86_64 ;; ++ powerpc) UNAME_PROCESSOR=powerpc64 ;; ++ esac ++ fi ++ fi + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) +diff -r c3896275c0f6 config.sub +--- a/config.sub ++++ b/config.sub +@@ -1,10 +1,8 @@ + #! /bin/sh + # Configuration validation subroutine script. +-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +-# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +-# 2011, 2012, 2013 Free Software Foundation, Inc. ++# Copyright 1992-2013 Free Software Foundation, Inc. + +-timestamp='2012-12-29' ++timestamp='2013-08-10' + + # This file is free software; you can redistribute it and/or modify it + # under the terms of the GNU General Public License as published by +@@ -70,9 +68,7 @@ + version="\ + GNU config.sub ($timestamp) + +-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, +-2012, 2013 Free Software Foundation, Inc. ++Copyright 1992-2013 Free Software Foundation, Inc. + + This is free software; see the source for copying conditions. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." +@@ -256,12 +252,12 @@ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ +- | arc \ ++ | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | be32 | be64 \ + | bfin \ +- | c4x | clipper \ ++ | c4x | c8051 | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | epiphany \ + | fido | fr30 | frv \ +@@ -290,16 +286,17 @@ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ ++ | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ +- | nios | nios2 \ ++ | nios | nios2 | nios2eb | nios2el \ + | ns16k | ns32k \ + | open8 \ +- | or32 \ ++ | or1k | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pyramid \ +@@ -369,13 +366,13 @@ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ +- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ ++ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ +- | clipper-* | craynv-* | cydra-* \ ++ | c8051-* | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ +@@ -407,12 +404,13 @@ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ ++ | mipsr5900-* | mipsr5900el-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ +- | nios-* | nios2-* \ ++ | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | orion-* \ +@@ -796,7 +794,7 @@ + os=-mingw64 + ;; + mingw32) +- basic_machine=i386-pc ++ basic_machine=i686-pc + os=-mingw32 + ;; + mingw32ce) +@@ -832,7 +830,7 @@ + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + msys) +- basic_machine=i386-pc ++ basic_machine=i686-pc + os=-msys + ;; + mvs) +@@ -1354,7 +1352,7 @@ + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ +- | -sym* | -kopensolaris* \ ++ | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ +@@ -1500,9 +1498,6 @@ + -aros*) + os=-aros + ;; +- -kaos*) +- os=-kaos +- ;; + -zvmoe) + os=-zvmoe + ;; +@@ -1551,6 +1546,9 @@ + c4x-* | tic4x-*) + os=-coff + ;; ++ c8051-*) ++ os=-elf ++ ;; + hexagon-*) + os=-elf + ;; +@@ -1594,6 +1592,9 @@ + mips*-*) + os=-elf + ;; ++ or1k-*) ++ os=-elf ++ ;; + or32-*) + os=-coff + ;; +diff -r c3896275c0f6 configure.ac +--- a/configure.ac ++++ b/configure.ac +@@ -4666,19 +4666,19 @@ + AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix]) + AC_OUTPUT + +-echo "creating Modules/Setup" ++echo "creating Modules/Setup" >&AS_MESSAGE_FD + if test ! -f Modules/Setup + then + cp $srcdir/Modules/Setup.dist Modules/Setup + fi + +-echo "creating Modules/Setup.local" ++echo "creating Modules/Setup.local" >&AS_MESSAGE_FD + if test ! -f Modules/Setup.local + then + echo "# Edit this file for local setup changes" >Modules/Setup.local + fi + +-echo "creating Makefile" ++echo "creating Makefile" >&AS_MESSAGE_FD + $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \ + -s Modules Modules/Setup.config \ + Modules/Setup.local Modules/Setup +diff -r c3896275c0f6 setup.py +--- a/setup.py ++++ b/setup.py +@@ -1945,7 +1945,7 @@ + undef_macros = [] + if '--with-system-libmpdec' in sysconfig.get_config_var("CONFIG_ARGS"): + include_dirs = [] +- libraries = ['mpdec'] ++ libraries = [':libmpdec.so.2'] + sources = ['_decimal/_decimal.c'] + depends = ['_decimal/docstrings.h'] + else: --- python3.3-3.3.3.orig/debian/patches/hurd-disable-nonworking-constants.diff +++ python3.3-3.3.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/socketmodule.c ++++ b/Modules/socketmodule.c +@@ -5956,9 +5956,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 +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -11598,12 +11598,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 + #ifdef O_EXEC + if (ins(d, "O_EXEC", (long)O_EXEC)) return -1; + #endif --- python3.3-3.3.3.orig/debian/patches/hurd-path_max.diff +++ python3.3-3.3.3/debian/patches/hurd-path_max.diff @@ -0,0 +1,13 @@ +--- a/Python/pythonrun.c ++++ b/Python/pythonrun.c +@@ -35,6 +35,10 @@ + #define PATH_MAX MAXPATHLEN + #endif + ++#ifdef __gnu_hurd__ ++#define PATH_MAX MAXPATHLEN ++#endif ++ + #ifndef Py_REF_DEBUG + #define PRINT_TOTAL_REFS() + #else /* Py_REF_DEBUG */ --- python3.3-3.3.3.orig/debian/patches/installed-testsuite.diff +++ python3.3-3.3.3/debian/patches/installed-testsuite.diff @@ -0,0 +1,15 @@ +# DP: Changes needed to run the installed testsuite. +# DP: Also removed: +# DP: - ctypes/test/test_macholib.py +# DP: - distutils/tests/test_bdist_wininst.py + +--- a/Lib/test/test_sysconfig.py ++++ b/Lib/test/test_sysconfig.py +@@ -340,6 +340,7 @@ + self.assertEqual(status, 0) + self.assertEqual(my_platform, test_platform) + ++ @unittest.skipUnless(sysconfig.is_python_build(), "test only in build location") + def test_srcdir(self): + # See Issues #15322, #15364. + srcdir = sysconfig.get_config_var('srcdir') --- python3.3-3.3.3.orig/debian/patches/kfreebsd-testsuite.diff +++ python3.3-3.3.3/debian/patches/kfreebsd-testsuite.diff @@ -0,0 +1,11 @@ +--- a/Lib/test/test_socket.py ++++ b/Lib/test/test_socket.py +@@ -825,7 +825,7 @@ + # Find one service that exists, then check all the related interfaces. + # I've ordered this by protocols that have both a tcp and udp + # protocol, at least for modern Linuxes. +- if (sys.platform.startswith(('freebsd', 'netbsd')) ++ if (sys.platform.startswith(('freebsd', 'netbsd', 'gnukfreebsd')) + or sys.platform in ('linux', 'darwin')): + # avoid the 'echo' service on this platform, as there is an + # assumption breaking non-standard port/protocol entry --- python3.3-3.3.3.orig/debian/patches/kfreebsd-xattrs.diff +++ python3.3-3.3.3/debian/patches/kfreebsd-xattrs.diff @@ -0,0 +1,13 @@ +# DP: Don't define USE_XATTRS on kfreebsd and the Hurd. + +--- a/Modules/posixmodule.c ++++ b/Modules/posixmodule.c +@@ -114,7 +114,7 @@ + #undef HAVE_SCHED_SETAFFINITY + #endif + +-#if defined(HAVE_SYS_XATTR_H) && defined(__GLIBC__) ++#if defined(HAVE_SYS_XATTR_H) && defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__GNU__) + #define USE_XATTRS + #endif + --- python3.3-3.3.3.orig/debian/patches/langpack-gettext.diff +++ python3.3-3.3.3/debian/patches/langpack-gettext.diff @@ -0,0 +1,36 @@ +# 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 + +Index: b/Lib/gettext.py +=================================================================== +--- a/Lib/gettext.py ++++ b/Lib/gettext.py +@@ -378,11 +378,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.3-3.3.3.orig/debian/patches/lib-argparse.diff +++ python3.3-3.3.3/debian/patches/lib-argparse.diff @@ -0,0 +1,22 @@ +# DP: argparse.py: Make the gettext import conditional + +--- a/Lib/argparse.py ++++ b/Lib/argparse.py +@@ -90,7 +90,16 @@ + import sys as _sys + import textwrap as _textwrap + +-from gettext import gettext as _, ngettext ++try: ++ from gettext import gettext as _, ngettext ++except ImportError: ++ def _(message): ++ return message ++ def ngettext(singular,plural,n): ++ if n == 1: ++ return singular ++ else: ++ return plural + + + SUPPRESS = '==SUPPRESS==' --- python3.3-3.3.3.orig/debian/patches/lib2to3-no-pickled-grammar.diff +++ python3.3-3.3.3/debian/patches/lib2to3-no-pickled-grammar.diff @@ -0,0 +1,14 @@ +--- a/Lib/lib2to3/pgen2/driver.py ++++ b/Lib/lib2to3/pgen2/driver.py +@@ -119,7 +119,10 @@ + if force or not _newer(gp, gt): + logger.info("Generating grammar tables from %s", gt) + g = pgen.generate_grammar(gt) +- if save: ++ # the pickle files mismatch, when built on different architectures. ++ # don't save these for now. An alternative solution might be to ++ # include the multiarch triplet into the file name ++ if False: + logger.info("Writing grammar tables to %s", gp) + try: + g.dump(gp) --- python3.3-3.3.3.orig/debian/patches/libffi-shared.diff +++ python3.3-3.3.3/debian/patches/libffi-shared.diff @@ -0,0 +1,11 @@ +--- a/setup.py ++++ b/setup.py +@@ -1930,7 +1930,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.3-3.3.3.orig/debian/patches/linecache.diff +++ python3.3-3.3.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.3-3.3.3.orig/debian/patches/link-opt.diff +++ python3.3-3.3.3/debian/patches/link-opt.diff @@ -0,0 +1,24 @@ +# DP: Call the linker with -O1 -Bsymbolic-functions + +--- a/configure.ac ++++ b/configure.ac +@@ -2005,8 +2005,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";; +@@ -2104,7 +2104,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.3-3.3.3.orig/debian/patches/link-timemodule.diff +++ python3.3-3.3.3/debian/patches/link-timemodule.diff @@ -0,0 +1,11 @@ +--- a/Modules/Setup.dist ++++ b/Modules/Setup.dist +@@ -166,7 +166,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 -lrt # -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.3-3.3.3.orig/debian/patches/locale-module.diff +++ python3.3-3.3.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 +@@ -1537,8 +1537,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.3-3.3.3.orig/debian/patches/lto-link-flags.diff +++ python3.3-3.3.3/debian/patches/lto-link-flags.diff @@ -0,0 +1,20 @@ +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -129,7 +129,7 @@ + EXT_SUFFIX= @EXT_SUFFIX@ + SO= $(SHLIB_SUFFIX) + LDSHARED= @LDSHARED@ $(PY_LDFLAGS) +-BLDSHARED= @BLDSHARED@ $(PY_LDFLAGS) ++BLDSHARED= @BLDSHARED@ $(PY_LDFLAGS) $(PY_CFLAGS) + LDCXXSHARED= @LDCXXSHARED@ + DESTSHARED= $(BINLIBDEST)/lib-dynload + +@@ -489,7 +489,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) pybuilddir.txt + $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print(get_platform()+"-"+sys.version[0:3])' >platform --- python3.3-3.3.3.orig/debian/patches/makesetup-bashism.diff +++ python3.3-3.3.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.3-3.3.3.orig/debian/patches/multiarch.diff +++ python3.3-3.3.3/debian/patches/multiarch.diff @@ -0,0 +1,149 @@ +Index: b/Lib/sysconfig.py +=================================================================== +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -359,6 +359,8 @@ + config_dir_name = 'config-%s%s' % (_PY_VERSION_SHORT, sys.abiflags) + else: + config_dir_name = 'config' ++ if hasattr(sys.implementation, '_multiarch'): ++ config_dir_name += '-%s' % sys.implementation._multiarch + return os.path.join(get_path('stdlib'), config_dir_name, 'Makefile') + + def _generate_posix_vars(): +@@ -561,6 +563,12 @@ + # the init-function. + _CONFIG_VARS['userbase'] = _getuserbase() + ++ multiarch = get_config_var('MULTIARCH') ++ if multiarch: ++ _CONFIG_VARS['multiarchsubdir'] = '/' + multiarch ++ else: ++ _CONFIG_VARS['multiarchsubdir'] = '' ++ + # Always convert srcdir to an absolute path + srcdir = _CONFIG_VARS.get('srcdir', _PROJECT_BASE) + if os.name == 'posix': +Index: b/Lib/distutils/sysconfig.py +=================================================================== +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -111,6 +111,9 @@ + incdir = os.path.join(get_config_var('srcdir'), 'Include') + return os.path.normpath(incdir) + python_dir = 'python' + get_python_version() + build_flags ++ if not python_build and plat_specific: ++ import sysconfig ++ return sysconfig.get_path('platinclude') + return os.path.join(prefix, "include", python_dir) + elif os.name == "nt": + return os.path.join(prefix, "include") +@@ -278,6 +281,8 @@ + return os.path.join(_sys_home or project_base, "Makefile") + lib_dir = get_python_lib(plat_specific=0, standard_lib=1) + config_file = 'config-{}{}'.format(get_python_version(), build_flags) ++ if hasattr(sys.implementation, '_multiarch'): ++ config_file += '-%s' % sys.implementation._multiarch + return os.path.join(lib_dir, config_file, 'Makefile') + + +Index: b/Makefile.pre.in +=================================================================== +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -669,6 +669,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 + +@@ -680,6 +681,7 @@ + Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile + $(CC) -c $(PY_CORE_CFLAGS) \ + -DABIFLAGS='"$(ABIFLAGS)"' \ ++ -DMULTIARCH='"$(MULTIARCH)"' \ + -o $@ $(srcdir)/Python/sysmodule.c + + $(IO_OBJS): $(IO_H) +@@ -1022,7 +1024,7 @@ + (cd $(DESTDIR)$(MANDIR)/man1; $(LN) -s python$(VERSION).1 python3.1) + + # Install the library +-PLATDIR= plat-$(MACHDEP) ++PLATDIR= plat-$(MULTIARCH) + EXTRAPLATDIR= @EXTRAPLATDIR@ + MACHDEPS= $(PLATDIR) $(EXTRAPLATDIR) + XMLLIBSUBDIRS= xml xml/dom xml/etree xml/parsers xml/sax +@@ -1159,6 +1161,10 @@ + $(srcdir)/Lib/$(PLATDIR): + mkdir $(srcdir)/Lib/$(PLATDIR) + cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen ++ if [ -n "$(MULTIARCH)" ]; then \ ++ cp -p $(srcdir)/Lib/plat-linux/*.py $(srcdir)/Lib/$(PLATDIR)/.; \ ++ rm -f $(srcdir)/Lib/$(PLATDIR)/IN.py; \ ++ fi + export PATH; PATH="`pwd`:$$PATH"; \ + export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \ + export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \ +@@ -1197,10 +1203,10 @@ + + # Install the library and miscellaneous stuff needed for extending/embedding + # This goes into $(exec_prefix) +-LIBPL= $(LIBDEST)/config-$(LDVERSION) ++LIBPL= $(LIBDEST)/config-$(LDVERSION)-$(MULTIARCH) + + # pkgconfig directory +-LIBPC= $(LIBDIR)/pkgconfig ++LIBPC= $(LIBDIR)/$(MULTIARCH)/pkgconfig + + libainstall: all python-config + @for i in $(LIBDIR) $(LIBPL) $(LIBPC); \ +Index: b/Python/dynload_shlib.c +=================================================================== +--- a/Python/dynload_shlib.c ++++ b/Python/dynload_shlib.c +@@ -48,6 +48,9 @@ + ".exe", + ".EXE", + #else /* !__VMS */ ++#ifdef MULTIARCH ++ "." SOABI "-" MULTIARCH ".so", ++#endif + "." SOABI ".so", + ".abi" PYTHON_ABI_STRING ".so", + ".so", +Index: b/Modules/Setup.dist +=================================================================== +--- a/Modules/Setup.dist ++++ b/Modules/Setup.dist +@@ -91,7 +91,7 @@ + TESTPATH= + + # Path components for machine- or system-dependent modules and shared libraries +-MACHDEPPATH=:plat-$(MACHDEP) ++MACHDEPPATH=:plat-$(MULTIARCH) + EXTRAMACHDEPPATH= + + COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH) +Index: b/Python/sysmodule.c +=================================================================== +--- a/Python/sysmodule.c ++++ b/Python/sysmodule.c +@@ -1534,6 +1534,15 @@ + if (res < 0) + goto error; + ++ /* For Debian multiarch support. */ ++ value = PyUnicode_FromString(MULTIARCH); ++ if (value == NULL) ++ goto error; ++ res = PyDict_SetItemString(impl_info, "_multiarch", value); ++ Py_DECREF(value); ++ if (res < 0) ++ goto error; ++ + /* dict ready */ + + ns = _PyNamespace_New(impl_info); --- python3.3-3.3.3.orig/debian/patches/ncurses-configure.diff +++ python3.3-3.3.3/debian/patches/ncurses-configure.diff @@ -0,0 +1,61 @@ +# DP: Fix ncurses configure checks + +--- a/configure.ac ++++ b/configure.ac +@@ -1512,11 +1512,9 @@ + + # checks for header files + AC_HEADER_STDC +-ac_save_cppflags="$CPPFLAGS" +-CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" +-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 process.h pthread.h \ ++ieeefp.h io.h langinfo.h libintl.h process.h pthread.h \ + sched.h shadow.h signal.h stdint.h stropts.h termios.h \ + unistd.h utime.h \ + poll.h sys/devpoll.h sys/epoll.h sys/poll.h \ +@@ -1527,7 +1525,6 @@ + sys/times.h sys/types.h sys/uio.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 alloca.h) +-CPPFLAGS=$ac_save_cppflags + AC_HEADER_DIRENT + AC_HEADER_MAJOR + +@@ -1547,14 +1544,6 @@ + #endif + ]) + +- +-# 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 +@@ -4282,8 +4271,19 @@ + [Define if you have struct stat.st_mtimensec]) + fi + ++# first curses header check + 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, --- python3.3-3.3.3.orig/debian/patches/no-large-file-support.diff +++ python3.3-3.3.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.3-3.3.3.orig/debian/patches/no-zip-on-sys.path.diff +++ python3.3-3.3.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 +@@ -474,7 +474,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; +@@ -677,6 +679,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() */ +@@ -689,6 +692,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) +@@ -734,7 +738,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)); +@@ -754,9 +760,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.3-3.3.3.orig/debian/patches/platform-lsbrelease.diff +++ python3.3-3.3.3/debian/patches/platform-lsbrelease.diff @@ -0,0 +1,50 @@ +# DP: Use /etc/lsb-release to identify the platform. + +--- a/Lib/platform.py ++++ b/Lib/platform.py +@@ -261,7 +261,7 @@ + _supported_dists = ( + 'SuSE', 'debian', 'fedora', 'redhat', 'centos', + 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', +- 'UnitedLinux', 'turbolinux', 'arch', 'mageia') ++ 'UnitedLinux', 'turbolinux', 'arch', 'mageia', 'Ubuntu') + + def _parse_release_file(firstline): + +@@ -290,6 +290,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, +@@ -314,6 +318,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: ++ with open("/etc/lsb-release", "rU") as etclsbrel: ++ 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.3-3.3.3.orig/debian/patches/profiled-build.diff +++ python3.3-3.3.3/debian/patches/profiled-build.diff @@ -0,0 +1,82 @@ +# DP: Ignore errors in the profile task. + +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -463,7 +463,20 @@ + + run_profile_task: + : # FIXME: can't run for a cross build +- $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK) ++ task="$(PROFILE_TASK)"; \ ++ case "$$task" in \ ++ *--next=*) \ ++ maxruns=500; \ ++ batch=$$(echo $$task | sed -n 's/.*--next=\([^ ]*\) .*/\1/p'); \ ++ while [ $$maxruns -gt 0 ]; do \ ++ $(RUNSHARED) ./$(BUILDPYTHON) $$task; \ ++ maxruns=$$(expr $$maxruns - $$batch); \ ++ [ -f $(srcdir)/build/pynexttest ] && continue; \ ++ break; \ ++ done;; \ ++ *) \ ++ $(RUNSHARED) ./$(BUILDPYTHON) $$task; \ ++ esac + + build_all_use_profile: + $(MAKE) all CFLAGS="$(CFLAGS) -fprofile-use -fprofile-correction" +--- a/Lib/test/regrtest.py ++++ b/Lib/test/regrtest.py +@@ -255,7 +255,7 @@ + + + def main(tests=None, testdir=None, verbose=0, quiet=False, +- exclude=False, single=False, randomize=False, fromfile=None, ++ exclude=False, single=0, randomize=False, fromfile=None, + findleaks=False, use_resources=None, trace=False, coverdir='coverage', + runleaks=False, huntrleaks=False, verbose2=False, print_slow=False, + random_seed=None, use_mp=None, verbose3=False, forever=False, +@@ -306,7 +306,7 @@ + 'runleaks', 'huntrleaks=', 'memlimit=', 'randseed=', + 'multiprocess=', 'coverage', 'slaveargs=', 'forever', 'debug', + 'start=', 'nowindows', 'header', 'testdir=', 'timeout=', 'wait', +- 'failfast', 'match=']) ++ 'failfast', 'match=', 'next=']) + except getopt.error as msg: + usage(msg) + +@@ -340,7 +340,9 @@ + elif o in ('-S', '--start'): + start = a + elif o in ('-s', '--single'): +- single = True ++ single = 1 ++ elif o == '--next': ++ single = int(a) + elif o in ('-o', '--slow'): + print_slow = True + elif o in ('-r', '--randomize'): +@@ -535,7 +537,7 @@ + args = [] + + # For a partial run, we do not need to clutter the output. +- if verbose or header or not (quiet or single or tests or args): ++ if verbose or header or not (quiet or single != 1 or tests or args): + # Print basic platform information + print("==", platform.python_implementation(), *sys.version.split()) + print("== ", platform.platform(aliased=True), +@@ -552,9 +554,13 @@ + + selected = tests or args or alltests + if single: +- selected = selected[:1] ++ first_selected = selected[0] ++ index_selected = alltests.index(first_selected) ++ if index_selected + single > len(alltests): ++ single = len(alltests) - index_selected ++ selected = alltests[index_selected:index_selected+single] + try: +- next_single_test = alltests[alltests.index(selected[0])+1] ++ next_single_test = alltests[index_selected+single] + except IndexError: + next_single_test = None + # Remove all the selected tests that precede start if it's set. --- python3.3-3.3.3.orig/debian/patches/revert-r83234.diff +++ python3.3-3.3.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.3-3.3.3.orig/debian/patches/revert-r83274.diff +++ python3.3-3.3.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.3-3.3.3.orig/debian/patches/series.in +++ python3.3-3.3.3/debian/patches/series.in @@ -0,0 +1,57 @@ +hg-updates.diff +deb-setup.diff +deb-locations.diff +site-locations.diff +distutils-install-layout.diff +locale-module.diff +distutils-link.diff +distutils-sysconfig.diff +test-sundry.diff +tkinter-import.diff +gdbm-import.diff +link-opt.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-disable-nonworking-constants.diff +enable-fpectl.diff +statvfs-f_flag-constants.diff +#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 +#endif +hurd-path_max.diff +#ifdef OLD_SPHINX +doc-build.diff +revert-r83234.diff +revert-r83274.diff +#endif +#link-system-expat.diff +disable-sem-check.diff +lib-argparse.diff +ctypes-arm.diff +link-timemodule.diff +lto-link-flags.diff +libffi-shared.diff +avoid-rpath.diff +multiarch.diff +ncurses-configure.diff +distutils-init.diff +lib2to3-no-pickled-grammar.diff +ext-no-libpython-link.diff +add-python-config-sh.diff +kfreebsd-xattrs.diff +installed-testsuite.diff +test-no-random-order.diff +atomic-pyc-rename.diff +kfreebsd-testsuite.diff --- python3.3-3.3.3.orig/debian/patches/setup-modules.diff +++ python3.3-3.3.3/debian/patches/setup-modules.diff @@ -0,0 +1,50 @@ +# DP: Modules/Setup.dist: patches to build some extensions statically + +--- a/Modules/Setup.dist ++++ b/Modules/Setup.dist +@@ -171,7 +171,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 _elementtree.c -lexpat # elementtree accelerator + #_pickle _pickle.c # pickle accelerator + #_datetime _datetimemodule.c # datetime accelerator + #_bisect _bisectmodule.c # Bisection algorithms +@@ -200,10 +200,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). +@@ -245,6 +242,7 @@ + #_sha256 sha256module.c + #_sha512 sha512module.c + ++#_hashlib _hashopenssl.c -lssl -lcrypto + + # The _tkinter module. + # +@@ -333,6 +331,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. +@@ -367,7 +366,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 pyexpat.c -lexpat + + # Hye-Shik Chang's CJKCodecs + --- python3.3-3.3.3.orig/debian/patches/site-locations.diff +++ python3.3-3.3.3/debian/patches/site-locations.diff @@ -0,0 +1,49 @@ +# DP: Set site-packages/dist-packages + +--- a/Lib/site.py ++++ b/Lib/site.py +@@ -7,12 +7,18 @@ + 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. ++lib/python3/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. ++ + If a file named "pyvenv.cfg" exists one directory above sys.executable, + sys.prefix and sys.exec_prefix are set to that directory and + it is also checked for site-packages and site-python (sys.base_prefix and +@@ -303,10 +309,21 @@ + if sys.platform in ('os2emx', 'riscos'): + sitepackages.append(os.path.join(prefix, "Lib", "site-packages")) + elif os.sep == '/': ++ if 'VIRTUAL_ENV' in os.environ: ++ sitepackages.append(os.path.join(prefix, "lib", ++ "python" + sys.version[:3], ++ "site-packages")) ++ 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")) ++ "python" + sys.version[:3], ++ "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.3-3.3.3.orig/debian/patches/statvfs-f_flag-constants.diff +++ python3.3-3.3.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 +@@ -11823,6 +11823,43 @@ + if (ins(d, "F_TEST", (long)F_TEST)) return -1; + #endif + ++ /* 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.3-3.3.3.orig/debian/patches/sysconfig-debian-schemes.diff +++ python3.3-3.3.3/debian/patches/sysconfig-debian-schemes.diff @@ -0,0 +1,67 @@ +# DP: Add schemes 'deb_system' and 'posix_local', make the latter the default + +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -32,6 +32,30 @@ + 'scripts': '{base}/bin', + 'data': '{base}', + }, ++ 'deb_system': { ++ 'stdlib': '{installed_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': ++ '{installed_base}/include/python{py_version_short}{abiflags}', ++ 'platinclude': ++ '{installed_platbase}/include/python{py_version_short}{abiflags}', ++ 'scripts': '{base}/bin', ++ 'data': '{base}', ++ }, ++ 'posix_local': { ++ 'stdlib': '{installed_base}/lib/python{py_version_short}', ++ 'platstdlib': '{platbase}/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': ++ '{installed_base}/local/include/python{py_version_short}{abiflags}', ++ 'platinclude': ++ '{installed_platbase}/local/include/python{py_version_short}{abiflags}', ++ 'scripts': '{base}/local/bin', ++ 'data': '{base}', ++ }, + 'posix_home': { + 'stdlib': '{installed_base}/lib/python', + 'platstdlib': '{base}/lib/python', +@@ -162,7 +186,7 @@ + _PYTHON_BUILD = is_python_build(True) + + if _PYTHON_BUILD: +- for scheme in ('posix_prefix', 'posix_home'): ++ for scheme in ('posix_prefix', 'posix_home', 'posix_local', 'deb_system'): + _INSTALL_SCHEMES[scheme]['include'] = '{srcdir}/Include' + _INSTALL_SCHEMES[scheme]['platinclude'] = '{projectbase}/.' + +@@ -200,7 +224,12 @@ + def _get_default_scheme(): + if os.name == 'posix': + # the default scheme for posix is posix_prefix +- return 'posix_prefix' ++ if 'real_prefix' in sys.__dict__ or 'VIRTUAL_ENV' in os.environ: ++ # virtual environments ++ return 'posix_prefix' ++ else: ++ # Debian default ++ return 'posix_local' + return os.name + + +@@ -485,7 +514,7 @@ + else: + inc_dir = _sys_home or _PROJECT_BASE + else: +- inc_dir = get_path('platinclude') ++ inc_dir = get_path('platinclude', 'posix_prefix') + return os.path.join(inc_dir, 'pyconfig.h') + + --- python3.3-3.3.3.orig/debian/patches/sysconfigdata.diff +++ python3.3-3.3.3/debian/patches/sysconfigdata.diff @@ -0,0 +1,76 @@ +# DP: Issue #15298: Generate _sysconfigdata.py in the build dir, not the source dir. + +diff -r 2ecdda96f970 Lib/sysconfig.py +--- a/Lib/sysconfig.py Tue Jul 10 18:27:54 2012 +0200 ++++ b/Lib/sysconfig.py Tue Jul 10 22:06:43 2012 +0200 +@@ -390,7 +390,7 @@ + if _PYTHON_BUILD: + vars['LDSHARED'] = vars['BLDSHARED'] + +- destfile = os.path.join(os.path.dirname(__file__), '_sysconfigdata.py') ++ destfile = '_sysconfigdata.py' + with open(destfile, 'w', encoding='utf8') as f: + f.write('# system configuration generated and used by' + ' the sysconfig module\n') +diff -r 2ecdda96f970 Makefile.pre.in +--- a/Makefile.pre.in Tue Jul 10 18:27:54 2012 +0200 ++++ b/Makefile.pre.in Tue Jul 10 22:06:43 2012 +0200 +@@ -410,7 +410,7 @@ + Objects/unicodectype.o \ + Objects/weakrefobject.o + +-SYSCONFIGDATA=$(srcdir)/Lib/_sysconfigdata.py ++SYSCONFIGDATA=_sysconfigdata.py + + ########################################################################## + # objects that get linked into the Python library +@@ -472,6 +472,9 @@ + # Generate the sysconfig build-time data + $(SYSCONFIGDATA): $(BUILDPYTHON) + $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars ++ $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -c 'import os,sys ; from distutils.util import get_platform ; d=os.path.join("build", "lib."+get_platform()+"-"+sys.version[0:3]+("-pydebug" if hasattr(sys, "gettotalrefcount") else "")); print(d, end="")' > pybuilddir.txt ++ mkdir -p `cat pybuilddir.txt` ++ cp $(SYSCONFIGDATA) `cat pybuilddir.txt`/. + + # Build the shared modules + sharedmods: $(BUILDPYTHON) $(SYSCONFIGDATA) +@@ -1036,7 +1039,7 @@ + else true; \ + fi; \ + done +- @for i in $(srcdir)/Lib/*.py ; \ ++ @for i in $(srcdir)/Lib/*.py $(SYSCONFIGDATA); \ + do \ + if test -x $$i; then \ + $(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \ +diff -r 2ecdda96f970 setup.py +--- a/setup.py Tue Jul 10 18:27:54 2012 +0200 ++++ b/setup.py Tue Jul 10 22:06:43 2012 +0200 +@@ -33,10 +33,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: +@@ -250,12 +246,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.3-3.3.3.orig/debian/patches/test-no-random-order.diff +++ python3.3-3.3.3/debian/patches/test-no-random-order.diff @@ -0,0 +1,12 @@ +# DP: Don't run the test suite in random order. + +--- a/Tools/scripts/run_tests.py ++++ b/Tools/scripts/run_tests.py +@@ -33,7 +33,6 @@ + # Allow user-specified interpreter options to override our defaults. + args.extend(test.support.args_from_interpreter_flags()) + args.extend(['-m', 'test', # Run the test suite +- '-r', # Randomize test order + '-w', # Re-run failed tests in verbose mode + ]) + if sys.platform == 'win32': --- python3.3-3.3.3.orig/debian/patches/test-sundry.diff +++ python3.3-3.3.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 +@@ -48,7 +48,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.3-3.3.3.orig/debian/patches/tkinter-import.diff +++ python3.3-3.3.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 +@@ -37,7 +37,10 @@ + + import warnings + +-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 python3-tk package') + TclError = _tkinter.TclError + from tkinter.constants import * + import re --- python3.3-3.3.3.orig/debian/pdb.1.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/pydoc.1.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/pygettext.1 +++ python3.3-3.3.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.3-3.3.3.orig/debian/pyhtml2devhelp.py +++ python3.3-3.3.3/debian/pyhtml2devhelp.py @@ -0,0 +1,273 @@ +#! /usr/bin/python3 + +from html.parser import HTMLParser +import formatter +import os, sys, re + +class PyHTMLParser(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()): + 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 handle_starttag(self, tag, attrs): + if tag == 'a': + self.start_a(attrs) + elif tag == 'li': + self.start_li(attrs) + + def handle_endtag(self, tag): + if tag == 'a': + self.end_a() + elif tag == 'li': + self.end_li() + + 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 'class' in self.link: + 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 = open(self.basedir + '/' + href, encoding='latin_1').read() + parser.feed(text) + parser.finish() + parser.close() + if parent in self.parents: + self.parents.remove(parent) + +class PyIdxHTMLParser(HTMLParser): + def __init__(self, formatter, basedir, fn, indent): + 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 handle_starttag(self, tag, attrs): + if tag == 'a': + self.start_a(attrs) + elif tag == 'dl': + self.start_dl(attrs) + elif tag == 'dt': + self.start_dt(attrs) + elif tag == 'h2': + self.start_h2(attrs) + elif tag == 'td': + self.start_td(attrs) + elif tag == 'table': + self.start_table(attrs) + + def handle_endtag(self, tag): + if tag == 'a': + self.end_a() + elif tag == 'dl': + self.end_dl() + elif tag == 'dt': + self.end_dt() + elif tag == 'h2': + self.end_h2() + elif tag == 'td': + self.end_td() + elif tag == 'table': + self.end_table() + + 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 end_h2(self): + pass + + def start_td(self, attrs): + self.indented = False + self.last_text = '' + + def end_td(self): + pass + + 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', ' ') + text = text.replace("Whats ", "What's ") + 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 handle_entityref(self, name): + self.data += '&%s;' % name + +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, version)) + print('') + parser.parse_file(fn) + print('') + + print('') + + fn = 'genindex-all.html' + parser = PyIdxHTMLParser(formatter.NullFormatter(), base, fn, indent=1) + text = open(base + '/' + fn, encoding='latin_1').read() + parser.feed(text) + parser.close() + + print('') + print('') + +main() --- python3.3-3.3.3.orig/debian/pylogo.xpm +++ python3.3-3.3.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.3-3.3.3.orig/debian/pymindeps.py +++ python3.3-3.3.3/debian/pymindeps.py @@ -0,0 +1,177 @@ +#! /usr/bin/python3 + +# Matthias Klose +# Modified to only exclude module imports from a given module. + +# 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 os, sys, pprint +import modulefinder +import imp + +class mymf(modulefinder.ModuleFinder): + def __init__(self,*args,**kwargs): + self._depgraph = {} + self._types = {} + self._last_caller = None + modulefinder.ModuleFinder.__init__(self, *args, **kwargs) + + def import_hook(self, name, caller=None, fromlist=None, level=-1): + old_last_caller = self._last_caller + try: + self._last_caller = caller + return modulefinder.ModuleFinder.import_hook(self, name, caller, + fromlist, level) + finally: + self._last_caller = old_last_caller + + def import_module(self, partnam, fqname, parent): + m = modulefinder.ModuleFinder.import_module(self, + partnam, fqname, parent) + if m is not None and self._last_caller: + caller = self._last_caller.__name__ + if '.' in caller: + caller = caller[:caller.index('.')] + callee = m.__name__ + if '.' in callee: + callee = callee[:callee.index('.')] + #print "XXX last_caller", caller, "MOD", callee + #self._depgraph.setdefault(self._last_caller.__name__,{})[r.__name__] = 1 + #if caller in ('pdb', 'doctest') or callee in ('pdb', 'doctest'): + # print caller, "-->", 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')), + #'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')), + 'reprlib': set(('_dummy_thread',)), + #'socket': set(('_ssl',)), + 'subprocess': set(('threading',)), + 'sysconfig': set(('pprint','_osx_support')), + 'tempfile': set(('_dummy_thread',)), + } + +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.3-3.3.3.orig/debian/pysetup3.1 +++ python3.3-3.3.3/debian/pysetup3.1 @@ -0,0 +1,42 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.40.4. +.TH PYSETUP3.3 "1" "January 2012" "pysetup3.3 3.3" "User Commands" +.SH NAME +pysetup3.3 \- pysetup tool +.SH SYNOPSIS +.B pysetup +[\fIoptions\fR] \fIaction \fR[\fIaction_options\fR] +.SH DESCRIPTION +.SS "Actions:" +.IP +run: Run one or several commands +metadata: Display the metadata of a project +install: Install a project +remove: Remove a project +search: Search for a project in the indexes +list: List installed projects +graph: Display a graph +create: Create a project +generate\-setup: Generate a backward\-compatible setup.py +.PP +To get more help on an action, use: +.IP +pysetup action \fB\-\-help\fR +.SS "Global options:" +.TP +\fB\-\-verbose\fR (\fB\-v\fR) +run verbosely (default) +.TP +\fB\-\-quiet\fR (\fB\-q\fR) +run quietly (turns verbosity off) +.TP +\fB\-\-dry\-run\fR (\fB\-n\fR) +don't actually do anything +.TP +\fB\-\-help\fR (\fB\-h\fR) +show detailed help message +.TP +\fB\-\-no\-user\-cfg\fR +ignore pydistutils.cfg in your home directory +.TP +\fB\-\-version\fR +Display the version --- python3.3-3.3.3.orig/debian/python3-config.1 +++ python3.3-3.3.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.3-3.3.3.orig/debian/pyvenv3.1 +++ python3.3-3.3.3/debian/pyvenv3.1 @@ -0,0 +1,34 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.40.10. +.TH PYVENV-3.3 "1" "June 2012" "pyvenv-3.3 3.3" "User Commands" +.SH NAME +pyvenv-3.3 \- create virtual python environments +.SH DESCRIPTION +usage: venv [\-h] [\-\-system\-site\-packages] [\-\-symlinks] [\-\-clear] [\-\-upgrade] +.IP +ENV_DIR [ENV_DIR ...] +.PP +Creates virtual Python environments in one or more target directories. +.SS "positional arguments:" +.TP +ENV_DIR +A directory to create the environment in. +.SS "optional arguments:" +.TP +\fB\-h\fR, \fB\-\-help\fR +show this help message and exit +.TP +\fB\-\-system\-site\-packages\fR +Give the virtual environment access to the system +site\-packages dir. +.TP +\fB\-\-symlinks\fR +Attempt to symlink rather than copy. +.TP +\fB\-\-clear\fR +Delete the environment directory if it already exists. +If not specified and the directory exists, an error is +raised. +.TP +\fB\-\-upgrade\fR +Upgrade the environment directory to use this version +of Python, assuming Python has been upgraded in\-place. --- python3.3-3.3.3.orig/debian/rules +++ python3.3-3.3.3/debian/rules @@ -0,0 +1,1381 @@ +#!/usr/bin/make -f + +unexport LANG LC_ALL LC_CTYPE LC_COLLATE LC_TIME LC_NUMERIC LC_MESSAGES +unexport CFLAGS CXXFLAGS LDFLAGS 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_BUILD_ARCH ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_ARCH) +DEB_BUILD_GNU_TYPE ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_GNU_TYPE) +DEB_HOST_ARCH ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH) +DEB_HOST_ARCH_ENDIAN ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH_ENDIAN) +DEB_HOST_ARCH_OS ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH_OS) +DEB_HOST_GNU_TYPE ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_GNU_TYPE) +DEB_HOST_MULTIARCH ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_MULTIARCH) + +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 -o "$$USER" = 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 +ifeq ($(on_buildd),yes) + ifneq (,$(filter $(DEB_HOST_ARCH), armel hppa mips mipsel mips64 mips64el s390 hurd-i386 kfreebsd-amd64 kfreebsd-i386)) + WITHOUT_CHECK := yes + endif + ifneq (,$(filter $(DEB_HOST_ARCH), armel hppa mips mipsel mips64 mips64el s390 hurd-i386)) + WITHOUT_BENCH := yes + endif +endif +ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + WITHOUT_BENCH := yes + WITHOUT_CHECK := yes +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) +distrelease := $(shell lsb_release -cs) + +VER=3.3 +SVER=3.3.3 +NVER=3.4 +PVER=python3.3 +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 +ifeq (,$(filter $(distrelease),lenny etch squeeze wheezy lucid maverick natty oneiric)) + bd_qual = :any +endif +ifeq (,$(filter $(distrelease),lenny etch squeeze wheezy lucid maverick natty oneiric)) + ma_filter = cat +else + ma_filter = grep -v '^Multi-Arch:' +endif + +CC=$(DEB_HOST_GNU_TYPE)-gcc +CXX=$(DEB_HOST_GNU_TYPE)-g++ + +DPKG_CPPFLAGS:= $(shell dpkg-buildflags --get CPPFLAGS) +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_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + ifeq ($(DEB_HOST_ARCH_OS),linux) + ifneq (,$(findstring $(DEB_HOST_ARCH), amd64 armel armhf i386 powerpc ppc64)) + with_pgo := yes + endif + endif +endif + +ifneq (,$(findstring $(DEB_HOST_ARCH), amd64 armel 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 + +p_lbase := lib$(PVER)-stdlib +p_lmin := lib$(PVER)-minimal +p_ldev := lib$(PVER)-dev +p_ldbg := lib$(PVER)-dbg +p_ltst := lib$(PVER)-testsuite + +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) + +d_lbase := debian/$(p_lbase) +d_lmin := debian/$(p_lmin) +d_ldev := debian/$(p_ldev) +d_ldbg := debian/$(p_ldbg) +d_ltst := debian/$(p_ltst) + +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_concurrent_futures test_ctypes \ + test_dbm_dumb test_dbm_ndbm test_pydoc test_sundry \ + test_signal test_ioctl test_gdb + +PROFILE_TASK = ../Lib/test/regrtest.py \ + -j 1 --next=20 -unone,decimal \ + -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) + + : # check that things are correctly built +ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + ifneq (,$(filter $(DEB_HOST_ARCH_OS), linux)) + cd $(buildd_static) && ./python -c 'from _multiprocessing import SemLock' + endif +endif + + touch stamps/stamp-build-static + +run-profile-task: + $(MAKE) -C $(buildd_static) \ + PROFILE_TASK='$(PROFILE_TASK)' run_profile_task + +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)m-pic.a libpython$(VER)m-pic.a + touch stamps/stamp-build-shared + +stamps/stamp-build-debug: stamps/stamp-configure-debug + dh_testdir + $(MAKE) $(NJOBS) -C $(buildd_debug) \ + EXTRA_CFLAGS="$(DEBUG_CFLAGS)" + 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) \ + EXTRA_CFLAGS="$(DEBUG_CFLAGS)" \ + libpython$(VER)dm.so pybuilddir.txt + touch stamps/stamp-build-shared-debug + +common_configure_args = \ + --prefix=/usr \ + --enable-ipv6 \ + --enable-loadable-sqlite-extensions \ + --with-dbmliborder=bdb:gdbm \ + --with-computed-gotos \ + --with-system-expat \ + +# --with-system-libmpdec \ + +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 + +ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + common_configure_args += --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) + config_site = ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=yes + ifeq (,$(filter $(DEB_HOST_ARCH),arm m68k)) + ifeq ($(DEB_HOST_ARCH_ENDIAN),little) + config_site += ac_cv_little_endian_double=yes + else + config_site += ac_cv_big_endian_double=yes + endif + endif +endif + +stamps/stamp-configure-shared: stamps/stamp-patch + rm -rf $(buildd_shared) + mkdir -p $(buildd_shared) + cd $(buildd_shared) && \ + CC="$(CC)" CXX="$(CXX)" CFLAGS="$(OPT_CFLAGS)" \ + CPPFLAGS="$(DPKG_CPPFLAGS)" LDFLAGS="$(DPKG_LDFLAGS)" \ + $(config_site) \ + ../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)" CXX="$(CXX)" CFLAGS="$(OPT_CFLAGS)" \ + CPPFLAGS="$(DPKG_CPPFLAGS)" LDFLAGS="$(DPKG_LDFLAGS)" \ + $(config_site) \ + ../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)" CXX="$(CXX)" CFLAGS="$(DEBUG_CFLAGS)" \ + CPPFLAGS="$(DPKG_CPPFLAGS)" LDFLAGS="$(DPKG_LDFLAGS)" \ + $(config_site) \ + ../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)" CXX="$(CXX)" CFLAGS="$(DEBUG_CFLAGS)" \ + CPPFLAGS="$(DPKG_CPPFLAGS)" LDFLAGS="$(DPKG_LDFLAGS)" \ + $(config_site) \ + ../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 +endef + +stamps/stamp-mincheck: stamps/stamp-build-static debian/PVER-minimal.README.Debian.in +ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + 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 \ + cd $(buildd_static) && ./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 +endif + touch stamps/stamp-mincheck + +TEST_RESOURCES = all +ifeq ($(on_buildd),yes) + TEST_RESOURCES := $(TEST_RESOURCES),-network,-urlfetch +endif +TESTOPTS = -j 1 -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 + +# FIXME: re-enable once fixed, see #708652 +ifneq (,$(filter $(DEB_HOST_ARCH_OS), hurd)) + TEST_EXCLUDES += test_asyncore test_curses test_exceptions \ + test_faulthandler test_imaplib test_io test_logging test_mmap \ + test_random test_signal test_socket test_socketserver test_ssl \ + test_threading test_pydoc test_runpy test_telnetlib test_tk +endif + +# FIXME: re-enable once fixed, see #708653 +ifneq (,$(filter $(DEB_HOST_ARCH_OS), kfreebsd)) + TEST_EXCLUDES += test_io test_signal test_socket test_socketserver \ + test_threading test_threadsignals test_threaded_import \ + test_time test_pty test_curses +endif + +# for debug builds only +TEST_EXCLUDES += test_gdb + +ifneq (,$(TEST_EXCLUDES)) + TESTOPTS += -x $(sort $(TEST_EXCLUDES)) +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="$(filter-out test_gdb,$(TESTOPTS))"'\'; \ + 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: +ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + @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" +endif + 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 mips64 mips64el 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" \ + -e "s/@bd_qual@/$(bd_qual)/g" \ + debian/control.in \ + $(if $(with_udeb),debian/control.udeb) \ + | $(ma_filter) \ + > 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 -f Lib/dist-packages + rm -rf Lib/plat-$(DEB_HOST_MULTIARCH) + 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-3.1 + help2man --no-info --version-string=$(VER) --no-discard-stderr \ + --name 'pysetup tool' \ + pysetup$(VER) > debian/pysetup3.1 + help2man --no-info --version-string=$(VER) --no-discard-stderr \ + --name 'create virtual python environments' \ + pyvenv-$(VER) > debian/pyvenv3.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 + sed -e '/^OPT/s,-O3,-O2,' \ + -e 's/$(LTO_CFLAGS)//g' \ + -e 's,^RUNSHARED *=.*,RUNSHARED=,' \ + -e '/BLDLIBRARY/s/-L\. //' \ + $(buildd_shared)/$(shell cat $(buildd_shared)/pybuilddir.txt)/_sysconfigdata.py \ + > $(d)/$(scriptdir)/_sysconfigdata.py +else + $(MAKE) -C $(buildd_shared) install prefix=$(CURDIR)/$(d)/usr +endif + mkdir -p $(d)/usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)m + mv $(d)/usr/include/$(PVER)m/pyconfig.h \ + $(d)/usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)m/. + mv $(d)/usr/bin/python-config.sh $(d)/usr/bin/python$(VER)m-config + rm -f $(d)/$(scriptdir)/lib-dynload/*.py + sed -i 's/ -O3 / -O2 /g;s/$(LTO_CFLAGS)//g;s/-fprofile-use *-fprofile-correction//g' \ + $(d)/$(scriptdir)/_sysconfigdata.py + mv $(d)/$(scriptdir)/_sysconfigdata.py \ + $(d)/$(scriptdir)/plat-$(DEB_HOST_MULTIARCH)/_sysconfigdata_m.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 + + for i in $(d)/$(scriptdir)/lib-dynload/*.so; do \ + b=$$(basename $$i .cpython-33m.so); \ + d=$${b}.cpython-33m-$(DEB_HOST_MULTIARCH).so; \ + mv $$i $(d)/$(scriptdir)/lib-dynload/$$d; \ + done + + mv $(d)/usr/lib/libpython*.a $(d)/usr/lib/$(DEB_HOST_MULTIARCH)/ + + 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 + rm -f $(d)/$(scriptdir)/plat-*/regen + rm -f $(d)/$(scriptdir)/lib2to3/*.pickle + rm -f $(d)/usr/share/man/man1/python3.1 + + : # 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)m.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-3.1 $(d)/usr/share/man/man1/2to3-$(VER).1 + cp -p debian/pysetup3.1 $(d)/usr/share/man/man1/pysetup$(VER).1 + cp -p debian/pyvenv3.1 $(d)/usr/share/man/man1/pyvenv-$(VER).1 + + : # versioned install only + rm -f $(d)/usr/bin/{2to3,idle3,pydoc3,pysetup3,python3,python3-config} + rm -f $(d)/usr/lib/*/pkgconfig/python3.pc + + dh_installdirs -p$(p_lib) \ + usr/lib/$(DEB_HOST_MULTIARCH) \ + $(scriptdir)/config-$(VER)m-$(DEB_HOST_MULTIARCH) \ + usr/share/doc + : # install the shared library + cp -p $(buildd_shared)/libpython$(VER)m.so.1.0 \ + $(d_lib)/usr/lib/$(DEB_HOST_MULTIARCH)/ + dh_link -p$(p_lib) \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)m.so.1.0 \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)m.so.1 \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)m.so.1 \ + /$(scriptdir)/config-$(VER)m-$(DEB_HOST_MULTIARCH)/libpython$(VER)m.so \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)m.so.1 \ + /$(scriptdir)/config-$(VER)m-$(DEB_HOST_MULTIARCH)/libpython$(VER).so + + ln -sf $(p_base) $(d_lib)/usr/share/doc/$(p_lib) + + ln -sf libpython$(VER)m.so.1 $(d)/usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)m.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=,' \ + -e '/BLDLIBRARY/s/-L\. //' \ + $(buildd_shared)/Makefile \ + > $(d)/$(scriptdir)/config-$(VER)m-$(DEB_HOST_MULTIARCH)/Makefile + + : # Move the minimal libraries into $(p_lmin). + dh_installdirs -p$(p_lmin) \ + etc/$(PVER) \ + usr/bin \ + usr/share/man/man1 \ + $(scriptdir)/lib-dynload + -cd $(d); for i in $(MIN_EXTS); do \ + test -e $(scriptdir)/lib-dynload/$$i.*.so \ + && echo $(scriptdir)/lib-dynload/$$i.*.so; \ + done + + DH_COMPAT=2 dh_movefiles -p$(p_lmin) --sourcedir=$(d) \ + $(foreach i,$(MIN_MODS),$(scriptdir)/$(i).py) \ + $(foreach i,$(MIN_PACKAGES),$(scriptdir)/$(i)) \ + $(foreach i,$(MIN_ENCODINGS),$(scriptdir)/$(i)) \ + $(scriptdir)/site.py \ + $(scriptdir)/_sysconfigdata.py \ + $(scriptdir)/plat-$(DEB_HOST_MULTIARCH)/_sysconfigdata_m.py \ + `cd $(d); for i in $(MIN_EXTS); do \ + test -e $(scriptdir)/lib-dynload/$$i.*.so \ + && echo $(scriptdir)/lib-dynload/$$i.*.so; \ + done` + ls -l $(d_lmin)/$(scriptdir)/lib-dynload/*.so + + : # Move the binary into $(p_min). + dh_installdirs -p$(p_min) \ + usr/bin \ + usr/share/man/man1 + DH_COMPAT=2 dh_movefiles -p$(p_min) --sourcedir=$(d) \ + usr/bin/python$(VER) \ + usr/bin/python$(VER)m \ + usr/share/man/man1/python$(VER).1 \ + usr/share/man/man1/python$(VER)m.1 + + 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_lmin)/etc/$(PVER)/ + dh_link -p$(p_lmin) \ + /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 + + cp $(d)/usr/bin/$(PVER)m-config $(d)/usr/bin/$(DEB_HOST_MULTIARCH)-$(PVER)m-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)m-config $(d)/usr/bin/$(DEB_HOST_MULTIARCH)-$(PVER)-config + + dh_installdirs -p$(p_ldev) \ + usr/bin \ + $(scriptdir) \ + usr/include \ + usr/share/man/man1 + + DH_COMPAT=2 dh_movefiles -p$(p_ldev) --sourcedir=$(d) \ + usr/bin/$(DEB_HOST_MULTIARCH)-$(PVER)*-config \ + usr/lib/python$(VER)/config-$(VER)m-$(DEB_HOST_MULTIARCH) \ + usr/include \ + usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)m.{a,so} \ + usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python-$(VER)*.pc \ + usr/lib/python$(VER)/distutils/command/wininst-*.exe + + sed 's/@subdir@/$(PVER)m/;s/@header@/pyconfig.h/' \ + debian/multiarch.h.in > $(d_ldev)/usr/include/$(PVER)m/pyconfig.h + + sed -i '/^Cflags:/s,$$, -I$${includedir}/$(DEB_HOST_MULTIARCH)/python$(VER)m,' \ + $(d_ldev)/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python-$(VER).pc + + dh_link -p$(p_ldev) \ + /usr/lib/$(PVER)/config-$(VER)m-$(DEB_HOST_MULTIARCH)/libpython$(VER)m.a \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)m.a + + cp -p $(buildd_shared)/libpython$(VER)m-pic.a \ + $(d_ldev)/usr/lib/python$(VER)/config-$(VER)m-$(DEB_HOST_MULTIARCH)/ + + : # symlinks for the "old" include directory name + ln -sf python$(VER)m $(d_ldev)/usr/include/python$(VER) + + dh_installdirs -p$(p_dev) \ + usr/share/doc/python$(VER) \ + usr/share/man/man1 \ + $(scriptdir) \ + $(scriptdir)/doc/html + 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/bin/python$(VER)*-config + + : # in $(p_ldev), prefix python-config with triplets + cp -p debian/python3-config.1 \ + $(d_ldev)/usr/share/man/man1/$(DEB_HOST_MULTIARCH)-$(PVER)m-config.1 + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)m-config.1.gz \ + $(d_ldev)/usr/share/man/man1/$(DEB_HOST_MULTIARCH)-$(PVER)-config.1.gz +ifneq ($(DEB_HOST_MULTIARCH),$(DEB_HOST_GNU_TYPE)) + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)m-config \ + $(d_ldev)/usr/bin/$(DEB_HOST_GNU_TYPE)-$(PVER)m-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config \ + $(d_ldev)/usr/bin/$(DEB_HOST_GNU_TYPE)-$(PVER)-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config.1.gz \ + $(d_ldev)/usr/share/man/man1/$(DEB_HOST_GNU_TYPE)-$(PVER)-config.1.gz + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config.1.gz \ + $(d_ldev)/usr/share/man/man1/$(DEB_HOST_GNU_TYPE)-$(PVER)m-config.1.gz +endif + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)m-config $(d_dev)/usr/bin/$(PVER)m-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)m-config.1.gz $(d_dev)/usr/share/man/man1/$(PVER)m-config.1.gz + + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config $(d_dev)/usr/bin/$(PVER)-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config.1.gz $(d_dev)/usr/share/man/man1/$(PVER)-config.1.gz + +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_lbase) + DH_COMPAT=2 dh_movefiles -p$(p_lbase) --sourcedir=$(d) \ + $(scriptdir)/test/{regrtest.py,support,__init__.py,pystone.py} + + : # The complete testsuite into $(p_lbase) + DH_COMPAT=2 dh_movefiles -p$(p_ltst) --sourcedir=$(d) \ + $(scriptdir)/test \ + $(scriptdir)/ctypes/test \ + $(scriptdir)/distutils/tests \ + $(scriptdir)/lib2to3/tests \ + $(scriptdir)/sqlite3/test \ + $(scriptdir)/tkinter/test \ + $(scriptdir)/unittest/test + : # test_ctypes fails with test_macholib.py installed + rm -f $(d_ltst)/$(scriptdir)/ctypes/test/test_macholib.py + : # test_bdist_wininst fails, '*.exe' files are not installed + rm -f $(d_ltst)/$(scriptdir)/distutils/tests/test_bdist_wininst.py + + : # fixed upstream ... + chmod -x $(d_ltst)/$(scriptdir)/test/{test_dbm_gnu,test_dbm_ndbm}.py + + : # 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) --sourcedir=$(d) \ + 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 + + : # library files into $(p_lbase) + dh_installdirs -p$(p_lbase) \ + usr/lib + dh_movefiles -p$(p_lbase) \ + usr/lib/python$(VER) + + : # 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 + rm -f $(d_base)/usr/bin/pyvenv + + : # 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 +ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + $(buildd_static)/python debian/mkbinfmt.py $(PVER) \ + > $(d_min)/usr/share/binfmts/$(PVER) +else + $(PVER) debian/mkbinfmt.py $(PVER) > $(d_min)/usr/share/binfmts/$(PVER) +endif + + : # 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 + : # install the Makefile of the shared python debug build + sed -e '/^OPT/s,-O3,-O2,' \ + -e 's/$(LTO_CFLAGS)//g' \ + -e 's,^RUNSHARED *=.*,RUNSHARED=,' \ + -e '/BLDLIBRARY/s/-L\. //' \ + $(buildd_shdebug)/Makefile \ + > $(d)-dbg/$(scriptdir)/config-$(VER)dm-$(DEB_HOST_MULTIARCH)/Makefile + sed -e 's,^RUNSHARED *=.*,RUNSHARED=,' \ + -e '/BLDLIBRARY/s/-L\. //' \ + $(buildd_shdebug)/$(shell cat $(buildd_shdebug)/pybuilddir.txt)/_sysconfigdata.py \ + > $(d)-dbg/$(scriptdir)/_sysconfigdata.py + rm -f $(d)-dbg/$(scriptdir)/lib-dynload/_sysconfigdata.py + sed -i 's/ -O3 / -O2 /g;s/$(LTO_CFLAGS)//g;s/-fprofile-use *-fprofile-correction//g' \ + $(d)-dbg/$(scriptdir)/_sysconfigdata.py + mv $(d)-dbg/$(scriptdir)/_sysconfigdata.py \ + $(d)-dbg/$(scriptdir)/plat-$(DEB_HOST_MULTIARCH)/_sysconfigdata_dm.py + + mv $(d)-dbg/usr/lib/libpython*.a $(d)-dbg/usr/lib/$(DEB_HOST_MULTIARCH)/ + + for i in $(d)-dbg/$(scriptdir)/lib-dynload/*.so; do \ + b=$$(basename $$i .cpython-33dm.so); \ + d=$${b}.cpython-33dm-$(DEB_HOST_MULTIARCH).so; \ + mv $$i $(d)-dbg/$(scriptdir)/lib-dynload/$$d; \ + done + + dh_installdirs -p$(p_ldbg) \ + usr/bin \ + usr/share/man/man1 \ + $(scriptdir)/lib-dynload \ + $(scriptdir)/plat-$(DEB_HOST_MULTIARCH) \ + usr/include/$(PVER)dm \ + usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)dm \ + usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig + + cp -p $(d)-dbg/$(scriptdir)/lib-dynload/*.so \ + $(d_ldbg)/$(scriptdir)/lib-dynload/ + cp -p $(d)-dbg/$(scriptdir)/plat-$(DEB_HOST_MULTIARCH)/_sysconfigdata_dm.py \ + $(d_ldbg)/$(scriptdir)/plat-$(DEB_HOST_MULTIARCH)/ + cp -p $(buildd_shdebug)/libpython$(VER)dm.so.1.0 \ + $(d_ldbg)/usr/lib/$(DEB_HOST_MULTIARCH)/ + dh_link -p$(p_ldbg) \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)dm.so.1.0 \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)dm.so.1 \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)dm.so.1 \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)dm.so + sed -e '/^Libs:/s,-lpython$(VER),-lpython$(VER)dm,' \ + -e '/^Cflags:/s,$$, -I$${includedir}/$(DEB_HOST_MULTIARCH)/python$(VER)dm,' \ + $(d)-dbg/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python-$(VER).pc \ + > $(d_ldbg)/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/python-$(VER)-dbg.pc + + dh_installdirs -p$(p_dbg) \ + usr/bin \ + usr/share/man/man1 \ + 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)dm + ln -sf python$(VER)dm $(d_dbg)/usr/bin/$(PVER)-dbg + +ifneq ($(with_tk),yes) + rm -f $(d_ldbg)/$(scriptdir)/lib-dynload/_tkinter*.so + rm -f $(d_ldbg)/usr/lib/debug/$(scriptdir)/lib-dynload/_tkinter*.so +endif +ifneq ($(with_gdbm),yes) + rm -f $(d_ldbg)/$(scriptdir)/lib-dynload/_gdbm*.so + rm -f $(d_ldbg)/usr/lib/debug/$(scriptdir)/lib-dynload/_gdbm*.so +endif + + cp -a $(d)-dbg/$(scriptdir)/config-$(VER)dm-$(DEB_HOST_MULTIARCH) \ + $(d_ldbg)/$(scriptdir)/ + dh_link -p$(p_ldbg) \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)dm.so \ + /$(scriptdir)/config-$(VER)dm-$(DEB_HOST_MULTIARCH)/libpython$(VER)dm.so \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)dm.so \ + /$(scriptdir)/config-$(VER)dm-$(DEB_HOST_MULTIARCH)/libpython$(VER).so \ + /$(scriptdir)/config-$(VER)dm-$(DEB_HOST_MULTIARCH)/libpython$(VER)dm.a \ + /usr/lib/$(DEB_HOST_MULTIARCH)/libpython$(VER)dm.a + + for i in $(d_ldev)/usr/include/$(PVER)m/*; do \ + i=$$(basename $$i); \ + case $$i in pyconfig.h) continue; esac; \ + ln -sf ../$(PVER)m/$$i $(d_ldbg)/usr/include/$(PVER)dm/$$i; \ + done + cp -p $(buildd_debug)/pyconfig.h $(d_ldbg)/usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)dm/ + sed 's/@subdir@/$(PVER)dm/;s/@header@/pyconfig.h/' \ + debian/multiarch.h.in > $(d_ldbg)/usr/include/$(PVER)dm/pyconfig.h + + ln -sf $(PVER).1.gz $(d_dbg)/usr/share/man/man1/$(PVER)-dbg.1.gz + + : # in $(p_ldbg), prefix python-config with triplets + cp $(d)-dbg/usr/bin/python-config.sh \ + $(d_ldbg)/usr/bin/$(DEB_HOST_MULTIARCH)-$(PVER)dm-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)dm-config \ + $(d_ldbg)/usr/bin/$(DEB_HOST_MULTIARCH)-$(PVER)-dbg-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)m-config.1.gz \ + $(d_ldbg)/usr/share/man/man1/$(DEB_HOST_MULTIARCH)-$(PVER)dm-config.1.gz + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)m-config.1.gz \ + $(d_ldbg)/usr/share/man/man1/$(DEB_HOST_MULTIARCH)-$(PVER)-dbg-config.1.gz +ifneq ($(DEB_HOST_MULTIARCH),$(DEB_HOST_GNU_TYPE)) + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)dm-config \ + $(d_ldbg)/usr/bin/$(DEB_HOST_GNU_TYPE)-$(PVER)dm-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-config.1.gz \ + $(d_ldbg)/usr/share/man/man1/$(DEB_HOST_GNU_TYPE)-$(PVER)dm-config.1.gz + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)dm-config \ + $(d_ldbg)/usr/bin/$(DEB_HOST_GNU_TYPE)-$(PVER)-dbg-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)dm-config.1.gz \ + $(d_ldbg)/usr/share/man/man1/$(DEB_HOST_GNU_TYPE)-$(PVER)-dbg-config.1.gz +endif + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)dm-config $(d_dbg)/usr/bin/$(PVER)dm-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)dm-config.1.gz $(d_dbg)/usr/share/man/man1/$(PVER)dm-config.1.gz + + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-dbg-config $(d_dbg)/usr/bin/$(PVER)-dbg-config + ln -sf $(DEB_HOST_MULTIARCH)-$(PVER)-dbg-config.1.gz $(d_dbg)/usr/share/man/man1/$(PVER)-dbg-config.1.gz + + : # symlinks for the "old" include / config directory names + 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)dm.1.gz + ln -sf $(PVER)-config.1.gz $(d_dbg)/usr/share/man/man1/$(PVER)dm-config.1.gz + +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)m-$(DEB_HOST_MULTIARCH) + 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)m-$(DEB_HOST_MULTIARCH)/Makefile \ + $(d_udeb)/$(scriptdir)/config-$(VER)m-$(DEB_HOST_MULTIARCH)/ + cp -p $(d_min)/usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)m/pyconfig.h \ + $(d_udeb)/usr/include/$(DEB_HOST_MULTIARCH)/$(PVER)m/ + 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 + 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 + cd $(buildd_static) && ./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) + + for i in $(p_ltst); do \ + rm -rf debian/$$i/usr/share/doc/$$i; \ + ln -s $(p_lbase) debian/$$i/usr/share/doc/$$i; \ + done + + 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); do \ + rm -rf debian/$$i/usr/share/doc/$$i; \ + ln -s $(p_base) debian/$$i/usr/share/doc/$$i; \ + done + for i in $(p_lbase); do \ + rm -rf debian/$$i/usr/share/doc/$$i; \ + ln -s $(p_lmin) debian/$$i/usr/share/doc/$$i; \ + done + for i in $(p_ldev) $(p_ldbg) $(p_lib); do \ + rm -rf debian/$$i/usr/share/doc/$$i; \ + ln -s $(p_lbase) debian/$$i/usr/share/doc/$$i; \ + done + -find debian ! -perm -200 -print -exec chmod +w {} \; +ifneq ($(with_tk),yes) + rm -f $(d_lbase)/$(scriptdir)/lib-dynload/_tkinter*.so +endif +ifneq ($(with_gdbm),yes) + rm -f $(d_lbase)/$(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)m-gdb.py + ln -sf $(PVER)m-gdb.py $(d_dbg)/usr/lib/debug/usr/bin/$(PVER)dm-gdb.py + ln -sf $(PVER)m-gdb.py $(d_dbg)/usr/lib/debug/usr/bin/$(PVER)-dbg-gdb.py + ln -sf ../bin/$(PVER)m-gdb.py \ + $(d_dbg)/usr/lib/debug/usr/lib/lib$(PVER)m.so.1.0-gdb.py + ln -sf ../bin/$(PVER)m-gdb.py \ + $(d_dbg)/usr/lib/lib$(PVER)dm.so.1.0-gdb.py + dh_link -a + dh_compress -a -X.py + dh_fixperms -a + chmod 644 $(d_lmin)/$(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_ldbg) -V '$(p_ldbg)' +# 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_ldbg)/DEBIAN/symbols + dh_installdeb -a + dh_shlibdeps -a + dep=`sed -n '/^shlibs:Depends/s/.*\(libc6[^,]*\).*/\1/p' $(d_min).substvars`; \ + echo "shlibs:Pre-Depends=$$dep" >> $(d_min).substvars + sed -i '/^shlibs:Depends/s/libc6[^,]*[, ]*//' $(d_min).substvars + 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 + uname -a + @echo USER=$$USER, LOGNAME=$$LOGNAME + 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 + + touch Parser/acceler.c Parser/grammar1.c Parser/listnode.c \ + Parser/node.c Parser/parser.c Parser/bitset.c Parser/metagrammar.c \ + Parser/firstsets.c Parser/grammar.c Parser/pgen.c + touch Objects/obmalloc.c Python/dynamic_annotations.c \ + Python/mysnprintf.c Python/pyctype.c Parser/tokenizer_pgen.c \ + Parser/printgrammar.c Parser/parsetok_pgen.c Parser/pgenmain.c + @sleep 1 + touch Grammar/Grammar + @sleep 1 + touch Include/graminit.h + @sleep 1 + touch Python/graminit.c + + ln -sf site-packages Lib/dist-packages + + 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.3-3.3.3.orig/debian/script.py +++ python3.3-3.3.3/debian/script.py @@ -0,0 +1,61 @@ +#! /usr/bin/python3 + +# 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 + +pid, status = os.wait() +returncode = 0 +if os.WIFSIGNALED(status): + returncode = -os.WTERMSIG(status) +elif os.WIFEXITED(status): + returncode = os.WEXITSTATUS(status) +else: + # Should never happen + raise RuntimeError("Unknown child exit status!") +os.close(master) +sys.exit(returncode) --- python3.3-3.3.3.orig/debian/sitecustomize.py.in +++ python3.3-3.3.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.3-3.3.3.orig/debian/source.lintian-overrides +++ python3.3-3.3.3/debian/source.lintian-overrides @@ -0,0 +1,2 @@ +# generated during the build +python3.3 source: quilt-build-dep-but-no-series-file --- python3.3-3.3.3.orig/debian/source.lintian-overrides.in +++ python3.3-3.3.3/debian/source.lintian-overrides.in @@ -0,0 +1,2 @@ +# generated during the build +@PVER@ source: quilt-build-dep-but-no-series-file --- python3.3-3.3.3.orig/debian/source/format +++ python3.3-3.3.3/debian/source/format @@ -0,0 +1 @@ +1.0 --- python3.3-3.3.3.orig/debian/tests/control +++ python3.3-3.3.3/debian/tests/control @@ -0,0 +1,9 @@ +Tests: testsuite +Depends: build-essential, python3.3-dev, libpython3.3-testsuite, python3-gdbm +# need to turn off apport +Restrictions: needs-root + +Tests: testsuite-dbg +Depends: build-essential, python3.3-dev, python3.3-dbg, libpython3.3-testsuite, python3-gdbm-dbg, gdb +# need to turn off apport +Restrictions: needs-root --- python3.3-3.3.3.orig/debian/tests/testsuite +++ python3.3-3.3.3/debian/tests/testsuite @@ -0,0 +1,86 @@ +#!/bin/sh + +set -e + +if [ "$(whoami)" = root ]; then + # stop apport + stop apport 2>/dev/null || true + sed -i '/^enabled=/s/=.*/=0/' /etc/default/apport 2>/dev/null + # don't change anything when runnning as nobody + if [ -n "$SUDO_USER" ]; then + if [ -n "$TMPDIR" ] && [ -d "$TMPDIR" ]; then + chown -R $SUDO_USER $TMPDIR + fi + if [ -n "$ADTTMP" ] && [ -d "$ADTTMP" ]; then + chown -R $SUDO_USER $ADTTMP + fi + fi + su_user=${SUDO_USER:-nobody} +fi +# no root access needed after this point + +if status apport | grep -q start; then + echo >&2 "apport is running. needs to be disabled before running the tests" + exit 1 +fi + +export LANG=C + +TESTPYTHON="python3.3 -W default -bb -E -R -m test" +TESTOPTS="-j 1 -w -uall,-network,-urlfetch,-gui" +TESTEXCLUSIONS="-x" + +# test_code_module: Issue 17756, reason unknown +TESTEXCLUSIONS="$TESTEXCLUSIONS test_code_module" + +# test_curses: Don't run for now, issue with new curses? +TESTEXCLUSIONS="$TESTEXCLUSIONS test_curses" + +# test_distutils: Issue 17752, many failures in installed location +TESTEXCLUSIONS="$TESTEXCLUSIONS test_distutils" + +# test_gdb: not run for the optimized build +TESTEXCLUSIONS="$TESTEXCLUSIONS test_gdb" + +# test_pydoc: Issue 17763, interfers with packages in dist-packages +TESTEXCLUSIONS="$TESTEXCLUSIONS test_pydoc" + +# test_tools: not relevant for installed version +TESTEXCLUSIONS="$TESTEXCLUSIONS test_tools" + +# test_zipfile: Issue 17753, requires write access to test and email.test +TESTEXCLUSIONS="$TESTEXCLUSIONS test_zipfile" + +# test_subprocess: Issue 17757, two failing tests +TESTEXCLUSIONS="$TESTEXCLUSIONS test_subprocess" + +# test_uuid: fails, but not on the buildd. need to investigate +TESTEXCLUSIONS="$TESTEXCLUSIONS test_uuid" + +if [ "$(whoami)" = root ]; then + su_user=${SUDO_USER:-nobody} +fi + +if [ "$su_user" = nobody ]; then + log=/dev/null + # test_site: Issue 17758, fails to create HOME + TESTEXCLUSIONS="$TESTEXCLUSIONS test_site" +else + log=testsuite.log +fi + +script=$(dirname $(dirname $0))/script.py +if [ -f "$script" ]; then + cmd="python3.3 $script \"$log\" \"$TESTPYTHON $TESTOPTS $TESTEXCLUSIONS\"" +else + cmd="$TESTPYTHON $TESTOPTS $TESTEXCLUSIONS" +fi + +echo "Running the python testsuite with the standard interpreter:" +if [ "$(whoami)" = root ]; then + echo "su -c $cmd $su_user" + su -c "$cmd" $su_user +else + echo "$cmd" + eval $cmd +fi --- python3.3-3.3.3.orig/debian/tests/testsuite-dbg +++ python3.3-3.3.3/debian/tests/testsuite-dbg @@ -0,0 +1,83 @@ +#!/bin/sh + +set -e + +if [ "$(whoami)" = root ]; then + # stop apport + stop apport 2>/dev/null || true + sed -i '/^enabled=/s/=.*/=0/' /etc/default/apport 2>/dev/null + # don't change anything when runnning as nobody + if [ -n "$SUDO_USER" ]; then + if [ -n "$TMPDIR" ] && [ -d "$TMPDIR" ]; then + chown -R $SUDO_USER $TMPDIR + fi + if [ -n "$ADTTMP" ] && [ -d "$ADTTMP" ]; then + chown -R $SUDO_USER $ADTTMP + fi + fi + su_user=${SUDO_USER:-nobody} +fi +# no root access needed after this point + +if status apport | grep -q start; then + echo >&2 "apport is running. needs to be disabled before running the tests" + exit 1 +fi + +export LANG=C + +TESTPYTHON="python3.3dm -W default -bb -E -R -m test" +TESTOPTS="-j 1 -w -uall,-network,-urlfetch,-gui" +TESTEXCLUSIONS="-x" + +# test_code_module: Issue 17756, reason unknown +TESTEXCLUSIONS="$TESTEXCLUSIONS test_code_module" + +# test_curses: Don't run for now, issue with new curses? +TESTEXCLUSIONS="$TESTEXCLUSIONS test_curses" + +# test_distutils: Issue 17752, many failures in installed location +TESTEXCLUSIONS="$TESTEXCLUSIONS test_distutils" + +# test_pydoc: Issue 17763, interfers with packages in dist-packages +TESTEXCLUSIONS="$TESTEXCLUSIONS test_pydoc" + +# test_tools: not relevant for installed version +TESTEXCLUSIONS="$TESTEXCLUSIONS test_tools" + +# test_zipfile: Issue 17753, requires write access to test and email.test +TESTEXCLUSIONS="$TESTEXCLUSIONS test_zipfile" + +# test_subprocess: Issue 17757, two failing tests +TESTEXCLUSIONS="$TESTEXCLUSIONS test_subprocess" + +# test_uuid: fails, but not on the buildd. need to investigate +TESTEXCLUSIONS="$TESTEXCLUSIONS test_uuid" + +if [ "$(whoami)" = root ]; then + su_user=${SUDO_USER:-nobody} +fi + +if [ "$su_user" = nobody ]; then + log=/dev/null + # test_site: Issue 17758, fails to create HOME + TESTEXCLUSIONS="$TESTEXCLUSIONS test_site" +else + log=testsuite-dbg.log +fi + +script=$(dirname $(dirname $0))/script.py +if [ -f "$script" ]; then + cmd="python3.3 $script \"$log\" \"$TESTPYTHON $TESTOPTS $TESTEXCLUSIONS\"" +else + cmd="$TESTPYTHON $TESTOPTS $TESTEXCLUSIONS" +fi + +echo "Running the python testsuite with the debug enabled interpreter:" +if [ "$(whoami)" = root ]; then + echo "su -c $cmd $su_user" + su -c "$cmd" $su_user +else + echo "$cmd" + eval $cmd +fi --- python3.3-3.3.3.orig/debian/watch +++ python3.3-3.3.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