[PATCH] rust-cpython: remove invalid __package__ attribute

Yuya Nishihara yuya at tcha.org
Sun Jan 6 03:53:46 UTC 2019


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1546741784 -32400
#      Sun Jan 06 11:29:44 2019 +0900
# Node ID 25c142f679c23fbc210d5bcbdf2f913e4dd55402
# Parent  536c83535cbdafdfe060cea2b8c80b0789863227
rust-cpython: remove invalid __package__ attribute

Since mercurial.rustext is a package, its __package__ should be, if set,
"mercurial.rustext". AFAIK, we don't have to set this attribute manually
as the rustext module will be imported by the system importer.

https://stackoverflow.com/a/21233334/10435339

diff --git a/rust/hg-cpython/src/lib.rs b/rust/hg-cpython/src/lib.rs
--- a/rust/hg-cpython/src/lib.rs
+++ b/rust/hg-cpython/src/lib.rs
@@ -35,7 +35,6 @@ py_module_initializer!(rustext, initrust
     )?;
 
     let dotted_name: String = m.get(py, "__name__")?.extract(py)?;
-    m.add(py, "__package__", "mercurial")?;
     m.add(py, "ancestor", ancestors::init_module(py, &dotted_name)?)?;
     m.add(py, "GraphError", py.get_type::<exceptions::GraphError>())?;
     Ok(())


More information about the Mercurial-devel mailing list