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

TypeError: descriptor '__subclasses__' of 'type' object needs an argument #316

Closed
zallek opened this issue Nov 13, 2020 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@zallek
Copy link

zallek commented Nov 13, 2020

Hi,

I have a TypeError when I try to upgrade the xsdata from 20.10 to 20.11.
We use python 3.7.9

With the 20.11, the lib is falling to get the subclasses of the following class
https://github.com/pallets/flask-sqlalchemy/blob/9876d6c0ec3ac3390f739bb3eb3ea5ab4c0905b7/src/flask_sqlalchemy/model.py#L121

The trackback

Error
Traceback (most recent call last):
  File "/Users/nicolasfortin/.pyenv/versions/3.7.9/lib/python3.7/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/Users/nicolasfortin/.pyenv/versions/3.7.9/lib/python3.7/unittest/case.py", line 628, in run
    testMethod()
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/components/be_core/claim_management/services/assur_card/tests/test_assur_card_parser.py", line 45, in test_parse_assur_pharma_file_invoice
    invoice = AssurCardParser.parse_assur_pharma_file_invoice(f.read())
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/components/be_core/claim_management/services/assur_card/assur_card_parser.py", line 63, in parse_assur_pharma_file_invoice
    return parser.from_string(invoice, SingleMessage)
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/bindings.py", line 24, in from_string
    return self.from_bytes(source.encode(), clazz)
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/bindings.py", line 28, in from_bytes
    return self.parse(io.BytesIO(source), clazz)
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/parsers/nodes.py", line 464, in parse
    result = handler.parse(source)
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/parsers/handlers/lxml.py", line 37, in parse
    return self.process_context(ctx)
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/parsers/handlers/lxml.py", line 50, in process_context
    element.nsmap,
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/parsers/xml.py", line 46, in start
    super().start(clazz, queue, objects, qname, attrs, ns_map)
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/parsers/nodes.py", line 483, in start
    child = item.child(qname, attrs, ns_map, len(objects))
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/parsers/nodes.py", line 114, in child
    node = self.build_node(var, attrs, ns_map, position)
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/parsers/nodes.py", line 136, in build_node
    var.clazz, attrs, ns_map, position, var.derived
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/parsers/nodes.py", line 191, in build_element_node
    meta = self.context.fetch(clazz, self.meta.namespace, xsi_type)
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/context.py", line 67, in fetch
    subclass = self.find_subclass(clazz, xsi_type)
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/context.py", line 111, in find_subclass
    types = self.find_types(qname)
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/context.py", line 95, in find_types
    self.build_xsi_cache()
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/context.py", line 75, in build_xsi_cache
    for clazz in self.get_subclasses(object):
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/context.py", line 360, in get_subclasses
    yield subclass
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/context.py", line 360, in get_subclasses
    yield subclass
  File "/Users/nicolasfortin/Workspaces/Alan/alan-backend/.venv/lib/python3.7/site-packages/xsdata/formats/dataclass/context.py", line 359, in get_subclasses
    yield from cls.get_subclasses(subclass)
TypeError: descriptor '__subclasses__' of 'type' object needs an argument
@tefra tefra added the bug Something isn't working label Nov 13, 2020
@tefra tefra closed this as completed in 313013b Nov 13, 2020
tefra added a commit that referenced this issue Nov 13, 2020
Fix #316 Catch all TypeErrors when building xsi cache
@tefra
Copy link
Owner

tefra commented Nov 13, 2020

Hi @zallek thanks for reporting, I just released a fix to catch all type errors when its building the xsi cache.

Unfortunately I failed to reproduced it correctly, can you share more info like your other project dependencies and os.

I created a venv with python 3.7.9, installed the flask-sqlalchemy and imported the module you mentioned in one of the tests that's triggering the xsi cache rebuild but I didn't get the exception, the previous check in that method actually worked as it was supposed to.

@zallek
Copy link
Author

zallek commented Nov 16, 2020

Your fix works for us. Thank you.

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