Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
13 changes: 11 additions & 2 deletions amitools/vamos/lib/DosLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,12 +855,21 @@ def PutStr(self, ctx, str_ptr):
log_dos.info("PutStr: %s", show_data)
return 0 # ok

@staticmethod
def _is_host_stdin(obj):
# sys.stdin may be a capture object without a real fd (e.g. under
# pytest), where fileno() raises
try:
return obj.fileno() == sys.stdin.fileno()
except (OSError, ValueError, AttributeError):
return False

def Flush(self, ctx):
fh_b_addr = ctx.cpu.r_reg(REG_D1)
fh = self.file_mgr.get_by_b_addr(fh_b_addr, True)
fh.flush()
# remove command line from stdin
if fh.obj.fileno() == sys.stdin.fileno():
if self._is_host_stdin(fh.obj):
fh.setbuf(bytearray())

return -1
Expand Down Expand Up @@ -986,7 +995,7 @@ def FGets(self, ctx):
fh = self.file_mgr.get_by_b_addr(fh_b_addr, False)

# Block until input is available
if fh.obj.fileno() == sys.stdin.fileno():
if self._is_host_stdin(fh.obj):
while True:
ready, _, _ = select.select([fh.obj], [], [], None)
if ready:
Expand Down
10 changes: 8 additions & 2 deletions amitools/vamos/lib/IntuitionLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ def open_lib(self, ctx, open_cnt):
if self._lib_opened:
return # already initialized

import sdl2
# stay headless without sdl2: functions that really render
# import sdl2 themselves and fail only when actually used
try:
import sdl2
except ImportError:
log_intui.warning("pysdl2 not installed, no display available")
return
sdl2.SDL_Init(sdl2.SDL_INIT_VIDEO | sdl2.SDL_INIT_TIMER)

# open graphics.library
Expand All @@ -91,7 +97,7 @@ def open_lib(self, ctx, open_cnt):
self._lib_opened = True

def close_lib(self, ctx, open_cnt):
if open_cnt == 0:
if open_cnt == 0 and self._lib_opened:
# close default screen
title_addr = self.default_screen.DefaultTitle.get()
ctx.cpu.w_reg(REG_A0, self.default_screen.addr)
Expand Down
2 changes: 1 addition & 1 deletion amitools/vamos/libnative/mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self, name, load_addr, seglist_baddr, lib_fd=None):
self.load_addr = load_addr
self.seglist_baddr = seglist_baddr
self.lib_fd = lib_fd
self.base_addrs = { load_addr: 1 } # base addr -> num of bases
self.base_addrs = {} # base addr -> num of bases

def __str__(self):
info = []
Expand Down