Patchwork rust-cpython: remove invalid __package__ attribute

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 6, 2019, 3:53 a.m.
Message ID <25c142f679c23fbc210d.1546746826@mimosa>
Download mbox | patch
Permalink /patch/37489/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 6, 2019, 3:53 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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
Augie Fackler - Jan. 8, 2019, 2:10 a.m.
On Sun, Jan 06, 2019 at 12:53:46PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1546741784 -32400
> #      Sun Jan 06 11:29:44 2019 +0900
> # Node ID 25c142f679c23fbc210d5bcbdf2f913e4dd55402
> # Parent  536c83535cbdafdfe060cea2b8c80b0789863227
> rust-cpython: remove invalid __package__ attribute

queued, thanks

Patch

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(())