Mercurial > public > mercurial-scm > hg-stable
view rust/hgcli/src/main.rs @ 49590:f09bc2ed9100 stable
help: fix a py3 error interpolating Set into b'%s'
I can't reproduce it, but a coworker hit this with `hg help -v` with 6.2.3:
...
File "mercurial\help.pyc", line 865, in helplist
TypeError: %b requires a bytes-like object, or an object that implements __bytes__, not 'set'
I can confirm that the original expression fails in `hg debugshell`, and the new
one works. The second instance was found by searching for "%s", but PyCharm
detects a lot of variables as Any type, so I have no idea if there are other
lurking problems.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 20 Nov 2022 15:55:27 -0500 |
parents | 426294d06ddc |
children |
line wrap: on
line source
use pyembed::MainPythonInterpreter; // Include an auto-generated file containing the default // `pyembed::PythonConfig` derived by the PyOxidizer configuration file. // // If you do not want to use PyOxidizer to generate this file, simply // remove this line and instantiate your own instance of // `pyembed::PythonConfig`. include!(env!("PYOXIDIZER_DEFAULT_PYTHON_CONFIG_RS")); fn main() { // The following code is in a block so the MainPythonInterpreter is // destroyed in an orderly manner, before process exit. let code = { // Load the default Python configuration as derived by the PyOxidizer // config file used at build time. let config = default_python_config(); // Construct a new Python interpreter using that config, handling any // errors from construction. match MainPythonInterpreter::new(config) { Ok(mut interp) => { // And run it using the default run configuration as specified // by the configuration. If an uncaught Python // exception is raised, handle it. // This includes the special SystemExit, which is a request to // terminate the process. interp.run_as_main() } Err(msg) => { eprintln!("{}", msg); 1 } } }; // And exit the process according to code execution results. std::process::exit(code); }