[pypy-dev] prevent extension module code from being executed during startup?

wlavrijsen at lbl.gov wlavrijsen at lbl.gov
Sat Mar 30 17:40:40 CET 2013


Hi Armin,

> Fwiw the patch I have in mind would look like
> this: http://bpaste.net/show/87755/

this line:

-        'gbl'                    : 'pythonify.gbl',

can not be removed, as w/o it 'gbl' will not show up at the module level.

>  and I have no clue about which
> part of the code contains an error message about being circular.

Looks like this (and I get it when running the translation with the patch
as above, but with 'gbl' still in the applevel defs). Sorry, the message
said recursive, not circular:

[translation:ERROR]    File "/home/wlav/pypy-dev/pypy/pypy/interpreter/mixedmodule.py", line 81, in getdictvalue
[translation:ERROR]     return self._load_lazily(space, name)
[translation:ERROR]    File "/home/wlav/pypy-dev/pypy/pypy/interpreter/mixedmodule.py", line 91, in _load_lazily
[translation:ERROR]     w_value = loader(space)
[translation:ERROR]    File "/home/wlav/pypy-dev/pypy/pypy/interpreter/mixedmodule.py", line 245, in afileloader
[translation:ERROR]     return app.wget(space, attrname)
[translation:ERROR]    File "/home/wlav/pypy-dev/pypy/pypy/interpreter/gateway.py", line 999, in wget
[translation:ERROR]     w_globals = self.getwdict(space)
[translation:ERROR]    File "/home/wlav/pypy-dev/pypy/pypy/interpreter/gateway.py", line 992, in getwdict
[translation:ERROR]     return space.fromcache(ApplevelCache).getorbuild(self)
[translation:ERROR]    File "/home/wlav/pypy-dev/pypy/rpython/rlib/cache.py", line 48, in getorbuild
[translation:ERROR]     self, key)
[translation:ERROR]  Exception: ("<Cache 'ApplevelCache' (18 items)> recursive building of <ApplevelClass filename='/home/wlav/pypy-dev/pypy/pypy/module/cppyy/pythonify.py'>", <
[translation:ERROR]  v42 = getattr(self_2, ('builtin_modules'))
[translation:ERROR] In <FunctionGraph of (pypy.interpreter.baseobjspace:407)getbuiltinmodule at 0x2fe303a0>:
[translation:ERROR] Happened at file /home/wlav/pypy-dev/pypy/pypy/interpreter/baseobjspace.py line 422
[translation:ERROR]
[translation:ERROR] ==>             w_mod = self.builtin_modules[name]
[translation:ERROR]
[translation:ERROR] Known variable annotations:
[translation:ERROR]  self_2 = SomePBC(can_be_None=False, const=StdObjSpace, subset_of=None)>)
[translation:ERROR] Processing block:
[translation:ERROR]  block at 120 is a <class 'rpython.flowspace.flowcontext.SpamBlock'>
[translation:ERROR]  in (pypy.interpreter.baseobjspace:407)getbuiltinmodule
[translation:ERROR]  containing the following operations:
[translation:ERROR]        v42 = getattr(self_2, ('builtin_modules'))
[translation:ERROR]        v43 = getitem_key(v42, name_0)
[translation:ERROR]  --end--

But again, the real problem is that startup() still runs immediately when I
type './pypy-c' and not when 'import cppyy' later on the prompt, so even if
the above problem gets solved, I still can't raise an ImportError in startup()
when the library is missing.

That is, if I leave the setup as-is and simply call verify_backend() in the
startup() function in cppyy/__init__.py, this is how it looks if the library
is missing:

  $ ./pypy-c
  Traceback (most recent call last):
    File "app_main.py", line 52, in run_toplevel
  ImportError: missing reflection module rflxlib.so!
  Python 2.7.3 (2377fb34943d+3ef424d4281f+, Mar 30 2013, 03:53:47)
  [PyPy 2.0.0-beta1 with GCC 4.6.2] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  And now for something completely different: ``things worked nicely till today
  just by chance''
  >>>>

(And copying rflxlib.so to an accessible location nicely makes the error
message go away, so the checking does work properly, unless that message I
got on the prompt is being prophetic. :) )

Thanks,
      Wim
-- 
WLavrijsen at lbl.gov    --    +1 (510) 486 6411    --    www.lavrijsen.net


More information about the pypy-dev mailing list