Repository navigation
Python 3.12 support #342
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Hi, I'm a pytest dev working on adding initial support for Python 3.12 alpha to pytest. pytest uses xmlschema in its testsuite. Importing xmlschema fails on 3.12:
testing/test_junitxml.py:13: in <module>
import xmlschema
.tox/py312/lib/python3.12/site-packages/xmlschema/__init__.py:21: in <module>
from .dataobjects import DataElement, DataElementConverter, DataBindingConverter
.tox/py312/lib/python3.12/site-packages/xmlschema/dataobjects.py:24: in <module>
from . import validators
.tox/py312/lib/python3.12/site-packages/xmlschema/validators/__init__.py:38: in <module>
from .schemas import XMLSchemaMeta, XMLSchemaBase, XMLSchema, XMLSchema10, XMLSchema11
.tox/py312/lib/python3.12/site-packages/xmlschema/validators/schemas.py:2183: in <module>
class XMLSchema10(XMLSchemaBase):
.tox/py312/lib/python3.12/site-packages/xmlschema/validators/schemas.py:134: in __new__
meta_schema = meta_schema_class.create_meta_schema(meta_schema_file)
.tox/py312/lib/python3.12/site-packages/xmlschema/validators/schemas.py:768: in create_meta_schema
meta_schema = meta_schema_class(source, XSD_NAMESPACE, defuse='never', build=False)
.tox/py312/lib/python3.12/site-packages/xmlschema/validators/schemas.py:345: in __init__
self.source = XMLResource(source, base_url, allow, defuse, timeout)
.tox/py312/lib/python3.12/site-packages/xmlschema/resources.py:470: in __init__
self.parse(source, lazy)
.tox/py312/lib/python3.12/site-packages/xmlschema/resources.py:728: in parse
url = normalize_url(source, self._base_url)
.tox/py312/lib/python3.12/site-packages/xmlschema/resources.py:144: in normalize_url
path = _PurePath.from_uri(url)
.tox/py312/lib/python3.12/site-packages/xmlschema/resources.py:65: in from_uri
return cls(uri)
.tox/py312/lib/python3.12/site-packages/xmlschema/resources.py:54: in __new__
return cast('_PurePath', cls._from_parts(args))
E AttributeError: type object '_PurePosixPath' has no attribute '_from_parts'. Did you mean: '_load_parts'?
Looks like pathlib removed the private _from_parts function.
I tried running the xmlschema testsuite on py3.12, however that currently fails because xmlschema's testsuite depends on lxml which fails to compile on py3.12 (because of cython). So might need to wait for lxml/cython here.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
brunato commentedon Apr 12, 2023
Hi,
the
pathlib.PurePathclass has many changes in Python 3.12, so I have to check deeply the new code to update_PurePathin xmlschema.Unfortunately I cannot avoid to use protected methods because the library needs to manage also relative file URIs.
brunato commentedon Apr 14, 2023
Release v2.2.3 is available.
Reworked
_PurePathremoving the use ofPurePathinternals, now xmlschema should work also with Python 3.12.bluetech commentedon Apr 14, 2023
Thank you! Can confirm that the problem is fixed.