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
eb4b7389
Commit
eb4b7389
authored
Aug 08, 2007
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert the fix for #1548891, it broke backwards compatibility with arbitrary read buffers.
Fixes #1730114. (backport from rev. 56830)
parent
e51d1d11
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
24 deletions
+12
-24
Doc/lib/libstringio.tex
Doc/lib/libstringio.tex
+4
-0
Lib/test/test_StringIO.py
Lib/test/test_StringIO.py
+0
-22
Misc/NEWS
Misc/NEWS
+3
-0
Modules/cStringIO.c
Modules/cStringIO.c
+5
-2
No files found.
Doc/lib/libstringio.tex
View file @
eb4b7389
...
...
@@ -78,6 +78,10 @@ Unlike the memory files implemented by the \refmodule{StringIO}
module, those provided by this module are not able to accept Unicode
strings that cannot be encoded as plain
\ASCII
{}
strings.
Calling
\function
{
StringIO()
}
with a Unicode string parameter populates
the object with the buffer representation of the Unicode string, instead of
encoding the string.
Another difference from the
\refmodule
{
StringIO
}
module is that calling
\function
{
StringIO()
}
with a string parameter creates a read-only object.
Unlike an object created without a string parameter, it does not have
...
...
Lib/test/test_StringIO.py
View file @
eb4b7389
...
...
@@ -120,28 +120,6 @@ class TestStringIO(TestGenericStringIO):
class
TestcStringIO
(
TestGenericStringIO
):
MODULE
=
cStringIO
def
test_unicode
(
self
):
if
not
test_support
.
have_unicode
:
return
# The cStringIO module converts Unicode strings to character
# strings when writing them to cStringIO objects.
# Check that this works.
f
=
self
.
MODULE
.
StringIO
()
f
.
write
(
unicode
(
self
.
_line
[:
5
]))
s
=
f
.
getvalue
()
self
.
assertEqual
(
s
,
'abcde'
)
self
.
assertEqual
(
type
(
s
),
types
.
StringType
)
f
=
self
.
MODULE
.
StringIO
(
unicode
(
self
.
_line
[:
5
]))
s
=
f
.
getvalue
()
self
.
assertEqual
(
s
,
'abcde'
)
self
.
assertEqual
(
type
(
s
),
types
.
StringType
)
self
.
assertRaises
(
UnicodeEncodeError
,
self
.
MODULE
.
StringIO
,
unicode
(
'
\
xf4
'
,
'latin-1'
))
import
sys
if
sys
.
platform
.
startswith
(
'java'
):
# Jython doesn't have a buffer object, so we just do a useless
...
...
Misc/NEWS
View file @
eb4b7389
...
...
@@ -26,6 +26,9 @@ Core and builtins
Library
-------
- Reverted the fix for bug #1548891 because it broke compatibility with
arbitrary read buffers. Added a note in the documentation.
- GB18030 codec now can encode additional two-byte characters that
are missing in GBK.
...
...
Modules/cStringIO.c
View file @
eb4b7389
...
...
@@ -665,8 +665,11 @@ newIobject(PyObject *s) {
char
*
buf
;
Py_ssize_t
size
;
if
(
PyObject_AsCharBuffer
(
s
,
(
const
char
**
)
&
buf
,
&
size
)
!=
0
)
return
NULL
;
if
(
PyObject_AsReadBuffer
(
s
,
(
const
char
**
)
&
buf
,
&
size
))
{
PyErr_Format
(
PyExc_TypeError
,
"expected read buffer, %.200s found"
,
s
->
ob_type
->
tp_name
);
return
NULL
;
}
self
=
PyObject_New
(
Iobject
,
&
Itype
);
if
(
!
self
)
return
NULL
;
...
...
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