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

Add Python 3.9 compatibility. #204

Open
wants to merge 2 commits into
base: master
from

Conversation

@tirkarthi
Copy link

@tirkarthi tirkarthi commented Dec 7, 2019

  • Importing ABC from collections module will raise ImportError in Python 3.9 and raises DeprecationWarning from 3.4 . Hence use collections.abc and also preserve compatibility with Python 2. Ref : python/cpython#10596
  • Use list instead of deprecated getchildren in Python 3. Fixes #206
@tirkarthi
Copy link
Author

@tirkarthi tirkarthi commented Dec 7, 2019

I am not sure the build failures in some of the pipelines are related to my PR.

@tirkarthi tirkarthi changed the title Import ABC from collections.abc for Python 3.9 compatibility. Add Python 3.9 compatibility. Mar 10, 2020
@@ -180,8 +181,12 @@ def _get_custom_widgets(ui_file):
return {}

custom_widget_classes = {}
if PY33:

This comment has been minimized.

@goanpeca

goanpeca Mar 12, 2020
Member

We are not supporting this version of python, so why do we need this?

Or is the extra 3 a type?

This comment has been minimized.

@tirkarthi

tirkarthi Oct 27, 2020
Author

Sorry for the late reply. PY33 is a variable to ensure the python version is 3.3 and above. As per the below deprecation it seems the methods were deprecated from 3.2. So I made sure to use list(custom_widgets) in Python 3.3+ and fallback to getchildren for versions below python 3.3 . Python 3.3 is listed in setup.py and this is the format used in most places for compatibility and hence my change.

Methods getchildren() and getiterator() of classes ElementTree and Element in the ElementTree module have been removed. They were deprecated in Python 3.2. Use iter(x) or list(x) instead of x.getchildren() and x.iter() or list(x.iter()) instead of x.getiterator(). (Contributed by Serhiy Storchaka in bpo-36543.)

https://docs.python.org/3.9/whatsnew/3.9.html#removed

@graingert
Copy link

@graingert graingert commented Nov 18, 2020

@goanpeca it might be nicer to use from six.moves.collections_abc import Callable

it seems that it would be more idiomatic to use six everywhere in place of qtpy.py3compat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.