question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

object of type 'dictionary-keyiterator' has no len()

See original GitHub issue

Hi guys,

I was using angr before without any problems for generating Control Flow Graphs. After I updated the angr libraries, I am having this strange error.

I am running it in python 2.7.12 (as before).

File "....convertbinary.py", line 23, in generateCFG
    cfg = project.analyses.CFG()
  File "/usr/local/lib/python2.7/dist-packages/angr/analyses/analysis.py", line 96, in make_analysis
    oself.__init__(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/angr/analyses/cfg/cfg.py", line 58, in __init__
    CFGFast.__init__(self, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/angr/analyses/cfg/cfg_fast.py", line 810, in __init__
    self._analyze()
  File "/usr/local/lib/python2.7/dist-packages/angr/analyses/forward_analysis.py", line 500, in _analyze
    self._analysis_core_baremetal()
  File "/usr/local/lib/python2.7/dist-packages/angr/analyses/forward_analysis.py", line 601, in _analysis_core_baremetal
    self._job_queue_empty()
  File "/usr/local/lib/python2.7/dist-packages/angr/analyses/cfg/cfg_fast.py", line 1287, in _job_queue_empty
    jump_targets = list(set(self._process_indirect_jumps()))
  File "/usr/local/lib/python2.7/dist-packages/angr/analyses/cfg/cfg_fast.py", line 2452, in _process_indirect_jumps
    resolved, targets = resolver.resolve(self, jump.addr, jump.func_addr, block, jump.jumpkind)
  File "/usr/local/lib/python2.7/dist-packages/angr/analyses/cfg/indirect_jump_resolvers/jumptable.py", line 79, in resolve
    if len(preds) != 1:
TypeError: object of type 'dictionary-keyiterator' has no len()

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rhelmotcommented, Apr 23, 2018

Yes… we know. We are competent programmers here. this was fixed in a later refactor pretty much by doing that. Also your example has an error, it should be len(list(G.neighbors(0)))

1reaction
DevanshuSavecommented, Apr 23, 2018

You can also use list() to make this work in networkx 2.0 For e.g. len(G.neighbors(0)) gave me an error where, G is a graph object. Simply use len(list(G.neighbors(0))) and it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

len throws with 'dict_keyiterator' has no len() when calculating ...
So it seems that direct use of iter(d) where d is a dict results in the object of type dict_keyiterator in Python 3....
Read more >
[Example code]-len throws with 'dict_keyiterator' has no len ...
Coding example for the question len throws with 'dict_keyiterator' has no len() when calculating outgoing and incoming edges in networkx.
Read more >
Migration guide from 1.X to 2.0 - NetworkX
Migration guide from 1.X to 2.0#. This is a guide for people moving from NetworkX 1.X to NetworkX 2.0. Any issues with these...
Read more >
collections — Container datatypes — Python 3.11.1 ...
The Counter class itself is a dictionary subclass with no restrictions on its keys and values. The values are intended to be numbers...
Read more >
3. Data model - Python 3.7.0a2 documentation
The type() function returns an object's type (which is an object itself). ... For set elements, the same immutability rules apply as for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found