[Fixed]FEM test sifio.py breaks when compiled with python 3.10

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

[Fixed]FEM test sifio.py breaks when compiled with python 3.10

Post by Kunda1 »

This line https://github.com/FreeCAD/FreeCAD/blob ... io.py#L342
breaks the test when python 3.10 is used. See issue #4825 specifically this comment

According to this stackoverflow answer
collections.Iterable is deprecated in favor of collections.abc.Iterable
How do we add the logic to support either?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: FEM test sifio.py breaks when compiled with python 3.10

Post by jnxd »

Kunda1 wrote: Sun Jan 23, 2022 7:41 pm This line https://github.com/FreeCAD/FreeCAD/blob ... io.py#L342
breaks the test when python 3.10 is used. ...

According to this stackoverflow answer
collections.Iterable is deprecated in favor of collections.abc.Iterable
How do we add the logic to support either?
Maybe something like this?

Code: Select all

 def _isCollection(self, data):
        if sys.version_info.major == 3 and sys.version_info.minor > 10:
                return (not isinstance(data, six.string_types)
                            and isinstance(data, collections.abc.Iterable)
        else:
                return (not isinstance(data, six.string_types)
                            and isinstance(data, collections.Iterable)
        )
My latest (or last) project: B-spline Construction Project.
hyarion
Posts: 139
Joined: Fri Jun 26, 2020 6:08 pm

Re: FEM test sifio.py breaks when compiled with python 3.10

Post by hyarion »

Wouldn't it be better to refactor whatever creates those iterables to always use the abc-version? It has been available in the new place since python 3.3 (10 years ago)
User avatar
jnxd
Posts: 951
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: FEM test sifio.py breaks when compiled with python 3.10

Post by jnxd »

hyarion wrote: Mon Jan 24, 2022 8:29 am Wouldn't it be better to refactor whatever creates those iterables to always use the abc-version? It has been available in the new place since python 3.3 (10 years ago)
Oh in that case of course (and I see wmayer already made the change). I was going solely from the information I read in the forum and tracker :mrgreen:
My latest (or last) project: B-spline Construction Project.
Post Reply