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
6b95f1d9
Commit
6b95f1d9
authored
Jun 03, 2005
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #1194181: bz2.BZ2File didn't handle mode 'U' correctly.
parent
6d6917be
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
0 deletions
+16
-0
Lib/test/test_bz2.py
Lib/test/test_bz2.py
+10
-0
Misc/NEWS
Misc/NEWS
+2
-0
Modules/bz2module.c
Modules/bz2module.c
+4
-0
No files found.
Lib/test/test_bz2.py
View file @
6b95f1d9
...
...
@@ -235,6 +235,16 @@ class BZ2FileTest(BaseTest):
# "Test opening a nonexistent file"
self
.
assertRaises
(
IOError
,
BZ2File
,
"/non/existent"
)
def
testModeU
(
self
):
# Bug #1194181: bz2.BZ2File opened for write with mode "U"
self
.
createTempFile
()
bz2f
=
BZ2File
(
self
.
filename
,
"U"
)
bz2f
.
close
()
f
=
file
(
self
.
filename
)
f
.
seek
(
0
,
2
)
self
.
assertEqual
(
f
.
tell
(),
len
(
self
.
DATA
))
f
.
close
()
class
BZ2CompressorTest
(
BaseTest
):
def
testCompress
(
self
):
# "Test BZ2Compressor.compress()/flush()"
...
...
Misc/NEWS
View file @
6b95f1d9
...
...
@@ -91,6 +91,8 @@ Core and builtins
Extension Modules
-----------------
- Bug #1194181: bz2.BZ2File didn'
t
handle
mode
'U'
correctly
.
-
Patch
#
1212117
:
os
.
stat
().
st_flags
is
now
accessible
as
a
attribute
if
available
on
the
platform
.
...
...
Modules/bz2module.c
View file @
6b95f1d9
...
...
@@ -1308,6 +1308,10 @@ BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
break
;
}
if
(
mode_char
==
0
)
{
mode_char
=
'r'
;
}
mode
=
(
mode_char
==
'r'
)
?
"rb"
:
"wb"
;
self
->
file
=
PyObject_CallFunction
((
PyObject
*
)
&
PyFile_Type
,
"(Osi)"
,
...
...
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