Created on 2007-11-21 14:03 by ygale, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Files |
|
|
|
File name |
Uploaded |
Description |
Edit |
test_prepare_input_source.py |
ygale,2008-02-24 14:06 |
Almost full set of tests for prepare_input_source() |
|
Messages (7) |
|
|
msg57737 - (view) |
Author: Yitz Gale (ygale) |
Date: 2007-11-21 14:03 |
In the documentation for xml.sax.xmlreader.InputSource objects (section 8.12.4 of the Library Reference) we find that users of InputSource objects should use the following sequence to get their input data: 1. If the InputSource has a character stream, use that. 2. Otherwise, if the InputSource has a byte stream, use that. 3. Otherwise, open a URI connection to the system ID. prepare_input_source() skips step 1. This is a one-line fix in Lib/xml/sax/saxutils.py: - if source.getByteStream() is None: + if source.getCharacterStream is None and source.getByteStream() is None: |
|
|
msg57749 - (view) |
Author: Yitz Gale (ygale) |
Date: 2007-11-22 09:38 |
Oops, obvious typo, sorry: - if source.getByteStream() is None: + if source.getCharacterStream() is None and source.getByteStream() is None: |
|
|
msg62808 - (view) |
Author: A.M. Kuchling (akuchling) *  |
Date: 2008-02-23 20:37 |
Could you please provide a simple little test case for the bug? I'd like to add a test when I commit the change, but you can probably boil the problem down into a test faster than I can. |
|
|
msg62902 - (view) |
Author: Yitz Gale (ygale) |
Date: 2008-02-24 14:06 |
Sure. Here is a simple test case: def testUseCharacterStream(self): '''If the source is an InputSource with a character stream, use it.''' src = xml.sax.xmlreader.InputSource(temp_file_name) src.setCharacterStream(StringIO.StringIO(u"foo")) prep = xml.sax.saxutils.prepare_input_source(src) self.failIf(prep.getCharacterStream() is None, "ignored character stream") If "temp_file_name" is omitted, you'll get an AttributeError, and if you put it in but the file doesn't exist, you'll get an IOError. I'm attaching an almost full set of tests. It omits the case of a URL. You can easily put that in if you have a handy function that converts a file path to a file URL, with all the fidgety stuff you need for Windows. (Does that already exist somewhere?) Unfortunately, I now see that the problem is a bit deeper than this. There are two more related bugs that need to be fixed before this really works. See #2174 and #2175. |
|
|
msg107425 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2010-06-09 22:02 |
Are this and the other issues still problems in 2.7 (rc out now) and 3.1? |
|
|
msg116791 - (view) |
Author: Mark Lawrence (BreamoreBoy) * |
Date: 2010-09-18 15:06 |
There's a one line patch in and some unit tests are attached so would a committer take a look please. Also note that #2174 and #2175 are related. |
|
|
msg239938 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2015-04-02 18:09 |
Fixed in . |
|
|
History |
|
|
|
Date |
User |
Action |
Args |
2022-04-11 14:56:28 |
admin |
set |
github: 45824 |
2015-04-02 18:09:58 |
serhiy.storchaka |
set |
status: open -> closedresolution: out of datemessages: + stage: patch review -> resolved |
2014-12-31 16:21:04 |
akuchling |
set |
nosy: - akuchling |
2014-02-03 18:41:31 |
BreamoreBoy |
set |
nosy: - BreamoreBoy |
2013-01-31 10:03:46 |
serhiy.storchaka |
set |
dependencies: + Expat parser parses strings only when XML encoding is UTF-8 |
2013-01-16 18:25:58 |
serhiy.storchaka |
set |
assignee: serhiy.storchakanosy: + serhiy.storchaka |
2010-11-12 21:04:04 |
akuchling |
set |
assignee: akuchling -> (no value) |
2010-09-18 15:06:35 |
BreamoreBoy |
set |
nosy: + BreamoreBoymessages: + type: behaviorstage: patch review |
2010-06-09 22:02:11 |
terry.reedy |
set |
nosy: + terry.reedymessages: + versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.5 |
2008-03-20 02:40:53 |
jafo |
set |
priority: normalassignee: akuchling |
2008-02-24 14:06:49 |
ygale |
set |
files: + test_prepare_input_source.pymessages: + |
2008-02-23 20:37:53 |
akuchling |
set |
nosy: + akuchlingmessages: + |
2007-11-22 09:38:37 |
ygale |
set |
messages: + |
2007-11-21 14:03:15 |
ygale |
create |
|