From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 25 May 2023 13:16:20 +0000 (-0700) Subject: [3.12] Fix indentation in `json.AttrDict` REPL example (GH-104930) (#104931) X-Git-Tag: v3.12.0b2~87 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b328ba194157ab5191d056608d35ab4353fc61af;p=thirdparty%2FPython%2Fcpython.git [3.12] Fix indentation in `json.AttrDict` REPL example (GH-104930) (#104931) Fix indentation in `json.AttrDict` REPL example (GH-104930) This is causing the docs to be rendered incorrectly. (cherry picked from commit 38539ef1267f26a8b3508fcc8c6199cf46fc300b) Co-authored-by: Alex Waygood --- diff --git a/Doc/library/json.rst b/Doc/library/json.rst index a752efd7ef22..ef58dd094236 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -559,14 +559,14 @@ Exceptions .. doctest:: - >>> json_string = '{"mercury": 88, "venus": 225, "earth": 365, "mars": 687}' - >>> orbital_period = json.loads(json_string, object_hook=AttrDict) - >>> orbital_period['earth'] # Dict style lookup - 365 - >>> orbital_period.earth # Attribute style lookup - 365 - >>> orbital_period.keys() # All dict methods are present - dict_keys(['mercury', 'venus', 'earth', 'mars']) + >>> json_string = '{"mercury": 88, "venus": 225, "earth": 365, "mars": 687}' + >>> orbital_period = json.loads(json_string, object_hook=AttrDict) + >>> orbital_period['earth'] # Dict style lookup + 365 + >>> orbital_period.earth # Attribute style lookup + 365 + >>> orbital_period.keys() # All dict methods are present + dict_keys(['mercury', 'venus', 'earth', 'mars']) Attribute style access only works for keys that are valid attribute names. In contrast, dictionary style access works for all keys. For