mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Fix various spots where int/long and str/unicode unification
lead to type checks like isinstance(foo, (str, str)) or isinstance(foo, (int, int)).
This commit is contained in:
parent
5d7a7001d9
commit
aa97f04964
14 changed files with 46 additions and 51 deletions
|
@ -70,7 +70,7 @@ def readPlist(pathOrFile):
|
|||
usually is a dictionary).
|
||||
"""
|
||||
didOpen = 0
|
||||
if isinstance(pathOrFile, (str, str)):
|
||||
if isinstance(pathOrFile, str):
|
||||
pathOrFile = open(pathOrFile)
|
||||
didOpen = 1
|
||||
p = PlistParser()
|
||||
|
@ -85,7 +85,7 @@ def writePlist(rootObject, pathOrFile):
|
|||
file name or a (writable) file object.
|
||||
"""
|
||||
didOpen = 0
|
||||
if isinstance(pathOrFile, (str, str)):
|
||||
if isinstance(pathOrFile, str):
|
||||
pathOrFile = open(pathOrFile, "w")
|
||||
didOpen = 1
|
||||
writer = PlistWriter(pathOrFile)
|
||||
|
@ -231,7 +231,7 @@ class PlistWriter(DumbXMLWriter):
|
|||
DumbXMLWriter.__init__(self, file, indentLevel, indent)
|
||||
|
||||
def writeValue(self, value):
|
||||
if isinstance(value, (str, str)):
|
||||
if isinstance(value, str):
|
||||
self.simpleElement("string", value)
|
||||
elif isinstance(value, bool):
|
||||
# must switch for bool before int, as bool is a
|
||||
|
@ -270,7 +270,7 @@ class PlistWriter(DumbXMLWriter):
|
|||
self.beginElement("dict")
|
||||
items = sorted(d.items())
|
||||
for key, value in items:
|
||||
if not isinstance(key, (str, str)):
|
||||
if not isinstance(key, str):
|
||||
raise TypeError("keys must be strings")
|
||||
self.simpleElement("key", key)
|
||||
self.writeValue(value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue