Skip to content

Commit e4fe2b0

Browse files
committed
removed call to __init__ in __new__
1 parent 3b38816 commit e4fe2b0

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313

14+
* Fixed cannot copy `Line` using `deepcopy`.
15+
1416
### Removed
1517

1618

src/compas/geometry/curves/line.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ class Line(Curve):
6969
# overwriting the __new__ method is necessary
7070
# to avoid triggering the plugin mechanism of the base curve class
7171
def __new__(cls, *args, **kwargs):
72-
curve = object.__new__(cls)
73-
curve.__init__(*args, **kwargs)
74-
return curve
72+
return object.__new__(cls)
7573

7674
DATASCHEMA = {
7775
"type": "object",

tests/compas/geometry/test_curves_line.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from copy import deepcopy
12
import pytest
23
import json
34
import compas
@@ -282,3 +283,17 @@ def test_line_flip(p1, p2):
282283
flipped_line = Line(p1, p2).flipped()
283284
assert TOL.is_zero(distance_point_point(flipped_line.start, p2))
284285
assert TOL.is_zero(distance_point_point(flipped_line.end, p1))
286+
287+
288+
def test_line_copy_deepcopy():
289+
line = Line([0, 0, 0], [1, 0, 0])
290+
291+
line_copy = line.copy()
292+
293+
assert line is not line_copy
294+
assert line == line_copy
295+
296+
line_deepcopy = deepcopy(line)
297+
298+
assert line is not line_deepcopy
299+
assert line == line_deepcopy

0 commit comments

Comments
 (0)