From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id IE1PIETNz15sRAAA0tVLHw (envelope-from ) for ; Thu, 28 May 2020 14:40:04 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id MFUEHETNz16cWAAAbx9fmQ (envelope-from ) for ; Thu, 28 May 2020 14:40:04 +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 B084D9402D1 for ; Thu, 28 May 2020 14:40:03 +0000 (UTC) Received: from localhost ([::1]:36792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeJhR-00078U-61 for larch@yhetil.org; Thu, 28 May 2020 10:40:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeJh1-00076j-7L for emacs-orgmode@gnu.org; Thu, 28 May 2020 10:39:35 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:43387) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jeJgz-0004t1-Sh for emacs-orgmode@gnu.org; Thu, 28 May 2020 10:39:34 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 185so5335438pgb.10 for ; Thu, 28 May 2020 07:39:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=ZC+QyOF6SH81hNPsWRx5/D7Dr0e08LvBo5j99TnXmus=; b=rblM2bGoW44sirnhpF3+KTLkQcyvCzp4u1XUnvOFielKmiTlRG+IRzCiMtphAt7LvC 0LteSak9KhNI9Q6lsQVf1uNrhVXJAKD5eod0gg6cG0n8csSFspn9/0rpOocscNycUuU9 8Bi9LEgKuZV7WLfFg8+jLizuGrBL5n7ZBBlLpBimcPE8e1iX6yV7QEV/FPpkpGhbTvan IaP82kK1QIrKlAzr8tNvXUjS5HcqQNtzt96fM0ollUQH82HqcjqwnXLGtxfyuEN5VGtL BfQJRt1yMA8CjIM5Ah6LpVXVFVzpdQU7dbzd6SBC6cxM5kYsMFaR/DdnGjwHh4s7bSzx FvaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=ZC+QyOF6SH81hNPsWRx5/D7Dr0e08LvBo5j99TnXmus=; b=i8+P0XQyIQGG3Iha+9iByCaL8O/nzOMmGOp5xkgRj6caHODo5gi70BLNu6J6+n7h79 eDp3IIjUWr7Qf7bvVJD3ImF+mmS9og2PR818oPdRQlz4uFxWSt7kOG4zHrUM97CyyQIR Q7HE+XC0JdFu0DO1hGOR2RRL9tBgzSUhag5RCKYrbkkO2Uo9Kpv6QCXLeRlKbMWLciee n/OjfMkjQQaipr50AfJ7ny11IgI5qGeKFBW6wEieamJt21IW3Ao+Y/nLShohszburaaE WpMl6trl4Hel8m6q7DPEyviDo+TBp0tJ+Nw0DbOUAsVi7TpfQr+xX0ER6K2wqNnhok0n fUzA== X-Gm-Message-State: AOAM532+onIMA8hCHBVinOzuJvLDTsi6/CoGVPy2pbhqeDrXlJcaQs4j 9AIRJyuwcmQqOAALGAcMl4I= X-Google-Smtp-Source: ABdhPJyouBJG5ymZ5J88GmI0+Ck8IvWHe8bwmmC7WD0WN3tcBSBbtk855+aVrTXcnZeQswh5Vi9mHQ== X-Received: by 2002:a63:792:: with SMTP id 140mr3216838pgh.65.1590676771674; Thu, 28 May 2020 07:39:31 -0700 (PDT) Received: from localhost (199-83-220-90.PUBLIC.monkeybrains.net. [199.83.220.90]) by smtp.gmail.com with ESMTPSA id g18sm4707364pgn.47.2020.05.28.07.39.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2020 07:39:30 -0700 (PDT) From: Jack Kamm To: Matthew Lundin , =?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: <87zh9t9hkw.fsf@gmail.com> References: <87sgico0ne.fsf@gmail.com> <87a71xtmh0.fsf@gmail.com> <87h7w18ca1.fsf@fastmail.fm> <87zh9t9hkw.fsf@gmail.com> Date: Thu, 28 May 2020 07:39:29 -0700 Message-ID: <87tv009l9a.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=jackkamm@gmail.com; helo=mail-pg1-x52e.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_PASS=-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=gmail.com header.s=20161025 header.b=rblM2bGo; dmarc=pass (policy=none) header.from=gmail.com; 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: R/8UIw3EQSnW An update on this -- I decided to revert my fix for multiline Python variables. I left the unit test I added for this, but marked it as expected to fail. I'll try to submit a proper fix for this soon. However I've been swamped at work so I can't promise when (hopefully a couple weeks). In the meantime, I think it better to leave the original bug in place, rather than break any existing ob-python use cases. When I do get to this, I'll submit it as a patch to the list first, to make sure I don't accidentally cause a new bug. Best, Jack Jack Kamm writes: > Hi Matt -- > >> 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 > > Thanks for noticing this and pointing it out. This was an oversight on > my end (I don't really use ":var" or non-session blocks). > > Unfortunately, the fix for the original bug will have to be a bit more > complicated to avoid this error. I'll put it on my todo list, but if > anyone wants to have a crack at it, that would be very welcome. > > We should also add a unit test for this regression so it doesn't happen > again. > >> 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. > > I think it's fair to call this a bug. I think it would be inconvenient > to be unable to assign to these variables. Also, I did not intend to > break any existing code with this. > >> 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? > > IMO everything ought to be in the same scope, and the user shouldn't > have to think about the scope of the main() function that ob-python > wraps the body in. Especially since non-session blocks are evaluated > independently of other blocks, we really shouldn't have to think about > their scope. > > I'm not sure if the Org manual provides any guidance here, but from a > quick check I didn't see anything about it. > > Ideally I think everything should just be in global scope; however > ob-python needs to use a wrapper function for the "return" keyword.