diff --git a/eden/scm/edenscmnative/bindings/modules/pyerror/src/lib.rs b/eden/scm/edenscmnative/bindings/modules/pyerror/src/lib.rs index 50151ecbfe..16568f01ab 100644 --- a/eden/scm/edenscmnative/bindings/modules/pyerror/src/lib.rs +++ b/eden/scm/edenscmnative/bindings/modules/pyerror/src/lib.rs @@ -36,13 +36,25 @@ pub fn init_module(py: Python, package: &str) -> PyResult { fn register_error_handlers() { fn specific_error_handler(py: Python, e: &error::Error) -> Option { if let Some(e) = e.downcast_ref::() { - Some(PyErr::new::(py, e.to_string())) + Some(PyErr::new::( + py, + cpython_ext::Str::from(e.to_string()), + )) } else if let Some(e) = e.downcast_ref::() { - Some(PyErr::new::(py, e.to_string())) + Some(PyErr::new::( + py, + cpython_ext::Str::from(e.to_string()), + )) } else if let Some(e) = e.downcast_ref::() { - Some(PyErr::new::(py, e.to_string())) + Some(PyErr::new::( + py, + cpython_ext::Str::from(e.to_string()), + )) } else if let Some(e) = e.downcast_ref::() { - Some(PyErr::new::(py, e.to_string())) + Some(PyErr::new::( + py, + cpython_ext::Str::from(e.to_string()), + )) } else { None } diff --git a/eden/scm/tests/test-adding-invalid-utf8-t.py b/eden/scm/tests/test-adding-invalid-utf8-t.py index 42dcc7539d..0ad3ea422d 100644 --- a/eden/scm/tests/test-adding-invalid-utf8-t.py +++ b/eden/scm/tests/test-adding-invalid-utf8-t.py @@ -1,3 +1,4 @@ +# coding=utf-8 # Copyright (c) Facebook, Inc. and its affiliates. # # This software may be used and distributed according to the terms of the @@ -16,10 +17,15 @@ feature.require(["no-windows", "no-osx"]) # Test that trying to add invalid utf8 files to the repository will fail. sh % "hg init" -open("invalid\x80utf8", "w").write("test") +open("\x9d\xc8\xac\xde\xa1\xee", "w").write("test") + +sh % "hg status" == r""" + abort: "\x9DȬޡ\xEE" is not a valid UTF-8 path + [255]""" + sh % "hg addremove" == r""" - abort: "invalid\x80utf8" is not a valid UTF-8 path + abort: "\x9DȬޡ\xEE" is not a valid UTF-8 path [255]""" sh % "hg commit -m 'adding a filename that is invalid utf8'" == r""" - abort: "invalid\x80utf8" is not a valid UTF-8 path + abort: "\x9DȬޡ\xEE" is not a valid UTF-8 path [255]"""