Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iter(query_result) fails with AttributeError #23

Open
gerritholl opened this issue Dec 23, 2022 · 0 comments · May be fixed by #24
Open

iter(query_result) fails with AttributeError #23

gerritholl opened this issue Dec 23, 2022 · 0 comments · May be fixed by #24

Comments

@gerritholl
Copy link

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'

I'm using pybufrkit 0.2.19.

@gerritholl gerritholl linked a pull request Dec 23, 2022 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant