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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
From ebd389075f48253a12a71e457445a05f4373fe5e Mon Sep 17 00:00:00 2001
From: Tim 'mithro' Ansell <mithro@mithis.com>
Date: Mon, 28 Jul 2014 01:01:59 +0930
Subject: [PATCH] Removing the _PatchedModuleImporter hook.
The _PatchedModuleImporter didn't pass through the level argument which is
needed for the future absolute_import to work properly.
```python
from __future__ import absolute_import
```
---
flumotion/common/package.py | 30 +-----------------------------
1 file changed, 1 insertion(+), 29 deletions(-)
diff --git a/flumotion/common/package.py b/flumotion/common/package.py
index 5dbb05c..d41c04a 100644
--- a/flumotion/common/package.py
+++ b/flumotion/common/package.py
@@ -31,29 +31,6 @@
__version__ = "$Rev$"
-class _PatchedModuleImporter(ihooks.ModuleImporter):
- """
- I am overriding ihook's ModuleImporter's import_module() method to
- accept (and ignore) the 'level' keyword argument that appeared in
- the built-in __import__() function in python2.5.
-
- While no built-in modules in python2.5 seem to use that keyword
- argument, 'encodings' module in python2.6 does and so it breaks if
- used together with ihooks.
-
- I make no attempt to properly support the 'level' argument -
- ihooks didn't make it into py3k, and the only use in python2.6
- we've seen so far, in 'encodings', serves as a performance hint
- and it seems that can be ignored with no difference in behaviour.
- """
-
- def import_module(self, name, globals=None, locals=None, fromlist=None,
- level=-1):
- # all we do is drop 'level' as ihooks don't support it, anyway
- return ihooks.ModuleImporter.import_module(self, name, globals,
- locals, fromlist)
-
-
class PackageHooks(ihooks.Hooks):
"""
I am an import Hooks object that makes sure that every package that gets
@@ -106,12 +83,7 @@ def install(self):
self.debug('installing custom importer')
self._hooks = PackageHooks()
self._hooks.packager = self
- if sys.version_info < (2, 6):
- self._importer = ihooks.ModuleImporter()
- else:
- self.debug('python2.6 or later detected - using patched'
- ' ModuleImporter')
- self._importer = _PatchedModuleImporter()
+ self._importer = ihooks.ModuleImporter()
self._importer.set_hooks(self._hooks)
self._importer.install()
|