Re: Issue 429 in pyglet: Exception when attributed text with mixed bold / nonbold is entirely deleted

3 views
Skip to first unread message

codesite...@google.com

unread,
Apr 27, 2010, 2:46:35 PM4/27/10
to pyglet...@googlegroups.com
Updates:
Summary: Exception when attributed text with mixed bold / nonbold is
entirely deleted
Status: Accepted

Comment #4 on issue 429 by oresmus: Exception when attributed text with
mixed bold / nonbold is entirely deleted
http://code.google.com/p/pyglet/issues/detail?id=429

Here's a variant of that code sample which generates a similar traceback
for me:

import pyglet

doc = pyglet.text.decode_attributed('{bold True}Hello{bold False}\n\n\n\n')
doc2 = pyglet.text.decode_attributed('{bold True}Goodbye{bold
False}\n\n\n\n')
layout = pyglet.text.layout.IncrementalTextLayout(doc, 100, 10)
layout.document = doc2
layout.document.delete_text(0, len(layout.document.text))

This is using pyglet 1.2dev (the current hg head) on Mac OS 10.6.3, using
Python
2.6.2 installed from python.org. (FYI, I have no problems running that
combination of
pyglet, python, and Mac OS in general, in spite of reported issues with
similar
combinations but pyglet 1.1.3, e.g. in issue 438.)

I think the real issue isn't the document replacement or the newlines, but
deleting
all text when there are mixed font styles, since the following simpler
example also
gives a similar traceback:

import pyglet
doc2 = pyglet.text.decode_attributed('{bold True}a{bold False}b')
layout = pyglet.text.layout.IncrementalTextLayout(doc2, 100, 10)
layout.document.delete_text(0, len(layout.document.text))

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyglet/text/document.py",
line 445, in delete_text
self.dispatch_event('on_delete_text', start, end)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyglet/event.py",
line 340, in dispatch_event
if handler(*args):
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyglet/text/layout.py",
line 1804, in on_delete_text
self._update()
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyglet/text/layout.py",
line 1837, in _update
font = self.document.get_font(0, dpi=self._dpi)
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyglet/text/document.py",
line 660, in get_font
return iter[position]
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyglet/text/document.py",
line 719, in __getitem__
font_name, font_size, bold, italic = self.zip_iter[index]
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyglet/text/runlist.py",
line 403, in __getitem__
return [i[index] for i in self.range_iterators]
File
"/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyglet/text/runlist.py",
line 293, in __getitem__
self.start, self.end, self.value = self.next()
StopIteration

A possible clue to the cause (but no guarantee, since it's different code):
in a
larger editor example (not posted here), doing the same thing manually gets
a similar
traceback, and a subsequent click in the text widget gets the following
additional
traceback:

Traceback (most recent call last):
File "_ctypes/callbacks.c", line 295, in 'calling callback function'
File "/Applications/pyglet/pyglet-hg/pyglet/window/carbon/__init__.py",
line 797,
in _on_mouse_down
self.dispatch_event('on_mouse_press', x, y, button, modifiers)
File "/Applications/pyglet/pyglet-hg/pyglet/window/__init__.py", line
1150, in
dispatch_event
if EventDispatcher.dispatch_event(self, *args) != False:
File "/Applications/pyglet/pyglet-hg/pyglet/event.py", line 369, in
dispatch_event
event_type, args, getattr(self, event_type))
File "/Applications/pyglet/pyglet-hg/pyglet/event.py", line 365, in
dispatch_event
if getattr(self, event_type)(*args):
File "edithack1.py", line 363, in on_mouse_press
self.focus.caret.on_mouse_press(x, y, button, modifiers)
File "/Applications/pyglet/pyglet-hg/pyglet/text/caret.py", line 552, in
on_mouse_press
self.move_to_point(x, y)
File "/Applications/pyglet/pyglet-hg/pyglet/text/caret.py", line 322, in
move_to_point
line = self._layout.get_line_from_point(x, y)
File "/Applications/pyglet/pyglet-hg/pyglet/text/layout.py", line 2272, in
get_line_from_point
if y > line.y + line.descent:
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

(Since this provides a repeatable example, I'm unblocking the bug. I'm also
revising
the summary to fit my guess about the true cause.)

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups "pyglet-issues" group.
To post to this group, send email to pyglet...@googlegroups.com.
To unsubscribe from this group, send email to pyglet-issue...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pyglet-issues?hl=en.

codesite...@google.com

unread,
Apr 27, 2010, 3:00:55 PM4/27/10
to pyglet...@googlegroups.com
Updates:
Status: Blocked

Comment #5 on issue 429 by oresmus: Exception when attributed text with
mixed bold / nonbold is entirely deleted
http://code.google.com/p/pyglet/issues/detail?id=429

Oops, I acted too fact -- it looks like the problem I posted is a duplicate
of open
issue 471 (which is itself a duplicate of improperly closed issue 241).
Also, the
traceback I posted ends similarly to the original traceback, but doesn't
look similar
at intermediate points, so it may or may not be the same bug.

I will reopen issue 241, officially mark issue 471 as a duplicate of issue
241, and
post my new info into issue 241. I'll change this issue's status and
summary (well, I
can't figure out how to find the old summary!) back to what they were
originally, and
let this issue's owner decide what to do further on it.
Reply all
Reply to author
Forward
0 new messages