Python-checkins
Threads by month
- ----- 2026 -----
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
November 2010
- 16 participants
- 934 discussions
Nov. 26, 2010
Author: stefan.krah
Date: Fri Nov 26 12:07:04 2010
New Revision: 86793
Log:
Merged revisions 86791 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r86791 | stefan.krah | 2010-11-26 11:54:09 +0100 (Fri, 26 Nov 2010) | 1 line
Indentation cleanup.
........
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Objects/obmalloc.c
Modified: python/branches/release31-maint/Objects/obmalloc.c
==============================================================================
--- python/branches/release31-maint/Objects/obmalloc.c (original)
+++ python/branches/release31-maint/Objects/obmalloc.c Fri Nov 26 12:07:04 2010
@@ -234,7 +234,7 @@
/* Pool for small blocks. */
struct pool_header {
union { block *_padding;
- uint count; } ref; /* number of allocated blocks */
+ uint count; } ref; /* number of allocated blocks */
block *freeblock; /* pool's free list head */
struct pool_header *nextpool; /* next pool of this size class */
struct pool_header *prevpool; /* previous pool "" */
@@ -389,7 +389,7 @@
immediately follow a pool_header's first two members:
union { block *_padding;
- uint count; } ref;
+ uint count; } ref;
block *freeblock;
each of which consume sizeof(block *) bytes. So what usedpools[i+i] really
@@ -694,7 +694,7 @@
#undef Py_ADDRESS_IN_RANGE
#if defined(__GNUC__) && ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) || \
- (__GNUC__ >= 4))
+ (__GNUC__ >= 4))
#define Py_NO_INLINE __attribute__((__noinline__))
#else
#define Py_NO_INLINE
@@ -1422,7 +1422,7 @@
if (nbytes > original_nbytes) {
/* growing: mark new extra memory clean */
memset(q + original_nbytes, CLEANBYTE,
- nbytes - original_nbytes);
+ nbytes - original_nbytes);
}
return q;
@@ -1532,11 +1532,11 @@
fputs("FORBIDDENBYTE, as expected.\n", stderr);
else {
fprintf(stderr, "not all FORBIDDENBYTE (0x%02x):\n",
- FORBIDDENBYTE);
+ FORBIDDENBYTE);
for (i = 0; i < SST; ++i) {
const uchar byte = tail[i];
fprintf(stderr, " at tail+%d: 0x%02x",
- i, byte);
+ i, byte);
if (byte != FORBIDDENBYTE)
fputs(" *** OUCH", stderr);
fputc('\n', stderr);
@@ -1642,7 +1642,7 @@
char buf[128];
fprintf(stderr, "Small block threshold = %d, in %u size classes.\n",
- SMALL_REQUEST_THRESHOLD, numclasses);
+ SMALL_REQUEST_THRESHOLD, numclasses);
for (i = 0; i < numclasses; ++i)
numpools[i] = numblocks[i] = numfreeblocks[i] = 0;
@@ -1700,7 +1700,7 @@
fputc('\n', stderr);
fputs("class size num pools blocks in use avail blocks\n"
"----- ---- --------- ------------- ------------\n",
- stderr);
+ stderr);
for (i = 0; i < numclasses; ++i) {
size_t p = numpools[i];
@@ -1715,7 +1715,7 @@
"%11" PY_FORMAT_SIZE_T "u "
"%15" PY_FORMAT_SIZE_T "u "
"%13" PY_FORMAT_SIZE_T "u\n",
- i, size, p, b, f);
+ i, size, p, b, f);
allocated_bytes += b * size;
available_bytes += f * size;
pool_header_bytes += p * POOL_OVERHEAD;
1
0
Nov. 26, 2010
Author: stefan.krah
Date: Fri Nov 26 12:03:55 2010
New Revision: 86792
Log:
Merged revisions 86791 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r86791 | stefan.krah | 2010-11-26 11:54:09 +0100 (Fri, 26 Nov 2010) | 1 line
Indentation cleanup.
........
Modified:
python/branches/release27-maint/ (props changed)
python/branches/release27-maint/Objects/obmalloc.c
Modified: python/branches/release27-maint/Objects/obmalloc.c
==============================================================================
--- python/branches/release27-maint/Objects/obmalloc.c (original)
+++ python/branches/release27-maint/Objects/obmalloc.c Fri Nov 26 12:03:55 2010
@@ -249,7 +249,7 @@
/* Pool for small blocks. */
struct pool_header {
union { block *_padding;
- uint count; } ref; /* number of allocated blocks */
+ uint count; } ref; /* number of allocated blocks */
block *freeblock; /* pool's free list head */
struct pool_header *nextpool; /* next pool of this size class */
struct pool_header *prevpool; /* previous pool "" */
@@ -404,7 +404,7 @@
immediately follow a pool_header's first two members:
union { block *_padding;
- uint count; } ref;
+ uint count; } ref;
block *freeblock;
each of which consume sizeof(block *) bytes. So what usedpools[i+i] really
@@ -709,7 +709,7 @@
#undef Py_ADDRESS_IN_RANGE
#if defined(__GNUC__) && ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) || \
- (__GNUC__ >= 4))
+ (__GNUC__ >= 4))
#define Py_NO_INLINE __attribute__((__noinline__))
#else
#define Py_NO_INLINE
@@ -1514,7 +1514,7 @@
if (nbytes > original_nbytes) {
/* growing: mark new extra memory clean */
memset(q + original_nbytes, CLEANBYTE,
- nbytes - original_nbytes);
+ nbytes - original_nbytes);
}
return q;
@@ -1641,11 +1641,11 @@
fputs("FORBIDDENBYTE, as expected.\n", stderr);
else {
fprintf(stderr, "not all FORBIDDENBYTE (0x%02x):\n",
- FORBIDDENBYTE);
+ FORBIDDENBYTE);
for (i = 0; i < SST; ++i) {
const uchar byte = tail[i];
fprintf(stderr, " at tail+%d: 0x%02x",
- i, byte);
+ i, byte);
if (byte != FORBIDDENBYTE)
fputs(" *** OUCH", stderr);
fputc('\n', stderr);
@@ -1751,7 +1751,7 @@
char buf[128];
fprintf(stderr, "Small block threshold = %d, in %u size classes.\n",
- SMALL_REQUEST_THRESHOLD, numclasses);
+ SMALL_REQUEST_THRESHOLD, numclasses);
for (i = 0; i < numclasses; ++i)
numpools[i] = numblocks[i] = numfreeblocks[i] = 0;
@@ -1807,7 +1807,7 @@
fputc('\n', stderr);
fputs("class size num pools blocks in use avail blocks\n"
"----- ---- --------- ------------- ------------\n",
- stderr);
+ stderr);
for (i = 0; i < numclasses; ++i) {
size_t p = numpools[i];
@@ -1822,7 +1822,7 @@
"%11" PY_FORMAT_SIZE_T "u "
"%15" PY_FORMAT_SIZE_T "u "
"%13" PY_FORMAT_SIZE_T "u\n",
- i, size, p, b, f);
+ i, size, p, b, f);
allocated_bytes += b * size;
available_bytes += f * size;
pool_header_bytes += p * POOL_OVERHEAD;
1
0
Author: stefan.krah
Date: Fri Nov 26 11:54:09 2010
New Revision: 86791
Log:
Indentation cleanup.
Modified:
python/branches/py3k/Objects/obmalloc.c
Modified: python/branches/py3k/Objects/obmalloc.c
==============================================================================
--- python/branches/py3k/Objects/obmalloc.c (original)
+++ python/branches/py3k/Objects/obmalloc.c Fri Nov 26 11:54:09 2010
@@ -249,7 +249,7 @@
/* Pool for small blocks. */
struct pool_header {
union { block *_padding;
- uint count; } ref; /* number of allocated blocks */
+ uint count; } ref; /* number of allocated blocks */
block *freeblock; /* pool's free list head */
struct pool_header *nextpool; /* next pool of this size class */
struct pool_header *prevpool; /* previous pool "" */
@@ -404,7 +404,7 @@
immediately follow a pool_header's first two members:
union { block *_padding;
- uint count; } ref;
+ uint count; } ref;
block *freeblock;
each of which consume sizeof(block *) bytes. So what usedpools[i+i] really
@@ -709,7 +709,7 @@
#undef Py_ADDRESS_IN_RANGE
#if defined(__GNUC__) && ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) || \
- (__GNUC__ >= 4))
+ (__GNUC__ >= 4))
#define Py_NO_INLINE __attribute__((__noinline__))
#else
#define Py_NO_INLINE
@@ -1514,7 +1514,7 @@
if (nbytes > original_nbytes) {
/* growing: mark new extra memory clean */
memset(q + original_nbytes, CLEANBYTE,
- nbytes - original_nbytes);
+ nbytes - original_nbytes);
}
return q;
@@ -1641,11 +1641,11 @@
fputs("FORBIDDENBYTE, as expected.\n", stderr);
else {
fprintf(stderr, "not all FORBIDDENBYTE (0x%02x):\n",
- FORBIDDENBYTE);
+ FORBIDDENBYTE);
for (i = 0; i < SST; ++i) {
const uchar byte = tail[i];
fprintf(stderr, " at tail+%d: 0x%02x",
- i, byte);
+ i, byte);
if (byte != FORBIDDENBYTE)
fputs(" *** OUCH", stderr);
fputc('\n', stderr);
@@ -1751,7 +1751,7 @@
char buf[128];
fprintf(stderr, "Small block threshold = %d, in %u size classes.\n",
- SMALL_REQUEST_THRESHOLD, numclasses);
+ SMALL_REQUEST_THRESHOLD, numclasses);
for (i = 0; i < numclasses; ++i)
numpools[i] = numblocks[i] = numfreeblocks[i] = 0;
@@ -1809,7 +1809,7 @@
fputc('\n', stderr);
fputs("class size num pools blocks in use avail blocks\n"
"----- ---- --------- ------------- ------------\n",
- stderr);
+ stderr);
for (i = 0; i < numclasses; ++i) {
size_t p = numpools[i];
@@ -1824,7 +1824,7 @@
"%11" PY_FORMAT_SIZE_T "u "
"%15" PY_FORMAT_SIZE_T "u "
"%13" PY_FORMAT_SIZE_T "u\n",
- i, size, p, b, f);
+ i, size, p, b, f);
allocated_bytes += b * size;
available_bytes += f * size;
pool_header_bytes += p * POOL_OVERHEAD;
1
0
Nov. 26, 2010
Author: ezio.melotti
Date: Fri Nov 26 10:30:44 2010
New Revision: 86790
Log:
Remove 3.1 from versionchanged
Modified:
python/branches/release27-maint/Doc/library/re.rst
Modified: python/branches/release27-maint/Doc/library/re.rst
==============================================================================
--- python/branches/release27-maint/Doc/library/re.rst (original)
+++ python/branches/release27-maint/Doc/library/re.rst Fri Nov 26 10:30:44 2010
@@ -574,7 +574,7 @@
>>> re.split("(?m)^$", "foo\n\nbar\n")
['foo\n\nbar\n']
- .. versionchanged:: 2.7,3.1
+ .. versionchanged:: 2.7
Added the optional flags argument.
@@ -652,7 +652,7 @@
character ``'0'``. The backreference ``\g<0>`` substitutes in the entire
substring matched by the RE.
- .. versionchanged:: 2.7,3.1
+ .. versionchanged:: 2.7
Added the optional flags argument.
@@ -661,7 +661,7 @@
Perform the same operation as :func:`sub`, but return a tuple ``(new_string,
number_of_subs_made)``.
- .. versionchanged:: 2.7,3.1
+ .. versionchanged:: 2.7
Added the optional flags argument.
1
0
Nov. 26, 2010
Author: georg.brandl
Date: Fri Nov 26 10:05:43 2010
New Revision: 86789
Log:
Merged revisions 86134,86315-86316,86390,86424-86425,86428,86550,86561-86562,86564-86565,86705,86708,86713 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
........
r86134 | georg.brandl | 2010-11-03 08:41:00 +0100 (Mi, 03 Nov 2010) | 1 line
A newline in lineno output breaks pyframe output.
........
r86315 | georg.brandl | 2010-11-08 12:05:18 +0100 (Mo, 08 Nov 2010) | 1 line
Fix latex conversion glitch in property/feature descriptions.
........
r86316 | georg.brandl | 2010-11-08 12:08:35 +0100 (Mo, 08 Nov 2010) | 1 line
Fix typo.
........
r86390 | georg.brandl | 2010-11-10 08:57:10 +0100 (Mi, 10 Nov 2010) | 1 line
Fix typo.
........
r86424 | georg.brandl | 2010-11-12 07:19:48 +0100 (Fr, 12 Nov 2010) | 1 line
Build a PDF of the FAQs too.
........
r86425 | georg.brandl | 2010-11-12 07:20:12 +0100 (Fr, 12 Nov 2010) | 1 line
#10008: Fix duplicate index entry.
........
r86428 | georg.brandl | 2010-11-12 09:09:26 +0100 (Fr, 12 Nov 2010) | 1 line
Fix weird line block in table.
........
r86550 | georg.brandl | 2010-11-20 11:24:34 +0100 (Sa, 20 Nov 2010) | 1 line
Fix rst markup errors.
........
r86561 | georg.brandl | 2010-11-20 12:47:10 +0100 (Sa, 20 Nov 2010) | 1 line
#10460: Update indent.pro to match PEP 7 better.
........
r86562 | georg.brandl | 2010-11-20 14:44:41 +0100 (Sa, 20 Nov 2010) | 1 line
#10439: document PyCodec C APIs.
........
r86564 | georg.brandl | 2010-11-20 15:08:53 +0100 (Sa, 20 Nov 2010) | 1 line
#10460: an even better indent.pro.
........
r86565 | georg.brandl | 2010-11-20 15:16:17 +0100 (Sa, 20 Nov 2010) | 1 line
socket.gethostbyname(socket.gethostname()) can fail when host name resolution is not set up correctly; do not fail test_socket if this is the case.
........
r86705 | georg.brandl | 2010-11-23 08:54:19 +0100 (Di, 23 Nov 2010) | 1 line
#10468: document Unicode exception creation and access functions.
........
r86708 | georg.brandl | 2010-11-23 09:37:54 +0100 (Di, 23 Nov 2010) | 2 lines
#10511: clarification of what heaps are; suggested by Johannes Hoff.
........
r86713 | georg.brandl | 2010-11-23 19:14:57 +0100 (Di, 23 Nov 2010) | 1 line
assert.h is also included. Thanks to Savio Sena.
........
Added:
python/branches/release31-maint/Doc/c-api/codec.rst
- copied, changed from r86565, /python/branches/py3k/Doc/c-api/codec.rst
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Doc/c-api/exceptions.rst
python/branches/release31-maint/Doc/c-api/intro.rst
python/branches/release31-maint/Doc/c-api/utilities.rst
python/branches/release31-maint/Doc/conf.py
python/branches/release31-maint/Doc/library/heapq.rst
python/branches/release31-maint/Doc/library/itertools.rst
python/branches/release31-maint/Doc/library/xml.sax.handler.rst
python/branches/release31-maint/Doc/library/zipfile.rst
python/branches/release31-maint/Doc/tutorial/datastructures.rst
python/branches/release31-maint/Include/codecs.h
python/branches/release31-maint/Lib/test/test_socket.py
python/branches/release31-maint/Misc/gdbinit
python/branches/release31-maint/Misc/indent.pro
Copied: python/branches/release31-maint/Doc/c-api/codec.rst (from r86565, /python/branches/py3k/Doc/c-api/codec.rst)
==============================================================================
--- /python/branches/py3k/Doc/c-api/codec.rst (original)
+++ python/branches/release31-maint/Doc/c-api/codec.rst Fri Nov 26 10:05:43 2010
@@ -3,19 +3,19 @@
Codec registry and support functions
====================================
-.. c:function:: int PyCodec_Register(PyObject *search_function)
+.. cfunction:: int PyCodec_Register(PyObject *search_function)
Register a new codec search function.
As side effect, this tries to load the :mod:`encodings` package, if not yet
done, to make sure that it is always first in the list of search functions.
-.. c:function:: int PyCodec_KnownEncoding(const char *encoding)
+.. cfunction:: int PyCodec_KnownEncoding(const char *encoding)
Return ``1`` or ``0`` depending on whether there is a registered codec for
the given *encoding*.
-.. c:function:: PyObject* PyCodec_Encode(PyObject *object, const char *encoding, const char *errors)
+.. cfunction:: PyObject* PyCodec_Encode(PyObject *object, const char *encoding, const char *errors)
Generic codec based encoding API.
@@ -24,7 +24,7 @@
be *NULL* to use the default method defined for the codec. Raises a
:exc:`LookupError` if no encoder can be found.
-.. c:function:: PyObject* PyCodec_Decode(PyObject *object, const char *encoding, const char *errors)
+.. cfunction:: PyObject* PyCodec_Decode(PyObject *object, const char *encoding, const char *errors)
Generic codec based decoding API.
@@ -42,27 +42,27 @@
effectively case-insensitive. If no codec is found, a :exc:`KeyError` is set
and *NULL* returned.
-.. c:function:: PyObject* PyCodec_Encoder(const char *encoding)
+.. cfunction:: PyObject* PyCodec_Encoder(const char *encoding)
Get an encoder function for the given *encoding*.
-.. c:function:: PyObject* PyCodec_Decoder(const char *encoding)
+.. cfunction:: PyObject* PyCodec_Decoder(const char *encoding)
Get a decoder function for the given *encoding*.
-.. c:function:: PyObject* PyCodec_IncrementalEncoder(const char *encoding, const char *errors)
+.. cfunction:: PyObject* PyCodec_IncrementalEncoder(const char *encoding, const char *errors)
Get an :class:`IncrementalEncoder` object for the given *encoding*.
-.. c:function:: PyObject* PyCodec_IncrementalDecoder(const char *encoding, const char *errors)
+.. cfunction:: PyObject* PyCodec_IncrementalDecoder(const char *encoding, const char *errors)
Get an :class:`IncrementalDecoder` object for the given *encoding*.
-.. c:function:: PyObject* PyCodec_StreamReader(const char *encoding, PyObject *stream, const char *errors)
+.. cfunction:: PyObject* PyCodec_StreamReader(const char *encoding, PyObject *stream, const char *errors)
Get a :class:`StreamReader` factory function for the given *encoding*.
-.. c:function:: PyObject* PyCodec_StreamWriter(const char *encoding, PyObject *stream, const char *errors)
+.. cfunction:: PyObject* PyCodec_StreamWriter(const char *encoding, PyObject *stream, const char *errors)
Get a :class:`StreamWriter` factory function for the given *encoding*.
@@ -70,7 +70,7 @@
Registry API for Unicode encoding error handlers
------------------------------------------------
-.. c:function:: int PyCodec_RegisterError(const char *name, PyObject *error)
+.. cfunction:: int PyCodec_RegisterError(const char *name, PyObject *error)
Register the error handling callback function *error* under the given *name*.
This callback function will be called by a codec when it encounters
@@ -80,40 +80,38 @@
The callback gets a single argument, an instance of
:exc:`UnicodeEncodeError`, :exc:`UnicodeDecodeError` or
:exc:`UnicodeTranslateError` that holds information about the problematic
- sequence of characters or bytes and their offset in the original string. The
+ sequence of characters or bytes and their offset in the original string (see
+ :ref:`unicodeexceptions` for functions to extract this information). The
callback must either raise the given exception, or return a two-item tuple
containing the replacement for the problematic sequence, and an integer
giving the offset in the original string at which encoding/decoding should be
resumed.
- .. XXX once they are documented, link to PyUnicode*Error access functions
- to show how to get at the exception properties
-
Return ``0`` on success, ``-1`` on error.
-.. c:function:: PyObject* PyCodec_LookupError(const char *name)
+.. cfunction:: PyObject* PyCodec_LookupError(const char *name)
Lookup the error handling callback function registered under *name*. As a
special case *NULL* can be passed, in which case the error handling callback
for "strict" will be returned.
-.. c:function:: PyObject* PyCodec_StrictErrors(PyObject *exc)
+.. cfunction:: PyObject* PyCodec_StrictErrors(PyObject *exc)
Raise *exc* as an exception.
-.. c:function:: PyObject* PyCodec_IgnoreErrors(PyObject *exc)
+.. cfunction:: PyObject* PyCodec_IgnoreErrors(PyObject *exc)
Ignore the unicode error, skipping the faulty input.
-.. c:function:: PyObject* PyCodec_ReplaceErrors(PyObject *exc)
+.. cfunction:: PyObject* PyCodec_ReplaceErrors(PyObject *exc)
Replace the unicode encode error with ``?`` or ``U+FFFD``.
-.. c:function:: PyObject* PyCodec_XMLCharRefReplaceErrors(PyObject *exc)
+.. cfunction:: PyObject* PyCodec_XMLCharRefReplaceErrors(PyObject *exc)
Replace the unicode encode error with XML character references.
-.. c:function:: PyObject* PyCodec_BackslashReplaceErrors(PyObject *exc)
+.. cfunction:: PyObject* PyCodec_BackslashReplaceErrors(PyObject *exc)
Replace the unicode encode error with backslash escapes (``\x``, ``\u`` and
``\U``).
Modified: python/branches/release31-maint/Doc/c-api/exceptions.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/exceptions.rst (original)
+++ python/branches/release31-maint/Doc/c-api/exceptions.rst Fri Nov 26 10:05:43 2010
@@ -446,6 +446,83 @@
This steals a reference to *ctx*.
+.. _unicodeexceptions:
+
+Unicode Exception Objects
+=========================
+
+The following functions are used to create and modify Unicode exceptions from C.
+
+.. cfunction:: PyObject* PyUnicodeDecodeError_Create(const char *encoding, const char *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
+
+ Create a :class:`UnicodeDecodeError` object with the attributes *encoding*,
+ *object*, *length*, *start*, *end* and *reason*.
+
+.. cfunction:: PyObject* PyUnicodeEncodeError_Create(const char *encoding, const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
+
+ Create a :class:`UnicodeEncodeError` object with the attributes *encoding*,
+ *object*, *length*, *start*, *end* and *reason*.
+
+.. cfunction:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
+
+ Create a :class:`UnicodeTranslateError` object with the attributes *object*,
+ *length*, *start*, *end* and *reason*.
+
+.. cfunction:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc)
+ PyObject* PyUnicodeEncodeError_GetEncoding(PyObject *exc)
+
+ Return the *encoding* attribute of the given exception object.
+
+.. cfunction:: PyObject* PyUnicodeDecodeError_GetObject(PyObject *exc)
+ PyObject* PyUnicodeEncodeError_GetObject(PyObject *exc)
+ PyObject* PyUnicodeTranslateError_GetObject(PyObject *exc)
+
+ Return the *object* attribute of the given exception object.
+
+.. cfunction:: int PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start)
+ int PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start)
+ int PyUnicodeTranslateError_GetStart(PyObject *exc, Py_ssize_t *start)
+
+ Get the *start* attribute of the given exception object and place it into
+ *\*start*. *start* must not be *NULL*. Return ``0`` on success, ``-1`` on
+ failure.
+
+.. cfunction:: int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start)
+ int PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start)
+ int PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start)
+
+ Set the *start* attribute of the given exception object to *start*. Return
+ ``0`` on success, ``-1`` on failure.
+
+.. cfunction:: int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
+ int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
+ int PyUnicodeTranslateError_GetEnd(PyObject *exc, Py_ssize_t *end)
+
+ Get the *end* attribute of the given exception object and place it into
+ *\*end*. *end* must not be *NULL*. Return ``0`` on success, ``-1`` on
+ failure.
+
+.. cfunction:: int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end)
+ int PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end)
+ int PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end)
+
+ Set the *end* attribute of the given exception object to *end*. Return ``0``
+ on success, ``-1`` on failure.
+
+.. cfunction:: PyObject* PyUnicodeDecodeError_GetReason(PyObject *exc)
+ PyObject* PyUnicodeEncodeError_GetReason(PyObject *exc)
+ PyObject* PyUnicodeTranslateError_GetReason(PyObject *exc)
+
+ Return the *reason* attribute of the given exception object.
+
+.. cfunction:: int PyUnicodeDecodeError_SetReason(PyObject *exc, const char *reason)
+ int PyUnicodeEncodeError_SetReason(PyObject *exc, const char *reason)
+ int PyUnicodeTranslateError_SetReason(PyObject *exc, const char *reason)
+
+ Set the *reason* attribute of the given exception object to *reason*. Return
+ ``0`` on success, ``-1`` on failure.
+
+
Recursion Control
=================
Modified: python/branches/release31-maint/Doc/c-api/intro.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/intro.rst (original)
+++ python/branches/release31-maint/Doc/c-api/intro.rst Fri Nov 26 10:05:43 2010
@@ -41,8 +41,8 @@
#include "Python.h"
This implies inclusion of the following standard headers: ``<stdio.h>``,
-``<string.h>``, ``<errno.h>``, ``<limits.h>``, and ``<stdlib.h>`` (if
-available).
+``<string.h>``, ``<errno.h>``, ``<limits.h>``, ``<assert.h>`` and ``<stdlib.h>``
+(if available).
.. note::
Modified: python/branches/release31-maint/Doc/c-api/utilities.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/utilities.rst (original)
+++ python/branches/release31-maint/Doc/c-api/utilities.rst Fri Nov 26 10:05:43 2010
@@ -18,3 +18,4 @@
arg.rst
conversion.rst
reflection.rst
+ codec.rst
Modified: python/branches/release31-maint/Doc/conf.py
==============================================================================
--- python/branches/release31-maint/Doc/conf.py (original)
+++ python/branches/release31-maint/Doc/conf.py Fri Nov 26 10:05:43 2010
@@ -129,6 +129,8 @@
'Python Tutorial', _stdauthor, 'manual'),
('using/index', 'using.tex',
'Python Setup and Usage', _stdauthor, 'manual'),
+ ('faq/index', 'faq.tex',
+ 'Python Frequently Asked Questions', _stdauthor, 'manual'),
('whatsnew/' + version, 'whatsnew.tex',
'What\'s New in Python', 'A. M. Kuchling', 'howto'),
]
Modified: python/branches/release31-maint/Doc/library/heapq.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/heapq.rst (original)
+++ python/branches/release31-maint/Doc/library/heapq.rst Fri Nov 26 10:05:43 2010
@@ -11,11 +11,12 @@
This module provides an implementation of the heap queue algorithm, also known
as the priority queue algorithm.
-Heaps are arrays for which ``heap[k] <= heap[2*k+1]`` and ``heap[k] <=
-heap[2*k+2]`` for all *k*, counting elements from zero. For the sake of
-comparison, non-existing elements are considered to be infinite. The
-interesting property of a heap is that ``heap[0]`` is always its smallest
-element.
+Heaps are binary trees for which every parent node has a value less than or
+equal to any of its children. This implementation uses arrays for which
+``heap[k] <= heap[2*k+1]`` and ``heap[k] <= heap[2*k+2]`` for all *k*, counting
+elements from zero. For the sake of comparison, non-existing elements are
+considered to be infinite. The interesting property of a heap is that its
+smallest element is always the root, ``heap[0]``.
The API below differs from textbook heap algorithms in two aspects: (a) We use
zero-based indexing. This makes the relationship between the index for a node
Modified: python/branches/release31-maint/Doc/library/itertools.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/itertools.rst (original)
+++ python/branches/release31-maint/Doc/library/itertools.rst Fri Nov 26 10:05:43 2010
@@ -67,7 +67,6 @@
:func:`permutations` p[, r] r-length tuples, all possible orderings, no repeated elements
:func:`combinations` p, r r-length tuples, in sorted order, no repeated elements
:func:`combinations_with_replacement` p, r r-length tuples, in sorted order, with repeated elements
-|
``product('ABCD', repeat=2)`` ``AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD``
``permutations('ABCD', 2)`` ``AB AC AD BA BC BD CA CB CD DA DB DC``
``combinations('ABCD', 2)`` ``AB AC AD BC BD CD``
Modified: python/branches/release31-maint/Doc/library/xml.sax.handler.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/xml.sax.handler.rst (original)
+++ python/branches/release31-maint/Doc/library/xml.sax.handler.rst Fri Nov 26 10:05:43 2010
@@ -49,52 +49,57 @@
.. data:: feature_namespaces
- Value: ``"http://xml.org/sax/features/namespaces"`` --- true: Perform Namespace
- processing. --- false: Optionally do not perform Namespace processing (implies
- namespace-prefixes; default). --- access: (parsing) read-only; (not parsing)
- read/write
+ | value: ``"http://xml.org/sax/features/namespaces"``
+ | true: Perform Namespace processing.
+ | false: Optionally do not perform Namespace processing (implies
+ namespace-prefixes; default).
+ | access: (parsing) read-only; (not parsing) read/write
.. data:: feature_namespace_prefixes
- Value: ``"http://xml.org/sax/features/namespace-prefixes"`` --- true: Report
- the original prefixed names and attributes used for Namespace
- declarations. --- false: Do not report attributes used for Namespace
- declarations, and optionally do not report original prefixed names
- (default). --- access: (parsing) read-only; (not parsing) read/write
+ | value: ``"http://xml.org/sax/features/namespace-prefixes"``
+ | true: Report the original prefixed names and attributes used for Namespace
+ declarations.
+ | false: Do not report attributes used for Namespace declarations, and
+ optionally do not report original prefixed names (default).
+ | access: (parsing) read-only; (not parsing) read/write
.. data:: feature_string_interning
- Value: ``"http://xml.org/sax/features/string-interning"`` --- true: All element
- names, prefixes, attribute names, Namespace URIs, and local names are interned
- using the built-in intern function. --- false: Names are not necessarily
- interned, although they may be (default). --- access: (parsing) read-only; (not
- parsing) read/write
+ | value: ``"http://xml.org/sax/features/string-interning"``
+ | true: All element names, prefixes, attribute names, Namespace URIs, and
+ local names are interned using the built-in intern function.
+ | false: Names are not necessarily interned, although they may be (default).
+ | access: (parsing) read-only; (not parsing) read/write
.. data:: feature_validation
- Value: ``"http://xml.org/sax/features/validation"`` --- true: Report all
- validation errors (implies external-general-entities and
- external-parameter-entities). --- false: Do not report validation errors. ---
- access: (parsing) read-only; (not parsing) read/write
+ | value: ``"http://xml.org/sax/features/validation"``
+ | true: Report all validation errors (implies external-general-entities and
+ external-parameter-entities).
+ | false: Do not report validation errors.
+ | access: (parsing) read-only; (not parsing) read/write
.. data:: feature_external_ges
- Value: ``"http://xml.org/sax/features/external-general-entities"`` --- true:
- Include all external general (text) entities. --- false: Do not include
- external general entities. --- access: (parsing) read-only; (not parsing)
- read/write
+ | value: ``"http://xml.org/sax/features/external-general-entities"``
+ | true: Include all external general (text) entities.
+ | false: Do not include external general entities.
+ | access: (parsing) read-only; (not parsing) read/write
.. data:: feature_external_pes
- Value: ``"http://xml.org/sax/features/external-parameter-entities"`` --- true:
- Include all external parameter entities, including the external DTD subset. ---
- false: Do not include any external parameter entities, even the external DTD
- subset. --- access: (parsing) read-only; (not parsing) read/write
+ | value: ``"http://xml.org/sax/features/external-parameter-entities"``
+ | true: Include all external parameter entities, including the external DTD
+ subset.
+ | false: Do not include any external parameter entities, even the external
+ DTD subset.
+ | access: (parsing) read-only; (not parsing) read/write
.. data:: all_features
@@ -104,34 +109,38 @@
.. data:: property_lexical_handler
- Value: ``"http://xml.org/sax/properties/lexical-handler"`` --- data type:
- xml.sax.sax2lib.LexicalHandler (not supported in Python 2) --- description: An
- optional extension handler for lexical events like comments. --- access:
- read/write
+ | value: ``"http://xml.org/sax/properties/lexical-handler"``
+ | data type: xml.sax.sax2lib.LexicalHandler (not supported in Python 2)
+ | description: An optional extension handler for lexical events like
+ comments.
+ | access: read/write
.. data:: property_declaration_handler
- Value: ``"http://xml.org/sax/properties/declaration-handler"`` --- data type:
- xml.sax.sax2lib.DeclHandler (not supported in Python 2) --- description: An
- optional extension handler for DTD-related events other than notations and
- unparsed entities. --- access: read/write
+ | value: ``"http://xml.org/sax/properties/declaration-handler"``
+ | data type: xml.sax.sax2lib.DeclHandler (not supported in Python 2)
+ | description: An optional extension handler for DTD-related events other
+ than notations and unparsed entities.
+ | access: read/write
.. data:: property_dom_node
- Value: ``"http://xml.org/sax/properties/dom-node"`` --- data type:
- org.w3c.dom.Node (not supported in Python 2) --- description: When parsing,
- the current DOM node being visited if this is a DOM iterator; when not parsing,
- the root DOM node for iteration. --- access: (parsing) read-only; (not parsing)
- read/write
+ | value: ``"http://xml.org/sax/properties/dom-node"``
+ | data type: org.w3c.dom.Node (not supported in Python 2)
+ | description: When parsing, the current DOM node being visited if this is
+ a DOM iterator; when not parsing, the root DOM node for iteration.
+ | access: (parsing) read-only; (not parsing) read/write
.. data:: property_xml_string
- Value: ``"http://xml.org/sax/properties/xml-string"`` --- data type: String ---
- description: The literal string of characters that was the source for the
- current event. --- access: read-only
+ | value: ``"http://xml.org/sax/properties/xml-string"``
+ | data type: String
+ | description: The literal string of characters that was the source for the
+ current event.
+ | access: read-only
.. data:: all_properties
Modified: python/branches/release31-maint/Doc/library/zipfile.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/zipfile.rst (original)
+++ python/branches/release31-maint/Doc/library/zipfile.rst Fri Nov 26 10:05:43 2010
@@ -36,6 +36,7 @@
.. class:: ZipFile
+ :noindex:
The class for reading and writing ZIP files. See section
:ref:`zipfile-objects` for constructor details.
Modified: python/branches/release31-maint/Doc/tutorial/datastructures.rst
==============================================================================
--- python/branches/release31-maint/Doc/tutorial/datastructures.rst (original)
+++ python/branches/release31-maint/Doc/tutorial/datastructures.rst Fri Nov 26 10:05:43 2010
@@ -379,7 +379,7 @@
>>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
>>> print(basket) # show that duplicates have been removed
- {'orange', 'bananna', 'pear', 'apple'}
+ {'orange', 'banana', 'pear', 'apple'}
>>> 'orange' in basket # fast membership testing
True
>>> 'crabgrass' in basket
Modified: python/branches/release31-maint/Include/codecs.h
==============================================================================
--- python/branches/release31-maint/Include/codecs.h (original)
+++ python/branches/release31-maint/Include/codecs.h Fri Nov 26 10:05:43 2010
@@ -144,7 +144,7 @@
/* Unicode encoding error handling callback registry API */
-/* Register the error handling callback function error under the name
+/* Register the error handling callback function error under the given
name. This function will be called by the codec when it encounters
unencodable characters/undecodable bytes and doesn't know the
callback name, when name is specified as the error parameter
@@ -152,8 +152,8 @@
Return 0 on success, -1 on error */
PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
-/* Lookup the error handling callback function registered under the
- name error. As a special case NULL can be passed, in which case
+/* Lookup the error handling callback function registered under the given
+ name. As a special case NULL can be passed, in which case
the error handling callback for "strict" will be returned. */
PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
@@ -163,7 +163,7 @@
/* ignore the unicode error, skipping the faulty input */
PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
-/* replace the unicode error with ? or U+FFFD */
+/* replace the unicode encode error with ? or U+FFFD */
PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
/* replace the unicode encode error with XML character references */
Modified: python/branches/release31-maint/Lib/test/test_socket.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_socket.py (original)
+++ python/branches/release31-maint/Lib/test/test_socket.py Fri Nov 26 10:05:43 2010
@@ -522,7 +522,11 @@
# XXX(nnorwitz): http://tinyurl.com/os5jz seems to indicate
# it reasonable to get the host's addr in addition to 0.0.0.0.
# At least for eCos. This is required for the S/390 to pass.
- my_ip_addr = socket.gethostbyname(socket.gethostname())
+ try:
+ my_ip_addr = socket.gethostbyname(socket.gethostname())
+ except socket.error:
+ # Probably name lookup wasn't set up right; skip this test
+ return
self.assertTrue(name[0] in ("0.0.0.0", my_ip_addr), '%s invalid' % name[0])
self.assertEqual(name[1], port)
Modified: python/branches/release31-maint/Misc/gdbinit
==============================================================================
--- python/branches/release31-maint/Misc/gdbinit (original)
+++ python/branches/release31-maint/Misc/gdbinit Fri Nov 26 10:05:43 2010
@@ -67,7 +67,7 @@
set $__p = $__p + 1
end
end
- printf "%d\n", $__li
+ printf "%d", $__li
end
# print the current frame - verbose
Modified: python/branches/release31-maint/Misc/indent.pro
==============================================================================
--- python/branches/release31-maint/Misc/indent.pro (original)
+++ python/branches/release31-maint/Misc/indent.pro Fri Nov 26 10:05:43 2010
@@ -1,15 +1,24 @@
--sob
--nbad
--bap
--br
--nce
--ncs
--npcs
--i8
--ip8
--c25
+--blank-lines-after-declarations
+--blank-lines-after-procedures
+--braces-after-func-def-line
+--braces-on-if-line
+--braces-on-struct-decl-line
+--break-after-boolean-operator
+--comment-indentation25
+--comment-line-length79
+--continue-at-parentheses
+--dont-cuddle-do-while
+--dont-cuddle-else
+--indent-level4
+--line-length79
+--no-space-after-casts
+--no-space-after-function-call-names
+--no-space-after-parentheses
+--no-tabs
+--procnames-start-lines
+--space-after-for
+--space-after-if
+--space-after-while
+--swallow-optional-blank-lines
+-T PyCFunction
-T PyObject
-
-
-
-
1
0
Author: georg.brandl
Date: Fri Nov 26 10:03:14 2010
New Revision: 86788
Log:
Blocked revisions 86256,86324,86409,86427,86429,86444-86446,86451,86479-86480,86608,86619,86725 via svnmerge
........
r86256 | georg.brandl | 2010-11-06 08:19:35 +0100 (Sa, 06 Nov 2010) | 1 line
#10334: add a role to refer to Python source files in SVN.
........
r86324 | georg.brandl | 2010-11-08 17:57:52 +0100 (Mo, 08 Nov 2010) | 1 line
Fix next version name.
........
r86409 | georg.brandl | 2010-11-11 08:26:40 +0100 (Do, 11 Nov 2010) | 1 line
Review the new configparser docs.
........
r86427 | georg.brandl | 2010-11-12 09:09:11 +0100 (Fr, 12 Nov 2010) | 1 line
Switch to Sphinx 1.0.5.
........
r86429 | georg.brandl | 2010-11-12 09:57:12 +0100 (Fr, 12 Nov 2010) | 1 line
Add a deprecated-removed directive that allows to give the version of removal for deprecations.
........
r86444 | georg.brandl | 2010-11-13 07:36:58 +0100 (Sa, 13 Nov 2010) | 1 line
Update pydoc topics.
........
r86445 | georg.brandl | 2010-11-13 07:38:37 +0100 (Sa, 13 Nov 2010) | 1 line
Ignore suspicious-ignore file.
........
r86446 | georg.brandl | 2010-11-13 07:39:58 +0100 (Sa, 13 Nov 2010) | 1 line
Bump to 3.2a4.
........
r86451 | georg.brandl | 2010-11-13 14:25:40 +0100 (Sa, 13 Nov 2010) | 1 line
Minor edits.
........
r86479 | georg.brandl | 2010-11-16 16:15:29 +0100 (Di, 16 Nov 2010) | 1 line
Add stub for PEP 3148.
........
r86480 | georg.brandl | 2010-11-16 16:15:56 +0100 (Di, 16 Nov 2010) | 1 line
Post-release bumps.
........
r86608 | georg.brandl | 2010-11-20 20:54:36 +0100 (Sa, 20 Nov 2010) | 1 line
#9724: add nonlocal to pydoc topics.
........
r86619 | georg.brandl | 2010-11-20 23:40:10 +0100 (Sa, 20 Nov 2010) | 1 line
Add error handling in range_count.
........
r86725 | georg.brandl | 2010-11-24 10:09:29 +0100 (Mi, 24 Nov 2010) | 1 line
Remove UTF-8 BOM.
........
Modified:
python/branches/release31-maint/ (props changed)
1
0
Author: georg.brandl
Date: Fri Nov 26 10:00:28 2010
New Revision: 86787
Log:
Blocked revisions 85680-85683,85692,85787-85789,85807,85822,85824,85828,85856,85874,85876-85877,85888-85889,85910,85979 via svnmerge
........
r85680 | georg.brandl | 2010-10-18 09:27:55 +0200 (Mo, 18 Okt 2010) | 1 line
Fix compiler warning about unused static function.
........
r85681 | georg.brandl | 2010-10-18 09:30:06 +0200 (Mo, 18 Okt 2010) | 1 line
Fix type of hash function.
........
r85682 | georg.brandl | 2010-10-18 09:32:48 +0200 (Mo, 18 Okt 2010) | 1 line
Remove unneeded casts to hashfunc.
........
r85683 | georg.brandl | 2010-10-18 09:35:09 +0200 (Mo, 18 Okt 2010) | 1 line
Remove more unneeded casts to hashfunc.
........
r85692 | georg.brandl | 2010-10-18 14:24:53 +0200 (Mo, 18 Okt 2010) | 1 line
Fix hash function type.
........
r85787 | georg.brandl | 2010-10-22 08:28:01 +0200 (Fr, 22 Okt 2010) | 1 line
#10166: rewrite self-recursion to iteration in pstats.Stats.add(). Also add a unittest and a stats test file.
........
r85788 | georg.brandl | 2010-10-22 08:29:21 +0200 (Fr, 22 Okt 2010) | 1 line
Make top_level attribute a set instead of a dict with None values.
........
r85789 | georg.brandl | 2010-10-22 08:35:59 +0200 (Fr, 22 Okt 2010) | 1 line
Refactor interesting use of try-finally.
........
r85807 | georg.brandl | 2010-10-23 19:31:52 +0200 (Sa, 23 Okt 2010) | 1 line
#6518: enable context manager protocol for ossaudiodev types.
........
r85822 | georg.brandl | 2010-10-24 16:21:42 +0200 (So, 24 Okt 2010) | 1 line
Add casts (one needed, one for consistency).
........
r85824 | georg.brandl | 2010-10-24 17:11:22 +0200 (So, 24 Okt 2010) | 6 lines
Add a new warning gategory, ResourceWarning, as discussed on python-dev. It is silent by default,
except when configured --with-pydebug.
Emit this warning from the GC shutdown procedure, rather than just printing to stderr.
........
r85828 | georg.brandl | 2010-10-24 22:47:32 +0200 (So, 24 Okt 2010) | 1 line
These are true PyCFunctions, after adding the second argument to oss_self, no need to cast.
........
r85856 | georg.brandl | 2010-10-27 09:27:06 +0200 (Mi, 27 Okt 2010) | 1 line
#5975: add unix_dialect to csv module.
........
r85874 | georg.brandl | 2010-10-28 08:42:33 +0200 (Do, 28 Okt 2010) | 1 line
#7351: add more consistent exception name alias.
........
r85876 | georg.brandl | 2010-10-28 11:03:20 +0200 (Do, 28 Okt 2010) | 1 line
#10218: return timeout status from Condition.wait, mirroring other primitives' behavior.
........
r85877 | georg.brandl | 2010-10-28 11:24:56 +0200 (Do, 28 Okt 2010) | 1 line
Condition.wait now returns bool.
........
r85888 | georg.brandl | 2010-10-28 15:01:06 +0200 (Do, 28 Okt 2010) | 1 line
Support new Condition return value in the multiprocessing version.
........
r85889 | georg.brandl | 2010-10-28 15:07:50 +0200 (Do, 28 Okt 2010) | 1 line
Review new Barrier docs.
........
r85910 | georg.brandl | 2010-10-29 07:30:17 +0200 (Fr, 29 Okt 2010) | 1 line
Port suspicious markup builder and patchlevel.py so that they can be used with Python 2 and 3 without conversion.
........
r85979 | georg.brandl | 2010-10-30 16:33:28 +0200 (Sa, 30 Okt 2010) | 1 line
Fix test_mailbox by supporting context manager protocol for get_file() returns.
........
Modified:
python/branches/release31-maint/ (props changed)
1
0
Author: georg.brandl
Date: Fri Nov 26 09:59:40 2010
New Revision: 86786
Log:
Merged revisions 85820,85823,85825,85840,85843-85845,85849-85851,85855,85867,85875,85907-85908,85911,85914 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
........
r85820 | georg.brandl | 2010-10-24 16:20:22 +0200 (So, 24 Okt 2010) | 1 line
Remove usage of exception indexing.
........
r85823 | georg.brandl | 2010-10-24 16:32:45 +0200 (So, 24 Okt 2010) | 1 line
Fix style.
........
r85825 | georg.brandl | 2010-10-24 17:16:02 +0200 (So, 24 Okt 2010) | 1 line
Add documentation about the default warnings filters.
........
r85840 | georg.brandl | 2010-10-25 19:50:20 +0200 (Mo, 25 Okt 2010) | 1 line
#3018: tkinter demo fixes for py3k.
........
r85843 | georg.brandl | 2010-10-26 08:59:23 +0200 (Di, 26 Okt 2010) | 1 line
Markup fix.
........
r85844 | georg.brandl | 2010-10-26 12:39:14 +0200 (Di, 26 Okt 2010) | 1 line
Work a bit more on tkinter demos.
........
r85845 | georg.brandl | 2010-10-26 12:42:16 +0200 (Di, 26 Okt 2010) | 1 line
faqwiz is removed.
........
r85849 | georg.brandl | 2010-10-26 21:31:06 +0200 (Di, 26 Okt 2010) | 1 line
#10200: typo.
........
r85850 | georg.brandl | 2010-10-26 21:58:11 +0200 (Di, 26 Okt 2010) | 1 line
#10200: typo.
........
r85851 | georg.brandl | 2010-10-26 22:12:37 +0200 (Di, 26 Okt 2010) | 1 line
Fix import.
........
r85855 | georg.brandl | 2010-10-27 09:21:54 +0200 (Mi, 27 Okt 2010) | 1 line
Encoding fix.
........
r85867 | georg.brandl | 2010-10-27 22:01:51 +0200 (Mi, 27 Okt 2010) | 1 line
Add David.
........
r85875 | georg.brandl | 2010-10-28 10:38:30 +0200 (Do, 28 Okt 2010) | 1 line
Fix bytes/str issues in get-remote-certificate.py.
........
r85907 | georg.brandl | 2010-10-29 06:54:13 +0200 (Fr, 29 Okt 2010) | 1 line
#10222: fix for overzealous AIX compiler.
........
r85908 | georg.brandl | 2010-10-29 07:22:17 +0200 (Fr, 29 Okt 2010) | 1 line
send_bytes obviously needs bytes...
........
r85911 | georg.brandl | 2010-10-29 07:36:28 +0200 (Fr, 29 Okt 2010) | 1 line
Fix markup error and update false positive entries from "make suspicious".
........
r85914 | georg.brandl | 2010-10-29 08:17:38 +0200 (Fr, 29 Okt 2010) | 1 line
(?:...) is a non-capturing, but still grouping construct.
........
Added:
python/branches/release31-maint/Demo/tkinter/guido/attr_dialog.py
- copied unchanged from r85845, /python/branches/py3k/Demo/tkinter/guido/attr_dialog.py
python/branches/release31-maint/Demo/tkinter/guido/manpage.py
- copied unchanged from r85845, /python/branches/py3k/Demo/tkinter/guido/manpage.py
python/branches/release31-maint/Demo/tkinter/guido/mimeviewer.py
- copied unchanged from r85845, /python/branches/py3k/Demo/tkinter/guido/mimeviewer.py
python/branches/release31-maint/Demo/tkinter/guido/shell_window.py
- copied unchanged from r85845, /python/branches/py3k/Demo/tkinter/guido/shell_window.py
Removed:
python/branches/release31-maint/Demo/tkinter/guido/AttrDialog.py
python/branches/release31-maint/Demo/tkinter/guido/ManPage.py
python/branches/release31-maint/Demo/tkinter/guido/MimeViewer.py
python/branches/release31-maint/Demo/tkinter/guido/ShellWindow.py
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Demo/cgi/README
python/branches/release31-maint/Demo/md5test/md5driver.py
python/branches/release31-maint/Demo/tkinter/guido/ (props changed)
python/branches/release31-maint/Demo/tkinter/guido/canvasevents.py
python/branches/release31-maint/Demo/tkinter/guido/dialog.py
python/branches/release31-maint/Demo/tkinter/guido/electrons.py
python/branches/release31-maint/Demo/tkinter/guido/hanoi.py
python/branches/release31-maint/Demo/tkinter/guido/listtree.py
python/branches/release31-maint/Demo/tkinter/guido/mbox.py
python/branches/release31-maint/Demo/tkinter/guido/rmt.py
python/branches/release31-maint/Demo/tkinter/guido/solitaire.py
python/branches/release31-maint/Demo/tkinter/guido/sortvisu.py
python/branches/release31-maint/Demo/tkinter/guido/ss1.py
python/branches/release31-maint/Demo/tkinter/guido/svkill.py
python/branches/release31-maint/Demo/tkinter/guido/tkman.py
python/branches/release31-maint/Demo/tkinter/guido/wish.py
python/branches/release31-maint/Demo/tkinter/matt/bind-w-mult-calls-p-type.py
python/branches/release31-maint/Demo/tkinter/matt/entry-with-shared-variable.py
python/branches/release31-maint/Demo/tkinter/matt/pong-demo-1.py
python/branches/release31-maint/Demo/tkinter/matt/printing-coords-of-items.py
python/branches/release31-maint/Doc/library/locale.rst
python/branches/release31-maint/Doc/library/multiprocessing.rst
python/branches/release31-maint/Doc/library/re.rst
python/branches/release31-maint/Doc/library/string.rst
python/branches/release31-maint/Doc/library/warnings.rst
python/branches/release31-maint/Doc/tools/sphinxext/susp-ignored.csv
python/branches/release31-maint/Lib/test/test_ssl.py
python/branches/release31-maint/Misc/developers.txt
python/branches/release31-maint/Parser/tokenizer.h
python/branches/release31-maint/Tools/pynche/pyColorChooser.py
python/branches/release31-maint/Tools/ssl/get-remote-certificate.py
Modified: python/branches/release31-maint/Demo/cgi/README
==============================================================================
--- python/branches/release31-maint/Demo/cgi/README (original)
+++ python/branches/release31-maint/Demo/cgi/README Fri Nov 26 09:59:40 2010
@@ -1,8 +1,7 @@
CGI Examples
------------
-Here are some example CGI programs. For a larger example, see
-../../Tools/faqwiz/.
+Here are some example CGI programs.
cgi0.sh -- A shell script to test your server is configured for CGI
cgi1.py -- A Python script to test your server is configured for CGI
Modified: python/branches/release31-maint/Demo/md5test/md5driver.py
==============================================================================
--- python/branches/release31-maint/Demo/md5test/md5driver.py (original)
+++ python/branches/release31-maint/Demo/md5test/md5driver.py Fri Nov 26 09:59:40 2010
@@ -80,7 +80,7 @@
mdContext = md5()
while 1:
- data = sys.stdin.read(16)
+ data = sys.stdin.read(16).encode()
if not data:
break
mdContext.update(data)
Deleted: python/branches/release31-maint/Demo/tkinter/guido/AttrDialog.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/AttrDialog.py Fri Nov 26 09:59:40 2010
+++ (empty file)
@@ -1,451 +0,0 @@
-
-# The options of a widget are described by the following attributes
-# of the Pack and Widget dialogs:
-#
-# Dialog.current: {name: value}
-# -- changes during Widget's lifetime
-#
-# Dialog.options: {name: (default, klass)}
-# -- depends on widget class only
-#
-# Dialog.classes: {klass: (v0, v1, v2, ...) | 'boolean' | 'other'}
-# -- totally static, though different between PackDialog and WidgetDialog
-# (but even that could be unified)
-
-from tkinter import *
-
-class Option:
-
- varclass = StringVar # May be overridden
-
- def __init__(self, dialog, option):
- self.dialog = dialog
- self.option = option
- self.master = dialog.top
- self.default, self.klass = dialog.options[option]
- self.var = self.varclass(self.master)
- self.frame = Frame(self.master)
- self.frame.pack(fill=X)
- self.label = Label(self.frame, text=(option + ":"))
- self.label.pack(side=LEFT)
- self.update()
- self.addoption()
-
- def refresh(self):
- self.dialog.refresh()
- self.update()
-
- def update(self):
- try:
- self.current = self.dialog.current[self.option]
- except KeyError:
- self.current = self.default
- self.var.set(self.current)
-
- def set(self, e=None): # Should be overridden
- pass
-
-class BooleanOption(Option):
-
- varclass = BooleanVar
-
- def addoption(self):
- self.button = Checkbutton(self.frame,
- text='on/off',
- onvalue=1,
- offvalue=0,
- variable=self.var,
- relief=RAISED,
- borderwidth=2,
- command=self.set)
- self.button.pack(side=RIGHT)
-
-class EnumOption(Option):
-
- def addoption(self):
- self.button = Menubutton(self.frame,
- textvariable=self.var,
- relief=RAISED, borderwidth=2)
- self.button.pack(side=RIGHT)
- self.menu = Menu(self.button)
- self.button['menu'] = self.menu
- for v in self.dialog.classes[self.klass]:
- self.menu.add_radiobutton(
- label=v,
- variable=self.var,
- value=v,
- command=self.set)
-
-class StringOption(Option):
-
- def addoption(self):
- self.entry = Entry(self.frame,
- textvariable=self.var,
- width=10,
- relief=SUNKEN,
- borderwidth=2)
- self.entry.pack(side=RIGHT, fill=X, expand=1)
- self.entry.bind('<Return>', self.set)
-
-class ReadonlyOption(Option):
-
- def addoption(self):
- self.label = Label(self.frame, textvariable=self.var,
- anchor=E)
- self.label.pack(side=RIGHT)
-
-class Dialog:
-
- def __init__(self, master):
- self.master = master
- self.fixclasses()
- self.refresh()
- self.top = Toplevel(self.master)
- self.top.title(self.__class__.__name__)
- self.top.minsize(1, 1)
- self.addchoices()
-
- def refresh(self): pass # Must override
-
- def fixclasses(self): pass # May override
-
- def addchoices(self):
- self.choices = {}
- list = []
- for k, dc in self.options.items():
- list.append((k, dc))
- list.sort()
- for k, (d, c) in list:
- try:
- cl = self.classes[c]
- except KeyError:
- cl = 'unknown'
- if type(cl) == TupleType:
- cl = self.enumoption
- elif cl == 'boolean':
- cl = self.booleanoption
- elif cl == 'readonly':
- cl = self.readonlyoption
- else:
- cl = self.stringoption
- self.choices[k] = cl(self, k)
-
- # Must override:
- options = {}
- classes = {}
-
- # May override:
- booleanoption = BooleanOption
- stringoption = StringOption
- enumoption = EnumOption
- readonlyoption = ReadonlyOption
-
-class PackDialog(Dialog):
-
- def __init__(self, widget):
- self.widget = widget
- Dialog.__init__(self, widget)
-
- def refresh(self):
- self.current = self.widget.info()
- self.current['.class'] = self.widget.winfo_class()
- self.current['.name'] = self.widget._w
-
- class packoption: # Mix-in class
- def set(self, e=None):
- self.current = self.var.get()
- try:
- self.dialog.widget.pack(**{self.option: self.current})
- except TclError as msg:
- print(msg)
- self.refresh()
-
- class booleanoption(packoption, BooleanOption): pass
- class enumoption(packoption, EnumOption): pass
- class stringoption(packoption, StringOption): pass
- class readonlyoption(packoption, ReadonlyOption): pass
-
- options = {
- '.class': (None, 'Class'),
- '.name': (None, 'Name'),
- 'after': (None, 'Widget'),
- 'anchor': ('center', 'Anchor'),
- 'before': (None, 'Widget'),
- 'expand': ('no', 'Boolean'),
- 'fill': ('none', 'Fill'),
- 'in': (None, 'Widget'),
- 'ipadx': (0, 'Pad'),
- 'ipady': (0, 'Pad'),
- 'padx': (0, 'Pad'),
- 'pady': (0, 'Pad'),
- 'side': ('top', 'Side'),
- }
-
- classes = {
- 'Anchor': (N, NE, E, SE, S, SW, W, NW, CENTER),
- 'Boolean': 'boolean',
- 'Class': 'readonly',
- 'Expand': 'boolean',
- 'Fill': (NONE, X, Y, BOTH),
- 'Name': 'readonly',
- 'Pad': 'pixel',
- 'Side': (TOP, RIGHT, BOTTOM, LEFT),
- 'Widget': 'readonly',
- }
-
-class RemotePackDialog(PackDialog):
-
- def __init__(self, master, app, widget):
- self.master = master
- self.app = app
- self.widget = widget
- self.refresh()
- self.top = Toplevel(self.master)
- self.top.title(self.app + ' PackDialog')
- self.top.minsize(1, 1)
- self.addchoices()
-
- def refresh(self):
- try:
- words = self.master.tk.splitlist(
- self.master.send(self.app,
- 'pack',
- 'info',
- self.widget))
- except TclError as msg:
- print(msg)
- return
- dict = {}
- for i in range(0, len(words), 2):
- key = words[i][1:]
- value = words[i+1]
- dict[key] = value
- dict['.class'] = self.master.send(self.app,
- 'winfo',
- 'class',
- self.widget)
- dict['.name'] = self.widget
- self.current = dict
-
- class remotepackoption: # Mix-in class
- def set(self, e=None):
- self.current = self.var.get()
- try:
- self.dialog.master.send(
- self.dialog.app,
- 'pack',
- 'config',
- self.dialog.widget,
- '-'+self.option,
- self.dialog.master.tk.merge(
- self.current))
- except TclError as msg:
- print(msg)
- self.refresh()
-
- class booleanoption(remotepackoption, BooleanOption): pass
- class enumoption(remotepackoption, EnumOption): pass
- class stringoption(remotepackoption, StringOption): pass
- class readonlyoption(remotepackoption, ReadonlyOption): pass
-
-class WidgetDialog(Dialog):
-
- def __init__(self, widget):
- self.widget = widget
- self.klass = widget.winfo_class()
- Dialog.__init__(self, widget)
-
- def fixclasses(self):
- if self.klass in self.addclasses:
- classes = {}
- for c in (self.classes,
- self.addclasses[self.klass]):
- for k in c.keys():
- classes[k] = c[k]
- self.classes = classes
-
- def refresh(self):
- self.configuration = self.widget.config()
- self.update()
- self.current['.class'] = self.widget.winfo_class()
- self.current['.name'] = self.widget._w
-
- def update(self):
- self.current = {}
- self.options = {}
- for k, v in self.configuration.items():
- if len(v) > 4:
- self.current[k] = v[4]
- self.options[k] = v[3], v[2] # default, klass
- self.options['.class'] = (None, 'Class')
- self.options['.name'] = (None, 'Name')
-
- class widgetoption: # Mix-in class
- def set(self, e=None):
- self.current = self.var.get()
- try:
- self.dialog.widget[self.option] = self.current
- except TclError as msg:
- print(msg)
- self.refresh()
-
- class booleanoption(widgetoption, BooleanOption): pass
- class enumoption(widgetoption, EnumOption): pass
- class stringoption(widgetoption, StringOption): pass
- class readonlyoption(widgetoption, ReadonlyOption): pass
-
- # Universal classes
- classes = {
- 'Anchor': (N, NE, E, SE, S, SW, W, NW, CENTER),
- 'Aspect': 'integer',
- 'Background': 'color',
- 'Bitmap': 'bitmap',
- 'BorderWidth': 'pixel',
- 'Class': 'readonly',
- 'CloseEnough': 'double',
- 'Command': 'command',
- 'Confine': 'boolean',
- 'Cursor': 'cursor',
- 'CursorWidth': 'pixel',
- 'DisabledForeground': 'color',
- 'ExportSelection': 'boolean',
- 'Font': 'font',
- 'Foreground': 'color',
- 'From': 'integer',
- 'Geometry': 'geometry',
- 'Height': 'pixel',
- 'InsertWidth': 'time',
- 'Justify': (LEFT, CENTER, RIGHT),
- 'Label': 'string',
- 'Length': 'pixel',
- 'MenuName': 'widget',
- 'Name': 'readonly',
- 'OffTime': 'time',
- 'OnTime': 'time',
- 'Orient': (HORIZONTAL, VERTICAL),
- 'Pad': 'pixel',
- 'Relief': (RAISED, SUNKEN, FLAT, RIDGE, GROOVE),
- 'RepeatDelay': 'time',
- 'RepeatInterval': 'time',
- 'ScrollCommand': 'command',
- 'ScrollIncrement': 'pixel',
- 'ScrollRegion': 'rectangle',
- 'ShowValue': 'boolean',
- 'SetGrid': 'boolean',
- 'Sliderforeground': 'color',
- 'SliderLength': 'pixel',
- 'Text': 'string',
- 'TickInterval': 'integer',
- 'To': 'integer',
- 'Underline': 'index',
- 'Variable': 'variable',
- 'Value': 'string',
- 'Width': 'pixel',
- 'Wrap': (NONE, CHAR, WORD),
- }
-
- # Classes that (may) differ per widget type
- _tristate = {'State': (NORMAL, ACTIVE, DISABLED)}
- _bistate = {'State': (NORMAL, DISABLED)}
- addclasses = {
- 'Button': _tristate,
- 'Radiobutton': _tristate,
- 'Checkbutton': _tristate,
- 'Entry': _bistate,
- 'Text': _bistate,
- 'Menubutton': _tristate,
- 'Slider': _bistate,
- }
-
-class RemoteWidgetDialog(WidgetDialog):
-
- def __init__(self, master, app, widget):
- self.app = app
- self.widget = widget
- self.klass = master.send(self.app,
- 'winfo',
- 'class',
- self.widget)
- Dialog.__init__(self, master)
-
- def refresh(self):
- try:
- items = self.master.tk.splitlist(
- self.master.send(self.app,
- self.widget,
- 'config'))
- except TclError as msg:
- print(msg)
- return
- dict = {}
- for item in items:
- words = self.master.tk.splitlist(item)
- key = words[0][1:]
- value = (key,) + words[1:]
- dict[key] = value
- self.configuration = dict
- self.update()
- self.current['.class'] = self.klass
- self.current['.name'] = self.widget
-
- class remotewidgetoption: # Mix-in class
- def set(self, e=None):
- self.current = self.var.get()
- try:
- self.dialog.master.send(
- self.dialog.app,
- self.dialog.widget,
- 'config',
- '-'+self.option,
- self.current)
- except TclError as msg:
- print(msg)
- self.refresh()
-
- class booleanoption(remotewidgetoption, BooleanOption): pass
- class enumoption(remotewidgetoption, EnumOption): pass
- class stringoption(remotewidgetoption, StringOption): pass
- class readonlyoption(remotewidgetoption, ReadonlyOption): pass
-
-def test():
- import sys
- root = Tk()
- root.minsize(1, 1)
- if sys.argv[1:]:
- remotetest(root, sys.argv[1])
- else:
- frame = Frame(root, name='frame')
- frame.pack(expand=1, fill=BOTH)
- button = Button(frame, name='button', text='button')
- button.pack(expand=1)
- canvas = Canvas(frame, name='canvas')
- canvas.pack()
- fpd = PackDialog(frame)
- fwd = WidgetDialog(frame)
- bpd = PackDialog(button)
- bwd = WidgetDialog(button)
- cpd = PackDialog(canvas)
- cwd = WidgetDialog(canvas)
- root.mainloop()
-
-def remotetest(root, app):
- from listtree import listtree
- list = listtree(root, app)
- list.bind('<Any-Double-1>', opendialogs)
- list.app = app # Pass it on to handler
-
-def opendialogs(e):
- import string
- list = e.widget
- sel = list.curselection()
- for i in sel:
- item = list.get(i)
- widget = string.split(item)[0]
- RemoteWidgetDialog(list, list.app, widget)
- if widget == '.': continue
- try:
- RemotePackDialog(list, list.app, widget)
- except TclError as msg:
- print(msg)
-
-test()
Deleted: python/branches/release31-maint/Demo/tkinter/guido/ManPage.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/ManPage.py Fri Nov 26 09:59:40 2010
+++ (empty file)
@@ -1,220 +0,0 @@
-# Widget to display a man page
-
-import re
-from tkinter import *
-from tkinter import _tkinter
-from tkinter.scrolledtext import ScrolledText
-
-# XXX These fonts may have to be changed to match your system
-BOLDFONT = '*-Courier-Bold-R-Normal-*-120-*'
-ITALICFONT = '*-Courier-Medium-O-Normal-*-120-*'
-
-# XXX Recognizing footers is system dependent
-# (This one works for IRIX 5.2 and Solaris 2.2)
-footerprog = re.compile(
- '^ Page [1-9][0-9]*[ \t]+\|^.*Last change:.*[1-9][0-9]*\n')
-emptyprog = re.compile('^[ \t]*\n')
-ulprog = re.compile('^[ \t]*[Xv!_][Xv!_ \t]*\n')
-
-# Basic Man Page class -- does not disable editing
-class EditableManPage(ScrolledText):
-
- # Initialize instance
- def __init__(self, master=None, **cnf):
- # Initialize base class
- ScrolledText.__init__(self, master, **cnf)
-
- # Define tags for formatting styles
- self.tag_config('X', underline=1)
- self.tag_config('!', font=BOLDFONT)
- self.tag_config('_', font=ITALICFONT)
-
- # Set state to idle
- self.fp = None
- self.lineno = 0
-
- # Test whether we are busy parsing a file
- def busy(self):
- return self.fp != None
-
- # Ensure we're not busy
- def kill(self):
- if self.busy():
- self._endparser()
-
- # Parse a file, in the background
- def asyncparsefile(self, fp):
- self._startparser(fp)
- self.tk.createfilehandler(fp, _tkinter.READABLE,
- self._filehandler)
-
- parsefile = asyncparsefile # Alias
-
- # I/O handler used by background parsing
- def _filehandler(self, fp, mask):
- nextline = self.fp.readline()
- if not nextline:
- self._endparser()
- return
- self._parseline(nextline)
-
- # Parse a file, now (cannot be aborted)
- def syncparsefile(self, fp):
- from select import select
- def avail(fp=fp, tout=0.0, select=select):
- return select([fp], [], [], tout)[0]
- height = self.getint(self['height'])
- self._startparser(fp)
- while 1:
- nextline = fp.readline()
- if not nextline:
- break
- self._parseline(nextline)
- self._endparser()
-
- # Initialize parsing from a particular file -- must not be busy
- def _startparser(self, fp):
- if self.busy():
- raise RuntimeError('startparser: still busy')
- fp.fileno() # Test for file-ness
- self.fp = fp
- self.lineno = 0
- self.ok = 0
- self.empty = 0
- self.buffer = None
- savestate = self['state']
- self['state'] = NORMAL
- self.delete('1.0', END)
- self['state'] = savestate
-
- # End parsing -- must be busy, need not be at EOF
- def _endparser(self):
- if not self.busy():
- raise RuntimeError('endparser: not busy')
- if self.buffer:
- self._parseline('')
- try:
- self.tk.deletefilehandler(self.fp)
- except TclError as msg:
- pass
- self.fp.close()
- self.fp = None
- del self.ok, self.empty, self.buffer
-
- # Parse a single line
- def _parseline(self, nextline):
- if not self.buffer:
- # Save this line -- we need one line read-ahead
- self.buffer = nextline
- return
- if emptyprog.match(self.buffer) >= 0:
- # Buffered line was empty -- set a flag
- self.empty = 1
- self.buffer = nextline
- return
- textline = self.buffer
- if ulprog.match(nextline) >= 0:
- # Next line is properties for buffered line
- propline = nextline
- self.buffer = None
- else:
- # Next line is read-ahead
- propline = None
- self.buffer = nextline
- if not self.ok:
- # First non blank line after footer must be header
- # -- skip that too
- self.ok = 1
- self.empty = 0
- return
- if footerprog.match(textline) >= 0:
- # Footer -- start skipping until next non-blank line
- self.ok = 0
- self.empty = 0
- return
- savestate = self['state']
- self['state'] = NORMAL
- if TkVersion >= 4.0:
- self.mark_set('insert', 'end-1c')
- else:
- self.mark_set('insert', END)
- if self.empty:
- # One or more previous lines were empty
- # -- insert one blank line in the text
- self._insert_prop('\n')
- self.lineno = self.lineno + 1
- self.empty = 0
- if not propline:
- # No properties
- self._insert_prop(textline)
- else:
- # Search for properties
- p = ''
- j = 0
- for i in range(min(len(propline), len(textline))):
- if propline[i] != p:
- if j < i:
- self._insert_prop(textline[j:i], p)
- j = i
- p = propline[i]
- self._insert_prop(textline[j:])
- self.lineno = self.lineno + 1
- self['state'] = savestate
-
- # Insert a string at the end, with at most one property (tag)
- def _insert_prop(self, str, prop = ' '):
- here = self.index(AtInsert())
- self.insert(AtInsert(), str)
- if TkVersion <= 4.0:
- tags = self.tag_names(here)
- for tag in tags:
- self.tag_remove(tag, here, AtInsert())
- if prop != ' ':
- self.tag_add(prop, here, AtInsert())
-
-# Readonly Man Page class -- disables editing, otherwise the same
-class ReadonlyManPage(EditableManPage):
-
- # Initialize instance
- def __init__(self, master=None, **cnf):
- cnf['state'] = DISABLED
- EditableManPage.__init__(self, master, **cnf)
-
-# Alias
-ManPage = ReadonlyManPage
-
-# Test program.
-# usage: ManPage [manpage]; or ManPage [-f] file
-# -f means that the file is nroff -man output run through ul -i
-def test():
- import os
- import sys
- # XXX This directory may be different on your system
- MANDIR = '/usr/local/man/mann'
- DEFAULTPAGE = 'Tcl'
- formatted = 0
- if sys.argv[1:] and sys.argv[1] == '-f':
- formatted = 1
- del sys.argv[1]
- if sys.argv[1:]:
- name = sys.argv[1]
- else:
- name = DEFAULTPAGE
- if not formatted:
- if name[-2:-1] != '.':
- name = name + '.n'
- name = os.path.join(MANDIR, name)
- root = Tk()
- root.minsize(1, 1)
- manpage = ManPage(root, relief=SUNKEN, borderwidth=2)
- manpage.pack(expand=1, fill=BOTH)
- if formatted:
- fp = open(name, 'r')
- else:
- fp = os.popen('nroff -man %s | ul -i' % name, 'r')
- manpage.parsefile(fp)
- root.mainloop()
-
-# Run the test program when called as a script
-if __name__ == '__main__':
- test()
Deleted: python/branches/release31-maint/Demo/tkinter/guido/MimeViewer.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/MimeViewer.py Fri Nov 26 09:59:40 2010
+++ (empty file)
@@ -1,143 +0,0 @@
-#! /usr/bin/env python
-
-# View a single MIME multipart message.
-# Display each part as a box.
-
-import string
-from types import *
-from tkinter import *
-from tkinter.scrolledtext import ScrolledText
-
-class MimeViewer:
- def __init__(self, parent, title, msg):
- self.title = title
- self.msg = msg
- self.frame = Frame(parent, {'relief': 'raised', 'bd': 2})
- self.frame.packing = {'expand': 0, 'fill': 'both'}
- self.button = Checkbutton(self.frame,
- {'text': title,
- 'command': self.toggle})
- self.button.pack({'anchor': 'w'})
- headertext = msg.getheadertext(
- lambda x: x != 'received' and x[:5] != 'x400-')
- height = countlines(headertext, 4)
- if height:
- self.htext = ScrolledText(self.frame,
- {'height': height,
- 'width': 80,
- 'wrap': 'none',
- 'relief': 'raised',
- 'bd': 2})
- self.htext.packing = {'expand': 1, 'fill': 'both',
- 'after': self.button}
- self.htext.insert('end', headertext)
- else:
- self.htext = Frame(self.frame,
- {'relief': 'raised', 'bd': 2})
- self.htext.packing = {'side': 'top',
- 'ipady': 2,
- 'fill': 'x',
- 'after': self.button}
- body = msg.getbody()
- if type(body) == StringType:
- self.pad = None
- height = countlines(body, 10)
- if height:
- self.btext = ScrolledText(self.frame,
- {'height': height,
- 'width': 80,
- 'wrap': 'none',
- 'relief': 'raised',
- 'bd': 2})
- self.btext.packing = {'expand': 1,
- 'fill': 'both'}
- self.btext.insert('end', body)
- else:
- self.btext = None
- self.parts = None
- else:
- self.pad = Frame(self.frame,
- {'relief': 'flat', 'bd': 2})
- self.pad.packing = {'side': 'left', 'ipadx': 10,
- 'fill': 'y', 'after': self.htext}
- self.parts = []
- for i in range(len(body)):
- p = MimeViewer(self.frame,
- '%s.%d' % (title, i+1),
- body[i])
- self.parts.append(p)
- self.btext = None
- self.collapsed = 1
- def pack(self):
- self.frame.pack(self.frame.packing)
- def destroy(self):
- self.frame.destroy()
- def show(self):
- if self.collapsed:
- self.button.invoke()
- def toggle(self):
- if self.collapsed:
- self.explode()
- else:
- self.collapse()
- def collapse(self):
- self.collapsed = 1
- for comp in self.htext, self.btext, self.pad:
- if comp:
- comp.forget()
- if self.parts:
- for part in self.parts:
- part.frame.forget()
- self.frame.pack({'expand': 0})
- def explode(self):
- self.collapsed = 0
- for comp in self.htext, self.btext, self.pad:
- if comp: comp.pack(comp.packing)
- if self.parts:
- for part in self.parts:
- part.pack()
- self.frame.pack({'expand': 1})
-
-def countlines(str, limit):
- i = 0
- n = 0
- while n < limit:
- i = string.find(str, '\n', i)
- if i < 0: break
- n = n+1
- i = i+1
- return n
-
-def main():
- import sys
- import getopt
- import mhlib
- opts, args = getopt.getopt(sys.argv[1:], '')
- for o, a in opts:
- pass
- message = None
- folder = 'inbox'
- for arg in args:
- if arg[:1] == '+':
- folder = arg[1:]
- else:
- message = string.atoi(arg)
-
- mh = mhlib.MH()
- f = mh.openfolder(folder)
- if not message:
- message = f.getcurrent()
- m = f.openmessage(message)
-
- root = Tk()
- tk = root.tk
-
- top = MimeViewer(root, '+%s/%d' % (folder, message), m)
- top.pack()
- top.show()
-
- root.minsize(1, 1)
-
- tk.mainloop()
-
-if __name__ == '__main__': main()
Deleted: python/branches/release31-maint/Demo/tkinter/guido/ShellWindow.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/ShellWindow.py Fri Nov 26 09:59:40 2010
+++ (empty file)
@@ -1,147 +0,0 @@
-import os
-import sys
-import string
-from tkinter import *
-from tkinter.scrolledtext import ScrolledText
-from tkinter.dialog import Dialog
-import signal
-
-BUFSIZE = 512
-
-class ShellWindow(ScrolledText):
-
- def __init__(self, master=None, shell=None, **cnf):
- if not shell:
- try:
- shell = os.environ['SHELL']
- except KeyError:
- shell = '/bin/sh'
- shell = shell + ' -i'
- args = string.split(shell)
- shell = args[0]
-
- ScrolledText.__init__(self, master, **cnf)
- self.pos = '1.0'
- self.bind('<Return>', self.inputhandler)
- self.bind('<Control-c>', self.sigint)
- self.bind('<Control-t>', self.sigterm)
- self.bind('<Control-k>', self.sigkill)
- self.bind('<Control-d>', self.sendeof)
-
- self.pid, self.fromchild, self.tochild = spawn(shell, args)
- self.tk.createfilehandler(self.fromchild, READABLE,
- self.outputhandler)
-
- def outputhandler(self, file, mask):
- data = os.read(file, BUFSIZE)
- if not data:
- self.tk.deletefilehandler(file)
- pid, sts = os.waitpid(self.pid, 0)
- print('pid', pid, 'status', sts)
- self.pid = None
- detail = sts>>8
- cause = sts & 0xff
- if cause == 0:
- msg = "exit status %d" % detail
- else:
- msg = "killed by signal %d" % (cause & 0x7f)
- if cause & 0x80:
- msg = msg + " -- core dumped"
- Dialog(self.master,
- text=msg,
- title="Exit status",
- bitmap='warning',
- default=0,
- strings=('OK',))
- return
- self.insert(END, data)
- self.pos = self.index("end - 1 char")
- self.yview_pickplace(END)
-
- def inputhandler(self, *args):
- if not self.pid:
- self.no_process()
- return "break"
- self.insert(END, "\n")
- line = self.get(self.pos, "end - 1 char")
- self.pos = self.index(END)
- os.write(self.tochild, line)
- return "break"
-
- def sendeof(self, *args):
- if not self.pid:
- self.no_process()
- return "break"
- os.close(self.tochild)
- return "break"
-
- def sendsig(self, sig):
- if not self.pid:
- self.no_process()
- return "break"
- os.kill(self.pid, sig)
- return "break"
-
- def sigint(self, *args):
- return self.sendsig(signal.SIGINT)
-
- def sigquit(self, *args):
- return self.sendsig(signal.SIGQUIT)
-
- def sigterm(self, *args):
- return self.sendsig(signal.SIGTERM)
-
- def sigkill(self, *args):
- return self.sendsig(signal.SIGKILL)
-
- def no_process(self):
- Dialog(self.master,
- text="No active process",
- title="No process",
- bitmap='error',
- default=0,
- strings=('OK',))
-
-MAXFD = 100 # Max number of file descriptors (os.getdtablesize()???)
-
-def spawn(prog, args):
- p2cread, p2cwrite = os.pipe()
- c2pread, c2pwrite = os.pipe()
- pid = os.fork()
- if pid == 0:
- # Child
- for i in 0, 1, 2:
- try:
- os.close(i)
- except os.error:
- pass
- if os.dup(p2cread) != 0:
- sys.stderr.write('popen2: bad read dup\n')
- if os.dup(c2pwrite) != 1:
- sys.stderr.write('popen2: bad write dup\n')
- if os.dup(c2pwrite) != 2:
- sys.stderr.write('popen2: bad write dup\n')
- os.closerange(3, MAXFD)
- try:
- os.execvp(prog, args)
- finally:
- sys.stderr.write('execvp failed\n')
- os._exit(1)
- os.close(p2cread)
- os.close(c2pwrite)
- return pid, c2pread, p2cwrite
-
-def test():
- shell = string.join(sys.argv[1:])
- root = Tk()
- root.minsize(1, 1)
- if shell:
- w = ShellWindow(root, shell=shell)
- else:
- w = ShellWindow(root)
- w.pack(expand=1, fill=BOTH)
- w.focus_set()
- w.tk.mainloop()
-
-if __name__ == '__main__':
- test()
Modified: python/branches/release31-maint/Demo/tkinter/guido/canvasevents.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/canvasevents.py (original)
+++ python/branches/release31-maint/Demo/tkinter/guido/canvasevents.py Fri Nov 26 09:59:40 2010
@@ -1,15 +1,41 @@
#! /usr/bin/env python
from tkinter import *
-from Canvas import Oval, Group, CanvasText
-# Fix a bug in Canvas.Group as distributed in Python 1.4. The
-# distributed bind() method is broken. This is what should be used:
+# Since Canvas.Group is no longer present, the following class reproduces
+# a subset of the old Group class that is used by this app.
+
+class Group:
+ def __init__(self, canvas, tag=None):
+ if tag is None:
+ tag = 'Group%d' % id(self)
+
+ self.tag = self.id = tag
+ self.canvas = canvas
+ self.canvas.dtag(self.tag)
+
+ def __str__(self):
+ return self.tag
+
+ def _do(self, cmd, *args):
+ return self.canvas.tk.call(self.canvas._w, cmd, self.tag, *args)
+
+ def addtag_withtag(self, tagOrId):
+ self._do('addtag', 'withtag', tagOrId)
+
+ def bind(self, sequence=None, command=None, add=None):
+ return self.canvas.tag_bind(self.id, sequence, command, add)
+
+ def move(self, x_amount, y_amount):
+ self._do('move', x_amount, y_amount)
+
+ def dtag(self, tagToDelete=None):
+ self._do('dtag', tagToDelete)
+
+ def tkraise(self, aboveThis=None):
+ self._do('raise', aboveThis)
-class Group(Group):
- def bind(self, sequence=None, command=None):
- return self.canvas.tag_bind(self.id, sequence, command)
class Object:
@@ -29,7 +55,6 @@
All instance attributes are public since the derived class may
need them.
-
"""
def __init__(self, canvas, x=0, y=0, fill='red', text='object'):
@@ -44,12 +69,10 @@
return str(self.group)
def createitems(self, fill, text):
- self.__oval = Oval(self.canvas,
- self.x-20, self.y-10, self.x+20, self.y+10,
- fill=fill, width=3)
+ self.__oval = self.canvas.create_oval(self.x - 20, self.y - 10,
+ self.x + 20, self.y + 20, fill=fill, width=3)
self.group.addtag_withtag(self.__oval)
- self.__text = CanvasText(self.canvas,
- self.x, self.y, text=text)
+ self.__text = self.canvas.create_text(self.x, self.y, text=text)
self.group.addtag_withtag(self.__text)
def moveby(self, dx, dy):
@@ -75,18 +98,15 @@
class Bottom(Object):
-
"""An object to serve as the bottom of a pile."""
def createitems(self, *args):
- self.__oval = Oval(self.canvas,
- self.x-20, self.y-10, self.x+20, self.y+10,
- fill='gray', outline='')
+ self.__oval = self.canvas.create_oval(self.x - 20, self.y - 10,
+ self.x + 20, self.y + 10, fill='gray', outline='')
self.group.addtag_withtag(self.__oval)
class Pile:
-
"""A group of graphical objects."""
def __init__(self, canvas, x, y, tag=None):
Modified: python/branches/release31-maint/Demo/tkinter/guido/dialog.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/dialog.py (original)
+++ python/branches/release31-maint/Demo/tkinter/guido/dialog.py Fri Nov 26 09:59:40 2010
@@ -24,8 +24,7 @@
# 2. Fill the top part with the bitmap and message.
- msg = Message(top, width='3i', text=text,
- font='-Adobe-Times-Medium-R-Normal-*-180-*')
+ msg = Message(top, width='3i', text=text)
msg.pack(side=RIGHT, expand=1, fill=BOTH, padx='3m', pady='3m')
if bitmap:
bm = Label(top, bitmap=bitmap)
Modified: python/branches/release31-maint/Demo/tkinter/guido/electrons.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/electrons.py (original)
+++ python/branches/release31-maint/Demo/tkinter/guido/electrons.py Fri Nov 26 09:59:40 2010
@@ -62,11 +62,11 @@
# Main program
def main():
- import sys, string
+ import sys
# First argument is number of electrons, default 30
if sys.argv[1:]:
- n = string.atoi(sys.argv[1])
+ n = int(sys.argv[1])
else:
n = 30
Modified: python/branches/release31-maint/Demo/tkinter/guido/hanoi.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/hanoi.py (original)
+++ python/branches/release31-maint/Demo/tkinter/guido/hanoi.py Fri Nov 26 09:59:40 2010
@@ -125,11 +125,11 @@
# Main program
def main():
- import sys, string
+ import sys
# First argument is number of pegs, default 4
if sys.argv[1:]:
- n = string.atoi(sys.argv[1])
+ n = int(sys.argv[1])
else:
n = 4
Modified: python/branches/release31-maint/Demo/tkinter/guido/listtree.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/listtree.py (original)
+++ python/branches/release31-maint/Demo/tkinter/guido/listtree.py Fri Nov 26 09:59:40 2010
@@ -1,7 +1,6 @@
# List a remote app's widget tree (names and classes only)
import sys
-import string
from tkinter import *
@@ -13,8 +12,6 @@
def listnodes(list, app, widget, level):
klass = list.send(app, 'winfo', 'class', widget)
-## i = string.rindex(widget, '.')
-## list.insert(END, '%s%s (%s)' % ((level-1)*'. ', widget[i:], klass))
list.insert(END, '%s (%s)' % (widget, klass))
children = list.tk.splitlist(
list.send(app, 'winfo', 'children', widget))
Modified: python/branches/release31-maint/Demo/tkinter/guido/mbox.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/mbox.py (original)
+++ python/branches/release31-maint/Demo/tkinter/guido/mbox.py Fri Nov 26 09:59:40 2010
@@ -3,17 +3,15 @@
# Scan MH folder, display results in window
import os
-import sys
import re
+import sys
import getopt
-import string
-import mhlib
-
+import mailbox
from tkinter import *
from dialog import dialog
-mailbox = os.environ['HOME'] + '/Mail'
+MBOXPATH = os.environ['HOME'] + '/Mail'
def main():
global root, tk, top, mid, bot
@@ -38,8 +36,8 @@
# Initialize MH
- mh = mhlib.MH()
- mhf = mh.openfolder(folder)
+ mh = mailbox.MH(MBOXPATH)
+ mhf = mh.get_folder(folder)
# Build widget hierarchy
@@ -171,7 +169,7 @@
return
i = sel[0]
folder = folderbox.get(i)
- mhf = mh.openfolder(folder)
+ mhf = mh.get_folder(folder)
rescan()
def open_message(e=None):
@@ -189,11 +187,12 @@
tk.call('update', 'idletasks')
i = sel[0]
line = scanbox.get(i)
- if scanparser.match(line) >= 0:
- num = string.atoi(scanparser.group(1))
- m = mhf.openmessage(num)
+ m = scanparser.match(line)
+ if m:
+ num = int(m.group(1))
+ m = mhf.get_message(num)
if viewer: viewer.destroy()
- from MimeViewer import MimeViewer
+ from mimeviewer import MimeViewer
viewer = MimeViewer(bot, '+%s/%d' % (folder, num), m)
viewer.pack()
viewer.show()
@@ -212,9 +211,11 @@
todo = []
for i in sel:
line = scanbox.get(i)
- if scanparser.match(line) >= 0:
- todo.append(string.atoi(scanparser.group(1)))
- mhf.removemessages(todo)
+ m = scanparser.match(line)
+ if m:
+ toremove = int(m.group(1))
+ todo.append(toremove)
+ mhf.remove(toremove)
rescan()
fixfocus(min(todo), itop)
@@ -240,12 +241,13 @@
todo = []
for i in sel:
line = scanbox.get(i)
- if scanparser.match(line) >= 0:
- todo.append(string.atoi(scanparser.group(1)))
+ m = scanparser.match(line)
+ if m:
+ todo.append(int(m.group(1)))
if lastrefile != refileto or not tofolder:
lastrefile = refileto
tofolder = None
- tofolder = mh.openfolder(lastrefile)
+ tofolder = mh.get_folder(lastrefile)
mhf.refilemessages(todo, tofolder)
rescan()
fixfocus(min(todo), itop)
@@ -254,18 +256,18 @@
n = scanbox.size()
for i in range(n):
line = scanbox.get(repr(i))
- if scanparser.match(line) >= 0:
- num = string.atoi(scanparser.group(1))
+ m = scanparser.match(line)
+ if m:
+ num = int(m.group(1))
if num >= near:
break
else:
i = 'end'
- scanbox.select_from(i)
scanbox.yview(itop)
def setfolders():
folderbox.delete(0, 'end')
- for fn in mh.listallfolders():
+ for fn in mh.list_folders():
folderbox.insert('end', fn)
def rescan():
@@ -278,6 +280,7 @@
scanbox.insert('end', line)
def scanfolder(folder = 'inbox', sequence = 'all'):
- return [line[:-1] for line in os.popen('scan +%s %s' % (folder, sequence), 'r').readlines()]
+ return [line[:-1] for line in
+ os.popen('scan +%s %s' % (folder, sequence), 'r').readlines()]
main()
Modified: python/branches/release31-maint/Demo/tkinter/guido/rmt.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/rmt.py (original)
+++ python/branches/release31-maint/Demo/tkinter/guido/rmt.py Fri Nov 26 09:59:40 2010
@@ -28,7 +28,7 @@
s.pack(side=RIGHT, fill=Y)
t = Text(f, relief=RAISED, borderwidth=2, yscrollcommand=s.set, setgrid=1)
t.pack(side=LEFT, fill=BOTH, expand=1)
-t.tag_config('bold', font='-Adobe-Courier-Bold-R-Normal-*-120-*')
+t.tag_config('bold')
s['command'] = t.yview
root.title('Tk Remote Controller')
Modified: python/branches/release31-maint/Demo/tkinter/guido/solitaire.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/solitaire.py (original)
+++ python/branches/release31-maint/Demo/tkinter/guido/solitaire.py Fri Nov 26 09:59:40 2010
@@ -22,20 +22,10 @@
# Imports
-import math
import random
from tkinter import *
-from Canvas import Rectangle, CanvasText, Group, Window
-
-
-# Fix a bug in Canvas.Group as distributed in Python 1.4. The
-# distributed bind() method is broken. Rather than asking you to fix
-# the source, we fix it here by deriving a subclass:
-
-class Group(Group):
- def bind(self, sequence=None, command=None):
- return self.canvas.tag_bind(self.id, sequence, command)
+from canvasevents import Group
# Constants determining the size and lay-out of cards and stacks. We
@@ -165,20 +155,22 @@
self.face_shown = 0
self.x = self.y = 0
+ self.canvas = canvas
self.group = Group(canvas)
text = "%s %s" % (VALNAMES[value], suit)
- self.__text = CanvasText(canvas, CARDWIDTH//2, 0,
- anchor=N, fill=self.color, text=text)
+ self.__text = canvas.create_text(CARDWIDTH // 2, 0, anchor=N,
+ fill=self.color, text=text)
self.group.addtag_withtag(self.__text)
- self.__rect = Rectangle(canvas, 0, 0, CARDWIDTH, CARDHEIGHT,
- outline='black', fill='white')
+ self.__rect = canvas.create_rectangle(0, 0, CARDWIDTH, CARDHEIGHT,
+ outline='black', fill='white')
self.group.addtag_withtag(self.__rect)
- self.__back = Rectangle(canvas, MARGIN, MARGIN,
- CARDWIDTH-MARGIN, CARDHEIGHT-MARGIN,
- outline='black', fill='blue')
+ self.__back = canvas.create_rectangle(MARGIN, MARGIN,
+ CARDWIDTH - MARGIN,
+ CARDHEIGHT - MARGIN,
+ outline='black', fill='blue')
self.group.addtag_withtag(self.__back)
def __repr__(self):
@@ -202,15 +194,15 @@
def showface(self):
"""Turn the card's face up."""
self.tkraise()
- self.__rect.tkraise()
- self.__text.tkraise()
+ self.canvas.tag_raise(self.__rect)
+ self.canvas.tag_raise(self.__text)
self.face_shown = 1
def showback(self):
"""Turn the card's face down."""
self.tkraise()
- self.__rect.tkraise()
- self.__back.tkraise()
+ self.canvas.tag_raise(self.__rect)
+ self.canvas.tag_raise(self.__back)
self.face_shown = 0
@@ -400,10 +392,9 @@
"""
def makebottom(self):
- bottom = Rectangle(self.game.canvas,
- self.x, self.y,
- self.x+CARDWIDTH, self.y+CARDHEIGHT,
- outline='black', fill=BACKGROUND)
+ bottom = self.game.canvas.create_rectangle(self.x, self.y,
+ self.x + CARDWIDTH, self.y + CARDHEIGHT, outline='black',
+ fill=BACKGROUND)
self.group.addtag_withtag(bottom)
def fill(self):
@@ -435,7 +426,7 @@
def randperm(n):
"""Function returning a random permutation of range(n)."""
- r = range(n)
+ r = list(range(n))
x = []
while r:
i = random.choice(r)
@@ -478,10 +469,8 @@
class SuitStack(OpenStack):
def makebottom(self):
- bottom = Rectangle(self.game.canvas,
- self.x, self.y,
- self.x+CARDWIDTH, self.y+CARDHEIGHT,
- outline='black', fill='')
+ bottom = self.game.canvas.create_rectangle(self.x, self.y,
+ self.x + CARDWIDTH, self.y + CARDHEIGHT, outline='black', fill='')
def userclickhandler(self):
pass
@@ -540,8 +529,8 @@
background=BACKGROUND,
activebackground="green",
command=self.deal)
- Window(self.canvas, MARGIN, 3*YSPACING + 20,
- window=self.dealbutton, anchor=SW)
+ self.canvas.create_window(MARGIN, 3 * YSPACING + 20,
+ window=self.dealbutton, anchor=SW)
x = MARGIN
y = MARGIN
Modified: python/branches/release31-maint/Demo/tkinter/guido/sortvisu.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/sortvisu.py (original)
+++ python/branches/release31-maint/Demo/tkinter/guido/sortvisu.py Fri Nov 26 09:59:40 2010
@@ -18,9 +18,7 @@
"""
-
from tkinter import *
-from Canvas import Line, Rectangle
import random
@@ -31,6 +29,9 @@
class Array:
+ class Cancelled(BaseException):
+ pass
+
def __init__(self, master, data=None):
self.master = master
self.frame = Frame(self.master)
@@ -41,9 +42,9 @@
self.canvas.pack()
self.report = Label(self.frame)
self.report.pack()
- self.left = Line(self.canvas, 0, 0, 0, 0)
- self.right = Line(self.canvas, 0, 0, 0, 0)
- self.pivot = Line(self.canvas, 0, 0, 0, 0)
+ self.left = self.canvas.create_line(0, 0, 0, 0)
+ self.right = self.canvas.create_line(0, 0, 0, 0)
+ self.pivot = self.canvas.create_line(0, 0, 0, 0)
self.items = []
self.size = self.maxvalue = 0
if data:
@@ -82,8 +83,6 @@
if self.in_mainloop:
self.master.quit()
- Cancelled = "Array.Cancelled" # Exception
-
def wait(self, msecs):
if self.speed == "fastest":
msecs = 0
@@ -110,15 +109,15 @@
for i in range(self.size):
item = self.items[i]
if first <= i < last:
- item.item.config(fill='red')
+ self.canvas.itemconfig(item, fill='red')
else:
- item.item.config(fill='orange')
+ self.canvas.itemconfig(item, fill='orange')
self.hide_left_right_pivot()
def hide_partition(self):
for i in range(self.size):
item = self.items[i]
- item.item.config(fill='red')
+ self.canvas.itemconfig(item, fill='red')
self.hide_left_right_pivot()
def show_left(self, left):
@@ -127,7 +126,7 @@
return
x1, y1, x2, y2 = self.items[left].position()
## top, bot = HIRO
- self.left.coords([(x1-2, 0), (x1-2, 9999)])
+ self.canvas.coords(self.left, (x1 - 2, 0, x1 - 2, 9999))
self.master.update()
def show_right(self, right):
@@ -135,7 +134,7 @@
self.hide_right()
return
x1, y1, x2, y2 = self.items[right].position()
- self.right.coords(((x2+2, 0), (x2+2, 9999)))
+ self.canvas.coords(self.right, (x2 + 2, 0, x2 + 2, 9999))
self.master.update()
def hide_left_right_pivot(self):
@@ -144,17 +143,17 @@
self.hide_pivot()
def hide_left(self):
- self.left.coords(((0, 0), (0, 0)))
+ self.canvas.coords(self.left, (0, 0, 0, 0))
def hide_right(self):
- self.right.coords(((0, 0), (0, 0)))
+ self.canvas.coords(self.right, (0, 0, 0, 0))
def show_pivot(self, pivot):
x1, y1, x2, y2 = self.items[pivot].position()
- self.pivot.coords(((0, y1-2), (9999, y1-2)))
+ self.canvas.coords(self.pivot, (0, y1 - 2, 9999, y1 - 2))
def hide_pivot(self):
- self.pivot.coords(((0, 0), (0, 0)))
+ self.canvas.coords(self.pivot, (0, 0, 0, 0))
def swap(self, i, j):
if i == j: return
@@ -199,28 +198,30 @@
self.array = array
self.index = index
self.value = value
+ self.canvas = array.canvas
x1, y1, x2, y2 = self.position()
- self.item = Rectangle(array.canvas, x1, y1, x2, y2,
- fill='red', outline='black', width=1)
- self.item.bind('<Button-1>', self.mouse_down)
- self.item.bind('<Button1-Motion>', self.mouse_move)
- self.item.bind('<ButtonRelease-1>', self.mouse_up)
+ self.item_id = array.canvas.create_rectangle(x1, y1, x2, y2,
+ fill='red', outline='black', width=1)
+ self.canvas.tag_bind(self.item_id, '<Button-1>', self.mouse_down)
+ self.canvas.tag_bind(self.item_id, '<Button1-Motion>', self.mouse_move)
+ self.canvas.tag_bind(self.item_id, '<ButtonRelease-1>', self.mouse_up)
def delete(self):
- item = self.item
+ item_id = self.item_id
self.array = None
- self.item = None
- item.delete()
+ self.item_id = None
+ self.canvas.delete(item_id)
def mouse_down(self, event):
self.lastx = event.x
self.lasty = event.y
self.origx = event.x
self.origy = event.y
- self.item.tkraise()
+ self.canvas.tag_raise(self.item_id)
def mouse_move(self, event):
- self.item.move(event.x - self.lastx, event.y - self.lasty)
+ self.canvas.move(self.item_id,
+ event.x - self.lastx, event.y - self.lasty)
self.lastx = event.x
self.lasty = event.y
@@ -235,7 +236,7 @@
self.array.items[here], self.array.items[i] = other, self
self.index = i
x1, y1, x2, y2 = self.position()
- self.item.coords(((x1, y1), (x2, y2)))
+ self.canvas.coords(self.item_id, (x1, y1, x2, y2))
other.setindex(here)
def setindex(self, index):
@@ -247,9 +248,9 @@
self.index = index
newpts = self.position()
trajectory = interpolate(oldpts, newpts, nsteps)
- self.item.tkraise()
+ self.canvas.tag_raise(self.item_id)
for pts in trajectory:
- self.item.coords((pts[:2], pts[2:]))
+ self.canvas.coords(self.item_id, pts)
self.array.wait(50)
def swapwith(self, other):
@@ -262,61 +263,63 @@
self.index, other.index = other.index, self.index
mynewpts = self.position()
othernewpts = other.position()
- myfill = self.item['fill']
- otherfill = other.item['fill']
- self.item.config(fill='green')
- other.item.config(fill='yellow')
+ myfill = self.canvas.itemcget(self.item_id, 'fill')
+ otherfill = self.canvas.itemcget(other.item_id, 'fill')
+ self.canvas.itemconfig(self.item_id, fill='green')
+ self.canvas.itemconfig(other.item_id, fill='yellow')
self.array.master.update()
if self.array.speed == "single-step":
- self.item.coords((mynewpts[:2], mynewpts[2:]))
- other.item.coords((othernewpts[:2], othernewpts[2:]))
+ self.canvas.coords(self.item_id, mynewpts)
+ self.canvas.coords(other.item_id, othernewpts)
self.array.master.update()
- self.item.config(fill=myfill)
- other.item.config(fill=otherfill)
+ self.canvas.itemconfig(self.item_id, fill=myfill)
+ self.canvas.itemconfig(other.item_id, fill=otherfill)
self.array.wait(0)
return
mytrajectory = interpolate(myoldpts, mynewpts, nsteps)
othertrajectory = interpolate(otheroldpts, othernewpts, nsteps)
if self.value > other.value:
- self.item.tkraise()
- other.item.tkraise()
+ self.canvas.tag_raise(self.item_id)
+ self.canvas.tag_raise(other.item_id)
else:
- other.item.tkraise()
- self.item.tkraise()
+ self.canvas.tag_raise(other.item_id)
+ self.canvas.tag_raise(self.item_id)
try:
for i in range(len(mytrajectory)):
mypts = mytrajectory[i]
otherpts = othertrajectory[i]
- self.item.coords((mypts[:2], mypts[2:]))
- other.item.coords((otherpts[:2], otherpts[2:]))
+ self.canvas.coords(self.item_id, mypts)
+ self.canvas.coords(other.item_id, otherpts)
self.array.wait(50)
finally:
mypts = mytrajectory[-1]
otherpts = othertrajectory[-1]
- self.item.coords((mypts[:2], mypts[2:]))
- other.item.coords((otherpts[:2], otherpts[2:]))
- self.item.config(fill=myfill)
- other.item.config(fill=otherfill)
+ self.canvas.coords(self.item_id, mypts)
+ self.canvas.coords(other.item_id, otherpts)
+ self.canvas.itemconfig(self.item_id, fill=myfill)
+ self.canvas.itemconfig(other.item_id, fill=otherfill)
def compareto(self, other):
- myfill = self.item['fill']
- otherfill = other.item['fill']
- outcome = cmp(self.value, other.value)
- if outcome < 0:
+ myfill = self.canvas.itemcget(self.item_id, 'fill')
+ otherfill = self.canvas.itemcget(other.item_id, 'fill')
+ if self.value < other.value:
myflash = 'white'
otherflash = 'black'
- elif outcome > 0:
+ outcome = -1
+ elif self.value > other.value:
myflash = 'black'
otherflash = 'white'
+ outcome = 1
else:
myflash = otherflash = 'grey'
+ outcome = 0
try:
- self.item.config(fill=myflash)
- other.item.config(fill=otherflash)
+ self.canvas.itemconfig(self.item_id, fill=myflash)
+ self.canvas.itemconfig(other.item_id, fill=otherflash)
self.array.wait(500)
finally:
- self.item.config(fill=myfill)
- other.item.config(fill=otherfill)
+ self.canvas.itemconfig(self.item_id, fill=myfill)
+ self.canvas.itemconfig(other.item_id, fill=otherfill)
return outcome
def position(self):
@@ -429,7 +432,7 @@
j = j-1
continue
array.message("Choosing pivot")
- j, i, k = first, (first+last)//2, last-1
+ j, i, k = first, (first+last) // 2, last-1
if array.compare(k, i) < 0:
array.swap(k, i)
if array.compare(k, j) < 0:
@@ -519,7 +522,7 @@
self.v_size = MyIntVar(self.master, self)
self.v_size.set(size)
- sizes = [1, 2, 3, 4] + range(5, 55, 5)
+ sizes = [1, 2, 3, 4] + list(range(5, 55, 5))
if self.size not in sizes:
sizes.append(self.size)
sizes.sort()
Modified: python/branches/release31-maint/Demo/tkinter/guido/ss1.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/ss1.py (original)
+++ python/branches/release31-maint/Demo/tkinter/guido/ss1.py Fri Nov 26 09:59:40 2010
@@ -3,7 +3,7 @@
import os
import re
import sys
-import cgi
+import html
from xml.parsers import expat
LEFT, CENTER, RIGHT = "LEFT", "CENTER", "RIGHT"
@@ -201,7 +201,7 @@
if hasattr(cell, 'xml'):
cellxml = cell.xml()
else:
- cellxml = '<value>%s</value>' % cgi.escape(cell)
+ cellxml = '<value>%s</value>' % html.escape(cell)
out.append('<cell row="%s" col="%s">\n %s\n</cell>' %
(y, x, cellxml))
out.append('</spreadsheet>')
@@ -216,7 +216,7 @@
f.close()
def load(self, filename):
- f = open(filename, 'r')
+ f = open(filename, 'rb')
SheetParser(self).parsefile(f)
f.close()
@@ -382,7 +382,7 @@
return s % (
align2xml[self.alignment],
self.fmt,
- cgi.escape(self.text))
+ html.escape(self.text))
class FormulaCell(BaseCell):
Modified: python/branches/release31-maint/Demo/tkinter/guido/svkill.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/svkill.py (original)
+++ python/branches/release31-maint/Demo/tkinter/guido/svkill.py Fri Nov 26 09:59:40 2010
@@ -7,8 +7,6 @@
if TkVersion < 4.0:
raise ImportError("This version of svkill requires Tk 4.0 or later")
-from string import splitfields
-from string import split
import subprocess
import os
@@ -40,14 +38,14 @@
]
def kill(self, selected):
c = self.format_list[self.format.get()][2]
- pid = split(selected)[c]
+ pid = selected.split()[c]
os.system('kill -9 ' + pid)
self.do_update()
def do_update(self):
format = self.format_list[self.format.get()][1]
view = self.view_list[self.view.get()][1]
s = subprocess.getoutput('ps %s %s' % (view, format))
- list = splitfields(s, '\n')
+ list = s.split('\n')
self.header.set(list[0] + ' ')
del list[0]
self.frame.list.delete(0, AtEnd())
@@ -97,14 +95,12 @@
self.header = StringVar(self)
self.frame.label = Label(
self.frame, relief=FLAT, anchor=NW, borderwidth=0,
- font='*-Courier-Bold-R-Normal-*-120-*',
textvariable=self.header)
self.frame.label.pack(fill=Y, anchor=W)
self.frame.vscroll = Scrollbar(self.frame, orient=VERTICAL)
self.frame.list = Listbox(
self.frame,
relief=SUNKEN,
- font='*-Courier-Medium-R-Normal-*-120-*',
width=40, height=10,
selectbackground='#eed5b7',
selectborderwidth=0,
Modified: python/branches/release31-maint/Demo/tkinter/guido/tkman.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/tkman.py (original)
+++ python/branches/release31-maint/Demo/tkinter/guido/tkman.py Fri Nov 26 09:59:40 2010
@@ -2,15 +2,15 @@
# Tk man page browser -- currently only shows the Tcl/Tk man pages
-import sys
import os
-import string
import re
+import sys
from tkinter import *
-from ManPage import ManPage
-MANNDIRLIST = ['/depot/sundry/man/mann','/usr/local/man/mann']
-MAN3DIRLIST = ['/depot/sundry/man/man3','/usr/local/man/man3']
+from manpage import ManPage
+
+MANNDIRLIST = ['/usr/local/man/mann', '/usr/share/man/mann']
+MAN3DIRLIST = ['/usr/local/man/man3', '/usr/share/man/man3']
foundmanndir = 0
for dir in MANNDIRLIST:
@@ -197,7 +197,7 @@
def show_page(self, name):
file = '%s/%s.?' % (self.chaptervar.get(), name)
- fp = os.popen('nroff -man %s | ul -i' % file, 'r')
+ fp = os.popen('nroff -man -c %s | ul -i' % file, 'r')
self.text.kill()
self.title['text'] = name
self.text.parsefile(fp)
@@ -221,9 +221,9 @@
print('Regex error:', msg)
return
here = self.text.index(AtInsert())
- lineno = string.atoi(here[:string.find(here, '.')])
+ lineno = int(here[:here.find('.')])
end = self.text.index(AtEnd())
- endlineno = string.atoi(end[:string.find(end, '.')])
+ endlineno = int(end[:end.find('.')])
wraplineno = lineno
found = 0
while 1:
@@ -237,9 +237,9 @@
line = self.text.get('%d.0 linestart' % lineno,
'%d.0 lineend' % lineno)
i = prog.search(line)
- if i >= 0:
+ if i:
found = 1
- n = max(1, len(prog.group(0)))
+ n = max(1, len(i.group(0)))
try:
self.text.tag_remove('sel',
AtSelFirst(),
@@ -247,10 +247,10 @@
except TclError:
pass
self.text.tag_add('sel',
- '%d.%d' % (lineno, i),
- '%d.%d' % (lineno, i+n))
+ '%d.%d' % (lineno, i.start()),
+ '%d.%d' % (lineno, i.start()+n))
self.text.mark_set(AtInsert(),
- '%d.%d' % (lineno, i))
+ '%d.%d' % (lineno, i.start()))
self.text.yview_pickplace(AtInsert())
break
if not found:
Modified: python/branches/release31-maint/Demo/tkinter/guido/wish.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/guido/wish.py (original)
+++ python/branches/release31-maint/Demo/tkinter/guido/wish.py Fri Nov 26 09:59:40 2010
@@ -4,21 +4,25 @@
import os
import sys
-tk = _tkinter.create(os.environ['DISPLAY'], 'wish', 'Tk', 1)
+tk = _tkinter.create(os.environ['DISPLAY'], 'wish', 'Tk', 1, 1)
tk.call('update')
cmd = ''
-while 1:
- if cmd: prompt = ''
- else: prompt = '% '
+while True:
+ if cmd:
+ prompt = ''
+ else:
+ prompt = '% '
try:
sys.stdout.write(prompt)
sys.stdout.flush()
line = sys.stdin.readline()
+ if not line:
+ break
except EOFError:
break
- cmd = cmd + (line + '\n')
+ cmd += line
if tk.getboolean(tk.call('info', 'complete', cmd)):
tk.record(line)
try:
Modified: python/branches/release31-maint/Demo/tkinter/matt/bind-w-mult-calls-p-type.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/matt/bind-w-mult-calls-p-type.py (original)
+++ python/branches/release31-maint/Demo/tkinter/matt/bind-w-mult-calls-p-type.py Fri Nov 26 09:59:40 2010
@@ -1,5 +1,4 @@
from tkinter import *
-import string
# This program shows how to use a simple type-in box
Modified: python/branches/release31-maint/Demo/tkinter/matt/entry-with-shared-variable.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/matt/entry-with-shared-variable.py (original)
+++ python/branches/release31-maint/Demo/tkinter/matt/entry-with-shared-variable.py Fri Nov 26 09:59:40 2010
@@ -1,5 +1,4 @@
from tkinter import *
-import string
# This program shows how to make a typein box shadow a program variable.
@@ -35,7 +34,7 @@
# because it's being looked at by the entry widget, changing
# the variable changes the entry widget display automatically.
# the strange get/set operators are clunky, true...
- str = string.upper(self.contents.get())
+ str = self.contents.get().upper()
self.contents.set(str)
def print_contents(self, event):
Modified: python/branches/release31-maint/Demo/tkinter/matt/pong-demo-1.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/matt/pong-demo-1.py (original)
+++ python/branches/release31-maint/Demo/tkinter/matt/pong-demo-1.py Fri Nov 26 09:59:40 2010
@@ -1,7 +1,5 @@
from tkinter import *
-import string
-
class Pong(Frame):
def createWidgets(self):
Modified: python/branches/release31-maint/Demo/tkinter/matt/printing-coords-of-items.py
==============================================================================
--- python/branches/release31-maint/Demo/tkinter/matt/printing-coords-of-items.py (original)
+++ python/branches/release31-maint/Demo/tkinter/matt/printing-coords-of-items.py Fri Nov 26 09:59:40 2010
@@ -35,7 +35,7 @@
# the "current" tag is applied to the object the cursor is over.
# this happens automatically.
self.draw.itemconfig(CURRENT, fill="red")
- print(self.draw.coords(CURRENT))
+ print(list(self.draw.coords(CURRENT)))
def mouseLeave(self, event):
# the "current" tag is applied to the object the cursor is over.
Modified: python/branches/release31-maint/Doc/library/locale.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/locale.rst (original)
+++ python/branches/release31-maint/Doc/library/locale.rst Fri Nov 26 09:59:40 2010
@@ -529,7 +529,7 @@
Python applications should normally find no need to invoke these functions, and
should use :mod:`gettext` instead. A known exception to this rule are
-applications that link use additional C libraries which internally invoke
+applications that link with additional C libraries which internally invoke
:cfunc:`gettext` or :func:`dcgettext`. For these applications, it may be
necessary to bind the text domain, so that the libraries can properly locate
their message catalogs.
Modified: python/branches/release31-maint/Doc/library/multiprocessing.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/multiprocessing.rst (original)
+++ python/branches/release31-maint/Doc/library/multiprocessing.rst Fri Nov 26 09:59:40 2010
@@ -792,9 +792,9 @@
>>> a.send([1, 'hello', None])
>>> b.recv()
[1, 'hello', None]
- >>> b.send_bytes('thank you')
+ >>> b.send_bytes(b'thank you')
>>> a.recv_bytes()
- 'thank you'
+ b'thank you'
>>> import array
>>> arr1 = array.array('i', range(5))
>>> arr2 = array.array('i', [0] * 10)
Modified: python/branches/release31-maint/Doc/library/re.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/re.rst (original)
+++ python/branches/release31-maint/Doc/library/re.rst Fri Nov 26 09:59:40 2010
@@ -229,7 +229,7 @@
undefined.
``(?:...)``
- A non-grouping version of regular parentheses. Matches whatever regular
+ A non-capturing version of regular parentheses. Matches whatever regular
expression is inside the parentheses, but the substring matched by the group
*cannot* be retrieved after performing a match or referenced later in the
pattern.
Modified: python/branches/release31-maint/Doc/library/string.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/string.rst (original)
+++ python/branches/release31-maint/Doc/library/string.rst Fri Nov 26 09:59:40 2010
@@ -114,7 +114,7 @@
Loop over the format_string and return an iterable of tuples
(*literal_text*, *field_name*, *format_spec*, *conversion*). This is used
- by :meth:`vformat` to break the string in to either literal text, or
+ by :meth:`vformat` to break the string into either literal text, or
replacement fields.
The values in the tuple conceptually represent a span of literal text
Modified: python/branches/release31-maint/Doc/library/warnings.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/warnings.rst (original)
+++ python/branches/release31-maint/Doc/library/warnings.rst Fri Nov 26 09:59:40 2010
@@ -159,6 +159,20 @@
warnings.simplefilter('default', ImportWarning)
+Default Warning Filters
+~~~~~~~~~~~~~~~~~~~~~~~
+
+By default, Python installs several warning filters, which can be overridden by
+the command-line options passed to :option:`-W` and calls to
+:func:`filterwarnings`.
+
+* :exc:`PendingDeprecationWarning`, and :exc:`ImportWarning` are ignored.
+
+* :exc:`BytesWarning` is ignored unless the :option:`-b` option is given once or
+ twice; in this case this warning is either printed (``-b``) or turned into an
+ exception (``-bb``).
+
+
.. _warning-suppress:
Temporarily Suppressing Warnings
Modified: python/branches/release31-maint/Doc/tools/sphinxext/susp-ignored.csv
==============================================================================
--- python/branches/release31-maint/Doc/tools/sphinxext/susp-ignored.csv (original)
+++ python/branches/release31-maint/Doc/tools/sphinxext/susp-ignored.csv Fri Nov 26 09:59:40 2010
@@ -207,14 +207,14 @@
library/nntplib,272,:lines,:lines
library/nntplib,272,:lines,"['xref', 'from', ':lines', ':bytes', 'references', 'date', 'message-id', 'subject']"
library/nntplib,272,:bytes,"['xref', 'from', ':lines', ':bytes', 'references', 'date', 'message-id', 'subject']"
-library/pickle,567,:memory,"conn = sqlite3.connect("":memory:"")"
-library/profile,293,:lineno,"(sort by filename:lineno),"
-library/socket,261,::,"(10, 1, 6, '', ('2001:888:2000:d::a2', 80, 0, 0))]"
+library/pickle,,:memory,"conn = sqlite3.connect("":memory:"")"
+library/profile,,:lineno,"(sort by filename:lineno),"
+library/socket,,::,"(10, 1, 6, '', ('2001:888:2000:d::a2', 80, 0, 0))]"
library/stdtypes,1026,:end,s[start:end]
library/stdtypes,1195,:end,s[start:end]
-library/urllib.request,64,:close,Connection:close
-library/urllib.request,901,:password,"""joe:password@python.org"""
-library/urllib.request,1064,:lang,"xmlns=""http://www.w3.org/1999/xhtml"" xml:lang=""en"" lang=""en"">\n\n<head>\n"
+library/urllib.request,,:close,Connection:close
+library/urllib.request,,:password,"""joe:password@python.org"""
+library/urllib.request,,:lang,"xmlns=""http://www.w3.org/1999/xhtml"" xml:lang=""en"" lang=""en"">\n\n<head>\n"
library/xmlrpc.client,103,:pass,http://user:pass@host:port/path
library/xmlrpc.client,103,:port,http://user:pass@host:port/path
library/xmlrpc.client,103,:pass,user:pass
Modified: python/branches/release31-maint/Lib/test/test_ssl.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_ssl.py (original)
+++ python/branches/release31-maint/Lib/test/test_ssl.py Fri Nov 26 09:59:40 2010
@@ -635,7 +635,7 @@
sys.stdout.write("\nSSLError is %s\n" % x.args[1])
except socket.error as x:
if support.verbose:
- sys.stdout.write("\nsocket.error is %s\n" % x[1])
+ sys.stdout.write("\nsocket.error is %s\n" % x.args[1])
else:
self.fail("Use of invalid cert should have failed!")
finally:
Modified: python/branches/release31-maint/Misc/developers.txt
==============================================================================
--- python/branches/release31-maint/Misc/developers.txt (original)
+++ python/branches/release31-maint/Misc/developers.txt Fri Nov 26 09:59:40 2010
@@ -23,6 +23,9 @@
Permissions History
-------------------
+- David Malcolm was given commit access on Oct 27 2010 by GFB,
+ at recommendation by Antoine Pitrou and Raymond Hettinger.
+
- Tal Einat was given commit access on Oct 4 2010 by MvL,
for improving IDLE.
Modified: python/branches/release31-maint/Parser/tokenizer.h
==============================================================================
--- python/branches/release31-maint/Parser/tokenizer.h (original)
+++ python/branches/release31-maint/Parser/tokenizer.h Fri Nov 26 09:59:40 2010
@@ -15,7 +15,7 @@
enum decoding_state {
STATE_INIT,
STATE_RAW,
- STATE_NORMAL, /* have a codec associated with input */
+ STATE_NORMAL /* have a codec associated with input */
};
/* Tokenizer state */
Modified: python/branches/release31-maint/Tools/pynche/pyColorChooser.py
==============================================================================
--- python/branches/release31-maint/Tools/pynche/pyColorChooser.py (original)
+++ python/branches/release31-maint/Tools/pynche/pyColorChooser.py Fri Nov 26 09:59:40 2010
@@ -31,7 +31,7 @@
if dbfile != self.__databasefile:
colordb = ColorDB.get_colordb(dbfile)
if not self.__master:
- from Tkinter import Tk
+ from tkinter import Tk
self.__master = Tk()
if not self.__pw:
self.__pw, self.__sb = \
@@ -92,7 +92,7 @@
# test stuff
if __name__ == '__main__':
- from Tkinter import *
+ from tkinter import *
class Tester:
def __init__(self):
Modified: python/branches/release31-maint/Tools/ssl/get-remote-certificate.py
==============================================================================
--- python/branches/release31-maint/Tools/ssl/get-remote-certificate.py (original)
+++ python/branches/release31-maint/Tools/ssl/get-remote-certificate.py Fri Nov 26 09:59:40 2010
@@ -6,11 +6,14 @@
#
# By Bill Janssen.
+import re
+import os
+import ssl
import sys
+import tempfile
-def fetch_server_certificate (host, port):
- import re, tempfile, os, ssl
+def fetch_server_certificate (host, port):
def subproc(cmd):
from subprocess import Popen, PIPE, STDOUT
@@ -20,15 +23,15 @@
return status, output
def strip_to_x509_cert(certfile_contents, outfile=None):
- m = re.search(r"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n"
- r".*[\r]*^[-]+END CERTIFICATE[-]+)$",
+ m = re.search(br"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n"
+ br".*[\r]*^[-]+END CERTIFICATE[-]+)$",
certfile_contents, re.MULTILINE | re.DOTALL)
if not m:
return None
else:
tn = tempfile.mktemp()
- fp = open(tn, "w")
- fp.write(m.group(1) + "\n")
+ fp = open(tn, "wb")
+ fp.write(m.group(1) + b"\n")
fp.close()
try:
tn2 = (outfile or tempfile.mktemp())
@@ -67,6 +70,7 @@
(host, port))
return certtext
+
if __name__ == "__main__":
if len(sys.argv) < 2:
sys.stderr.write(
@@ -75,5 +79,5 @@
sys.exit(1)
for arg in sys.argv[1:]:
host, port = arg.split(":")
- sys.stdout.write(fetch_server_certificate(host, int(port)))
+ sys.stdout.buffer.write(fetch_server_certificate(host, int(port)))
sys.exit(0)
1
0
r86785 - in python/branches/release27-maint/Doc/library: syslog.rst warnings.rst
by georg.brandl Nov. 26, 2010
by georg.brandl Nov. 26, 2010
Nov. 26, 2010
Author: georg.brandl
Date: Fri Nov 26 09:58:14 2010
New Revision: 86785
Log:
Fix mismerges of version directives.
Modified:
python/branches/release27-maint/Doc/library/syslog.rst
python/branches/release27-maint/Doc/library/warnings.rst
Modified: python/branches/release27-maint/Doc/library/syslog.rst
==============================================================================
--- python/branches/release27-maint/Doc/library/syslog.rst (original)
+++ python/branches/release27-maint/Doc/library/syslog.rst Fri Nov 26 09:58:14 2010
@@ -43,11 +43,6 @@
keyword argument (default is :const:`LOG_USER`) sets the default facility for
messages which do not have a facility explicitly encoded.
- .. versionchanged:: 3.2
- In previous versions, keyword arguments were not allowed, and *ident* was
- required. The default for *ident* was dependent on the system libraries,
- and often was ``python`` instead of the name of the python program file.
-
.. function:: closelog()
Modified: python/branches/release27-maint/Doc/library/warnings.rst
==============================================================================
--- python/branches/release27-maint/Doc/library/warnings.rst (original)
+++ python/branches/release27-maint/Doc/library/warnings.rst Fri Nov 26 09:58:14 2010
@@ -159,17 +159,12 @@
the command-line options passed to :option:`-W` and calls to
:func:`filterwarnings`.
-* :exc:`DeprecationWarning` and :exc:`PendingDeprecationWarning`, and
- :exc:`ImportWarning` are ignored.
+* :exc:`PendingDeprecationWarning`, and :exc:`ImportWarning` are ignored.
* :exc:`BytesWarning` is ignored unless the :option:`-b` option is given once or
twice; in this case this warning is either printed (``-b``) or turned into an
exception (``-bb``).
-.. versionchanged:: 3.2
- :exc:`DeprecationWarning` is now ignored by default in addition to
- :exc:`PendingDeprecationWarning`.
-
.. _warning-suppress:
1
0
Author: georg.brandl
Date: Fri Nov 26 09:52:36 2010
New Revision: 86784
Log:
Merged revisions 85728,85731,85735,85766-85771,85773,85777 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
........
r85728 | georg.brandl | 2010-10-19 20:54:25 +0200 (Di, 19 Okt 2010) | 1 line
#10092: Properly reset locale in Locale*Calendar classes. The context manager was buggy because setlocale() returns the *new* locale, not the old. Also add a test for this.
........
r85731 | georg.brandl | 2010-10-19 23:07:16 +0200 (Di, 19 Okt 2010) | 1 line
Be consistent in the spelling of thread-safe(ty).
........
r85735 | georg.brandl | 2010-10-20 08:50:19 +0200 (Mi, 20 Okt 2010) | 1 line
Fix r85728: use "" to mean the system default locale, which should work on more systems.
........
r85766 | georg.brandl | 2010-10-21 09:40:03 +0200 (Do, 21 Okt 2010) | 1 line
#10159: sort completion matches before comparing to dir() result.
........
r85767 | georg.brandl | 2010-10-21 14:49:28 +0200 (Do, 21 Okt 2010) | 1 line
#9095, #8912, #8999: add support in patchcheck for Mercurial checkouts, C file reindenting, and docs whitespace fixing.
........
r85768 | georg.brandl | 2010-10-21 14:59:14 +0200 (Do, 21 Okt 2010) | 1 line
#9919: fix off-by-one error in lineno command in Misc/gdbinit; also add newline to its output.
........
r85769 | georg.brandl | 2010-10-21 15:01:23 +0200 (Do, 21 Okt 2010) | 1 line
Fix missing import.
........
r85770 | georg.brandl | 2010-10-21 15:29:10 +0200 (Do, 21 Okt 2010) | 1 line
#3077: fix h2py substitution of character literals.
........
r85771 | georg.brandl | 2010-10-21 15:34:51 +0200 (Do, 21 Okt 2010) | 1 line
#1203650: allow larger list of files in windows makefile for freeze.
........
r85773 | georg.brandl | 2010-10-21 15:45:52 +0200 (Do, 21 Okt 2010) | 1 line
#4829: better error message for invalid file mode
........
r85777 | georg.brandl | 2010-10-21 17:44:51 +0200 (Do, 21 Okt 2010) | 1 line
Add .hgeol file for the Mercurial EOL extension.
........
Added:
python/branches/release31-maint/.hgeol
- copied unchanged from r85777, /python/branches/py3k/.hgeol
Modified:
python/branches/release31-maint/ (props changed)
python/branches/release31-maint/Doc/c-api/init.rst
python/branches/release31-maint/Doc/library/calendar.rst
python/branches/release31-maint/Doc/library/locale.rst
python/branches/release31-maint/Doc/library/multiprocessing.rst
python/branches/release31-maint/Doc/library/threading.rst
python/branches/release31-maint/Lib/calendar.py
python/branches/release31-maint/Lib/test/test_calendar.py
python/branches/release31-maint/Lib/test/test_rlcompleter.py
python/branches/release31-maint/Misc/NEWS
python/branches/release31-maint/Misc/gdbinit
python/branches/release31-maint/Modules/_io/fileio.c
python/branches/release31-maint/Tools/freeze/makeconfig.py
python/branches/release31-maint/Tools/freeze/winmakemakefile.py
python/branches/release31-maint/Tools/scripts/h2py.py
python/branches/release31-maint/Tools/scripts/patchcheck.py
python/branches/release31-maint/Tools/scripts/reindent-rst.py
python/branches/release31-maint/Tools/scripts/untabify.py
Modified: python/branches/release31-maint/Doc/c-api/init.rst
==============================================================================
--- python/branches/release31-maint/Doc/c-api/init.rst (original)
+++ python/branches/release31-maint/Doc/c-api/init.rst Fri Nov 26 09:52:36 2010
@@ -416,7 +416,7 @@
single: interpreter lock
single: lock, interpreter
-The Python interpreter is not fully thread safe. In order to support
+The Python interpreter is not fully thread-safe. In order to support
multi-threaded Python programs, there's a global lock, called the :dfn:`global
interpreter lock` or :dfn:`GIL`, that must be held by the current thread before
it can safely access Python objects. Without the lock, even the simplest
Modified: python/branches/release31-maint/Doc/library/calendar.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/calendar.rst (original)
+++ python/branches/release31-maint/Doc/library/calendar.rst Fri Nov 26 09:52:36 2010
@@ -170,9 +170,9 @@
.. class:: LocaleTextCalendar(firstweekday=0, locale=None)
This subclass of :class:`TextCalendar` can be passed a locale name in the
- constructor and will return month and weekday names in the specified
- locale. If this locale includes an encoding all strings containing month and
- weekday names will be returned as unicode.
+ constructor and will return month and weekday names in the specified locale.
+ If this locale includes an encoding all strings containing month and weekday
+ names will be returned as unicode.
.. class:: LocaleHTMLCalendar(firstweekday=0, locale=None)
@@ -182,6 +182,12 @@
locale. If this locale includes an encoding all strings containing month and
weekday names will be returned as unicode.
+.. note::
+
+ The :meth:`formatweekday` and :meth:`formatmonthname` methods of these two
+ classes temporarily change the current locale to the given *locale*. Because
+ the current locale is a process-wide setting, they are not thread-safe.
+
For simple text calendars this module provides the following functions.
Modified: python/branches/release31-maint/Doc/library/locale.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/locale.rst (original)
+++ python/branches/release31-maint/Doc/library/locale.rst Fri Nov 26 09:52:36 2010
@@ -39,7 +39,7 @@
If *locale* is omitted or ``None``, the current setting for *category* is
returned.
- :func:`setlocale` is not thread safe on most systems. Applications typically
+ :func:`setlocale` is not thread-safe on most systems. Applications typically
start with a call of ::
import locale
Modified: python/branches/release31-maint/Doc/library/multiprocessing.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/multiprocessing.rst (original)
+++ python/branches/release31-maint/Doc/library/multiprocessing.rst Fri Nov 26 09:52:36 2010
@@ -214,7 +214,7 @@
The ``'d'`` and ``'i'`` arguments used when creating ``num`` and ``arr`` are
typecodes of the kind used by the :mod:`array` module: ``'d'`` indicates a
double precision float and ``'i'`` indicates a signed integer. These shared
- objects will be process and thread safe.
+ objects will be process and thread-safe.
For more flexibility in using shared memory one can use the
:mod:`multiprocessing.sharedctypes` module which supports the creation of
Modified: python/branches/release31-maint/Doc/library/threading.rst
==============================================================================
--- python/branches/release31-maint/Doc/library/threading.rst (original)
+++ python/branches/release31-maint/Doc/library/threading.rst Fri Nov 26 09:52:36 2010
@@ -753,9 +753,9 @@
Importing in threaded code
--------------------------
-While the import machinery is thread safe, there are two key
-restrictions on threaded imports due to inherent limitations in the way
-that thread safety is provided:
+While the import machinery is thread-safe, there are two key restrictions on
+threaded imports due to inherent limitations in the way that thread-safety is
+provided:
* Firstly, other than in the main module, an import should not have the
side effect of spawning a new thread and then waiting for that thread in
Modified: python/branches/release31-maint/Lib/calendar.py
==============================================================================
--- python/branches/release31-maint/Lib/calendar.py (original)
+++ python/branches/release31-maint/Lib/calendar.py Fri Nov 26 09:52:36 2010
@@ -486,8 +486,8 @@
self.locale = locale
def __enter__(self):
- self.oldlocale = _locale.setlocale(_locale.LC_TIME, self.locale)
- #return _locale.getlocale(_locale.LC_TIME)[1]
+ self.oldlocale = _locale.getlocale(_locale.LC_TIME)
+ _locale.setlocale(_locale.LC_TIME, self.locale)
def __exit__(self, *args):
_locale.setlocale(_locale.LC_TIME, self.oldlocale)
Modified: python/branches/release31-maint/Lib/test/test_calendar.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_calendar.py (original)
+++ python/branches/release31-maint/Lib/test/test_calendar.py Fri Nov 26 09:52:36 2010
@@ -2,6 +2,7 @@
import unittest
from test import support
+import locale
result_2004_text = """
@@ -250,6 +251,19 @@
# verify it "acts like a sequence" in two forms of iteration
self.assertEqual(value[::-1], list(reversed(value)))
+ def test_localecalendars(self):
+ # ensure that Locale{Text,HTML}Calendar resets the locale properly
+ # (it is still not thread-safe though)
+ old_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
+ try:
+ calendar.LocaleTextCalendar(locale='').formatmonthname(2010, 10, 10)
+ except locale.Error:
+ # cannot set the system default locale -- skip rest of test
+ return
+ calendar.LocaleHTMLCalendar(locale='').formatmonthname(2010, 10)
+ new_october = calendar.TextCalendar().formatmonthname(2010, 10, 10)
+ self.assertEquals(old_october, new_october)
+
class MonthCalendarTestCase(unittest.TestCase):
def setUp(self):
Modified: python/branches/release31-maint/Lib/test/test_rlcompleter.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_rlcompleter.py (original)
+++ python/branches/release31-maint/Lib/test/test_rlcompleter.py Fri Nov 26 09:52:36 2010
@@ -31,9 +31,9 @@
def test_global_matches(self):
# test with builtins namespace
- self.assertEqual(self.stdcompleter.global_matches('di'),
+ self.assertEqual(sorted(self.stdcompleter.global_matches('di')),
[x+'(' for x in dir(builtins) if x.startswith('di')])
- self.assertEqual(self.stdcompleter.global_matches('st'),
+ self.assertEqual(sorted(self.stdcompleter.global_matches('st')),
[x+'(' for x in dir(builtins) if x.startswith('st')])
self.assertEqual(self.stdcompleter.global_matches('akaksajadhak'), [])
Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS (original)
+++ python/branches/release31-maint/Misc/NEWS Fri Nov 26 09:52:36 2010
@@ -18,6 +18,8 @@
- Issue #10459: Update CJK character names to Unicode 5.1.
+- Issue #10092: Properly reset locale in calendar.Locale*Calendar classes.
+
- Issue #6098: Don't claim DOM level 3 conformance in minidom.
- Issue #5762: Fix AttributeError raised by ``xml.dom.minidom`` when an empty
Modified: python/branches/release31-maint/Misc/gdbinit
==============================================================================
--- python/branches/release31-maint/Misc/gdbinit (original)
+++ python/branches/release31-maint/Misc/gdbinit Fri Nov 26 09:52:36 2010
@@ -62,11 +62,12 @@
set $__p = $__p + 1
if ($__ad > $__lasti)
set $__continue = 0
+ else
+ set $__li = $__li + *$__p
+ set $__p = $__p + 1
end
- set $__li = $__li + *$__p
- set $__p = $__p + 1
end
- printf "%d", $__li
+ printf "%d\n", $__li
end
# print the current frame - verbose
Modified: python/branches/release31-maint/Modules/_io/fileio.c
==============================================================================
--- python/branches/release31-maint/Modules/_io/fileio.c (original)
+++ python/branches/release31-maint/Modules/_io/fileio.c Fri Nov 26 09:52:36 2010
@@ -265,7 +265,8 @@
if (rwa) {
bad_mode:
PyErr_SetString(PyExc_ValueError,
- "Must have exactly one of read/write/append mode");
+ "Must have exactly one of read/write/append "
+ "mode and at most one plus");
goto error;
}
rwa = 1;
Modified: python/branches/release31-maint/Tools/freeze/makeconfig.py
==============================================================================
--- python/branches/release31-maint/Tools/freeze/makeconfig.py (original)
+++ python/branches/release31-maint/Tools/freeze/makeconfig.py Fri Nov 26 09:52:36 2010
@@ -1,5 +1,5 @@
import re
-
+import sys
# Write the config.c file
@@ -38,7 +38,6 @@
# Test program.
def test():
- import sys
if not sys.argv[3:]:
print('usage: python makeconfig.py config.c.in outputfile', end=' ')
print('modulename ...')
Modified: python/branches/release31-maint/Tools/freeze/winmakemakefile.py
==============================================================================
--- python/branches/release31-maint/Tools/freeze/winmakemakefile.py (original)
+++ python/branches/release31-maint/Tools/freeze/winmakemakefile.py Fri Nov 26 09:52:36 2010
@@ -134,12 +134,14 @@
print() ; print()
print("$(target)$(debug_suffix)%s: $(temp_dir) $(OBJS)" % (target_ext))
- print("\tlink -out:$(target)$(debug_suffix)%s %s" % (target_ext, target_link_flags), end=' ')
- print("\t$(OBJS) \\")
- print("\t$(LIBS) \\")
- print("\t$(ADDN_LINK_FILES) \\")
- print("\t$(pythonlib) $(lcustom) $(l_debug)\\")
+ print("\tlink -out:$(target)$(debug_suffix)%s %s" %
+ (target_ext, target_link_flags), "@<<")
+ print("\t$(OBJS)")
+ print("\t$(LIBS)")
+ print("\t$(ADDN_LINK_FILES)")
+ print("\t$(pythonlib) $(lcustom) $(l_debug)")
print("\t$(resources)")
+ print("<<")
print()
print("clean:")
print("\t-rm -f *.obj")
Modified: python/branches/release31-maint/Tools/scripts/h2py.py
==============================================================================
--- python/branches/release31-maint/Tools/scripts/h2py.py (original)
+++ python/branches/release31-maint/Tools/scripts/h2py.py Fri Nov 26 09:52:36 2010
@@ -93,7 +93,7 @@
for p in ignores:
body = p.sub(' ', body)
# replace char literals by ord(...)
- body = p_char.sub('ord(\\0)', body)
+ body = p_char.sub("ord('\\1')", body)
# Compute negative hexadecimal constants
start = 0
UMAX = 2*(sys.maxsize+1)
Modified: python/branches/release31-maint/Tools/scripts/patchcheck.py
==============================================================================
--- python/branches/release31-maint/Tools/scripts/patchcheck.py (original)
+++ python/branches/release31-maint/Tools/scripts/patchcheck.py Fri Nov 26 09:52:36 2010
@@ -1,8 +1,16 @@
+import re
+import sys
+import shutil
import os.path
import subprocess
-import sys
import reindent
+import untabify
+
+
+def n_files_str(count):
+ """Return 'N file(s)' with the proper plurality on 'file'."""
+ return "{} file{}".format(count, "s" if count != 1 else "")
def status(message, modal=False, info=None):
@@ -17,53 +25,105 @@
elif info:
print(info(result))
else:
- if result:
- print("yes")
- else:
- print("NO")
+ print("yes" if result else "NO")
return result
return call_fxn
return decorated_fxn
+
@status("Getting the list of files that have been added/changed",
- info=lambda x: "%s files" % len(x))
+ info=lambda x: n_files_str(len(x)))
def changed_files():
- """Run ``svn status`` and return a set of files that have been
- changed/added."""
- cmd = 'svn status --quiet --non-interactive --ignore-externals'
- svn_st = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
- svn_st.wait()
- output = [x.decode().rstrip() for x in svn_st.stdout.readlines()]
- files = set()
- for line in output:
- if not line[0] in ('A', 'M'):
- continue
- line_parts = line.split()
- path = line_parts[-1]
- if os.path.isfile(path):
- files.add(path)
- return files
+ """Get the list of changed or added files from the VCS."""
+ if os.path.isdir('.hg'):
+ vcs = 'hg'
+ cmd = 'hg status --added --modified --no-status'
+ elif os.path.isdir('.svn'):
+ vcs = 'svn'
+ cmd = 'svn status --quiet --non-interactive --ignore-externals'
+ else:
+ sys.exit('need a checkout to get modified files')
+
+ st = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
+ try:
+ st.wait()
+ if vcs == 'hg':
+ return [x.decode().rstrip() for x in st.stdout]
+ else:
+ output = (x.decode().rstrip().rsplit(None, 1)[-1]
+ for x in st.stdout if x[0] in b'AM')
+ return set(path for path in output if os.path.isfile(path))
+ finally:
+ st.stdout.close()
+
+
+def report_modified_files(file_paths):
+ count = len(file_paths)
+ if count == 0:
+ return n_files_str(count)
+ else:
+ lines = ["{}:".format(n_files_str(count))]
+ for path in file_paths:
+ lines.append(" {}".format(path))
+ return "\n".join(lines)
+
-@status("Fixing whitespace", info=lambda x: "%s files" % x)
+@status("Fixing whitespace", info=report_modified_files)
def normalize_whitespace(file_paths):
"""Make sure that the whitespace for .py files have been normalized."""
reindent.makebackup = False # No need to create backups.
- result = list(map(reindent.check, (x for x in file_paths if x.endswith('.py'))))
- return sum(result)
+ fixed = []
+ for path in (x for x in file_paths if x.endswith('.py')):
+ if reindent.check(path):
+ fixed.append(path)
+ return fixed
+
+
+@status("Fixing C file whitespace", info=report_modified_files)
+def normalize_c_whitespace(file_paths):
+ """Report if any C files """
+ fixed = []
+ for path in file_paths:
+ with open(path, 'r') as f:
+ if '\t' not in f.read():
+ continue
+ untabify.process(path, 8, verbose=False)
+ fixed.append(path)
+ return fixed
+
+
+ws_re = re.compile(br'\s+(\r?\n)$')
+
+@status("Fixing docs whitespace", info=report_modified_files)
+def normalize_docs_whitespace(file_paths):
+ fixed = []
+ for path in file_paths:
+ try:
+ with open(path, 'rb') as f:
+ lines = f.readlines()
+ new_lines = [ws_re.sub(br'\1', line) for line in lines]
+ if new_lines != lines:
+ shutil.copyfile(path, path + '.bak')
+ with open(path, 'wb') as f:
+ f.writelines(new_lines)
+ fixed.append(path)
+ except Exception as err:
+ print('Cannot fix %s: %s' % (path, err))
+ return fixed
+
@status("Docs modified", modal=True)
def docs_modified(file_paths):
- """Report if any files in the Docs directory."""
- for path in file_paths:
- if path.startswith("Doc"):
- return True
- return False
+ """Report if any file in the Doc directory has been changed."""
+ return bool(file_paths)
+
@status("Misc/ACKS updated", modal=True)
def credit_given(file_paths):
"""Check if Misc/ACKS has been changed."""
return 'Misc/ACKS' in file_paths
+
@status("Misc/NEWS updated", modal=True)
def reported_news(file_paths):
"""Check if Misc/NEWS has been changed."""
@@ -72,14 +132,22 @@
def main():
file_paths = changed_files()
- # PEP 7/8 verification.
- normalize_whitespace(file_paths)
+ python_files = [fn for fn in file_paths if fn.endswith('.py')]
+ c_files = [fn for fn in file_paths if fn.endswith(('.c', '.h'))]
+ doc_files = [fn for fn in file_paths if fn.startswith('Doc')]
+ special_files = {'Misc/ACKS', 'Misc/NEWS'} & set(file_paths)
+ # PEP 8 whitespace rules enforcement.
+ normalize_whitespace(python_files)
+ # C rules enforcement.
+ normalize_c_whitespace(c_files)
+ # Doc whitespace enforcement.
+ normalize_docs_whitespace(doc_files)
# Docs updated.
- docs_modified(file_paths)
+ docs_modified(doc_files)
# Misc/ACKS changed.
- credit_given(file_paths)
+ credit_given(special_files)
# Misc/NEWS changed.
- reported_news(file_paths)
+ reported_news(special_files)
# Test suite run and passed.
print()
Modified: python/branches/release31-maint/Tools/scripts/reindent-rst.py
==============================================================================
--- python/branches/release31-maint/Tools/scripts/reindent-rst.py (original)
+++ python/branches/release31-maint/Tools/scripts/reindent-rst.py Fri Nov 26 09:52:36 2010
@@ -3,27 +3,12 @@
# Make a reST file compliant to our pre-commit hook.
# Currently just remove trailing whitespace.
+import sys
-import sys, re, shutil
-
-ws_re = re.compile(r'\s+(\r?\n)$')
+import patchcheck
def main(argv=sys.argv):
- rv = 0
- for filename in argv[1:]:
- try:
- with open(filename, 'rb') as f:
- lines = f.readlines()
- new_lines = [ws_re.sub(r'\1', line) for line in lines]
- if new_lines != lines:
- print('Fixing %s...' % filename)
- shutil.copyfile(filename, filename + '.bak')
- with open(filename, 'wb') as f:
- f.writelines(new_lines)
- except Exception as err:
- print('Cannot fix %s: %s' % (filename, err))
- rv = 1
- return rv
+ patchcheck.normalize_docs_whitespace(argv[1:])
if __name__ == '__main__':
sys.exit(main())
Modified: python/branches/release31-maint/Tools/scripts/untabify.py
==============================================================================
--- python/branches/release31-maint/Tools/scripts/untabify.py (original)
+++ python/branches/release31-maint/Tools/scripts/untabify.py Fri Nov 26 09:52:36 2010
@@ -23,7 +23,7 @@
for filename in args:
process(filename, tabsize)
-def process(filename, tabsize):
+def process(filename, tabsize, verbose=True):
try:
f = open(filename)
text = f.read()
@@ -46,7 +46,8 @@
f = open(filename, "w")
f.write(newtext)
f.close()
- print(filename)
+ if verbose:
+ print(filename)
if __name__ == '__main__':
main()
1
0