D7612: py3: send bytes from Rust-created warning patterns

Alphare (Raphaël Gomès) phabricator at mercurial-scm.org
Thu Dec 12 12:38:21 EST 2019


Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Python code expects bytes in both Python 2 and Python 3, so we should send
  bytes.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D7612

AFFECTED FILES
  rust/hg-cpython/src/filepatterns.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/filepatterns.rs b/rust/hg-cpython/src/filepatterns.rs
--- a/rust/hg-cpython/src/filepatterns.rs
+++ b/rust/hg-cpython/src/filepatterns.rs
@@ -13,8 +13,7 @@
 //!
 use crate::exceptions::{PatternError, PatternFileError};
 use cpython::{
-    PyBytes, PyDict, PyModule, PyObject, PyResult, PyString, PyTuple, Python,
-    ToPyObject,
+    PyBytes, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, ToPyObject,
 };
 use hg::{
     build_single_regex, read_pattern_file, utils::files::get_path_from_bytes,
@@ -66,12 +65,12 @@
 fn warnings_to_py_bytes(
     py: Python,
     warnings: &[(PathBuf, Vec<u8>)],
-) -> Vec<(PyString, PyBytes)> {
+) -> Vec<(PyBytes, PyBytes)> {
     warnings
         .iter()
         .map(|(path, syn)| {
             (
-                PyString::new(py, &path.to_string_lossy()),
+                PyBytes::new(py, &path.to_string_lossy().as_bytes()),
                 PyBytes::new(py, syn),
             )
         })



To: Alphare, #hg-reviewers
Cc: durin42, kevincox, mercurial-devel


More information about the Mercurial-devel mailing list