Skip to content

Fix module dir #598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 5, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
dir show module content
  • Loading branch information
palaviv committed Mar 4, 2019
commit d24f79b17d41681a6a62d4a23e58767ec14d3d4b
11 changes: 9 additions & 2 deletions vm/src/obj/objtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use super::objdict;
use super::objstr;
use super::objtype; // Required for arg_check! to use isinstance
use crate::pyobject::{
AttributeProtocol, IdProtocol, PyAttributes, PyContext, PyFuncArgs, PyObject, PyObjectPayload,
PyObjectRef, PyResult, TypeProtocol,
AttributeProtocol, DictProtocol, IdProtocol, PyAttributes, PyContext, PyFuncArgs, PyObject,
PyObjectPayload, PyObjectRef, PyResult, TypeProtocol,
};
use crate::vm::VirtualMachine;
use std::cell::RefCell;
Expand Down Expand Up @@ -277,6 +277,13 @@ pub fn get_attributes(obj: &PyObjectRef) -> PyAttributes {
attributes.insert(name.to_string(), value.clone());
}
}

// Get module attributes:
if let PyObjectPayload::Module { ref scope, .. } = &obj.payload {
for (name, value) in scope.locals.get_key_value_pairs().iter() {
attributes.insert(objstr::get_value(name).to_string(), value.clone());
}
}
attributes
}

Expand Down