~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lazy_import.py

(gz) Fix deprecations of win32utils path function unicode wrappers (Martin
 Packman)

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
to inherit from them).
42
42
"""
43
43
 
 
44
from __future__ import absolute_import
 
45
 
44
46
 
45
47
class ScopeReplacer(object):
46
48
    """A lazy object that will replace itself in the appropriate scope.
98
100
 
99
101
    def _cleanup(self):
100
102
        """Stop holding on to all the extra stuff"""
101
 
        del self._factory
102
 
        del self._scope
 
103
        try:
 
104
            del self._factory
 
105
        except AttributeError:
 
106
            # Oops, we just lost a race with another caller of _cleanup.  Just
 
107
            # ignore it.
 
108
            pass
 
109
 
 
110
        try:
 
111
            del self._scope
 
112
        except AttributeError:
 
113
            # Another race loss.  See above.
 
114
            pass
 
115
 
103
116
        # We keep _name, so that we can report errors
104
117
        # del self._name
105
118
 
197
210
        module_path = object.__getattribute__(self, '_module_path')
198
211
        module_python_path = '.'.join(module_path)
199
212
        if member is not None:
200
 
            module = __import__(module_python_path, scope, scope, [member])
 
213
            module = __import__(module_python_path, scope, scope, [member], level=0)
201
214
            return getattr(module, member)
202
215
        else:
203
 
            module = __import__(module_python_path, scope, scope, [])
 
216
            module = __import__(module_python_path, scope, scope, [], level=0)
204
217
            for path in module_path[1:]:
205
218
                module = getattr(module, path)
206
219