Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111988 > unrolled thread
| Started by | Enjoys Math <enjoysmath@gmail.com> |
|---|---|
| First post | 2016-07-28 08:47 -0700 |
| Last post | 2016-08-02 04:48 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
`exec`-based routine crashes app upon migration from 3.4.3 to python 3.5.2. Enjoys Math <enjoysmath@gmail.com> - 2016-07-28 08:47 -0700
Re: `exec`-based routine crashes app upon migration from 3.4.3 to python 3.5.2. Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-08-01 18:45 -0700
Re: `exec`-based routine crashes app upon migration from 3.4.3 to python 3.5.2. eryk sun <eryksun@gmail.com> - 2016-08-02 04:48 +0000
| From | Enjoys Math <enjoysmath@gmail.com> |
|---|---|
| Date | 2016-07-28 08:47 -0700 |
| Subject | `exec`-based routine crashes app upon migration from 3.4.3 to python 3.5.2. |
| Message-ID | <mailman.4.1469730339.6033.python-list@python.org> |
I've manually set breakpoints and traced this app crash back to this
function:
def loadLSobjsOfType(self, objType, listJ):
if listJ != None:
for objJ in listJ:
_locals = locals()
exec('obj = ' + objType + '(self)', None, _locals)
obj = _locals['obj']
obj.loadJson(objJ)
self.addLSobjOfType(objType, obj)
when breakpoints are set on `obj=_locals['obj']` my wingware debugger kicks
in and throws a KeyError exeption.
So what's the proper way to get the return value of an exec call when there
is one?
Thanks.
Regards,
EM
[toc] | [next] | [standalone]
| From | Lawrence D’Oliveiro <lawrencedo99@gmail.com> |
|---|---|
| Date | 2016-08-01 18:45 -0700 |
| Message-ID | <9c6b75e0-67ba-4495-9ec4-fde591249c36@googlegroups.com> |
| In reply to | #111988 |
On Friday, July 29, 2016 at 6:25:51 AM UTC+12, Enjoys Math wrote:
> exec('obj = ' + objType + '(self)', None, _locals)
> obj = _locals['obj']
Why? Why not just
obj = objType(self)
?
[toc] | [prev] | [next] | [standalone]
| From | eryk sun <eryksun@gmail.com> |
|---|---|
| Date | 2016-08-02 04:48 +0000 |
| Message-ID | <mailman.106.1470113334.6033.python-list@python.org> |
| In reply to | #112200 |
On Tue, Aug 2, 2016 at 1:45 AM, Lawrence D’Oliveiro
<lawrencedo99@gmail.com> wrote:
> On Friday, July 29, 2016 at 6:25:51 AM UTC+12, Enjoys Math wrote:
>
>> exec('obj = ' + objType + '(self)', None, _locals)
>> obj = _locals['obj']
>
> Why? Why not just
>
> obj = objType(self)
I think you meant to use `globals()[objType](self)`, as was already
suggested by Chris Angelico. The value of objType appears to be the
type's name, maybe from marshaled data.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web