summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/library/smtplib.rst10
-rw-r--r--Include/bytes_methods.h14
-rwxr-xr-xLib/smtplib.py3
-rw-r--r--Lib/test/outstanding_bugs.py33
-rw-r--r--Lib/test/test_future4.py1
-rw-r--r--Lib/test/test_tokenize.py24
-rw-r--r--Lib/tokenize.py9
-rw-r--r--Misc/ACKS7
-rw-r--r--Modules/_ssl.c4
-rw-r--r--Objects/bytesobject.c8
-rw-r--r--Objects/floatobject.c2
-rw-r--r--Objects/longobject.c10
-rw-r--r--Objects/unicodeobject.c4
-rw-r--r--Python/mystrtoul.c16
14 files changed, 71 insertions, 74 deletions
diff --git a/Doc/library/smtplib.rst b/Doc/library/smtplib.rst
index 1ffe812..d4dd43f 100644
--- a/Doc/library/smtplib.rst
+++ b/Doc/library/smtplib.rst
@@ -193,8 +193,6 @@ An :class:`SMTP` instance has the following methods:
:exc:SMTPHeloError
The server didn't reply properly to the ``HELO`` greeting.
- .. versionadded:: 2.6
-
.. method:: SMTP.has_extn(name)
Return :const:`True` if *name* is in the set of SMTP service extensions returned
@@ -243,16 +241,12 @@ An :class:`SMTP` instance has the following methods:
If there has been no previous ``EHLO`` or ``HELO`` command this session,
this method tries ESMTP ``EHLO`` first.
- .. versionchanged:: 2.6
-
:exc:`SMTPHeloError`
The server didn't reply properly to the ``HELO`` greeting.
:exc:`SMTPException`
The server does not support the STARTTLS extension.
- .. versionchanged:: 2.6
-
:exc:`RuntimeError`
SSL/TLS support is not available to your python interpreter.
@@ -311,7 +305,9 @@ An :class:`SMTP` instance has the following methods:
.. method:: SMTP.quit()
- Terminate the SMTP session and close the connection.
+ Terminate the SMTP session and close the connection. Return the result of
+ the SMTP ``QUIT`` command.
+
Low-level methods corresponding to the standard SMTP/ESMTP commands ``HELP``,
``RSET``, ``NOOP``, ``MAIL``, ``RCPT``, and ``DATA`` are also supported.
diff --git a/Include/bytes_methods.h b/Include/bytes_methods.h
index 59873f2..a05e11f 100644
--- a/Include/bytes_methods.h
+++ b/Include/bytes_methods.h
@@ -44,13 +44,13 @@ extern const char _Py_swapcase__doc__[];
extern const unsigned int _Py_ctype_table[256];
-#define ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_LOWER)
-#define ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_UPPER)
-#define ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_ALPHA)
-#define ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_DIGIT)
-#define ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_XDIGIT)
-#define ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_ALNUM)
-#define ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_SPACE)
+#define ISLOWER(c) (_Py_ctype_table[(unsigned)Py_CHARMASK(c)] & FLAG_LOWER)
+#define ISUPPER(c) (_Py_ctype_table[(unsigned)Py_CHARMASK(c)] & FLAG_UPPER)
+#define ISALPHA(c) (_Py_ctype_table[(unsigned)Py_CHARMASK(c)] & FLAG_ALPHA)
+#define ISDIGIT(c) (_Py_ctype_table[(unsigned)Py_CHARMASK(c)] & FLAG_DIGIT)
+#define ISXDIGIT(c) (_Py_ctype_table[(unsigned)Py_CHARMASK(c)] & FLAG_XDIGIT)
+#define ISALNUM(c) (_Py_ctype_table[(unsigned)Py_CHARMASK(c)] & FLAG_ALNUM)
+#define ISSPACE(c) (_Py_ctype_table[(unsigned)Py_CHARMASK(c)] & FLAG_SPACE)
#undef islower
#define islower(c) undefined_islower(c)
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index 63732c8..a3cc65d 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -729,8 +729,9 @@ class SMTP:
def quit(self):
"""Terminate the SMTP session."""
- self.docmd("quit")
+ res = self.docmd("quit")
self.close()
+ return res
if _have_ssl:
diff --git a/Lib/test/outstanding_bugs.py b/Lib/test/outstanding_bugs.py
index 9c75bfc..3f672fb 100644
--- a/Lib/test/outstanding_bugs.py
+++ b/Lib/test/outstanding_bugs.py
@@ -13,38 +13,6 @@ from test import test_support
# One test case for outstanding bugs at the moment:
#
-class TestDifflibLongestMatch(unittest.TestCase):
- # From Patch #1678339:
- # The find_longest_match method in the difflib's SequenceMatcher has a bug.
-
- # The bug is in turn caused by a problem with creating a b2j mapping which
- # should contain a list of indices for each of the list elements in b.
- # However, when the b2j mapping is being created (this is being done in
- # __chain_b method in the SequenceMatcher) the mapping becomes broken. The
- # cause of this is that for the frequently used elements the list of indices
- # is removed and the element is being enlisted in the populardict mapping.
-
- # The test case tries to match two strings like:
- # abbbbbb.... and ...bbbbbbc
-
- # The number of b is equal and the find_longest_match should have returned
- # the proper amount. However, in case the number of "b"s is large enough, the
- # method reports that the length of the longest common substring is 0. It
- # simply can't find it.
-
- # A bug was raised some time ago on this matter. It's ID is 1528074.
-
- def test_find_longest_match(self):
- import difflib
- for i in (190, 200, 210):
- text1 = "a" + "b"*i
- text2 = "b"*i + "c"
- m = difflib.SequenceMatcher(None, text1, text2)
- (aptr, bptr, l) = m.find_longest_match(0, len(text1), 0, len(text2))
- self.assertEquals(i, l)
- self.assertEquals(aptr, 1)
- self.assertEquals(bptr, 0)
-
# test_io
import io
class TextIOWrapperTest(unittest.TestCase):
@@ -114,7 +82,6 @@ class TextIOWrapperTest(unittest.TestCase):
def test_main():
test_support.run_unittest(
- TestDifflibLongestMatch,
TextIOWrapperTest)
if __name__ == "__main__":
diff --git a/Lib/test/test_future4.py b/Lib/test/test_future4.py
index 5456449..8ada489 100644
--- a/Lib/test/test_future4.py
+++ b/Lib/test/test_future4.py
@@ -1,4 +1,3 @@
-from __future__ import print_function
from __future__ import unicode_literals
import unittest
diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py
index 308158f..371e2b9 100644
--- a/Lib/test/test_tokenize.py
+++ b/Lib/test/test_tokenize.py
@@ -88,7 +88,7 @@ Some error-handling code
>>> roundtrip("try: import somemodule\\n"
... "except ImportError: # comment\\n"
- ... " print 'Can not import' # comment2\\n"
+ ... " print('Can not import' # comment2\\n)"
... "else: print 'Loaded'\\n")
True
@@ -509,6 +509,28 @@ Backslash means line continuation, except for comments
True
>>> roundtrip("# Comment \\\\nx = 0")
True
+
+Two string literals on the same line
+
+ >>> roundtrip("'' ''")
+ True
+
+Test roundtrip on random python modules.
+pass the '-ucompiler' option to process the full directory.
+
+ >>> import random
+ >>> tempdir = os.path.dirname(f) or os.curdir
+ >>> testfiles = glob.glob(os.path.join(tempdir, "test*.py"))
+
+ >>> if not test_support.is_resource_enabled("compiler"):
+ ... testfiles = random.sample(testfiles, 10)
+ ...
+ >>> for testfile in testfiles:
+ ... if not roundtrip(open(testfile, 'rb')):
+ ... print("Roundtrip failed for file %s" % testfile)
+ ... break
+ ... else: True
+ True
"""
from test import test_support
diff --git a/Lib/tokenize.py b/Lib/tokenize.py
index d7043b1..fdc5cbf 100644
--- a/Lib/tokenize.py
+++ b/Lib/tokenize.py
@@ -178,6 +178,7 @@ class Untokenizer:
tokval += ' '
if toknum in (NEWLINE, NL):
startline = True
+ prevstring = False
for tok in iterable:
toknum, tokval = tok[:2]
if toknum == ENCODING:
@@ -187,6 +188,14 @@ class Untokenizer:
if toknum in (NAME, NUMBER):
tokval += ' '
+ # Insert a space between two consecutive strings
+ if toknum == STRING:
+ if prevstring:
+ tokval = ' ' + tokval
+ prevstring = True
+ else:
+ prevstring = False
+
if toknum == INDENT:
indents.append(tokval)
continue
diff --git a/Misc/ACKS b/Misc/ACKS
index 58e55d2..196c148 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1,14 +1,13 @@
-Acknowledgements
-----------------
+
This list is not complete and not in any useful order, but I would
like to thank everybody who contributed in any way, with code, hints,
bug reports, ideas, moral support, endorsement, or even complaints....
-Without you I would've stopped working on Python long ago!
+Without you, I would've stopped working on Python long ago!
--Guido
-PS: In the standard Python distribution this file is encoded in Latin-1.
+PS: In the standard Python distribution, this file is encoded in Latin-1.
David Abrahams
Jim Ahlstrom
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 331bffa..296a425 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -1518,7 +1518,7 @@ static void _ssl_thread_locking_function
*/
if ((_ssl_locks == NULL) ||
- (n < 0) || (n >= _ssl_locks_count))
+ (n < 0) || ((unsigned)n >= _ssl_locks_count))
return;
if (mode & CRYPTO_LOCK) {
@@ -1530,7 +1530,7 @@ static void _ssl_thread_locking_function
static int _setup_ssl_threads(void) {
- int i;
+ unsigned int i;
if (_ssl_locks == NULL) {
_ssl_locks_count = CRYPTO_num_locks();
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index e0e3cd0..1cfdbae 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -2609,17 +2609,21 @@ bytes_extend(PyBytesObject *self, PyObject *arg)
if (! _getbytevalue(item, &value)) {
Py_DECREF(item);
Py_DECREF(it);
+ PyMem_Free(buf);
return NULL;
}
buf[len++] = value;
Py_DECREF(item);
if (len >= buf_size) {
+ char *new_buf;
buf_size = len + (len >> 1) + 1;
- buf = (char *)PyMem_Realloc(buf, buf_size * sizeof(char));
- if (buf == NULL) {
+ new_buf = (char *)PyMem_Realloc(buf, buf_size * sizeof(char));
+ if (new_buf == NULL) {
Py_DECREF(it);
+ PyMem_Free(buf);
return PyErr_NoMemory();
}
+ buf = new_buf;
}
}
Py_DECREF(it);
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 353a21d..20f1510 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1607,7 +1607,7 @@ PyFloat_Fini(void)
}
else {
fprintf(stderr,
- ": %" PY_FORMAT_SIZE_T "d unfreed floats%s in %"
+ ": %" PY_FORMAT_SIZE_T "d unfreed float%s in %"
PY_FORMAT_SIZE_T "d out of %"
PY_FORMAT_SIZE_T "d block%s\n",
fsum, fsum == 1 ? "" : "s",
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 1d4b502..b8725df 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -1620,7 +1620,7 @@ long_from_binary_base(char **str, int base)
n >>= 1;
/* n <- total # of bits needed, while setting p to end-of-string */
n = 0;
- while (_PyLong_DigitValue[Py_CHARMASK(*p)] < base)
+ while (_PyLong_DigitValue[(unsigned)Py_CHARMASK(*p)] < base)
++p;
*str = p;
/* n <- # of Python digits needed, = ceiling(n/PyLong_SHIFT). */
@@ -1641,7 +1641,7 @@ long_from_binary_base(char **str, int base)
bits_in_accum = 0;
pdigit = z->ob_digit;
while (--p >= start) {
- int k = _PyLong_DigitValue[Py_CHARMASK(*p)];
+ int k = _PyLong_DigitValue[(unsigned)Py_CHARMASK(*p)];
assert(k >= 0 && k < base);
accum |= (twodigits)(k << bits_in_accum);
bits_in_accum += bits_per_char;
@@ -1828,7 +1828,7 @@ digit beyond the first.
/* Find length of the string of numeric characters. */
scan = str;
- while (_PyLong_DigitValue[Py_CHARMASK(*scan)] < base)
+ while (_PyLong_DigitValue[(unsigned)Py_CHARMASK(*scan)] < base)
++scan;
/* Create a long object that can contain the largest possible
@@ -1854,10 +1854,10 @@ digit beyond the first.
/* Work ;-) */
while (str < scan) {
/* grab up to convwidth digits from the input string */
- c = (digit)_PyLong_DigitValue[Py_CHARMASK(*str++)];
+ c = (digit)_PyLong_DigitValue[(unsigned)Py_CHARMASK(*str++)];
for (i = 1; i < convwidth && str != scan; ++i, ++str) {
c = (twodigits)(c * base +
- _PyLong_DigitValue[Py_CHARMASK(*str)]);
+ _PyLong_DigitValue[(unsigned)Py_CHARMASK(*str)]);
assert(c < PyLong_BASE);
}
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 60cbffa..fef304a 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -512,13 +512,13 @@ PyObject *PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size)
/* Single characters are shared when using this constructor.
Restrict to ASCII, since the input must be UTF-8. */
if (size == 1 && Py_CHARMASK(*u) < 128) {
- unicode = unicode_latin1[Py_CHARMASK(*u)];
+ unicode = unicode_latin1[(unsigned)Py_CHARMASK(*u)];
if (!unicode) {
unicode = _PyUnicode_New(1);
if (!unicode)
return NULL;
unicode->str[0] = Py_CHARMASK(*u);
- unicode_latin1[Py_CHARMASK(*u)] = unicode;
+ unicode_latin1[(unsigned)Py_CHARMASK(*u)] = unicode;
}
Py_INCREF(unicode);
return (PyObject *)unicode;
diff --git a/Python/mystrtoul.c b/Python/mystrtoul.c
index 347f361..ac34c26 100644
--- a/Python/mystrtoul.c
+++ b/Python/mystrtoul.c
@@ -109,7 +109,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
++str;
if (*str == 'x' || *str == 'X') {
/* there must be at least one digit after 0x */
- if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 16) {
+ if (_PyLong_DigitValue[(unsigned)Py_CHARMASK(str[1])] >= 16) {
if (ptr)
*ptr = str;
return 0;
@@ -118,7 +118,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
base = 16;
} else if (*str == 'o' || *str == 'O') {
/* there must be at least one digit after 0o */
- if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 8) {
+ if (_PyLong_DigitValue[(unsigned)Py_CHARMASK(str[1])] >= 8) {
if (ptr)
*ptr = str;
return 0;
@@ -127,7 +127,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
base = 8;
} else if (*str == 'b' || *str == 'B') {
/* there must be at least one digit after 0b */
- if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 2) {
+ if (_PyLong_DigitValue[(unsigned)Py_CHARMASK(str[1])] >= 2) {
if (ptr)
*ptr = str;
return 0;
@@ -155,7 +155,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
++str;
if (*str == 'x' || *str == 'X') {
/* there must be at least one digit after 0x */
- if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 16) {
+ if (_PyLong_DigitValue[(unsigned)Py_CHARMASK(str[1])] >= 16) {
if (ptr)
*ptr = str;
return 0;
@@ -169,7 +169,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
++str;
if (*str == 'o' || *str == 'O') {
/* there must be at least one digit after 0o */
- if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 8) {
+ if (_PyLong_DigitValue[(unsigned)Py_CHARMASK(str[1])] >= 8) {
if (ptr)
*ptr = str;
return 0;
@@ -183,7 +183,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
++str;
if (*str == 'b' || *str == 'B') {
/* there must be at least one digit after 0b */
- if (_PyLong_DigitValue[Py_CHARMASK(str[1])] >= 2) {
+ if (_PyLong_DigitValue[(unsigned)Py_CHARMASK(str[1])] >= 2) {
if (ptr)
*ptr = str;
return 0;
@@ -209,7 +209,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
ovlimit = digitlimit[base];
/* do the conversion until non-digit character encountered */
- while ((c = _PyLong_DigitValue[Py_CHARMASK(*str)]) < base) {
+ while ((c = _PyLong_DigitValue[(unsigned)Py_CHARMASK(*str)]) < base) {
if (ovlimit > 0) /* no overflow check required */
result = result * base + c;
else { /* requires overflow check */
@@ -246,7 +246,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
overflowed:
if (ptr) {
/* spool through remaining digit characters */
- while (_PyLong_DigitValue[Py_CHARMASK(*str)] < base)
+ while (_PyLong_DigitValue[(unsigned)Py_CHARMASK(*str)] < base)
++str;
*ptr = str;
}