mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Merge pull request #2302 from shcheklein/fix-2259
url info: fix infinite recustion on deepcopy
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user