blob: 2819347eb5d71815b873e07ec8d55d3de4d2a38c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
"""
Module objects.
"""
from pypy.interpreter.baseobjspace import Wrappable
class Module(Wrappable):
"""A module."""
def __init__(self, space, w_name, w_dict=None):
self.space = space
if w_dict is None:
w_dict = space.newdict([])
self.w_dict = w_dict
self.w_name = w_name
space.setitem(w_dict, space.wrap('__name__'), w_name)
def getdict(self):
return self.w_dict
def setdict(self, w_dict):
self.w_dict = w_dict
def descr_module__new__(space, w_subtype, __args__):
module = space.allocate_instance(Module, w_subtype)
module.__init__(space, space.wrap('?'))
return space.wrap(module)
def descr_module__init__(self, w_name):
space = self.space
self.w_name = w_name
space.setitem(self.w_dict, space.wrap('__name__'), w_name)
|