Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/demandimport.py @ 3888:3b628b5da9e9
use parent.__setattr__ instead of __dict__
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Thu, 14 Dec 2006 23:51:41 +0100 |
parents | abaee83ce0a6 |
children | 316cd5b0c940 |
comparison
equal
deleted
inserted
replaced
3887:79e5a6e7c451 | 3888:3b628b5da9e9 |
---|---|
33 head, rest = name.split('.', 1) | 33 head, rest = name.split('.', 1) |
34 after = [rest] | 34 after = [rest] |
35 else: | 35 else: |
36 head = name | 36 head = name |
37 after = [] | 37 after = [] |
38 self.__dict__["_data"] = (head, globals, locals, after) | 38 object.__setattr__(self, "_data", (head, globals, locals, after)) |
39 self.__dict__["_module"] = None | 39 object.__setattr__(self, "_module", None) |
40 def _extend(self, name): | 40 def _extend(self, name): |
41 """add to the list of submodules to load""" | 41 """add to the list of submodules to load""" |
42 self._data[3].append(name) | 42 self._data[3].append(name) |
43 def _load(self): | 43 def _load(self): |
44 if not self._module: | 44 if not self._module: |
52 if not hasattr(mod, hx): | 52 if not hasattr(mod, hx): |
53 setattr(mod, hx, _demandmod(x, mod.__dict__, mod.__dict__)) | 53 setattr(mod, hx, _demandmod(x, mod.__dict__, mod.__dict__)) |
54 # are we in the locals dictionary still? | 54 # are we in the locals dictionary still? |
55 if locals and locals.get(head) == self: | 55 if locals and locals.get(head) == self: |
56 locals[head] = mod | 56 locals[head] = mod |
57 self.__dict__["_module"] = mod | 57 object.__setattr__(self, "_module", mod) |
58 def __repr__(self): | 58 def __repr__(self): |
59 return "<unloaded module '%s'>" % self._data[0] | 59 return "<unloaded module '%s'>" % self._data[0] |
60 def __call__(self, *args, **kwargs): | 60 def __call__(self, *args, **kwargs): |
61 raise TypeError("'unloaded module' object is not callable") | 61 raise TypeError("'unloaded module' object is not callable") |
62 def __getattr__(self, attr): | 62 def __getattr__(self, attr): |