Skip to content
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

Python 3.12 support #342

Closed
bluetech opened this issue Apr 11, 2023 · 3 comments
Closed

Python 3.12 support #342

bluetech opened this issue Apr 11, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@bluetech
Copy link

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.

@brunato
Copy link
Member

brunato commented Apr 12, 2023

Hi,
the pathlib.PurePath class has many changes in Python 3.12, so I have to check deeply the new code to update _PurePath in xmlschema.
Unfortunately I cannot avoid to use protected methods because the library needs to manage also relative file URIs.

@brunato brunato added the bug Something isn't working label Apr 12, 2023
@brunato
Copy link
Member

brunato commented Apr 14, 2023

Release v2.2.3 is available.
Reworked _PurePath removing the use of PurePath internals, now xmlschema should work also with Python 3.12.

@bluetech
Copy link
Author

Thank you! Can confirm that the problem is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants