Hello,
I’m using a Python script in which I create histograms that I would like to write to a postscript file. I import the TPostScript class from Root and create an object but when I try to do NewPage() the script crashes and my Python session is ended with a segmentation violation. I use:
from ROOT import TPostScript
ps = TPostScript (“somefile.ps”, 111)
ps.NewPage()
Without ps.NewPage() everything is fine.
I would be glad for any help or suggestions.
Best regards,
Brian
I use ROOT 4.00.08 and Python 2.2.2 on a DESY-Linux 5 (not exactly sure which real Linux version this corresponds to but I suppose it is quite recent) machine.
Here is what I do:
Python 2.2.2 (#1, Feb 7 2005, 15:23:55)
[GCC 3.3 20030226 (prerelease) (SuSE Linux)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
execfile(‘test.py’)
*** Break *** segmentation violation
Generating stack trace…
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
/usr/bin/addr2line: python: No such file or directory
0x4018b5c8 in from /lib/libc.so.6
0x403426a6 in PyROOT::MethodHolder::execute(void*) + 0x52 from /opt/products/root/4.00.08/lib/libPyROOT.so
0x40342a17 in PyROOT::MethodHolder::operator()(_object*, _object*) + 0x123 from /opt/products/root/4.00.08/lib/libPyROOT.so
0x4033ffd2 in PyROOT::MethodDispatcher::operator()(_object*, _object*) + 0x92 from /opt/products/root/4.00.08/lib/libPyROOT.so
0x4033fe17 in PyROOT::MethodDispatcher::invoke(_object*, _object*, _object*) + 0x35 from /opt/products/root/4.00.08/lib/libPyROOT.so
0x080cd05e in PyCFunction_Call + 0xae from python
0x080af5a7 in PyObject_Call + 0x37 from python
0x0807cb86 in from python
0x080788c5 in from python
0x0807b419 in PyEval_EvalCodeEx + 0x4e9 from python
0x08077ed3 in PyEval_EvalCode + 0x63 from python
0x0807db04 in from python
0x08079bd0 in from python
0x0807b419 in PyEval_EvalCodeEx + 0x4e9 from python
0x0807c871 in from python
0x0807a71e in from python
0x0807b419 in PyEval_EvalCodeEx + 0x4e9 from python
0x080c0dfa in from python
0x080af5a7 in PyObject_Call + 0x37 from python
0x0807c518 in PyEval_CallObjectWithKeywords + 0x78 from python
0x080971f7 in PyErr_PrintEx + 0xd7 from python
0x08096e6e in PyErr_Print + 0x1e from python
0x08096806 in PyRun_InteractiveOneFlags + 0x236 from python
0x080964f6 in PyRun_InteractiveLoopFlags + 0x66 from python
0x080963f7 in PyRun_AnyFileExFlags + 0x47 from python
0x080539c2 in Py_Main + 0x432 from python
0x08053487 in main + 0x27 from python
0x401778ae in __libc_start_main + 0xce from /lib/libc.so.6
0x080533b1 in strcpy + 0x39 from python
zsh: 18177 abort python
It seems that you fixed this problem between version 4.0./08 used by Brian
and the current version 5.02.
When running Brian case in 4.00/08, I get a crash with the following traceback:
code bt #0 0x41b65d60 in PyROOT::MethodHolder::calcOffset_ ()
from /home/brun/root400/root/lib/libPyROOT.so #1 0x41b66a2a in PyROOT::MethodHolder::execute ()
from /home/brun/root400/root/lib/libPyROOT.so #2 0x41b66dcf in PyROOT::MethodHolder::operator() ()
from /home/brun/root400/root/lib/libPyROOT.so #3 0x41b647fa in PyROOT::MethodDispatcher::operator() ()
from /home/brun/root400/root/lib/libPyROOT.so #4 0x41b64637 in PyROOT::MethodDispatcher::invoke ()
from /home/brun/root400/root/lib/libPyROOT.so #5 0x41bc8b22 in PyCFunction_Call (func=0x4204e9ec, arg=0x4204e24c,
kw=0x922af08) at Objects/methodobject.c:77 #6 0x41ba1297 in PyObject_Call (func=0x747069, arg=0x0, kw=0x0)
at Objects/abstract.c:1755 #7 0x41bff385 in do_call (func=0x4204e9ec, pp_stack=0xbffe577c,
na=0, nk=0) at Python/ceval.c:3644 #8 0x41bfef8e in call_function (pp_stack=0xbffe577c, oparg=0)
at Python/ceval.c:3460[/code]
just for completeness sake: in 4.00/08, you can’t do "from ROOT import " in a script that is execfiled. () Further, gStyle was at the time bound as a pointer at startup, so if you set it to “Plain”, gStyle would still point to the old style. Now it’s bound as an address of a pointer, so if gROOT changes gStyle, it works properly.
Btw., I looked at the reference guide for 4.00/08, and there was no TPostScript class in the class index? Strange, it’s there in CVS.
Cheers,
Wim
(*) To see why, put a print statement in the script, and compare it with running the commands interactively. Every time a class is missing, the exception is handled by creating the class and re-executing the frame. Fine interactively, but an execfile as a whole lives on one frame …