AttributeError: 'dict' object has no attribute 'iter'
See original GitHub issue- Package Name: azure-storage-file-datalake
- Package Version: 12.2.0
- Operating System: Linux
- Python Version: 3.5.2 (from HDInsight cluster with ESP)
Describe the bug When listing an Azure directory which doesn’t have proper permission, we get AttributeError. Traceback:
Traceback (most recent call last):
File "azure.whl/azure/storage/filedatalake/_list_paths_helper.py", line 56, in _get_next_cb
File "azure.whl/azure/storage/filedatalake/_generated/operations/_file_system_operations.py", line 442, in list_paths
azure.storage.filedatalake._generated.models._models_py3.StorageErrorException: (AuthorizationPermissionMismatch) This request is not authorized to perform this operation using this permission.
RequestId:e6038639-e01f-007e-5013-df0d71000000
Time:2020-12-31T01:21:21.9445915Z
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test_client.py", line 18, in <module>
for run_result in fs_client.get_paths(path='rtgasi/negotiation/hdfs_rfe_v1/results/205ba9c9-8cdb-4f77-887f-c561e2c8edc3', recursive=False):
File "azure.whl/azure/core/paging.py", line 129, in __next__
File "azure.whl/azure/core/paging.py", line 76, in __next__
File "azure.whl/azure/storage/filedatalake/_list_paths_helper.py", line 58, in _get_next_cb
File "azure.whl/azure/storage/filedatalake/_shared/response_handlers.py", line 94, in process_storage_error
AttributeError: 'dict' object has no attribute 'iter'
To Reproduce Steps to reproduce the behavior:
- Just run the following code where
some/pathdoes not have the proper permission:
credential = identity.ClientSecretCredential('xx', 'xx', 'xx')
service_client = filedatalake.DataLakeServiceClient('https://xx.dfs.core.windows.net', credential=credential)
fs_client = service_client.get_file_system_client(file_system='xx')
for result in fs_client.get_paths(path='some/path', recursive=False):
pass
Expected behavior
Should raise StorageErrorException or other more relevant errors
From the look of the exception, we just need to remove .iter() part and it should work for both Python 2 and 3:
https://github.com/Azure/azure-sdk-for-python/blob/d59d06d75131f4e5ac133bcfdc442c38416808ad/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/response_handlers.py#L94
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top Results From Across the Web
How come Python's dict doesn't have .iter()? - Stack Overflow
Considering the following dict : ... line 1, in <module> AttributeError: 'dict' object has no attribute 'iter' ... tuple(d.itervalues()) (1, 3, 2).
Read more >AttributeError: 'dict' object has no attribute 'iteritems' | bobbyhadz
The Python "AttributeError: 'dict' object has no attribute 'iteritems'" occurs because the iteritems() method has been removed in Python 3.
Read more >How to Fix the error 'dict' object has no attribute 'iteritems' in ...
Many changes are done from Python 2 to Python 3. One such change is in the attributes of the dictionary class. The dict...
Read more >How to fix : dict object has no attribute iteritems - YouTube
dict object has no attribute iteritems it is Attribute error in Python caused by removal of iteritems methods in Python 3.x.
Read more >How To Fix Python Error - “ 'dict' object has no attribute ...
In this post , we will see How To Fix Python Error: “ 'dict' object has no attribute 'iteritems' ”. ... This is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

My bad, I used a BlobClient with a Datalake container. In this case, the object returned was a dict and .iter() errored without showing me the actual content of the response. It’s fixed for me now, but you may want to check this case to help dump people like me 😄
Hi @prevostc, it is supported in Py3, you can call
.iter()onelementtreeobjects which in this case it is. Could you please provide me a code sample of what you’re attempting to do and how that’s failing?