From 483aa54bd6ca0c1a5eb3ef59b025576ed153babc Mon Sep 17 00:00:00 2001 From: Willi Ballenthin Date: Mon, 8 May 2023 11:45:56 +0200 Subject: [PATCH] Catch OSError when source code is not available (#2469) * Catch OSError when source code is not available * update changelog with reference to fixed bug --- CHANGELOG.md | 1 + src/textual/app.py | 2 +- src/textual/dom.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69042e4a8..6e2d125b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fixed `!important` not applying to `overflow` https://github.com/Textualize/textual/issues/2420 - Fixed `!important` not applying to `scrollbar-size` https://github.com/Textualize/textual/issues/2420 - Fixed `outline-right` not being recognised https://github.com/Textualize/textual/issues/2446 +- Fixed OSError when a file system is not available https://github.com/Textualize/textual/issues/2468 ### Changed diff --git a/src/textual/app.py b/src/textual/app.py index e2199a47f..113a7a220 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -1660,7 +1660,7 @@ class App(Generic[ReturnType], DOMNode): app_css_path = ( f"{inspect.getfile(self.__class__)}:{self.__class__.__name__}" ) - except TypeError: + except (TypeError, OSError): app_css_path = f"{self.__class__.__name__}" self.stylesheet.add_source( self.CSS, path=app_css_path, is_default_css=False diff --git a/src/textual/dom.py b/src/textual/dom.py index 1c8512f11..ef73557f3 100644 --- a/src/textual/dom.py +++ b/src/textual/dom.py @@ -418,7 +418,7 @@ class DOMNode(MessagePump): """Get a path to the DOM Node""" try: return f"{getfile(base)}:{base.__name__}" - except TypeError: + except (TypeError, OSError): return f"{base.__name__}" for tie_breaker, base in enumerate(self._node_bases):