Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #111994

Re: `exec`-based routine crashes app upon migration from 3.4.3 to python 3.5.2.

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Random832 <random832@fastmail.com>
Newsgroups comp.lang.python
Subject Re: `exec`-based routine crashes app upon migration from 3.4.3 to python 3.5.2.
Date Thu, 28 Jul 2016 16:46:33 -0400
Lines 19
Message-ID <mailman.9.1469738797.6033.python-list@python.org> (permalink)
References <CAPKUSf6241yGYgVag-+P_Tob_Jq_UMWCbS6TGafYk2OVXvdOSw@mail.gmail.com> <1469738793.69613.679743369.5667BF8D@webmail.messagingengine.com>
Mime-Version 1.0
Content-Type text/plain
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de VVdmH7rbujkXh8q4YYUK1Asm0x047p8y1CNBz/pK1SFA==
Return-Path <random832@fastmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'none,': 0.05; 'one?': 0.05; 'enjoys': 0.09; 'obj': 0.09; 'received:internal': 0.09; 'throw': 0.09; 'exception': 0.13; 'def': 0.13; 'subject:python': 0.14; 'subject: \n ': 0.15; 'thu,': 0.15; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'self.obj': 0.16; 'subject:based': 0.16; 'wrote:': 0.16; 'try:': 0.18; 'math': 0.20; 'exec': 0.22; 'pass': 0.22; 'header:In-Reply- To:1': 0.24; "skip:' 10": 0.28; 'context,': 0.29; 'code': 0.30; 'skip:_ 10': 0.32; 'class': 0.33; 'values.': 0.33; 'wrap': 0.33; 'except': 0.34; 'there': 0.36; 'to:addr:python-list': 0.36; 'received:10': 0.37; 'received:66': 0.38; 'skip:o 20': 0.38; 'subject:from': 0.39; 'to:addr:python.org': 0.40; 'header:Message- Id:1': 0.61; 'jul': 0.72
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=ujMsgy/mzIAzoqz/ddoJazP9AS8=; b=rRtZcR Ne4kRxd1DCEmGdFhRBLi1ri3nbTgM6oXNqZU6HnU9UrbeV9clRopn96dyHlaub4Y jgrbjfJlwYav5Tv424AIMPTZcMh6nE2yZXxA7L3NcusA6sOqtJUfKfn8r3c3hlLH wDyZfVN7cjQTcq0sDM/CXTRrrri6fhyUX2ZR0=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=ujMsgy/mzIAzoqz /ddoJazP9AS8=; b=evVbe3StesecNHOGUtI+CLXG6WbQGmdOHMm9oDUeBmnTO76 dJ4uCxzBKtOBIyz2DqQ8XwlW6cSn4Jj3de0Lwql1n4R0d9X9xT5LIH6khu7bWQuJ 31tnU5qzwFaLChCSnZNangpROllbkqpksUlTh1atwfGxHQfNcZqZTOb3m/sI=
X-Sasl-Enc YwIMgTz13kPrR6+DNzrLRPIhMkJnngZu79d5BnKMzJzk 1469738793
X-Mailer MessagingEngine.com Webmail Interface - ajax-aabce84e
In-Reply-To <CAPKUSf6241yGYgVag-+P_Tob_Jq_UMWCbS6TGafYk2OVXvdOSw@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <1469738793.69613.679743369.5667BF8D@webmail.messagingengine.com>
X-Mailman-Original-References <CAPKUSf6241yGYgVag-+P_Tob_Jq_UMWCbS6TGafYk2OVXvdOSw@mail.gmail.com>
Xref csiph.com comp.lang.python:111994

Show key headers only | View raw


On Thu, Jul 28, 2016, at 11:47, Enjoys Math wrote:
> So what's the proper way to get the return value of an exec call when
> there is one?

Exec calls do not have return values.

If you need to pass an object out of the exec call to the surrounding
context, you can wrap it in an exception and throw it.

class ObjectWrapperException(Exception):
  def __init__(self, obj):
    self.obj = obj
    super().__init__()

code = 'obj = ' + objType + '(self)\nraise ObjectWrapperException(obj)'
try:
    exec(code, None, _locals)
except ObjectWrapperException as e
    obj = e.obj

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: `exec`-based routine crashes app upon migration from 3.4.3 to python 3.5.2. Random832 <random832@fastmail.com> - 2016-07-28 16:46 -0400

csiph-web