From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id yMXQNy6xzl6XZwAA0tVLHw (envelope-from ) for ; Wed, 27 May 2020 18:27:58 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id HAiuMy6xzl52WgAAB5/wlQ (envelope-from ) for ; Wed, 27 May 2020 18:27:58 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 82D2D9403EE for ; Wed, 27 May 2020 18:27:57 +0000 (UTC) Received: from localhost ([::1]:59006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1je0mQ-0000Yy-I3 for larch@yhetil.org; Wed, 27 May 2020 14:27:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1je0lk-0000Yl-A2 for emacs-orgmode@gnu.org; Wed, 27 May 2020 14:27:12 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:51763) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1je0la-0001wW-ER for emacs-orgmode@gnu.org; Wed, 27 May 2020 14:27:12 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id A74F67F8; Wed, 27 May 2020 14:27:00 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 27 May 2020 14:27:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imapmail.org; h= from:to:subject:in-reply-to:message-id:references:date :mime-version:content-type; s=fm3; bh=grs30RaVoTdiNss3N1OQt1/SsJ nzy5aEXV1qzW9LiOo=; b=WlkX1dWLp7herlMVOzmQDDo6cjEcqDNw5DUBsu5wXm OBFsHHqO+/MUn3EF9eF+f5/s+EG/jjeNvMHPNbITI6+ZA652OjMtVSYbt339yUEH B7xO1FLG01LnNkI5bqa6t9lkj2iJ4cdKAFbV5S3imd+MBTDkGAtxSviKsW+yBPOd QP/57aEisXvcauL9G4iF0lFvHeiQXG+cS6otPiRjlQvDg7azWJJRmbCXLdT9ecfX FBUtxlThT8IYfJwGFql89N6FAAuXTymmS+bhmkcDNtC9PnunrcEyc1re6WjXLNVD HH47nRLkFuwzFCl+KrE71idpGwbUELPSlHOssTwqvX7w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=grs30R aVoTdiNss3N1OQt1/SsJnzy5aEXV1qzW9LiOo=; b=INzAWDWmImQ6k8Gob9Xwkh M4OzWJfgzjOLzh+j95jWhfnKfiQ83Ss+I+ak3F9S2tAh6kGiQ/MqSPJM8HW5pVw6 jBdhlnp1MOnxP8XeANp8TeK09ErGikxOWy5t6Bty0y3rv6eIkGT1GP8yjLjPdTo9 fywF6rBeqeDbr/qKXiCaHqD+eUMGYJwarafQew1tsnx5DmyGLF6HA9FoBwrlhL/1 8aGdQByIqs3dBetUQJ2mkmVapT8jVnekZqOWHepCT8XVoi0xGrmqs9tSKHZY9Atz 1lApbzH9c2LypBCocaxC/pGjnj3/YkESJdqoCtpXNIQ5pZEFLc2J0OuijO6wkX9Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedruddvgedguddufecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffujgfkfhffgggtsehttdertddttddtnecuhfhrohhmpeforghtthhh vgifucfnuhhnughinhcuoehmughlsehimhgrphhmrghilhdrohhrgheqnecuggftrfgrth htvghrnhepjeduffeglefhueevjedutdekudfgtefggfekteehheetkedvueeghfeujeet hefhnecukfhppeejiedrudeirddufeehrdduudelnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhgulhesihhmrghpmhgrihhlrdhorhhg X-ME-Proxy: Received: from localhost (c-76-16-135-119.hsd1.il.comcast.net [76.16.135.119]) by mail.messagingengine.com (Postfix) with ESMTPA id F034B30618C1; Wed, 27 May 2020 14:26:59 -0400 (EDT) From: Matthew Lundin To: Jack Kamm , =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= , emacs-orgmode@gnu.org Subject: Re: Bug: ob-python mangles multiline :var values [9.3.6 (release_9.3.6-397-ga089600)] In-Reply-To: <87a71xtmh0.fsf@gmail.com> Message-ID: <87h7w18ca1.fsf@fastmail.fm> References: <87sgico0ne.fsf@gmail.com> <87a71xtmh0.fsf@gmail.com> Date: Wed, 27 May 2020 13:26:58 -0500 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=64.147.123.25; envelope-from=mdl@imapmail.org; helo=wout2-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/27 14:27:01 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=imapmail.org header.s=fm3 header.b=WlkX1dWL; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=INzAWDWm; dmarc=pass (policy=none) header.from=imapmail.org; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.71 X-TUID: qMs2WbNIHp3z Jack Kamm writes: > Hello, > > Thanks for reporting. I've just fixed this issue in master (commit > 6149b6cb6). > > The problem was that ob-python adds tab indentation to the code body > before putting it inside a main() function, which adds spurious > indentation to multiline strings passed through :var. > > I fixed the issue by moving variable assignment from the code body to > the code preamble, which is executed outside the main() function. A heads up... I believe this changes the scope of the :var variables, since they previously were local to the main() function and now they are declared globally. After this change, some of my existing python source blocks (i.e., ones in which I attempt to assign a new value to a variable defined by :var) now generate the following error: Traceback (most recent call last): File "", line 223, in File "", line 214, in main UnboundLocalError: local variable 'members' referenced before assignment I hesitate to call this a bug, since it would be fine to think of everything within the source block as local and the header :var declarations as global. But if this is the case, then I think it should be documented somewhere, especially since this change may break people's existing source blocks. And I suppose it would be worthwhile to ask: Is this change consistent with other org-babel modules? Is there a canonical way that org-babel handles scope? Best, Matt