mirror of
https://github.com/python/cpython.git
synced 2025-08-29 05:05:03 +00:00
Remove uses of the string and types modules:
x in string.whitespace => x.isspace() type(x) in types.StringTypes => isinstance(x, basestring) isinstance(x, types.StringTypes) => isinstance(x, basestring) type(x) is types.StringType => isinstance(x, str) type(x) == types.StringType => isinstance(x, str) string.split(x, ...) => x.split(...) string.join(x, y) => y.join(x) string.zfill(x, ...) => x.zfill(...) string.count(x, ...) => x.count(...) hasattr(types, "UnicodeType") => try: unicode except NameError: type(x) != types.TupleTuple => not isinstance(x, tuple) isinstance(x, types.TupleType) => isinstance(x, tuple) type(x) is types.IntType => isinstance(x, int) Do not mention the string module in the rlcompleter docstring. This partially applies SF patch http://www.python.org/sf/562373 (with basestring instead of string). (It excludes the changes to unittest.py and does not change the os.stat stuff.)
This commit is contained in:
parent
a401ae4010
commit
65230a2de7
15 changed files with 44 additions and 72 deletions
|
@ -1,7 +1,6 @@
|
|||
"""Shared support for scanning document type declarations in HTML and XHTML."""
|
||||
|
||||
import re
|
||||
import string
|
||||
|
||||
_declname_match = re.compile(r'[a-zA-Z][-_.a-zA-Z0-9]*\s*').match
|
||||
_declstringlit_match = re.compile(r'(\'[^\']*\'|"[^"]*")\s*').match
|
||||
|
@ -151,7 +150,7 @@ class ParserBase:
|
|||
j = j + 1
|
||||
elif c == "]":
|
||||
j = j + 1
|
||||
while j < n and rawdata[j] in string.whitespace:
|
||||
while j < n and rawdata[j].isspace():
|
||||
j = j + 1
|
||||
if j < n:
|
||||
if rawdata[j] == ">":
|
||||
|
@ -160,7 +159,7 @@ class ParserBase:
|
|||
self.error("unexpected char after internal subset")
|
||||
else:
|
||||
return -1
|
||||
elif c in string.whitespace:
|
||||
elif c.isspace():
|
||||
j = j + 1
|
||||
else:
|
||||
self.updatepos(declstartpos, j)
|
||||
|
@ -203,7 +202,7 @@ class ParserBase:
|
|||
j = rawdata.find(")", j) + 1
|
||||
else:
|
||||
return -1
|
||||
while rawdata[j:j+1] in string.whitespace:
|
||||
while rawdata[j:j+1].isspace():
|
||||
j = j + 1
|
||||
if not rawdata[j:]:
|
||||
# end of buffer, incomplete
|
||||
|
@ -268,7 +267,7 @@ class ParserBase:
|
|||
c = rawdata[j:j+1]
|
||||
if not c:
|
||||
return -1
|
||||
if c in string.whitespace:
|
||||
if c.isspace():
|
||||
j = j + 1
|
||||
else:
|
||||
break
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue