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
461d9048
Commit
461d9048
authored
Jan 02, 2013
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Merge heads
parents
9bce4bd4
bdfa2399
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
4 deletions
+55
-4
Lib/configparser.py
Lib/configparser.py
+2
-1
Lib/test/test_cfgparser.py
Lib/test/test_cfgparser.py
+26
-0
Lib/test/test_os.py
Lib/test/test_os.py
+9
-0
Misc/NEWS
Misc/NEWS
+11
-0
Modules/posixmodule.c
Modules/posixmodule.c
+7
-3
No files found.
Lib/configparser.py
View file @
461d9048
...
...
@@ -959,7 +959,8 @@ class RawConfigParser(MutableMapping):
# XXX this is not atomic if read_dict fails at any point. Then again,
# no update method in configparser is atomic in this implementation.
self.remove_section(key)
if key in self._sections:
self._sections[key].clear()
self.read_dict({key: value})
def __delitem__(self, key):
...
...
Lib/test/test_cfgparser.py
View file @
461d9048
...
...
@@ -797,6 +797,32 @@ boolean {0[0]} NO
self
.
assertEqual
(
set
(
cf
.
sections
()),
set
())
self
.
assertEqual
(
set
(
cf
[
self
.
default_section
].
keys
()),
{
'foo'
})
def
test_setitem
(
self
):
cf
=
self
.
fromstring
(
"""
[section1]
name1 {0[0]} value1
[section2]
name2 {0[0]} value2
[section3]
name3 {0[0]} value3
"""
.
format
(
self
.
delimiters
),
defaults
=
{
"nameD"
:
"valueD"
})
self
.
assertEqual
(
set
(
cf
[
'section1'
].
keys
()),
{
'name1'
,
'named'
})
self
.
assertEqual
(
set
(
cf
[
'section2'
].
keys
()),
{
'name2'
,
'named'
})
self
.
assertEqual
(
set
(
cf
[
'section3'
].
keys
()),
{
'name3'
,
'named'
})
self
.
assertEqual
(
cf
[
'section1'
][
'name1'
],
'value1'
)
self
.
assertEqual
(
cf
[
'section2'
][
'name2'
],
'value2'
)
self
.
assertEqual
(
cf
[
'section3'
][
'name3'
],
'value3'
)
self
.
assertEqual
(
cf
.
sections
(),
[
'section1'
,
'section2'
,
'section3'
])
cf
[
'section2'
]
=
{
'name22'
:
'value22'
}
self
.
assertEqual
(
set
(
cf
[
'section2'
].
keys
()),
{
'name22'
,
'named'
})
self
.
assertEqual
(
cf
[
'section2'
][
'name22'
],
'value22'
)
self
.
assertNotIn
(
'name2'
,
cf
[
'section2'
])
self
.
assertEqual
(
cf
.
sections
(),
[
'section1'
,
'section2'
,
'section3'
])
cf
[
'section3'
]
=
{}
self
.
assertEqual
(
set
(
cf
[
'section3'
].
keys
()),
{
'named'
})
self
.
assertNotIn
(
'name3'
,
cf
[
'section3'
])
self
.
assertEqual
(
cf
.
sections
(),
[
'section1'
,
'section2'
,
'section3'
])
class
StrictTestCase
(
BasicTestCase
):
config_class
=
configparser
.
RawConfigParser
...
...
Lib/test/test_os.py
View file @
461d9048
...
...
@@ -1057,6 +1057,15 @@ if sys.platform != 'win32':
f
=
open
(
os
.
path
.
join
(
self
.
dir
,
fn
),
'rb'
)
f
.
close
()
@
unittest
.
skipUnless
(
hasattr
(
os
,
'statvfs'
),
"need os.statvfs()"
)
def
test_statvfs
(
self
):
# issue #9645
for
fn
in
self
.
unicodefn
:
# should not fail with file not found error
fullname
=
os
.
path
.
join
(
self
.
dir
,
fn
)
os
.
statvfs
(
fullname
)
def
test_stat
(
self
):
for
fn
in
self
.
unicodefn
:
os
.
stat
(
os
.
path
.
join
(
self
.
dir
,
fn
))
...
...
Misc/NEWS
View file @
461d9048
...
...
@@ -191,6 +191,17 @@ Library
- Issue #16541: tk_setPalette() now works with keyword arguments.
- Issue #16820: In configparser, `parser.popitem()` no longer raises ValueError.
This makes `parser.clean()` work correctly.
- Issue #16820: In configparser, ``parser['section'] = {}`` now preserves
section order within the parser. This makes `parser.update()` preserve section
order as well.
- Issue #9644: Fix the encoding used by os.statvfs(): use the filesystem
encoding with the surrogateescape error handler, instead of UTF-8 in strict
mode.
- Issue #16819: IDLE method completion now correctly works for bytes literals.
- Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy.
...
...
Modules/posixmodule.c
View file @
461d9048
...
...
@@ -6463,18 +6463,22 @@ Perform a statvfs system call on the given path.");
static
PyObject
*
posix_statvfs
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
opath
,
*
result
=
NULL
;
char
*
path
;
int
res
;
struct
statvfs
st
;
if
(
!
PyArg_ParseTuple
(
args
,
"
s:statvfs"
,
&
path
))
if
(
!
PyArg_ParseTuple
(
args
,
"
O&:statvfs"
,
PyUnicode_FSConverter
,
&
o
path
))
return
NULL
;
path
=
PyBytes_AS_STRING
(
opath
);
Py_BEGIN_ALLOW_THREADS
res
=
statvfs
(
path
,
&
st
);
Py_END_ALLOW_THREADS
if
(
res
!=
0
)
return
posix_error_with_
filename
(
path
);
return
posix_error_with_
allocated_filename
(
o
path
);
return
_pystatvfs_fromstructstatvfs
(
st
);
result
=
_pystatvfs_fromstructstatvfs
(
st
);
Py_DECREF
(
opath
);
return
result
;
}
#endif
/* HAVE_STATVFS */
...
...
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