Merge pull request #2302 from shcheklein/fix-2259

url info: fix infinite recustion on deepcopy
This commit is contained in:
Ruslan Kuprieiev
2019-07-21 04:32:30 +03:00
committed by GitHub
2 changed files with 14 additions and 0 deletions
+6
View File
@@ -184,6 +184,12 @@ class URLInfo(object):
__truediv__ = __div__
def __getattr__(self, name):
# When deepcopy is called, it creates and object without __init__,
# self.parsed is not initialized and it causes infinite recursion.
# More on this special casing here:
# https://stackoverflow.com/a/47300262/298182
if name.startswith("__"):
raise AttributeError(name)
return getattr(self.parsed, name)
@cached_property
+8
View File
@@ -1,4 +1,5 @@
import pytest
import copy
from dvc.path_info import URLInfo, CloudURLInfo
@@ -34,3 +35,10 @@ def test_url_info_parents(cls):
cls("ssh://[email protected]/test1"),
cls("ssh://[email protected]/"),
]
@pytest.mark.parametrize("cls", [URLInfo, CloudURLInfo])
def test_url_info_deepcopy(cls):
u1 = cls("ssh://[email protected]:/test1/test2/test3")
u2 = copy.deepcopy(u1)
assert u1 == u2