pyocd / pyocd/pyOCD

Error: 'NoneType' object is not iterable [__main__]

Open
#1,768 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
560
Avg merge
1h 41m
Merged PRs (30d)
3

Description

In tcp_client_probe.py the following code exists:

    _PROPERTY_CONVERTERS = {
            'capabilities':                 lambda value: [DebugProbe.Capability[v] for v in value],
            'supported_wire_protocols':     lambda value: [DebugProbe.Protocol[v] for v in value],
            'wire_protocol':                lambda value: DebugProbe.Protocol[value] if (value is not None) else None,
        }

Presumably, that None shield needs to be present for all of them right?

I'm also more used to seeing something like: for ii in value or [] rather than that if statement, but I don't know if they are precisely equivalent.

Side note: the logging didn't give me a very useful traceback and I had to add a bunch of code to main.py to get a useful traceback. All it gave was the useless:
0000575 C Error: 'NoneType' object is not iterable [__main__]

Full traceback after I added code:

pyOCD % pyocd erase -L pyocd.probe.tcp_client_probe.trace=debug --uid=remote:192.168.13.17:3333 --chip --target stm32g0b1retx
0000401 D Request: {"id": 0, "request": "hello", "arguments": [1]} [tcp_client_probe]
0000420 D decoded_response = {'id': 0, 'status': 0} [tcp_client_probe]
0000420 D Request: {"id": 1, "request": "open"} [tcp_client_probe]
0000437 D decoded_response = {'id': 0, 'status': 0} [tcp_client_probe]
0000437 D Request: {"id": 2, "request": "set_clock", "arguments": [1000000]} [tcp_client_probe]
0000459 D decoded_response = {'id': 0, 'status': 0} [tcp_client_probe]
0000497 D Request: {"id": 3, "request": "lock"} [tcp_client_probe]
0000521 D decoded_response = {'id': 0, 'status': 0} [tcp_client_probe]
0000526 D Request: {"id": 4, "request": "readprop", "arguments": ["capabilities"]} [tcp_client_probe]
0000549 D decoded_response = {'id': 0, 'status': 0} [tcp_client_probe]
0000549 D Request: {"id": 5, "request": "disconnect"} [tcp_client_probe]
0000567 D decoded_response = {'id': 0, 'status': 0} [tcp_client_probe]
0000568 D Request: {"id": 6, "request": "close"} [tcp_client_probe]
0000585 D decoded_response = {'id': 0, 'status': 0} [tcp_client_probe]
0000585 C FAULT 2! [__main__]
0000586 C Error: 'NoneType' object is not iterable [__main__]
Traceback (most recent call last):
  File "/var/home/foo/stdev/pyOCD/pyocd/__main__.py", line 161, in run
    status = cmd.invoke()
  File "/var/home/foo/stdev/pyOCD/pyocd/subcommands/erase_cmd.py", line 94, in invoke
    with session:
         ^^^^^^^
  File "/var/home/foo/stdev/pyOCD/pyocd/core/session.py", line 415, in __enter__
    self.open()
    ~~~~~~~~~^^
  File "/var/home/foo/stdev/pyOCD/pyocd/core/session.py", line 553, in open
    self._board.init()
    ~~~~~~~~~~~~~~~~^^
  File "/var/home/foo/stdev/pyOCD/pyocd/board/board.py", line 143, in init
    self.target.init()
    ~~~~~~~~~~~~~~~~^^
  File "/var/home/foo/stdev/pyOCD/pyocd/coresight/coresight_target.py", line 123, in init
    super().init()
    ~~~~~~~~~~~~^^
  File "/var/home/foo/stdev/pyOCD/pyocd/core/soc_target.py", line 174, in init
    seq.invoke()
    ~~~~~~~~~~^^
  File "/var/home/foo/stdev/pyOCD/pyocd/utility/sequencer.py", line 213, in invoke
    resultSequence.invoke()
    ~~~~~~~~~~~~~~~~~~~~~^^
  File "/var/home/foo/stdev/pyOCD/pyocd/utility/sequencer.py", line 208, in invoke
    resultSequence = call()
  File "/var/home/foo/stdev/pyOCD/pyocd/coresight/dap.py", line 435, in _get_probe_capabilities
    caps = self._probe.capabilities
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/home/foo/stdev/pyOCD/pyocd/probe/tcp_client_probe.py", line 141, in capabilities
    return self._read_property('capabilities')
           ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/var/home/foo/stdev/pyOCD/pyocd/probe/tcp_client_probe.py", line 217, in _read_property
    result = self._PROPERTY_CONVERTERS[name](result)
  File "/var/home/foo/stdev/pyOCD/pyocd/probe/tcp_client_probe.py", line 207, in <lambda>
    'capabilities':                 lambda value: [DebugProbe.Capability[v] for v in value],
                                                                                     ^^^^^
TypeError: 'NoneType' object is not iterable

> /var/home/foo/stdev/pyOCD/pyocd/probe/tcp_client_probe.py(207)<lambda>()
-> 'capabilities':                 lambda value: [DebugProbe.Capability[v] for v in value],
(Pdb)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pyocd/probe/tcp_client_probe.py at _PROPERTY_CONVERTERS and _read_property, using the provided pyocd erase command to reproduce the failure. Check how null capabilities and supported_wire_protocols responses are converted, and confirm the command completes without the reported TypeError while preserving the existing wire_protocol behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.