Commits

Benjamin Peterson committed 624a49f Merge

Merged in alexanderlukanin13/six/urllib_import_weirdness (pull request #22)

moves import bug fixed

  • Participants
  • Parent commits 64ebd04, 6fa2f11

Comments (0)

Files changed (3)

File .hgignore

File contents unchanged.
 
     def __init__(self, name):
         self.name = name
+        self._cached_value = None
 
     def __get__(self, obj, tp):
+        if self._cached_value is not None:
+            return self._cached_value
         result = self._resolve()
         setattr(obj, self.name, result)
-        # This is a bit ugly, but it avoids running this again.
-        delattr(tp, self.name)
         return result
 
+    def __set__(self, obj, value):
+        self._cached_value = value
+
+    def __delete__(self, obj):
+        self._cached_value = None
+
 
 class MovedModule(_LazyDescr):
 
     getattr(six.moves.urllib.robotparser, item_name)
 
 
+def test_import_moves_error_1():
+    from six.moves.urllib.parse import urljoin
+    from six import moves
+    # In 1.4.1: AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'urljoin'
+    assert moves.urllib.parse.urljoin
+
+
+def test_import_moves_error_2():
+    from six import moves
+    assert moves.urllib.parse.urljoin
+    # In 1.4.1: ImportError: cannot import name urljoin
+    from six.moves.urllib.parse import urljoin
+
+
+def test_import_moves_error_3():
+    from six.moves.urllib.parse import urljoin
+    # In 1.4.1: ImportError: cannot import name urljoin
+    from six.moves.urllib_parse import urljoin
+
+
 def test_filter():
     from six.moves import filter
     f = filter(lambda x: x % 2, range(10))