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


Groups > comp.lang.python > #71943 > unrolled thread

how to create a frame object when embedding python?

Started byRobert Snoeberger <robert.snoeberger@icloud.com>
First post2014-05-23 20:52 +0000
Last post2014-05-23 20:52 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  how to create a frame object when embedding python? Robert Snoeberger <robert.snoeberger@icloud.com> - 2014-05-23 20:52 +0000

#71943 — how to create a frame object when embedding python?

FromRobert Snoeberger <robert.snoeberger@icloud.com>
Date2014-05-23 20:52 +0000
Subjecthow to create a frame object when embedding python?
Message-ID<mailman.10255.1400881973.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

Hi python-list,

I'm embedding Python in an application and I have encountered two crashes while calling built-in functions that expect a top-level frame. See the following bug reports: http://bugs.python.org/issue21563 and http://bugs.python.org/issue21418. The problem is that the workflow for embedding the Python interpreter does not involve creation of a frame. RubyPython, a language interface to call Python from Ruby, has the same problem, http://rubypython.rubyforge.org/#known-problems. Since there is not a top-level frame object, some built-in functions do not work properly. In most cases, this problem is easily worked-around because globals and locals can be passed as optional arguments. The crashes, however, are more unfortunate. 

As an example, I can crash RubyPython by calling the built-in function execfile with a single argument.

irb(main):001:0> require('rubypython')
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/blankslate-3.1.2/lib/blankslate.rb:51: warning: undefining `object_id' may cause serious problems
=> true
irb(main):002:0> RubyPython.start
=> true
irb(main):003:0> binmod = RubyPython.import('__builtin__')
=> <module '__builtin__' (built-in)>
irb(main):004:0> binmod.execfile('foo.py')

The fourth line crashed the ruby interpreter. This is an example where an application might want to give full access to the functions in a Python module. It would be nice to find a way to prevent the crash without restricting the API.

I am curious if anyone has suggestions for creating a top-level frame?

Thank you,
Rob  



[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web