This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: precompiled code and nameError.
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, effbot, megath, nnorwitz
Priority: normal Keywords:

Created on 2005-08-17 06:50 by megath, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg60803 - (view) Author: Vladimir Menshakov (megath) Date: 2005-08-17 06:50
i experienced problem with call'ing python unmarshalled
and eval'ed code. 

similar problem described in mailing list, but
unfortunately has not got any solution or work-around. 
http://mail.python.org/pipermail/c++-sig/2003-October/006094.html

actually I have code like this: 
-------------
import m

class A:
  def do(self): 
    print m.User().GetName()
------------
test.py
a = A() 
a.do()

running script from python works perfectly. but when I
call 'do' from c++ code I get following error : 
PyObject_CallMethod: exceptions.NameError:global name
'm' is not defined

I checked locals dictionary, it contains missing name
('m'). 
msg60804 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2005-09-30 06:30
Logged In: YES 
user_id=33168

Can you provide the c++ code?  Thanks.
msg60805 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2005-11-12 16:43
Logged In: YES 
user_id=38376

How do you call "do" from your C++ code?

"m" isn't a local variable, so what you stuff into the
locals directory doesn't matter; the important thing is that
the module associated with the function
(A.do.im_func.func_globals) contains the right thing.
msg82295 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-02-17 02:21
Closing on lack of input from OP.
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42285
2009-02-17 02:21:05benjamin.petersonsetstatus: open -> closed
resolution: not a bug
messages: + msg82295
nosy: + benjamin.peterson
2005-08-17 06:50:54megathcreate