Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
15cf3703
Commit
15cf3703
authored
Jul 01, 2003
by
Just van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- replaced a couple of asserts with proper exceptions
- use isinstance instead of flaky file-detection code
parent
5300a771
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
Lib/plat-mac/plistlib.py
Lib/plat-mac/plistlib.py
+5
-4
No files found.
Lib/plat-mac/plistlib.py
View file @
15cf3703
...
...
@@ -142,7 +142,7 @@ class PlistWriter(DumbXMLWriter):
elif
isinstance
(
value
,
(
tuple
,
list
)):
self
.
writeArray
(
value
)
else
:
assert
0
,
"unsuported type: %s"
%
type
(
value
)
raise
TypeError
(
"unsuported type: %s"
%
type
(
value
)
)
def
writeData
(
self
,
data
):
self
.
beginElement
(
"data"
)
...
...
@@ -156,7 +156,8 @@ class PlistWriter(DumbXMLWriter):
items
=
d
.
items
()
items
.
sort
()
for
key
,
value
in
items
:
assert
isinstance
(
key
,
(
str
,
unicode
)),
"keys must be strings"
if
not
isinstance
(
key
,
(
str
,
unicode
)):
raise
TypeError
(
"keys must be strings"
)
self
.
simpleElement
(
"key"
,
key
)
self
.
writeValue
(
value
)
self
.
endElement
(
"dict"
)
...
...
@@ -204,7 +205,7 @@ class Plist(Dict):
def
fromFile
(
cls
,
pathOrFile
):
didOpen
=
0
if
not
hasattr
(
pathOrFile
,
"write"
):
if
isinstance
(
pathOrFile
,
(
str
,
unicode
)
):
pathOrFile
=
open
(
pathOrFile
)
didOpen
=
1
p
=
PlistParser
()
...
...
@@ -215,7 +216,7 @@ class Plist(Dict):
fromFile
=
classmethod
(
fromFile
)
def
write
(
self
,
pathOrFile
):
if
not
hasattr
(
pathOrFile
,
"write"
):
if
isinstance
(
pathOrFile
,
(
str
,
unicode
)
):
pathOrFile
=
open
(
pathOrFile
,
"w"
)
didOpen
=
1
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment