It would make the traceback clearer when malformed data is passed.
Traceback (most recent call last):
File "/home/user/src/arcade/.scratch/line_validation_reason.py", line 24, in <module>
arcade.run()
File "/home/user/src/arcade/arcade/window_commands.py", line 139, in run
pyglet.app.run(window._draw_rate)
File "/home/user/src/arcade/.venv/lib/python3.9/site-packages/pyglet/app/__init__.py", line 80, in run
event_loop.run(interval)
File "/home/user/src/arcade/.venv/lib/python3.9/site-packages/pyglet/app/base.py", line 165, in run
timeout = self.idle()
File "/home/user/src/arcade/.venv/lib/python3.9/site-packages/pyglet/app/base.py", line 226, in idle
self.clock.call_scheduled_functions(dt)
File "/home/user/src/arcade/.venv/lib/python3.9/site-packages/pyglet/clock.py", line 217, in call_scheduled_functions
item.func(now - item.last_ts, *item.args, **item.kwargs)
File "/home/user/src/arcade/.venv/lib/python3.9/site-packages/pyglet/app/base.py", line 120, in _redraw_windows
window.dispatch_event('on_draw')
File "/home/user/src/arcade/.venv/lib/python3.9/site-packages/pyglet/window/__init__.py", line 676, in dispatch_event
super().dispatch_event(*args)
File "/home/user/src/arcade/.venv/lib/python3.9/site-packages/pyglet/event.py", line 394, in dispatch_event
self._raise_dispatch_exception(event_type, args, getattr(self, event_type), exception)
File "/home/user/src/arcade/.venv/lib/python3.9/site-packages/pyglet/event.py", line 446, in _raise_dispatch_exception
raise exception
File "/home/user/src/arcade/.venv/lib/python3.9/site-packages/pyglet/event.py", line 387, in dispatch_event
if getattr(self, event_type)(*args):
File "/home/user/src/arcade/.scratch/line_validation_reason.py", line 19, in on_draw
arcade.draw_lines(self.malformed, arcade.color.RED, line_width=10)
File "/home/user/src/arcade/arcade/draw/line.py", line 98, in draw_lines
line_pos_array = array.array("f", (v for point in point_list for v in point))
File "/home/user/src/arcade/arcade/draw/line.py", line 98, in <genexpr>
line_pos_array = array.array("f", (v for point in point_list for v in point))
TypeError: 'int' object is not iterable
Enhancement request:
TL;DR: Add clearer exceptions on malformed visually
Point2Listcases like[(1,), (2, 2), (1,)]What should be added/changed?
As of #2213, we annotate 2D line drawing functions with
Point2List.We should the following:
try/catchblock or other validation to help detect bad data and report it nicelyValueErrorsince the current behavior returns aTypeErrorWhat would it help with?
It would make the traceback clearer when malformed data is passed.
The traceback below is produced by this (example code):