Skip to content

Commit 1ab1d8e

Browse files
authored
Merge pull request #1229 from godot-rust/qol/utf8-panic
Verify that panic messages support UTF-8
2 parents 4902b34 + bc3842b commit 1ab1d8e

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

godot-core/src/global/print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ macro_rules! inner_godot_msg {
2929
//($($args:tt),* $(,)?) => {
3030
unsafe {
3131
let msg = format!("{}\0", format_args!($fmt $(, $args)*));
32-
// assert!(msg.is_ascii(), "godot_error: message must be ASCII");
32+
// Godot supports Unicode messages, not only ASCII. See `do_panic` test.
3333

3434
// Check whether engine is loaded, otherwise fall back to stderr.
3535
if $crate::sys::is_initialized() {

itest/rust/src/object_tests/dynamic_call_test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fn dynamic_call_with_panic() {
163163

164164
let expected_error_message = "godot-rust function call failed: Object::call(&\"do_panic\")\
165165
\n Source: ObjPayload::do_panic()\
166-
\n Reason: function panicked: do_panic exploded"
166+
\n Reason: function panicked: do_panic exploded 💥"
167167
.to_string();
168168

169169
assert_eq!(call_error.to_string(), expected_error_message);
@@ -188,9 +188,9 @@ fn dynamic_call_with_panic() {
188188
// In Debug, there is a context -> message is multi-line -> '\n' is inserted after [panic ...].
189189
// In Release, simpler message -> single line -> no '\n'.
190190
let expected_panic_message = if cfg!(debug_assertions) {
191-
format!("[panic {path}:{line}]\n do_panic exploded{context}")
191+
format!("[panic {path}:{line}]\n do_panic exploded 💥{context}")
192192
} else {
193-
format!("[panic {path}:{line}] do_panic exploded")
193+
format!("[panic {path}:{line}] do_panic exploded 💥")
194194
};
195195

196196
assert_eq!(panic_message, expected_panic_message);

itest/rust/src/object_tests/object_test.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,8 @@ impl ObjPayload {
907907

908908
#[func]
909909
fn do_panic(&self) {
910-
panic!("do_panic exploded");
910+
// Unicode character as regression test for https://github.com/godot-rust/gdext/issues/384.
911+
panic!("do_panic exploded 💥");
911912
}
912913

913914
// Obtain the line number of the panic!() call above; keep equidistant to do_panic() method.

0 commit comments

Comments
 (0)