Merged revisions 61964-61979 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r61964 | benjamin.peterson | 2008-03-27 01:25:33 +0100 (Thu, 27 Mar 2008) | 2 lines add commas for introductory clauses ........ r61965 | christian.heimes | 2008-03-27 02:36:21 +0100 (Thu, 27 Mar 2008) | 1 line Hopefully added _fileio module to the Windows build system ........ r61966 | christian.heimes | 2008-03-27 02:38:47 +0100 (Thu, 27 Mar 2008) | 1 line Revert commit accident ........ r61967 | neal.norwitz | 2008-03-27 04:49:54 +0100 (Thu, 27 Mar 2008) | 3 lines Fix bytes so it works on 64-bit platforms. (Also remove some #if 0 code that is already handled in _getbytevalue.) ........ r61968 | neal.norwitz | 2008-03-27 05:40:07 +0100 (Thu, 27 Mar 2008) | 1 line Fix memory leaks ........ r61969 | neal.norwitz | 2008-03-27 05:40:50 +0100 (Thu, 27 Mar 2008) | 3 lines Fix warnings about using char as an array subscript. This is not portable since char is signed on some platforms and unsigned on others. ........ r61970 | neal.norwitz | 2008-03-27 06:02:57 +0100 (Thu, 27 Mar 2008) | 1 line Fix test_compiler after adding unicode_literals ........ r61971 | neal.norwitz | 2008-03-27 06:03:11 +0100 (Thu, 27 Mar 2008) | 1 line Fix compiler warnings ........ r61972 | neal.norwitz | 2008-03-27 07:52:01 +0100 (Thu, 27 Mar 2008) | 1 line Pluralss only need one s, not 2 (intss -> ints) ........ r61973 | christian.heimes | 2008-03-27 10:02:33 +0100 (Thu, 27 Mar 2008) | 1 line Quick 'n dirty hack: Increase the magic by 2 to force a rebuild of pyc/pyo files on the build bots ........ r61974 | eric.smith | 2008-03-27 10:42:35 +0100 (Thu, 27 Mar 2008) | 3 lines Added test cases for single quoted strings, both forms of triple quotes, and some string concatenations. Removed unneeded __future__ print_function import. ........ r61975 | christian.heimes | 2008-03-27 11:35:52 +0100 (Thu, 27 Mar 2008) | 1 line Build bots are working again - removing the hack ........ r61976 | christian.heimes | 2008-03-27 12:46:37 +0100 (Thu, 27 Mar 2008) | 2 lines Fixed tokenize tests The tokenize module doesn't understand __future__.unicode_literals yet ........ r61977 | georg.brandl | 2008-03-27 14:27:31 +0100 (Thu, 27 Mar 2008) | 2 lines #2248: return result of QUIT from quit(). ........ r61978 | georg.brandl | 2008-03-27 14:34:59 +0100 (Thu, 27 Mar 2008) | 2 lines The bug for which there was a test in outstanding_bugs.py was agreed not to be a bug. ........ r61979 | amaury.forgeotdarc | 2008-03-28 00:23:54 +0100 (Fri, 28 Mar 2008) | 5 lines Issue2495: tokenize.untokenize did not insert space between two consecutive string literals: "" "" => """", which is invalid code. Will backport ........
This commit is contained in:
parent
3a93212824
commit
ba4af493a5
|
@ -193,8 +193,6 @@ An :class:`SMTP` instance has the following methods:
|
||||||
:exc:SMTPHeloError
|
:exc:SMTPHeloError
|
||||||
The server didn't reply properly to the ``HELO`` greeting.
|
The server didn't reply properly to the ``HELO`` greeting.
|
||||||
|
|
||||||
.. versionadded:: 2.6
|
|
||||||
|
|
||||||
.. method:: SMTP.has_extn(name)
|
.. method:: SMTP.has_extn(name)
|
||||||
|
|
||||||
Return :const:`True` if *name* is in the set of SMTP service extensions returned
|
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,
|
If there has been no previous ``EHLO`` or ``HELO`` command this session,
|
||||||
this method tries ESMTP ``EHLO`` first.
|
this method tries ESMTP ``EHLO`` first.
|
||||||
|
|
||||||
.. versionchanged:: 2.6
|
|
||||||
|
|
||||||
:exc:`SMTPHeloError`
|
:exc:`SMTPHeloError`
|
||||||
The server didn't reply properly to the ``HELO`` greeting.
|
The server didn't reply properly to the ``HELO`` greeting.
|
||||||
|
|
||||||
:exc:`SMTPException`
|
:exc:`SMTPException`
|
||||||
The server does not support the STARTTLS extension.
|
The server does not support the STARTTLS extension.
|
||||||
|
|
||||||
.. versionchanged:: 2.6
|
|
||||||
|
|
||||||
:exc:`RuntimeError`
|
:exc:`RuntimeError`
|
||||||
SSL/TLS support is not available to your python interpreter.
|
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()
|
.. 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``,
|
Low-level methods corresponding to the standard SMTP/ESMTP commands ``HELP``,
|
||||||
``RSET``, ``NOOP``, ``MAIL``, ``RCPT``, and ``DATA`` are also supported.
|
``RSET``, ``NOOP``, ``MAIL``, ``RCPT``, and ``DATA`` are also supported.
|
||||||
|
|
|
@ -44,13 +44,13 @@ extern const char _Py_swapcase__doc__[];
|
||||||
|
|
||||||
extern const unsigned int _Py_ctype_table[256];
|
extern const unsigned int _Py_ctype_table[256];
|
||||||
|
|
||||||
#define ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_LOWER)
|
#define ISLOWER(c) (_Py_ctype_table[(unsigned)Py_CHARMASK(c)] & FLAG_LOWER)
|
||||||
#define ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_UPPER)
|
#define ISUPPER(c) (_Py_ctype_table[(unsigned)Py_CHARMASK(c)] & FLAG_UPPER)
|
||||||
#define ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_ALPHA)
|
#define ISALPHA(c) (_Py_ctype_table[(unsigned)Py_CHARMASK(c)] & FLAG_ALPHA)
|
||||||
#define ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_DIGIT)
|
#define ISDIGIT(c) (_Py_ctype_table[(unsigned)Py_CHARMASK(c)] & FLAG_DIGIT)
|
||||||
#define ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_XDIGIT)
|
#define ISXDIGIT(c) (_Py_ctype_table[(unsigned)Py_CHARMASK(c)] & FLAG_XDIGIT)
|
||||||
#define ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_ALNUM)
|
#define ISALNUM(c) (_Py_ctype_table[(unsigned)Py_CHARMASK(c)] & FLAG_ALNUM)
|
||||||
#define ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & FLAG_SPACE)
|
#define ISSPACE(c) (_Py_ctype_table[(unsigned)Py_CHARMASK(c)] & FLAG_SPACE)
|
||||||
|
|
||||||
#undef islower
|
#undef islower
|
||||||
#define islower(c) undefined_islower(c)
|
#define islower(c) undefined_islower(c)
|
||||||
|
|
|
@ -729,8 +729,9 @@ class SMTP:
|
||||||
|
|
||||||
def quit(self):
|
def quit(self):
|
||||||
"""Terminate the SMTP session."""
|
"""Terminate the SMTP session."""
|
||||||
self.docmd("quit")
|
res = self.docmd("quit")
|
||||||
self.close()
|
self.close()
|
||||||
|
return res
|
||||||
|
|
||||||
if _have_ssl:
|
if _have_ssl:
|
||||||
|
|
||||||
|
|
|
@ -13,38 +13,6 @@ from test import test_support
|
||||||
# One test case for outstanding bugs at the moment:
|
# 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
|
# test_io
|
||||||
import io
|
import io
|
||||||
class TextIOWrapperTest(unittest.TestCase):
|
class TextIOWrapperTest(unittest.TestCase):
|
||||||
|
@ -114,7 +82,6 @@ class TextIOWrapperTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
test_support.run_unittest(
|
test_support.run_unittest(
|
||||||
TestDifflibLongestMatch,
|
|
||||||
TextIOWrapperTest)
|
TextIOWrapperTest)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
|
@ -88,7 +88,7 @@ Some error-handling code
|
||||||
|
|
||||||
>>> roundtrip("try: import somemodule\\n"
|
>>> roundtrip("try: import somemodule\\n"
|
||||||
... "except ImportError: # comment\\n"
|
... "except ImportError: # comment\\n"
|
||||||
... " print 'Can not import' # comment2\\n"
|
... " print('Can not import' # comment2\\n)"
|
||||||
... "else: print 'Loaded'\\n")
|
... "else: print 'Loaded'\\n")
|
||||||
True
|
True
|
||||||
|
|
||||||
|
@ -509,6 +509,28 @@ Backslash means line continuation, except for comments
|
||||||
True
|
True
|
||||||
>>> roundtrip("# Comment \\\\nx = 0")
|
>>> roundtrip("# Comment \\\\nx = 0")
|
||||||
True
|
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
|
from test import test_support
|
||||||
|
|
|
@ -178,6 +178,7 @@ class Untokenizer:
|
||||||
tokval += ' '
|
tokval += ' '
|
||||||
if toknum in (NEWLINE, NL):
|
if toknum in (NEWLINE, NL):
|
||||||
startline = True
|
startline = True
|
||||||
|
prevstring = False
|
||||||
for tok in iterable:
|
for tok in iterable:
|
||||||
toknum, tokval = tok[:2]
|
toknum, tokval = tok[:2]
|
||||||
if toknum == ENCODING:
|
if toknum == ENCODING:
|
||||||
|
@ -187,6 +188,14 @@ class Untokenizer:
|
||||||
if toknum in (NAME, NUMBER):
|
if toknum in (NAME, NUMBER):
|
||||||
tokval += ' '
|
tokval += ' '
|
||||||
|
|
||||||
|
# Insert a space between two consecutive strings
|
||||||
|
if toknum == STRING:
|
||||||
|
if prevstring:
|
||||||
|
tokval = ' ' + tokval
|
||||||
|
prevstring = True
|
||||||
|
else:
|
||||||
|
prevstring = False
|
||||||
|
|
||||||
if toknum == INDENT:
|
if toknum == INDENT:
|
||||||
indents.append(tokval)
|
indents.append(tokval)
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
Acknowledgements
|
|
||||||
----------------
|
|
||||||
|
|
||||||
This list is not complete and not in any useful order, but I would
|
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,
|
like to thank everybody who contributed in any way, with code, hints,
|
||||||
bug reports, ideas, moral support, endorsement, or even complaints....
|
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
|
--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
|
David Abrahams
|
||||||
Jim Ahlstrom
|
Jim Ahlstrom
|
||||||
|
|
|
@ -1518,7 +1518,7 @@ static void _ssl_thread_locking_function
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((_ssl_locks == NULL) ||
|
if ((_ssl_locks == NULL) ||
|
||||||
(n < 0) || (n >= _ssl_locks_count))
|
(n < 0) || ((unsigned)n >= _ssl_locks_count))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mode & CRYPTO_LOCK) {
|
if (mode & CRYPTO_LOCK) {
|
||||||
|
@ -1530,7 +1530,7 @@ static void _ssl_thread_locking_function
|
||||||
|
|
||||||
static int _setup_ssl_threads(void) {
|
static int _setup_ssl_threads(void) {
|
||||||
|
|
||||||
int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (_ssl_locks == NULL) {
|
if (_ssl_locks == NULL) {
|
||||||
_ssl_locks_count = CRYPTO_num_locks();
|
_ssl_locks_count = CRYPTO_num_locks();
|
||||||
|
|
|
@ -2609,17 +2609,21 @@ bytes_extend(PyBytesObject *self, PyObject *arg)
|
||||||
if (! _getbytevalue(item, &value)) {
|
if (! _getbytevalue(item, &value)) {
|
||||||
Py_DECREF(item);
|
Py_DECREF(item);
|
||||||
Py_DECREF(it);
|
Py_DECREF(it);
|
||||||
|
PyMem_Free(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
buf[len++] = value;
|
buf[len++] = value;
|
||||||
Py_DECREF(item);
|
Py_DECREF(item);
|
||||||
if (len >= buf_size) {
|
if (len >= buf_size) {
|
||||||
|
char *new_buf;
|
||||||
buf_size = len + (len >> 1) + 1;
|
buf_size = len + (len >> 1) + 1;
|
||||||
buf = (char *)PyMem_Realloc(buf, buf_size * sizeof(char));
|
new_buf = (char *)PyMem_Realloc(buf, buf_size * sizeof(char));
|
||||||
if (buf == NULL) {
|
if (new_buf == NULL) {
|
||||||
Py_DECREF(it);
|
Py_DECREF(it);
|
||||||
|
PyMem_Free(buf);
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
|
buf = new_buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Py_DECREF(it);
|
Py_DECREF(it);
|
||||||
|
|
|
@ -1607,7 +1607,7 @@ PyFloat_Fini(void)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr,
|
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 out of %"
|
||||||
PY_FORMAT_SIZE_T "d block%s\n",
|
PY_FORMAT_SIZE_T "d block%s\n",
|
||||||
fsum, fsum == 1 ? "" : "s",
|
fsum, fsum == 1 ? "" : "s",
|
||||||
|
|
|
@ -1620,7 +1620,7 @@ long_from_binary_base(char **str, int base)
|
||||||
n >>= 1;
|
n >>= 1;
|
||||||
/* n <- total # of bits needed, while setting p to end-of-string */
|
/* n <- total # of bits needed, while setting p to end-of-string */
|
||||||
n = 0;
|
n = 0;
|
||||||
while (_PyLong_DigitValue[Py_CHARMASK(*p)] < base)
|
while (_PyLong_DigitValue[(unsigned)Py_CHARMASK(*p)] < base)
|
||||||
++p;
|
++p;
|
||||||
*str = p;
|
*str = p;
|
||||||
/* n <- # of Python digits needed, = ceiling(n/PyLong_SHIFT). */
|
/* 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;
|
bits_in_accum = 0;
|
||||||
pdigit = z->ob_digit;
|
pdigit = z->ob_digit;
|
||||||
while (--p >= start) {
|
while (--p >= start) {
|
||||||
int k = _PyLong_DigitValue[Py_CHARMASK(*p)];
|
int k = _PyLong_DigitValue[(unsigned)Py_CHARMASK(*p)];
|
||||||
assert(k >= 0 && k < base);
|
assert(k >= 0 && k < base);
|
||||||
accum |= (twodigits)(k << bits_in_accum);
|
accum |= (twodigits)(k << bits_in_accum);
|
||||||
bits_in_accum += bits_per_char;
|
bits_in_accum += bits_per_char;
|
||||||
|
@ -1828,7 +1828,7 @@ digit beyond the first.
|
||||||
|
|
||||||
/* Find length of the string of numeric characters. */
|
/* Find length of the string of numeric characters. */
|
||||||
scan = str;
|
scan = str;
|
||||||
while (_PyLong_DigitValue[Py_CHARMASK(*scan)] < base)
|
while (_PyLong_DigitValue[(unsigned)Py_CHARMASK(*scan)] < base)
|
||||||
++scan;
|
++scan;
|
||||||
|
|
||||||
/* Create a long object that can contain the largest possible
|
/* Create a long object that can contain the largest possible
|
||||||
|
@ -1854,10 +1854,10 @@ digit beyond the first.
|
||||||
/* Work ;-) */
|
/* Work ;-) */
|
||||||
while (str < scan) {
|
while (str < scan) {
|
||||||
/* grab up to convwidth digits from the input string */
|
/* 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) {
|
for (i = 1; i < convwidth && str != scan; ++i, ++str) {
|
||||||
c = (twodigits)(c * base +
|
c = (twodigits)(c * base +
|
||||||
_PyLong_DigitValue[Py_CHARMASK(*str)]);
|
_PyLong_DigitValue[(unsigned)Py_CHARMASK(*str)]);
|
||||||
assert(c < PyLong_BASE);
|
assert(c < PyLong_BASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -512,13 +512,13 @@ PyObject *PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size)
|
||||||
/* Single characters are shared when using this constructor.
|
/* Single characters are shared when using this constructor.
|
||||||
Restrict to ASCII, since the input must be UTF-8. */
|
Restrict to ASCII, since the input must be UTF-8. */
|
||||||
if (size == 1 && Py_CHARMASK(*u) < 128) {
|
if (size == 1 && Py_CHARMASK(*u) < 128) {
|
||||||
unicode = unicode_latin1[Py_CHARMASK(*u)];
|
unicode = unicode_latin1[(unsigned)Py_CHARMASK(*u)];
|
||||||
if (!unicode) {
|
if (!unicode) {
|
||||||
unicode = _PyUnicode_New(1);
|
unicode = _PyUnicode_New(1);
|
||||||
if (!unicode)
|
if (!unicode)
|
||||||
return NULL;
|
return NULL;
|
||||||
unicode->str[0] = Py_CHARMASK(*u);
|
unicode->str[0] = Py_CHARMASK(*u);
|
||||||
unicode_latin1[Py_CHARMASK(*u)] = unicode;
|
unicode_latin1[(unsigned)Py_CHARMASK(*u)] = unicode;
|
||||||
}
|
}
|
||||||
Py_INCREF(unicode);
|
Py_INCREF(unicode);
|
||||||
return (PyObject *)unicode;
|
return (PyObject *)unicode;
|
||||||
|
|
|
@ -109,7 +109,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
|
||||||
++str;
|
++str;
|
||||||
if (*str == 'x' || *str == 'X') {
|
if (*str == 'x' || *str == 'X') {
|
||||||
/* there must be at least one digit after 0x */
|
/* 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)
|
if (ptr)
|
||||||
*ptr = str;
|
*ptr = str;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -118,7 +118,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
|
||||||
base = 16;
|
base = 16;
|
||||||
} else if (*str == 'o' || *str == 'O') {
|
} else if (*str == 'o' || *str == 'O') {
|
||||||
/* there must be at least one digit after 0o */
|
/* 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)
|
if (ptr)
|
||||||
*ptr = str;
|
*ptr = str;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -127,7 +127,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
|
||||||
base = 8;
|
base = 8;
|
||||||
} else if (*str == 'b' || *str == 'B') {
|
} else if (*str == 'b' || *str == 'B') {
|
||||||
/* there must be at least one digit after 0b */
|
/* 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)
|
if (ptr)
|
||||||
*ptr = str;
|
*ptr = str;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -155,7 +155,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
|
||||||
++str;
|
++str;
|
||||||
if (*str == 'x' || *str == 'X') {
|
if (*str == 'x' || *str == 'X') {
|
||||||
/* there must be at least one digit after 0x */
|
/* 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)
|
if (ptr)
|
||||||
*ptr = str;
|
*ptr = str;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -169,7 +169,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
|
||||||
++str;
|
++str;
|
||||||
if (*str == 'o' || *str == 'O') {
|
if (*str == 'o' || *str == 'O') {
|
||||||
/* there must be at least one digit after 0o */
|
/* 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)
|
if (ptr)
|
||||||
*ptr = str;
|
*ptr = str;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -183,7 +183,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
|
||||||
++str;
|
++str;
|
||||||
if (*str == 'b' || *str == 'B') {
|
if (*str == 'b' || *str == 'B') {
|
||||||
/* there must be at least one digit after 0b */
|
/* 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)
|
if (ptr)
|
||||||
*ptr = str;
|
*ptr = str;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -209,7 +209,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
|
||||||
ovlimit = digitlimit[base];
|
ovlimit = digitlimit[base];
|
||||||
|
|
||||||
/* do the conversion until non-digit character encountered */
|
/* 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 */
|
if (ovlimit > 0) /* no overflow check required */
|
||||||
result = result * base + c;
|
result = result * base + c;
|
||||||
else { /* requires overflow check */
|
else { /* requires overflow check */
|
||||||
|
@ -246,7 +246,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
|
||||||
overflowed:
|
overflowed:
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
/* spool through remaining digit characters */
|
/* spool through remaining digit characters */
|
||||||
while (_PyLong_DigitValue[Py_CHARMASK(*str)] < base)
|
while (_PyLong_DigitValue[(unsigned)Py_CHARMASK(*str)] < base)
|
||||||
++str;
|
++str;
|
||||||
*ptr = str;
|
*ptr = str;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue