[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] PMT Oddities
From: |
Martin Braun |
Subject: |
Re: [Discuss-gnuradio] PMT Oddities |
Date: |
Fri, 9 Dec 2016 10:32:43 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 |
On 12/05/2016 01:56 PM, Dave NotTelling wrote:
> Marcus & Martin:
>
> I tried the dict_keys() method of checking, but even that can
> fail. Here is an example:
>
> [code]
>
> import pmt
>
> d = pmt.make_dict()
> d = pmt.dict_add(d, pmt.intern('a'), pmt.intern('a'))
> d = pmt.dict_add(d, pmt.intern('b'), pmt.intern('b'))
> d = pmt.dict_add(d, pmt.intern('c'), pmt.intern('c'))
>
> a = pmt.cons(d, pmt.make_u8vector(10, 10))
>
> print pmt.dict_keys(a)
>
> [/code]
>
> You end up with: ((c . c))
>
> The dict_keys() method will bomb if there are no elements in the dictionary:
>
> print pmt.dict_keys(pmt.cons(pmt.make_dict(), pmt.make_u8vector(10, 10)))
It's supposed to bomb -- pmt.cons() does not return a dict. That's
exactly how you can test for dicts.
See:
https://github.com/gnuradio/gnuradio/blob/1e8562c8d5430667b48fced2d2e50ab5771dfb5e/gr-uhd/lib/usrp_block_impl.cc#L486-L494
-- M