kne / pybox2d-from-googlecode

Automatically exported from code.google.com/p/pybox2d
Other
0 stars 0 forks source link

**kwargs does not have iteritems() in python3.3.3 #53

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

$ python examples/hello.py 
Traceback (most recent call last):
  File "examples/hello.py", line 14, in <module>
    world=b2World() # default gravity is (0,-10) and doSleep is True
  File "/usr/lib/python3.3/site-packages/Box2D-2.3b0-py3.3-linux-x86_64.egg/Box2D/Box2D.py", line 4625, in __init__
    for key, value in kwargs.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'

What is the expected output? What do you see instead?

I expect to be able to create any of the box2d objects. Using python2.7 it 
works as expected.

What version of pybox2d are you using? On what operating system? 32-bit or
64-bit?

Archlinux x86_64

Please provide any additional information below.

This idiom is used all over the place:
def test(**kwargs):
    for key, value in kwargs.iteritems():
        print(key)
test()

In python3 this results in:
AttributeError: 'dict' object has no attribute 'iteritems'

but in python2.7 there's no problem.

Original issue reported on code.google.com by charlie....@gmail.com on 19 Jan 2014 at 4:46

GoogleCodeExporter commented 9 years ago
I suspect this is the fix but I don't know swig and can't get it working so I 
can't test it.

Index: Box2D/Box2D_kwargs.i
===================================================================
--- Box2D/Box2D_kwargs.i        (revision 376)
+++ Box2D/Box2D_kwargs.i        (working copy)
@@ -20,7 +20,7 @@

 %pythoncode %{
     def _init_kwargs(self, **kwargs):
-        for key, value in kwargs.iteritems():
+        for key, value in kwargs.items():
             try:
                 setattr(self, key, value)
             except:

Original comment by charlie....@gmail.com on 19 Jan 2014 at 5:55

GoogleCodeExporter commented 9 years ago
Thanks for the report. I'll switch over to using items() exclusively from now 
on. Should be fixed in rev 377

Original comment by sir...@gmail.com on 17 May 2014 at 6:59