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
42d54450
Commit
42d54450
authored
Sep 22, 2010
by
Florent Xicluna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix typo and add test case.
parent
31c604d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
Lib/configparser.py
Lib/configparser.py
+3
-4
Lib/test/test_cfgparser.py
Lib/test/test_cfgparser.py
+16
-1
No files found.
Lib/configparser.py
View file @
42d54450
...
...
@@ -493,11 +493,10 @@ class RawConfigParser:
read_ok = []
for filename in filenames:
try:
fp = open(filename, encoding=encoding)
with open(filename, encoding=encoding) as fp:
self._read(fp, filename)
except IOError:
continue
self._read(fp, filename)
fp.close()
read_ok.append(filename)
return read_ok
...
...
@@ -511,7 +510,7 @@ class RawConfigParser:
"""
if source is None:
try:
s
rou
ce = f.name
s
our
ce = f.name
except AttributeError:
source = '<???>'
self._read(f, source)
...
...
Lib/test/test_cfgparser.py
View file @
42d54450
...
...
@@ -328,9 +328,24 @@ boolean {0[0]} NO
e
=
self
.
parse_error
(
cf
,
configparser
.
ParsingError
,
"[Foo]
\
n
wrong-indent
\
n
"
)
self
.
assertEqual
(
e
.
args
,
(
'<???>'
,))
# read_file on a real file
tricky
=
support
.
findfile
(
"cfgparser.3"
)
if
self
.
delimiters
[
0
]
==
'='
:
error
=
configparser
.
ParsingError
expected
=
(
tricky
,)
else
:
error
=
configparser
.
MissingSectionHeaderError
expected
=
(
tricky
,
1
,
' # INI with as many tricky parts as possible
\
n
'
)
with
open
(
tricky
)
as
f
:
e
=
self
.
parse_error
(
cf
,
error
,
f
)
self
.
assertEqual
(
e
.
args
,
expected
)
def
parse_error
(
self
,
cf
,
exc
,
src
):
sio
=
io
.
StringIO
(
src
)
if
hasattr
(
src
,
'readline'
):
sio
=
src
else
:
sio
=
io
.
StringIO
(
src
)
with
self
.
assertRaises
(
exc
)
as
cm
:
cf
.
read_file
(
sio
)
return
cm
.
exception
...
...
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