booglybob / pyglet

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

[patch] py3 compatibility problem in pyglet/graphics/__init__.py #704

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
1. pyglet tip from default repo ( rc43bc57c954f tip , dated 2014 01 03 )
2. as I'am in windows, applied the fix suggested in pyglet issue 702, comment 5
3. install for py3 with 
    py -3.3 setup.py install
   so the py2to3 adjusts are performed
4. checkout the branch b_py3 of cocos
5. most of cocos test (microdemos) work ok in py3
6. but test/test_htmllabel.py tracebacks:

D:\cocos_pristine\b_py3\test>py -3.3 test_htmllabel.py
Traceback (most recent call last):
  File "test_htmllabel.py", line 38, in <module>
    main()
  File "test_htmllabel.py", line 35, in main
    director.run (main_scene)
  File "..\cocos\director.py", line 375, in run
    event_loop.run()
  File "C:\Python33\lib\site-packages\pyglet\app\base.py", line 136, in run
    self._run_estimated()
  File "C:\Python33\lib\site-packages\pyglet\app\base.py", line 165, in _run_est
imated
    timeout = self.idle()
  File "C:\Python33\lib\site-packages\pyglet\app\base.py", line 280, in idle
    window.dispatch_event('on_draw')
  File "C:\Python33\lib\site-packages\pyglet\window\__init__.py", line 1154, in
dispatch_event
    if EventDispatcher.dispatch_event(self, *args) != False:
  File "C:\Python33\lib\site-packages\pyglet\event.py", line 355, in dispatch_event
    if handler(*args):
  File "..\cocos\director.py", line 433, in on_draw
    self.scene.visit()
  File "..\cocos\cocosnode.py", line 685, in visit
    c.visit()
  File "..\cocos\cocosnode.py", line 685, in visit
    c.visit()
  File "..\cocos\cocosnode.py", line 678, in visit
    self.draw()
  File "..\cocos\text.py", line 80, in draw
    self.element.draw()
  File "C:\Python33\lib\site-packages\pyglet\text\layout.py", line 854, in draw
    self.batch.draw_subset(self._vertex_lists)
  File "C:\Python33\lib\site-packages\pyglet\graphics\__init__.py", line 593, in draw_subset
    visit(group)
  File "C:\Python33\lib\site-packages\pyglet\graphics\__init__.py", line 577, in visit
    for (_, mode, _), domain in list(domain_map.items()):
UnboundLocalError: local variable 'list' referenced before assignment

Additional info:
python 3.3.1, win xp 32bits
The script runs fine with python 2.6

Patch:
Inspecting pyglet/graphics/__init__.py around the line that tracebacks, shows a 
loop that tries to use a local variable named 'list'.
Renaming that variable to 'alist' fixes the problem.

I copied the modification to the working copy, done a
  cd working_copy
  hg diff pyglet/graphics/__init__.py >py3_list.diff

The patch could be applied to a clean checkout of tip by
  cd working_copy
  hg patch py3_list.diff --no-commit

Original issue reported on code.google.com by ccanepacc@gmail.com on 22 Feb 2014 at 8:26

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by useboxnet on 6 Mar 2014 at 9:45

GoogleCodeExporter commented 8 years ago
I don't want to be a pest, but can the suggested change land on trunk ?
As I mentioned in pyglet issue #702, I will release cocos 0.6.0 in a few days, 
and wanted to mention a 'know good' pyglet release.

If it facilitated your work, I also created a pyglet clone with the fix, at
http://code.google.com/r/ccanepacc-fix-704/

If you see some problem with the change, please comment.

Thanks for your attention.   

Original comment by ccanepacc@gmail.com on 20 Mar 2014 at 2:28

GoogleCodeExporter commented 8 years ago
I'll do it ASAP (it might be this weekend).

Thanks for the patch!

Original comment by useboxnet on 20 Mar 2014 at 6:43

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

Original comment by useboxnet on 20 Mar 2014 at 7:02

GoogleCodeExporter commented 8 years ago
I applied the patch. My apologies for not applying the patch sooner, it's been 
in my TODO list for some time.

Don't hesitate to ping me for any other patch that you need to get into the 
repo!

Original comment by useboxnet on 20 Mar 2014 at 7:03

GoogleCodeExporter commented 8 years ago
No, problem, and thanks for the help.

Original comment by ccanepacc@gmail.com on 20 Mar 2014 at 7:07