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

[solved] cocos.text can traceback with AttributeError: 'RunIterator' object has no attribute 'length' #322

Closed
ccanepa opened this issue Aug 11, 2019 · 5 comments

Comments

@ccanepa
Copy link
Contributor

ccanepa commented Aug 11, 2019

solved a bit, but you need to upgrade to latest pyglet master (and now Label instead of HTMLLabel will be broken; waiting for a more complete pyglet fix correcting both cases)

runing test_htmllabel_opacity.py got traceback

(py-cocos) E:\dev\cocos2019\test>python test_htmllabel_opacity.py
Traceback (most recent call last):
  File "test_htmllabel_opacity.py", line 37, in <module>
    main()
  File "test_htmllabel_opacity.py", line 34, in main
    director.run (main_scene)
  File "..\cocos\director.py", line 406, in run
    event_loop.run()
  File "e:\dev\pyglet-2019\pyglet\app\base.py", line 175, in run
    self._run()
  File "e:\dev\pyglet-2019\pyglet\app\base.py", line 187, in _run
    timeout = self.idle()
  File "e:\dev\pyglet-2019\pyglet\app\base.py", line 308, in idle
    redraw_all = self.clock.call_scheduled_functions(dt)
  File "e:\dev\pyglet-2019\pyglet\clock.py", line 290, in call_scheduled_functio
ns
    item.func(dt, *item.args, **item.kwargs)
  File "..\cocos\cocosnode.py", line 879, in _step
    action.step(dt)
  File "..\cocos\actions\base_actions.py", line 525, in step
    self.update(min(1, self._elapsed / self.duration))
  File "..\cocos\actions\interval_actions.py", line 421, in update
    self.target.opacity = 255 * (1 - t)
  File "..\cocos\text.py", line 89, in _set_opacity
    self.element.color = tuple(self.element.color[:3]) + (int(value),)
  File "e:\dev\pyglet-2019\pyglet\text\__init__.py", line 309, in color
    {'color': color})
  File "e:\dev\pyglet-2019\pyglet\text\document.py", line 512, in set_style
    self.dispatch_event('on_style_text', start, end, attributes)
  File "e:\dev\pyglet-2019\pyglet\event.py", line 400, in dispatch_event
    if handler(*args):
  File "e:\dev\pyglet-2019\pyglet\text\layout.py", line 1062, in on_style_text
    self._update_color()
  File "e:\dev\pyglet-2019\pyglet\text\layout.py", line 977, in _update_color
    for start, end, color in colors_iter.ranges(0, colors_iter.length):
AttributeError: 'RunIterator' object has no attribute 'length'

win7 64.bits, python 3.7

pyglet:
commit 58dfdb6314fc900cfbba6355b79bb09e718a41c9 master github
Author: Benjamin Moran
Date: Fri Aug 9 09:43:50 2019 +0900

cocos:
commit 26ef349 master
Author: Richard Jones
Date: Sun Aug 11 13:15:17 2019 +1000

@ccanepa
Copy link
Contributor Author

ccanepa commented Aug 12, 2019

Reproduced with a pure pyglet script, opened an issue at pyglet github issues,
pyglet/pyglet#40

@ccanepa
Copy link
Contributor Author

ccanepa commented Aug 13, 2019

solved: pyglet fixed the issue. You will need to update from pyglet master if you experience this problem.

Keeping open until next pyglet release.

@ccanepa ccanepa changed the title cocos.text can traceback with AttributeError: 'RunIterator' object has no attribute 'length' [solved] cocos.text can traceback with AttributeError: 'RunIterator' object has no attribute 'length' Aug 13, 2019
@ccanepa
Copy link
Contributor Author

ccanepa commented Aug 20, 2019

The pyglet fix for the initial issue broke changing color for Label

Opened pyglet/pyglet#45

The cocos related crashes are:

test_label_changing.py
test_label_opacity.py

The traceback from thje first (the other ends the same)

(py37-cocos) E:\dev\cocos2019\test>python test_label_changing.py
Traceback (most recent call last):
  File "test_label_changing.py", line 51, in <module>
    main()
  File "test_label_changing.py", line 46, in main
    test_layer = TestLayer ()
  File "test_label_changing.py", line 35, in __init__
    self.set_color(2)
  File "test_label_changing.py", line 42, in set_color
    self.label.element.color = color
  File "e:\dev\pyglet-2019\pyglet\text\__init__.py", line 309, in color
    {'color': color})
  File "e:\dev\pyglet-2019\pyglet\text\document.py", line 604, in set_style
    0, len(self.text), attributes)
  File "e:\dev\pyglet-2019\pyglet\text\document.py", line 512, in set_style
    self.dispatch_event('on_style_text', start, end, attributes)
  File "e:\dev\pyglet-2019\pyglet\event.py", line 400, in dispatch_event
    if handler(*args):
  File "e:\dev\pyglet-2019\pyglet\text\layout.py", line 1062, in on_style_text
    self._update_color()
  File "e:\dev\pyglet-2019\pyglet\text\layout.py", line 977, in _update_color
    for start, end, color in colors_iter.ranges(0, colors_iter.end):
AttributeError: 'ConstRunIterator' object has no attribute 'end'

Deleting the [Solved], the two cases, Label and HTMLLabel, will need a shared fix from pyglet.

win 7-64, python 3.7

pyglet
from github master
commit ebe94a0
Date: Fri Aug 16 16:55:35 2019 +0900
Tweaked Travis-CI due to OSX breakage.

cocos
commit a95f236
Date: Sun Aug 18 01:25:10 2019 -0300
doc: compatibilty notes for pyglet.image, #321, #323

@ccanepa ccanepa changed the title [solved] cocos.text can traceback with AttributeError: 'RunIterator' object has no attribute 'length' cocos.text can traceback with AttributeError: 'RunIterator' object has no attribute 'length' Aug 20, 2019
@ccanepa
Copy link
Contributor Author

ccanepa commented Aug 23, 2019

pyglet fixed in master, would be available in pyglet 1.4.3

pyglet master in github
commit 22e1a3aa03f7ae298f98d53e6364e95d45d3b49a
Date: Wed Aug 21 13:41:23 2019 +0900
Make some text.runlist APIs consistent.

@ccanepa ccanepa changed the title cocos.text can traceback with AttributeError: 'RunIterator' object has no attribute 'length' [solved] cocos.text can traceback with AttributeError: 'RunIterator' object has no attribute 'length' Aug 23, 2019
@ccanepa
Copy link
Contributor Author

ccanepa commented Sep 23, 2019

fixed in pyglet, pyglet 1.4.3 recommended

@ccanepa ccanepa closed this as completed Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant