Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c502df4e
Kaydet (Commit)
c502df4e
authored
May 12, 2013
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #17915: Fix interoperability of xml.sax with file objects returned by
codecs.open().
üst
93b061bc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
0 deletions
+39
-0
test_sax.py
Lib/test/test_sax.py
+31
-0
saxutils.py
Lib/xml/sax/saxutils.py
+5
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_sax.py
Dosyayı görüntüle @
c502df4e
...
@@ -15,6 +15,7 @@ from xml.sax.expatreader import create_parser
...
@@ -15,6 +15,7 @@ from xml.sax.expatreader import create_parser
from
xml.sax.handler
import
feature_namespaces
from
xml.sax.handler
import
feature_namespaces
from
xml.sax.xmlreader
import
InputSource
,
AttributesImpl
,
AttributesNSImpl
from
xml.sax.xmlreader
import
InputSource
,
AttributesImpl
,
AttributesNSImpl
from
io
import
BytesIO
,
StringIO
from
io
import
BytesIO
,
StringIO
import
codecs
import
os.path
import
os.path
import
shutil
import
shutil
from
test
import
support
from
test
import
support
...
@@ -538,6 +539,34 @@ class WriterXmlgenTest(BytesXmlgenTest):
...
@@ -538,6 +539,34 @@ class WriterXmlgenTest(BytesXmlgenTest):
def
getvalue
(
self
):
def
getvalue
(
self
):
return
b
''
.
join
(
self
)
return
b
''
.
join
(
self
)
class
StreamWriterXmlgenTest
(
XmlgenTest
,
unittest
.
TestCase
):
def
ioclass
(
self
):
raw
=
BytesIO
()
writer
=
codecs
.
getwriter
(
'ascii'
)(
raw
,
'xmlcharrefreplace'
)
writer
.
getvalue
=
raw
.
getvalue
return
writer
def
xml
(
self
,
doc
,
encoding
=
'iso-8859-1'
):
return
(
'<?xml version="1.0" encoding="
%
s"?>
\n
%
s'
%
(
encoding
,
doc
))
.
encode
(
'ascii'
,
'xmlcharrefreplace'
)
class
StreamReaderWriterXmlgenTest
(
XmlgenTest
,
unittest
.
TestCase
):
fname
=
support
.
TESTFN
+
'-codecs'
def
ioclass
(
self
):
writer
=
codecs
.
open
(
self
.
fname
,
'w'
,
encoding
=
'ascii'
,
errors
=
'xmlcharrefreplace'
,
buffering
=
0
)
self
.
addCleanup
(
support
.
unlink
,
self
.
fname
)
writer
.
getvalue
=
self
.
getvalue
return
writer
def
getvalue
(
self
):
with
open
(
self
.
fname
,
'rb'
)
as
f
:
return
f
.
read
()
def
xml
(
self
,
doc
,
encoding
=
'iso-8859-1'
):
return
(
'<?xml version="1.0" encoding="
%
s"?>
\n
%
s'
%
(
encoding
,
doc
))
.
encode
(
'ascii'
,
'xmlcharrefreplace'
)
start
=
b
'<?xml version="1.0" encoding="iso-8859-1"?>
\n
'
start
=
b
'<?xml version="1.0" encoding="iso-8859-1"?>
\n
'
...
@@ -946,6 +975,8 @@ def test_main():
...
@@ -946,6 +975,8 @@ def test_main():
StringXmlgenTest
,
StringXmlgenTest
,
BytesXmlgenTest
,
BytesXmlgenTest
,
WriterXmlgenTest
,
WriterXmlgenTest
,
StreamWriterXmlgenTest
,
StreamReaderWriterXmlgenTest
,
ExpatReaderTest
,
ExpatReaderTest
,
ErrorReportingTest
,
ErrorReportingTest
,
XmlReaderTest
)
XmlReaderTest
)
...
...
Lib/xml/sax/saxutils.py
Dosyayı görüntüle @
c502df4e
...
@@ -5,6 +5,7 @@ convenience of application and driver writers.
...
@@ -5,6 +5,7 @@ convenience of application and driver writers.
import
os
,
urllib
.
parse
,
urllib
.
request
import
os
,
urllib
.
parse
,
urllib
.
request
import
io
import
io
import
codecs
from
.
import
handler
from
.
import
handler
from
.
import
xmlreader
from
.
import
xmlreader
...
@@ -77,6 +78,10 @@ def _gettextwriter(out, encoding):
...
@@ -77,6 +78,10 @@ def _gettextwriter(out, encoding):
# use a text writer as is
# use a text writer as is
return
out
return
out
if
isinstance
(
out
,
(
codecs
.
StreamWriter
,
codecs
.
StreamReaderWriter
)):
# use a codecs stream writer as is
return
out
# wrap a binary writer with TextIOWrapper
# wrap a binary writer with TextIOWrapper
if
isinstance
(
out
,
io
.
RawIOBase
):
if
isinstance
(
out
,
io
.
RawIOBase
):
# Keep the original file open when the TextIOWrapper is
# Keep the original file open when the TextIOWrapper is
...
...
Misc/NEWS
Dosyayı görüntüle @
c502df4e
...
@@ -20,6 +20,9 @@ Library
...
@@ -20,6 +20,9 @@ Library
- Issue #1159051: Back out a fix for handling corrupted gzip files that
- Issue #1159051: Back out a fix for handling corrupted gzip files that
broke backwards compatibility.
broke backwards compatibility.
- Issue #17915: Fix interoperability of xml.sax with file objects returned by
codecs.open().
Build
Build
-----
-----
...
...
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