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

Remove iteritems() calls if Python 3 compatibility is desired #173

Open
guidovranken opened this issue Feb 11, 2015 · 1 comment
Open

Remove iteritems() calls if Python 3 compatibility is desired #173

guidovranken opened this issue Feb 11, 2015 · 1 comment

Comments

@guidovranken
Copy link
Contributor

Python 3 does not support the iteritems() for the dict object:

$ cat p.py 
d = {'x':10, 'y':20}
for k, v in d.iteritems():
    print(k,v)
$ python2 -V
Python 2.7.6
$ python2 p.py 
('y', 20)
('x', 10)
$ python3 -V
Python 3.4.0
$ python3 p.py 
Traceback (most recent call last):
  File "p.py", line 2, in <module>
    for k, v in d.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'

So if you want libtaxii to work with Python 3, these calls have to be replaced or made possible by using six. If achieving Python 3 compatibility is deliberately avoided for now, then you can disregard this report. (I couldn't find any explicit mention about this).

libtaxii-master$ find -name '*.py' -exec grep -Hn iteritems {} \;

./libtaxii/messages_10.py:410:        for k, v in self.extended_headers.iteritems():
./libtaxii/messages_10.py:428:        for k, v in self.extended_headers.iteritems():
./libtaxii/messages_10.py:498:        for k, v in d['extended_headers'].iteritems():
./libtaxii/common.py:311:                for k, v in self_value.iteritems():
./libtaxii/taxii_default_query.py:708:        for k, v in self.parameters.iteritems():
./libtaxii/clients.py:215:            for k, v in headers.iteritems():
./libtaxii/__init__.py:83:        header_dict = http_response.info().dict.iteritems()
./libtaxii/messages_11.py:1073:        for k, v in self.extended_headers.iteritems():
./libtaxii/messages_11.py:1088:        for k, v in self.extended_headers.iteritems():
./libtaxii/messages_11.py:1145:        for k, v in d['extended_headers'].iteritems():
./libtaxii/messages_11.py:2970:        for sd_name, rules in detail_rules.iteritems():
./libtaxii/messages_11.py:2993:            for k, v in self.status_detail.iteritems():
./libtaxii/messages_11.py:3022:        for k, v in self.status_detail.iteritems():
@MarkDavidson
Copy link
Contributor

I think working with Python 3 is a nice to have, at least for now. If these are the only things preventing Python 3 compatibility, then I think these changes are no brainers to make. Otherwise, I'd be interested in what the full scope of changes required are for Python 3 compatibility.

-Mark

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

No branches or pull requests

2 participants