Skip to content

Commit 5e271c0

Browse files
author
ShresthSamyak
committed
fix(macos): address fifth round of Copilot review feedback
1 parent 2cabfe9 commit 5e271c0

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

mpv.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,10 @@ def _wait_for_future(self, result, timeout):
10591059
start_time = time.monotonic()
10601060
try:
10611061
if _core_foundation is None or _cf_runloop_default_mode is None:
1062-
_core_foundation = ctypes.cdll.LoadLibrary(ctypes.util.find_library('CoreFoundation'))
1062+
core_foundation_path = ctypes.util.find_library('CoreFoundation')
1063+
if not core_foundation_path:
1064+
raise OSError("CoreFoundation library not found")
1065+
_core_foundation = ctypes.cdll.LoadLibrary(core_foundation_path)
10631066

10641067
# CFRunLoopRunInMode(CFStringRef mode, CFTimeInterval seconds, Boolean returnAfterSourceHandled)
10651068
_core_foundation.CFRunLoopRunInMode.argtypes = [ctypes.c_void_p, ctypes.c_double, ctypes.c_bool]

tests/test_mpv.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ def test_macos_wait_for_future(self):
10111011
mock_cf = mock.Mock()
10121012
mock_load_library.return_value = mock_cf
10131013
mock_in_dll.return_value = mock.Mock()
1014+
mock_find_library.return_value = 'CoreFoundation'
10141015

10151016
# Reset globals from mpv module to force re-initialization
10161017
orig_cf = mpv._core_foundation
@@ -1054,6 +1055,7 @@ def test_macos_wait_for_future_timeout(self):
10541055
mock_cf = mock.Mock()
10551056
mock_load_library.return_value = mock_cf
10561057
mock_in_dll.return_value = mock.Mock()
1058+
mock_find_library.return_value = 'CoreFoundation'
10571059

10581060
orig_cf = mpv._core_foundation
10591061
orig_mode = mpv._cf_runloop_default_mode
@@ -1084,8 +1086,8 @@ def test_macos_wait_for_future_fallback(self):
10841086
mock_current_thread.return_value = sentinel
10851087
mock_main_thread.return_value = sentinel
10861088

1087-
# Force CoreFoundation init to fail
1088-
mock_load_library.side_effect = OSError("Library not found")
1089+
# Force CoreFoundation init to fail by having find_library return None
1090+
mock_find_library.return_value = None
10891091

10901092
orig_cf = mpv._core_foundation
10911093
orig_mode = mpv._cf_runloop_default_mode

0 commit comments

Comments
 (0)