File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
66and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
77
8+ ## Unreleased
9+
10+ ### Fixed
11+
12+ - Fixed infinite loop when appending Text to same instance
813
914## [ 13.8.0] - 2024-08-26
1015
Original file line number Diff line number Diff line change @@ -998,7 +998,7 @@ def append(
998998 self ._text .append (text .plain )
999999 self ._spans .extend (
10001000 _Span (start + text_length , end + text_length , style )
1001- for start , end , style in text ._spans
1001+ for start , end , style in text ._spans . copy ()
10021002 )
10031003 self ._length += len (text )
10041004 return self
@@ -1020,7 +1020,7 @@ def append_text(self, text: "Text") -> "Text":
10201020 self ._text .append (text .plain )
10211021 self ._spans .extend (
10221022 _Span (start + text_length , end + text_length , style )
1023- for start , end , style in text ._spans
1023+ for start , end , style in text ._spans . copy ()
10241024 )
10251025 self ._length += len (text )
10261026 return self
Original file line number Diff line number Diff line change @@ -1001,3 +1001,14 @@ def test_append_tokens() -> None:
10011001 output = capture .get ()
10021002 print (repr (output ))
10031003 assert output == "long text that will be wrapped with a \n control code \n \n "
1004+
1005+
1006+ def test_append_loop_regression () -> None :
1007+ """Regression text for https://github.com/Textualize/rich/issues/3479"""
1008+ a = Text ("one" , "blue" )
1009+ a .append (a )
1010+ assert a .plain == "oneone"
1011+
1012+ b = Text ("two" , "blue" )
1013+ b .append_text (b )
1014+ assert b .plain == "twotwo"
You can’t perform that action at this time.
0 commit comments