diff --git a/tests/test_items.py b/tests/test_items.py index edf77a1..7f875ce 100644 --- a/tests/test_items.py +++ b/tests/test_items.py @@ -1,5 +1,6 @@ import math import pickle +import copy from datetime import date from datetime import datetime @@ -860,3 +861,17 @@ def test_table_copy(): table["foo"] = "baz" assert table_copy["foo"] == "bar" assert table_copy.as_string() == 'foo = "bar"\n' + + +def test_copy_copy(): + result = parse(""" + [tool.poetry] + classifiers = [ + # comment + "a", + "b", + ] + """) + classifiers = result["tool"]["poetry"]["classifiers"] + new = copy.copy(classifiers) + assert new == classifiers diff --git a/tomlkit/items.py b/tomlkit/items.py index 5128807..f4ca6d9 100644 --- a/tomlkit/items.py +++ b/tomlkit/items.py @@ -656,7 +656,6 @@ def as_string(self) -> str: return self._raw def __add__(self, other): - return self._new(int(self._raw) + other) def __radd__(self, other): @@ -1139,7 +1138,8 @@ def __init__( ) -> None: super().__init__(trivia) list.__init__( - self, [v.value for v in value if not isinstance(v, (Whitespace, Comment))] + self, + [v.value for v in value if not isinstance(v, (Whitespace, Comment, Null))], ) self._index_map: Dict[int, int] = {} self._value = self._group_values(value)