Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error occers when alert() is called with non-string arguments #1506

Closed
yunline opened this issue Oct 21, 2024 · 2 comments
Closed

Error occers when alert() is called with non-string arguments #1506

yunline opened this issue Oct 21, 2024 · 2 comments

Comments

@yunline
Copy link

yunline commented Oct 21, 2024

Specification

  • pywebview version: 5.3
  • operating system: Windows10
  • web renderer: [pywebview] Using WinForms / Chromium

Test Code:

import webview

html = """
<head>
<script>
function click_me() {
    // alert("hello") // this won't cause an error
    alert({hello:"world"}) // err
    // alert(114514.1919) // err
    // alert([1,2,3,4,5]) // err
};
</script>
</head>

<body>
<button style="width: 150px; height: 50px;", onclick="click_me()">Click me</button>
</body>
"""


window = webview.create_window('Window', html=html)
webview.start(debug=True)

Behavior:

Click the button, the messagebox is not out, an error occered.
Error message:

[pywebview] Exception occurred during on_script_notify
Python.Runtime.PythonException: 'dict' value cannot be converted to System.String

The above exception was the direct cause of the following exception:

System.ArgumentException: 'dict' value cannot be converted to System.String in method System.Windows.Forms.DialogResult Show(System.String) ---> Python.Runtime.PythonException: 'dict' value cannot be converted to System.String
   --- 内部异常堆栈跟踪的结尾 ---

The above exception was the direct cause of the following exception:

System.AggregateException: 发生一个或多个错误。 ---> System.ArgumentException: 'dict' value cannot be converted to System.String in method System.Windows.Forms.DialogResult Show(System.String) ---> Python.Runtime.PythonException: 'dict' value cannot be converted to System.String
   --- 内部异常堆栈跟踪的结尾 ---
   --- 内部异常堆栈跟踪的结尾 ---
---> (内部异常 #0) System.ArgumentException: 'dict' value cannot be converted to System.String in method System.Windows.Forms.DialogResult Show(System.String) ---> Python.Runtime.PythonException: 'dict' value cannot be converted to System.String
   --- 内部异常堆栈跟踪的结尾 ---<---


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\yunline\AppData\Local\Programs\Python\Python311\Lib\site-packages\webview\platforms\edgechromium.py", line 194, in on_script_notify 
    WinForms.MessageBox.Show(func_param)
TypeError: No method matches given arguments for MessageBox.Show: (<class 'dict'>)
@yunline
Copy link
Author

yunline commented Oct 21, 2024

@yunline
Copy link
Author

yunline commented Oct 23, 2024

Have been fixed by 7afbde5 in version 5.3.2

@yunline yunline closed this as completed Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant