Skip to content

Commit f5694e5

Browse files
authored
Merge dev to main for 0.3.7
2 parents 9ac382a + 3cb4702 commit f5694e5

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

engine/core/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from ..logger import logger, Status as LoggerStatus
2222
from .image import EntityImage
23+
from .errors import ABSFatalError
2324
from .types import RGBType, EntityImageType
2425
from ..version import __version__ as version
2526

@@ -268,7 +269,7 @@ def destroy(self) -> None:
268269
ValueError: If the entity cannot be removed from its parent.
269270
"""
270271

271-
parent = getattr(self, "parent", None) # See #29
272+
parent: Optional["Scene"] = getattr(self, "parent", None) # See #29
272273

273274
if parent is None:
274275
return
@@ -418,6 +419,10 @@ def __init__(
418419
icon_path (Optional[str]): Path to window icon image. Defaults to None.
419420
IS_EDITOR (bool): Whether running in editor mode. Defaults to False.
420421
GP_BASE_PATH (str): Base path for game assets
422+
423+
424+
Raises:
425+
ABSFatalError: If the window size is invalid
421426
"""
422427

423428
# For use by entities
@@ -429,6 +434,9 @@ def __init__(
429434
display_flags: int = pygame.FULLSCREEN if fullscreen else 0
430435
self.wsize: tuple[int, int] = (width, height)
431436

437+
if width < 0 or height < 0:
438+
raise ABSFatalError("Window width and height must be positive")
439+
432440
self.screen: pygame.Surface = pygame.display.set_mode(self.wsize, display_flags)
433441
pygame.display.set_caption(title)
434442

@@ -587,7 +595,6 @@ def run(self, fps: int = 60) -> None:
587595
self.step(dt)
588596

589597
pygame.quit()
590-
sys.exit(0)
591598

592599
def quit(self) -> None:
593600
"""

engine/core/errors.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
import faulthandler
44
import os
55
import sys
6+
import dis
67

78
from typing import Never
9+
from types import FrameType
810
from colorama import Fore, Style
11+
from functools import partial
912

1013

1114
class ABSFatalError(RuntimeError):
@@ -27,14 +30,21 @@ def __init__(self, message: str) -> Never:
2730
super().__init__(message)
2831

2932
isatty: bool = sys.stderr.isatty()
33+
eprint = partial(print, file=sys.stderr)
3034

3135
if isatty:
32-
print(Fore.RED + Style.BRIGHT, end="", file=sys.stderr)
36+
eprint(Fore.RED + Style.BRIGHT, end="")
3337

34-
print(f"ABS Engine hit a fatal exception: \n\n{message}\nAborting.\n", file=sys.stderr)
38+
eprint(f"ABS Engine hit a fatal exception: \n\n{message}\nAborting.\n")
3539

3640
if isatty:
37-
print(Style.RESET_ALL, end="", file=sys.stderr)
41+
eprint(Style.RESET_ALL, end="")
42+
43+
frame: FrameType = sys._getframe(1)
44+
45+
print(file=sys.stderr)
46+
dis.disassemble(frame.f_code, frame.f_lasti, file=sys.stderr)
47+
print(file=sys.stderr)
3848

3949
faulthandler.enable()
4050
os.abort()

engine/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3.6"
1+
__version__ = "0.3.7"

0 commit comments

Comments
 (0)