booglybob / pyglet

Automatically exported from code.google.com/p/pyglet
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

TypeError in graphics test suite with python3.x #722

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Have you tried Pyglet 1.2 alpha1 or the repository code?
default branch, changeset: 
http://code.google.com/p/pyglet/source/detail?r=af64b8ab77ff, Tue Apr 01 
17:54:03 2014 +0100
using Python 3.3.5

What steps will reproduce the problem?
1. apply 2to3
2. run tests/test.py graphics

Paste in the traceback or error message:
ERROR Error in graphics.IMMEDIATE_INDEXED
ERROR Traceback (most recent call last):
  File "./../tests/graphics/graphics_common.py", line 206, in setUp
    self.index_data = list(range(self.n_vertices/2)) + list(range(self.n_vertices/2))
TypeError: 'float' object cannot be interpreted as an integer

ERROR Error in graphics.RETAINED_INDEXED
ERROR Traceback (most recent call last):
  File "./../tests/graphics/graphics_common.py", line 206, in setUp
    self.index_data = list(range(self.n_vertices/2)) + list(range(self.n_vertices/2))
TypeError: 'float' object cannot be interpreted as an integer

^multiple times.

Problem:
`self.n_vertices/2` returns float because Python 3.x uses the new division 
operator by default.
http://legacy.python.org/dev/peps/pep-0238/

Proposed fix:
diff --git a/tests/graphics/graphics_common.py 
b/tests/graphics/graphics_common.py
--- a/tests/graphics/graphics_common.py
+++ b/tests/graphics/graphics_common.py
@@ -203,7 +203,7 @@
         GraphicsGenericTestCase.setUp(self)

         # we use half of the data so we repeat vertices.
-        self.index_data = range(self.n_vertices/2) + range(self.n_vertices/2)
+        self.index_data = range(self.n_vertices//2) * 2
         random.seed(1)
         random.shuffle(self.index_data)

Original issue reported on code.google.com by Risimi...@gmail.com on 1 Apr 2014 at 7:38

GoogleCodeExporter commented 8 years ago
Thanks for the report (and the patch!).

Original comment by useboxnet on 2 Apr 2014 at 6:58

GoogleCodeExporter commented 8 years ago
Btw, can you write your name in a comment so I can add it to the changelog?

Original comment by useboxnet on 2 Apr 2014 at 6:58

GoogleCodeExporter commented 8 years ago
Risimi.

Original comment by Risimi...@gmail.com on 2 Apr 2014 at 4:14

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 9781eb46dca2.

Original comment by useboxnet on 3 Apr 2014 at 6:14