-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-54873: Add support for namespaces prefixes to xml.sax.expatreader
#118317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
6ecfc28
e9ac454
9c365c2
2fc666a
fe9d82f
be878cb
0e3f870
c88e7ed
27cb273
91112b9
d3cbe5f
1d343f1
256a97b
7c0da60
e219450
34af031
8075f8b
2004846
c3e00e2
d3b08ec
e8bcb30
dfff704
7de4ce5
08d659e
7cdc402
cd7de73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -660,6 +660,9 @@ xml.parsers.expat | |
|
|
||
| .. _billion laughs: https://en.wikipedia.org/wiki/Billion_laughs_attack | ||
|
|
||
| * Add support for namespace prefixes. | ||
| (Contributed by Yassir Karroum in :gh:`118317`.) | ||
|
|
||
|
Comment on lines
+1389
to
+1391
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is adding to section
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ukarroum did you see this one? ⬆️
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, I will move it to a new section.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe it's adding it in two places now, it looks like this upper entry ⬇️ still needs to be dropped?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry should have reviewed the diffs one more time before tagging you ^^" |
||
|
|
||
| zlib | ||
| ---- | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| # regression test for SAX 2.0 | ||
|
|
||
| from xml.sax import make_parser, ContentHandler, \ | ||
| SAXException, SAXReaderNotAvailable, SAXParseException | ||
| SAXException, SAXReaderNotAvailable, SAXParseException, handler | ||
|
ukarroum marked this conversation as resolved.
Outdated
|
||
| import unittest | ||
| from unittest import mock | ||
| try: | ||
|
|
@@ -1307,6 +1307,38 @@ def test_expat_locator_withinfo_nonascii(self): | |
| self.assertEqual(parser.getSystemId(), fname) | ||
| self.assertEqual(parser.getPublicId(), None) | ||
|
|
||
| def test_namespace_prefix(self): | ||
| parser = create_parser() | ||
| parser.setFeature(handler.feature_namespaces, 1) | ||
| parser.setFeature(handler.feature_namespace_prefixes, 1) | ||
|
|
||
| class Handler(handler.ContentHandler): | ||
| def startElementNS(self, name, qname, attrs): | ||
| self.qname = qname | ||
|
|
||
| h = Handler() | ||
|
|
||
| parser.setContentHandler(h) | ||
| parser.feed("<Q:E xmlns:Q='http://example.org/testuri'/>") | ||
| parser.close() | ||
| self.assertEqual(h.qname, "Q:E") | ||
|
|
||
| def test_default_namespace(self): | ||
| parser = create_parser() | ||
| parser.setFeature(handler.feature_namespaces, 1) | ||
|
|
||
| class Handler(handler.ContentHandler): | ||
| def startElementNS(self, name, qname, attrs): | ||
| self.qname = qname | ||
|
|
||
| h = Handler() | ||
|
|
||
| parser.setContentHandler(h) | ||
| parser.feed("<E xmlns='http://example.org/testuri'/>") | ||
| parser.close() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, but I didn't add the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh. Wait, @hartwork should we do feed() + close() or parse()?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @picnixz hi! My understanding is that:
What do you think? |
||
| self.assertEqual(h.qname, "E") | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't leave 3 blank lines, only 2 is sufficient.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
|
|
||
|
|
||
| # =========================================================================== | ||
| # | ||
|
|
||
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be also documented in the expat docs.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean I should add a link to the C libexpat doc ?
EDIT: I think you probably meant to document this here: https://docs.python.org/3/library/pyexpat.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, to the specs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done