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
a6dc5310
Kaydet (Commit)
a6dc5310
authored
Eki 26, 2018
tarafından
Andrés Delfino
Kaydeden (comit)
Tal Einat
Eki 26, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-34789: make xml.sax.make_parser accept iterables of all types (GH-9576)
üst
10cb3760
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
5 deletions
+38
-5
xml.sax.rst
Doc/library/xml.sax.rst
+4
-1
test_sax.py
Lib/test/test_sax.py
+28
-0
__init__.py
Lib/xml/sax/__init__.py
+4
-4
2018-09-25-15-48-50.bpo-34789.rPOEj5.rst
...S.d/next/Library/2018-09-25-15-48-50.bpo-34789.rPOEj5.rst
+2
-0
No files found.
Doc/library/xml.sax.rst
Dosyayı görüntüle @
a6dc5310
...
...
@@ -40,10 +40,13 @@ The convenience functions are:
Create and return a SAX :class:`~xml.sax.xmlreader.XMLReader` object. The
first parser found will
be used. If *parser_list* is provided, it must be a
sequenc
e of strings which
be used. If *parser_list* is provided, it must be a
n iterabl
e of strings which
name modules that have a function named :func:`create_parser`. Modules listed
in *parser_list* will be used before modules in the default list of parsers.
.. versionchanged:: 3.8
The *parser_list* argument can be any iterable, not just a list.
.. function:: parse(filename_or_stream, handler, error_handler=handler.ErrorHandler())
...
...
Lib/test/test_sax.py
Dosyayı görüntüle @
a6dc5310
...
...
@@ -254,6 +254,34 @@ class MakeParserTest(unittest.TestCase):
from
xml.sax
import
make_parser
p
=
make_parser
()
def
test_make_parser3
(
self
):
# Testing that make_parser can handle different types of
# iterables.
make_parser
([
'module'
])
make_parser
((
'module'
,
))
make_parser
({
'module'
})
make_parser
(
frozenset
({
'module'
}))
make_parser
({
'module'
:
None
})
make_parser
(
iter
([
'module'
]))
def
test_make_parser4
(
self
):
# Testing that make_parser can handle empty iterables.
make_parser
([])
make_parser
(
tuple
())
make_parser
(
set
())
make_parser
(
frozenset
())
make_parser
({})
make_parser
(
iter
([]))
def
test_make_parser5
(
self
):
# Testing that make_parser can handle iterables with more than
# one item.
make_parser
([
'module1'
,
'module2'
])
make_parser
((
'module1'
,
'module2'
))
make_parser
({
'module1'
,
'module2'
})
make_parser
(
frozenset
({
'module1'
,
'module2'
}))
make_parser
({
'module1'
:
None
,
'module2'
:
None
})
make_parser
(
iter
([
'module1'
,
'module2'
]))
# ===========================================================================
#
...
...
Lib/xml/sax/__init__.py
Dosyayı görüntüle @
a6dc5310
...
...
@@ -67,15 +67,15 @@ if sys.platform[:4] == "java" and sys.registry.containsKey(_key):
default_parser_list
=
sys
.
registry
.
getProperty
(
_key
)
.
split
(
","
)
def
make_parser
(
parser_list
=
[]
):
def
make_parser
(
parser_list
=
()
):
"""Creates and returns a SAX parser.
Creates the first parser it is able to instantiate of the ones
given in the
list created by doing parser_list +
default_parser_list. The
list
s must contain the names of Python
given in the
iterable created by chaining parser_list and
default_parser_list. The
iterable
s must contain the names of Python
modules containing both a SAX parser and a create_parser function."""
for
parser_name
in
parser_list
+
default_parser_list
:
for
parser_name
in
list
(
parser_list
)
+
default_parser_list
:
try
:
return
_create_parser
(
parser_name
)
except
ImportError
as
e
:
...
...
Misc/NEWS.d/next/Library/2018-09-25-15-48-50.bpo-34789.rPOEj5.rst
0 → 100644
Dosyayı görüntüle @
a6dc5310
:func:`xml.sax.make_parser` now accepts any iterable as its *parser_list*
argument. Patch by Andrés Delfino.
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