Skip to content

Commit 4007b86

Browse files
committed
Bump Cython to 3.2.9, restore py_string aliases
1 parent 7a19e1b commit 4007b86

23 files changed

Lines changed: 106 additions & 110 deletions

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[build-system]
22
requires = [
33
"scikit-build-core>=0.9",
4-
"cython>=3.2",
4+
"cython==3.2.9",
55
]
66
build-backend = "scikit_build_core.build"
77

src/browser.pyx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ cdef class PyBrowser:
232232
if self.imageBuffer:
233233
free(self.imageBuffer)
234234

235-
cpdef py_void SetClientCallback(self, object name, object callback):
235+
cpdef py_void SetClientCallback(self, py_string name, object callback):
236236
if not self.allowedClientCallbacks:
237237
# DisplayHandler
238238
self.allowedClientCallbacks += [
@@ -290,7 +290,7 @@ cdef class PyBrowser:
290290
raise Exception("Browser.SetClientHandler() failed: __class__ "
291291
"attribute missing")
292292
cdef dict methods = {}
293-
cdef object key
293+
cdef py_string key
294294
cdef object method
295295
cdef tuple value
296296
for value in inspect.getmembers(clientHandler,
@@ -300,7 +300,7 @@ cdef class PyBrowser:
300300
if key and key[0] != '_':
301301
self.SetClientCallback(key, method)
302302

303-
cpdef object GetClientCallback(self, object name):
303+
cpdef object GetClientCallback(self, py_string name):
304304
if name in self.clientCallbacks:
305305
return self.clientCallbacks[name]
306306

@@ -346,7 +346,7 @@ cdef class PyBrowser:
346346
NonCriticalError("GetImage not implemented on this platform")
347347
return None
348348

349-
cpdef object GetSetting(self, object key):
349+
cpdef object GetSetting(self, py_string key):
350350
cdef int browser_id = self.GetIdentifier()
351351
if browser_id in g_browser_settings:
352352
if key in g_browser_settings[browser_id]:
@@ -357,7 +357,7 @@ cdef class PyBrowser:
357357
# CEF API.
358358
# --------------
359359

360-
cpdef py_void AddWordToDictionary(self, object word):
360+
cpdef py_void AddWordToDictionary(self, py_string word):
361361
cdef CefString cef_word
362362
PyToCefString(word, cef_word)
363363
self.GetCefBrowserHost().get().AddWordToDictionary(cef_word)
@@ -410,13 +410,11 @@ cdef class PyBrowser:
410410
def ExecuteFunction(self, *args):
411411
self.GetMainFrame().ExecuteFunction(*args)
412412

413-
cpdef py_void ExecuteJavascript(self, object jsCode,
414-
object scriptUrl=None, int startLine=1):
415-
if scriptUrl is None:
416-
scriptUrl = u""
413+
cpdef py_void ExecuteJavascript(self, py_string jsCode,
414+
py_string scriptUrl="", int startLine=1):
417415
self.GetMainFrame().ExecuteJavascript(jsCode, scriptUrl, startLine)
418416

419-
cpdef py_void Find(self, object searchText,
417+
cpdef py_void Find(self, py_string searchText,
420418
py_bool forward, py_bool matchCase,
421419
py_bool findNext):
422420
cdef CefString cefSearchText
@@ -429,14 +427,14 @@ cdef class PyBrowser:
429427
"Browser.GetFocusedFrame() may only be called on UI thread")
430428
return GetPyFrame(self.GetCefBrowser().get().GetFocusedFrame())
431429

432-
cpdef PyFrame GetFrameByName(self, object name):
430+
cpdef PyFrame GetFrameByName(self, py_string name):
433431
assert IsThread(TID_UI), (
434432
"Browser.GetFrameByName() may only be called on the UI thread")
435433
cdef CefString cefName
436434
PyToCefString(name, cefName)
437435
return GetPyFrame(self.GetCefBrowser().get().GetFrameByName(cefName))
438436

439-
cpdef object GetFrameByIdentifier(self, object identifier):
437+
cpdef object GetFrameByIdentifier(self, py_string identifier):
440438
cdef CefString cefIdentifier
441439
PyToCefString(identifier, cefIdentifier)
442440
return GetPyFrame(self.GetCefBrowser().get().GetFrameByIdentifier(
@@ -483,7 +481,7 @@ cdef class PyBrowser:
483481
else:
484482
return self.GetWindowHandle()
485483

486-
cpdef object GetUrl(self):
484+
cpdef py_string GetUrl(self):
487485
return self.GetMainFrame().GetUrl()
488486

489487
cpdef object GetUserData(self, object key):
@@ -526,10 +524,10 @@ cdef class PyBrowser:
526524
cpdef py_bool IsWindowRenderingDisabled(self):
527525
return self.GetCefBrowserHost().get().IsWindowRenderingDisabled()
528526

529-
cpdef object LoadUrl(self, object url):
527+
cpdef py_string LoadUrl(self, py_string url):
530528
self.GetMainFrame().LoadUrl(url)
531529

532-
cpdef py_void Navigate(self, object url):
530+
cpdef py_void Navigate(self, py_string url):
533531
self.LoadUrl(url)
534532

535533
cpdef py_void NotifyMoveOrResizeStarted(self):
@@ -544,7 +542,7 @@ cdef class PyBrowser:
544542
cpdef py_void ReloadIgnoreCache(self):
545543
self.GetCefBrowser().get().ReloadIgnoreCache()
546544

547-
cpdef py_void ReplaceMisspelling(self, object word):
545+
cpdef py_void ReplaceMisspelling(self, py_string word):
548546
cdef CefString cef_word
549547
PyToCefString(word, cef_word)
550548
self.GetCefBrowserHost().get().ReplaceMisspelling(cef_word)
@@ -740,7 +738,7 @@ cdef class PyBrowser:
740738
cpdef py_void SendCaptureLostEvent(self):
741739
self.GetCefBrowserHost().get().SendCaptureLostEvent()
742740

743-
cpdef py_void StartDownload(self, object url):
741+
cpdef py_void StartDownload(self, py_string url):
744742
self.GetCefBrowserHost().get().StartDownload(PyToCefStringValue(
745743
url))
746744

src/cefpython.pyx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -387,15 +387,15 @@ cdef public void cefpython_GetDebugOptions(
387387
cdef public cpp_bool ApplicationSettings_GetBool(const char* key
388388
) noexcept with gil:
389389
# Called from client_handler/client_handler.cpp for example
390-
cdef object pyKey = CharToPyString(key)
390+
cdef py_string pyKey = CharToPyString(key)
391391
if pyKey in g_applicationSettings:
392392
return bool(g_applicationSettings[pyKey])
393393
return False
394394

395395
cdef public cpp_bool ApplicationSettings_GetBoolFromDict(const char* key1,
396396
const char* key2) noexcept with gil:
397-
cdef object pyKey1 = CharToPyString(key1)
398-
cdef object pyKey2 = CharToPyString(key2)
397+
cdef py_string pyKey1 = CharToPyString(key1)
398+
cdef py_string pyKey2 = CharToPyString(key2)
399399
cdef object dictValue # Yet to be checked whether it is `dict`
400400
if pyKey1 in g_applicationSettings:
401401
dictValue = g_applicationSettings[pyKey1]
@@ -407,14 +407,14 @@ cdef public cpp_bool ApplicationSettings_GetBoolFromDict(const char* key1,
407407

408408
cdef public cpp_string ApplicationSettings_GetString(const char* key
409409
) noexcept with gil:
410-
cdef object pyKey = CharToPyString(key)
410+
cdef py_string pyKey = CharToPyString(key)
411411
cdef cpp_string cppString
412412
if pyKey in g_applicationSettings:
413413
cppString = PyStringToChar(AnyToPyString(g_applicationSettings[pyKey]))
414414
return cppString
415415

416416
cdef public int CommandLineSwitches_GetInt(const char* key) noexcept with gil:
417-
cdef object pyKey = CharToPyString(key)
417+
cdef py_string pyKey = CharToPyString(key)
418418
if pyKey in g_commandLineSwitches:
419419
return int(g_commandLineSwitches[pyKey])
420420
return 0
@@ -1014,7 +1014,7 @@ def SetOsModalLoop(py_bool modalLoop):
10141014
with nogil:
10151015
CefSetOSModalLoop(cefModalLoop)
10161016

1017-
cpdef py_void SetGlobalClientCallback(object name, object callback):
1017+
cpdef py_void SetGlobalClientCallback(py_string name, object callback):
10181018
global g_globalClientCallbacks
10191019
# Global callbacks are prefixed with "_" in documentation.
10201020
# Accept both with and without a prefix.
@@ -1032,7 +1032,7 @@ cpdef py_void SetGlobalClientHandler(object clientHandler):
10321032
raise Exception("SetGlobalClientHandler() failed: __class__ "
10331033
"attribute missing")
10341034
cdef dict methods = {}
1035-
cdef object key
1035+
cdef py_string key
10361036
cdef object method
10371037
cdef tuple value
10381038
for value in inspect.getmembers(clientHandler,
@@ -1042,14 +1042,14 @@ cpdef py_void SetGlobalClientHandler(object clientHandler):
10421042
if key and key[0:2] != '__':
10431043
SetGlobalClientCallback(key, method)
10441044

1045-
cpdef object GetGlobalClientCallback(object name):
1045+
cpdef object GetGlobalClientCallback(py_string name):
10461046
global g_globalClientCallbacks
10471047
if name in g_globalClientCallbacks:
10481048
return g_globalClientCallbacks[name]
10491049
else:
10501050
return None
10511051

1052-
cpdef object GetAppSetting(object key):
1052+
cpdef object GetAppSetting(py_string key):
10531053
global g_applicationSettings
10541054
if key in g_applicationSettings:
10551055
return g_applicationSettings[key]
@@ -1069,7 +1069,7 @@ cpdef dict GetVersion():
10691069
cef_commit_number=__cef_commit_number__,
10701070
)
10711071

1072-
cpdef LoadCrlSetsFile(object path):
1072+
cpdef LoadCrlSetsFile(py_string path):
10731073
CefLoadCRLSetsFile(PyToCefStringValue(path))
10741074

10751075
cpdef GetDataUrl(data, mediatype="html"):

src/command_line.pyx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ cdef void AppendSwitchesToCommandLine(
1212
# 1. App_OnBeforeCommandLineProcessing_BrowserProcess()
1313
# 2. BrowserProcessHandler_OnRenderProcessThreadCreated()
1414
cdef PyCommandLine pyCommandLine = CreatePyCommandLine(cefCommandLine)
15-
cdef object switch
16-
cdef object value
15+
cdef py_string switch
16+
cdef py_string value
1717
for switch, value in switches.items():
1818
if not isinstance(switch, (str, bytes)) or switch[0] == '-':
1919
Debug("Invalid command line switch: %s" % switch)
@@ -39,27 +39,27 @@ cdef PyCommandLine CreatePyCommandLine(
3939
cdef class PyCommandLine:
4040
cdef CefRefPtr[CefCommandLine] cefCommandLine
4141

42-
cdef py_void AppendSwitch(self, object switch):
42+
cdef py_void AppendSwitch(self, py_string switch):
4343
cdef CefString cefSwitch
4444
cefSwitch = PyToCefStringValue(switch)
4545
self.cefCommandLine.get().AppendSwitch(cefSwitch)
4646

47-
cdef py_void AppendSwitchWithValue(self, object switch, object value):
47+
cdef py_void AppendSwitchWithValue(self, py_string switch, py_string value):
4848
cdef CefString cefSwitch
4949
cdef CefString cefValue
5050
cefSwitch = PyToCefStringValue(switch)
5151
cefValue = PyToCefStringValue(value)
5252
self.cefCommandLine.get().AppendSwitchWithValue(cefSwitch, cefValue)
5353

54-
cdef object GetCommandLineString(self):
54+
cdef py_string GetCommandLineString(self):
5555
return CefToPyString(self.cefCommandLine.get().GetCommandLineString())
5656

57-
cdef py_bool HasSwitch(self, object switch):
57+
cdef py_bool HasSwitch(self, py_string switch):
5858
cdef CefString cefSwitch
5959
cefSwitch = PyToCefStringValue(switch)
6060
return self.cefCommandLine.get().HasSwitch(cefSwitch)
6161

62-
cdef object GetSwitchValue(self, object switch):
62+
cdef py_string GetSwitchValue(self, py_string switch):
6363
cdef CefString cefValue
6464
cdef CefString cefSwitch
6565
cefSwitch = PyToCefStringValue(switch)

src/cookie.pyx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ cdef class Cookie:
9090
"priority": self.GetPriority(),
9191
}
9292

93-
cpdef py_void SetName(self, object name):
93+
cpdef py_void SetName(self, py_string name):
9494
# This works:
9595
# | CefString(&self.cefCookie.name).FromString(name)
9696
# This does not work:
@@ -114,7 +114,7 @@ cdef class Cookie:
114114
cefString.Attach(&self.cefCookie.name, False)
115115
return CefToPyString(cefString)
116116

117-
cpdef py_void SetValue(self, object value):
117+
cpdef py_void SetValue(self, py_string value):
118118
cdef CefString cefString
119119
cefString.Attach(&self.cefCookie.value, False)
120120
PyToCefString(value, cefString)
@@ -124,7 +124,7 @@ cdef class Cookie:
124124
cefString.Attach(&self.cefCookie.value, False)
125125
return CefToPyString(cefString)
126126

127-
cpdef py_void SetDomain(self, object domain):
127+
cpdef py_void SetDomain(self, py_string domain):
128128
cdef CefString cefString
129129
cefString.Attach(&self.cefCookie.domain, False)
130130
PyToCefString(domain, cefString)
@@ -134,7 +134,7 @@ cdef class Cookie:
134134
cefString.Attach(&self.cefCookie.domain, False)
135135
return CefToPyString(cefString)
136136

137-
cpdef py_void SetPath(self, object path):
137+
cpdef py_void SetPath(self, py_string path):
138138
cdef CefString cefString
139139
cefString.Attach(&self.cefCookie.path, False)
140140
PyToCefString(path, cefString)
@@ -239,7 +239,7 @@ cdef class PyCookieManager:
239239
return self.cefCookieManager.get().VisitAllCookies(
240240
cefCookieVisitor)
241241

242-
cpdef py_bool VisitUrlCookies(self, object url,
242+
cpdef py_bool VisitUrlCookies(self, py_string url,
243243
py_bool includeHttpOnly, object userCookieVisitor):
244244
self.ValidateUserCookieVisitor(userCookieVisitor)
245245
cdef int cookieVisitorId = StoreUserCookieVisitor(userCookieVisitor)
@@ -250,14 +250,14 @@ cdef class PyCookieManager:
250250
PyToCefStringValue(url), bool(includeHttpOnly),
251251
cefCookieVisitor)
252252

253-
cpdef py_void SetCookie(self, object url, PyCookie cookie):
253+
cpdef py_void SetCookie(self, py_string url, PyCookie cookie):
254254
assert isinstance(cookie, Cookie), "cookie object is invalid"
255255
CefPostTask(TID_IO, CreateTask_SetCookie(
256256
self.cefCookieManager.get(),
257257
PyToCefStringValue(url), cookie.cefCookie,
258258
<CefRefPtr[CefSetCookieCallback]?>nullptr))
259259

260-
cpdef py_void DeleteCookies(self, object url, object cookie_name):
260+
cpdef py_void DeleteCookies(self, py_string url, py_string cookie_name):
261261
CefPostTask(TID_IO, CreateTask_DeleteCookies(
262262
self.cefCookieManager.get(),
263263
PyToCefStringValue(url), PyToCefStringValue(cookie_name),

src/drag_data.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ cdef class DragData:
2424
cpdef py_bool IsFragment(self):
2525
return self.cef_drag_data.get().IsFragment()
2626

27-
cpdef object GetLinkUrl(self):
27+
cpdef py_string GetLinkUrl(self):
2828
return CefToPyString(self.cef_drag_data.get().GetLinkURL())
2929

30-
cpdef object GetLinkTitle(self):
30+
cpdef py_string GetLinkTitle(self):
3131
return CefToPyString(self.cef_drag_data.get().GetLinkTitle())
3232

33-
cpdef object GetFragmentText(self):
33+
cpdef py_string GetFragmentText(self):
3434
return CefToPyString(self.cef_drag_data.get().GetFragmentText())
3535

36-
cpdef object GetFragmentHtml(self):
36+
cpdef py_string GetFragmentHtml(self):
3737
return CefToPyString(self.cef_drag_data.get().GetFragmentHtml())
3838

3939
cpdef PyImage GetImage(self):

src/frame.pyx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ cdef dict g_pyFrames = {}
1111
# it shouldn't be kept global anymore.
1212
cdef list g_unreferenced_frames = [] # [str unique identifier, ..]
1313

14-
cdef str GetUniqueFrameId(int browserId, object frameId):
14+
cdef str GetUniqueFrameId(int browserId, py_string frameId):
1515
return str(browserId) +"#"+ frameId
1616

17-
cdef PyFrame GetPyFrameById(int browserId, object frameId):
17+
cdef PyFrame GetPyFrameById(int browserId, py_string frameId):
1818
cdef str uniqueFrameId = GetUniqueFrameId(browserId, frameId)
1919
if uniqueFrameId in g_pyFrames:
2020
return g_pyFrames[uniqueFrameId]
@@ -146,7 +146,7 @@ cdef class PyFrame:
146146
return self.cefFrame
147147
raise Exception("PyFrame.GetCefFrame() failed: CefFrame was destroyed")
148148

149-
def __init__(self, int browserId, object frameId):
149+
def __init__(self, int browserId, py_string frameId):
150150
self.browserId = browserId
151151
self.frameId = frameId
152152

@@ -180,10 +180,8 @@ cdef class PyFrame:
180180
code += ")"
181181
self.ExecuteJavascript(code)
182182

183-
cpdef py_void ExecuteJavascript(self, object jsCode,
184-
object scriptUrl=None, int startLine=1):
185-
if scriptUrl is None:
186-
scriptUrl = u""
183+
cpdef py_void ExecuteJavascript(self, py_string jsCode,
184+
py_string scriptUrl="", int startLine=1):
187185
self.GetCefFrame().get().ExecuteJavaScript(PyToCefStringValue(jsCode),
188186
PyToCefStringValue(scriptUrl), startLine)
189187

@@ -222,7 +220,7 @@ cdef class PyFrame:
222220
cpdef py_bool IsMain(self):
223221
return self.GetCefFrame().get().IsMain()
224222

225-
cpdef py_void LoadUrl(self, object url):
223+
cpdef py_void LoadUrl(self, py_string url):
226224
cdef CefString cefUrl
227225
PyToCefString(url, cefUrl)
228226
self.GetCefFrame().get().LoadURL(cefUrl)
@@ -243,7 +241,7 @@ cdef class PyFrame:
243241
self.GetCefFrame().get().ViewSource()
244242

245243
cpdef py_void SendProcessMessage(self, cef_process_id_t targetProcess,
246-
object frameId, object messageName, list pyArguments
244+
py_string frameId, py_string messageName, list pyArguments
247245
) :
248246
cdef CefRefPtr[CefProcessMessage] message = \
249247
CefProcessMessage_Create(PyToCefStringValue(messageName))

0 commit comments

Comments
 (0)