From d39c2037c49b32c4cae5df07597a6ff38b3b66e8 Mon Sep 17 00:00:00 2001 From: Steve Petterborg Date: Thu, 7 Mar 2024 19:56:59 -0800 Subject: [PATCH] Fix NameError when pyglet cannot create window Unfortunately I do not currently have an easy repro case, but I hope that scoping rules, at least in 3/3.x should be sufficient to demonstrate the need for this change. --- pyrender/platforms/pyglet_platform.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyrender/platforms/pyglet_platform.py b/pyrender/platforms/pyglet_platform.py index a70cf7b..ef2f4d5 100644 --- a/pyrender/platforms/pyglet_platform.py +++ b/pyrender/platforms/pyglet_platform.py @@ -45,6 +45,7 @@ def init_context(self): double_buffer=True, major_version=MIN_OPEN_GL_MAJOR, minor_version=MIN_OPEN_GL_MINOR)] + error_message = None for conf in confs: try: self._window = pyglet.window.Window(config=conf, visible=False, @@ -52,6 +53,7 @@ def init_context(self): width=1, height=1) break except pyglet.window.NoSuchConfigException as e: + error_message = e pass if not self._window: @@ -59,7 +61,7 @@ def init_context(self): 'Failed to initialize Pyglet window with an OpenGL >= 3+ ' 'context. If you\'re logged in via SSH, ensure that you\'re ' 'running your script with vglrun (i.e. VirtualGL). The ' - 'internal error message was "{}"'.format(e) + 'internal error message was "{}"'.format(error_message) ) def make_current(self):