Skip to content

Conversation

@ermirh
Copy link
Contributor

@ermirh ermirh commented May 5, 2021

importing the ABCs from 'collections' instead of from 'collections.abc'
is deprecated since Python 3.3, and in 3.10 it will stop working.

Description
On Python 3.10 running any az commands show the following error:

$ az account list
The command failed with an unexpected error. Here is the traceback:
module 'collections' has no attribute 'Iterable'
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/local/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute
    raise ex
  File "/usr/local/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/usr/local/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    elif _is_paged(result):
  File "/usr/local/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 1119, in _is_paged
    if isinstance(obj, collections.Iterable) \
AttributeError: module 'collections' has no attribute 'Iterable'
To open an issue, please run: 'az feedback'

Testing Guide
Testing any az commands like: az account list or az account get-access-token


This checklist is used to make sure that common guidelines for a pull request are followed.

@ghost ghost added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label May 5, 2021
@ghost
Copy link

ghost commented May 5, 2021

Thank you for your contribution ermirh! We will review the pull request and get back to you soon.

@yonzhan yonzhan added this to the S187 milestone May 5, 2021
@yonzhan
Copy link
Collaborator

yonzhan commented May 5, 2021

@jiasli for awareness

@jiasli
Copy link
Member

jiasli commented May 6, 2021

According to https://docs.python.org/3/library/collections.html

Deprecated since version 3.3, will be removed in version 3.10: Moved Collections Abstract Base Classes to the collections.abc module. For backwards compatibility, they continue to be visible in this module through Python 3.9.

> C:\Users\xxx\AppData\Local\Programs\Python\Python39\python.exe -V
Python 3.9.5
> C:\Users\xxx\AppData\Local\Programs\Python\Python39\python.exe -c "from collections import Iterable"
<string>:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working

So it still works in Python 3.9, but stops working in Python 3.10.

@jiasli jiasli changed the title [Core] Support Python 3.9 {Core} Use from collections.abc import Iterable to support Python 3.10 May 6, 2021
@ermirh ermirh force-pushed the support_for_python39 branch from e31ed09 to 8755b69 Compare May 6, 2021 07:33
importing the ABCs from 'collections' instead of from 'collections.abc'
is deprecated since Python 3.3, and in 3.10 it will stop working.
@ermirh ermirh force-pushed the support_for_python39 branch from 8755b69 to b2b06bc Compare May 6, 2021 07:45
@jiasli jiasli merged commit dc295b8 into Azure:dev May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants