From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 9 Mar 2024 22:08:23 +0000 (+0100) Subject: [3.11] gh-116535: Fix distracting "TypeError" in example code (gh-116538) (gh-116552) X-Git-Tag: v3.11.9~78 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=982f457f6f86700a62ce00f1914101dcbde7de15;p=thirdparty%2FPython%2Fcpython.git [3.11] gh-116535: Fix distracting "TypeError" in example code (gh-116538) (gh-116552) gh-116535: Fix distracting "TypeError" in example code (gh-116538) (cherry picked from commit db8f423f58e336eb6180a70d9886b443d7203c2c) Co-authored-by: Declan <5962877+dec1@users.noreply.github.com> --- diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index a1066c748a77..ee34cd76b2cc 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -712,7 +712,7 @@ Using dataclasses, *if* this code was valid:: class D: x: list = [] # This code raises ValueError def add(self, element): - self.x += element + self.x.append(element) it would generate code similar to:: @@ -721,7 +721,7 @@ it would generate code similar to:: def __init__(self, x=x): self.x = x def add(self, element): - self.x += element + self.x.append(element) assert D().x is D().x