The QueryResult class in the dataquery module defines a method __iter__. Calling this method unconditionally fails with AttributeError, due to calling a historical dict method viewitems that existed in Python 2.
To reproduce:
from pybufrkit.decoder import Decoder, generate_bufr_message
from pybufrkit.dataquery import NodePathParser, DataQuerent
fn = "/home/gholl/checkouts/pybufrkit/tests/data/jaso_214.bufr"
with open(fn, "rb") as fp:
for bufr_message in generate_bufr_message(Decoder(), fp.read()):
query_result = DataQuerent(NodePathParser()).query(bufr_message, '001015')
iter(query_result)
Using Python 3.11, this fails with:
Traceback (most recent call last):
File "/data/gholl/checkouts/protocode/mwe/pybufrkit-attributeerror.py", line 7, in <module>
iter(query_result)
File "/data/gholl/mambaforge/envs/py311/lib/python3.11/site-packages/pybufrkit/dataquery.py", line 313, in __iter__
return iter(self.results.viewitems())
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'collections.OrderedDict' object has no attribute 'viewitems'
The
QueryResult
class in thedataquery
module defines a method__iter__
. Calling this method unconditionally fails withAttributeError
, due to calling a historical dict methodviewitems
that existed in Python 2.To reproduce:
Using Python 3.11, this fails with:
I'm using pybufrkit 0.2.19.