Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyROOT tutorial numberEntry.py broken #7436

Closed
1 task done
jblomer opened this issue Mar 10, 2021 · 1 comment · Fixed by #7668
Closed
1 task done

PyROOT tutorial numberEntry.py broken #7436

jblomer opened this issue Mar 10, 2021 · 1 comment · Fixed by #7668

Comments

@jblomer
Copy link
Contributor

jblomer commented Mar 10, 2021

  • Checked for duplicates

Describe the bug

The tutorial does not start but prints a backtrace:

Traceback (most recent call last):
  File "/home/jakob/Documents/CERN/ROOT/ntuple/install-git/tutorials/pyroot/numberEntry.py", line 51, in <module>
    window = pMyMainFrame( gClient.GetRoot(), 50, 50 )
  File "/home/jakob/Documents/CERN/ROOT/ntuple/install-git/tutorials/pyroot/numberEntry.py", line 25, in __init__
    self.fLabelDispatch = TPyDispatcher( self.DoSetlabel )
NameError: name 'TPyDispatcher' is not defined

Expected behavior

The tutorial should run

To Reproduce

cd $ROOTSYS/tutorials/pyroot
python -i numberEntry.py

Setup

Compiled from latest ROOT sources / Arch Linux

Additional context

See ROOT forum

@vepadulano
Copy link
Member

Indeed TPyDispatcher is present in ROOT:

vpadulan@fedorathinkpad-T550 [~]: python
Python 3.8.7 (default, Jan 20 2021, 00:00:00) 
[GCC 10.2.1 20201125 (Red Hat 10.2.1-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>> ROOT.TPyDispatcher
<class cppyy.gbl.TPyDispatcher at 0x55b264067990>

But in the tutorial numberEntry.py the ROOT objects are imported via from ROOT import * which somehow doesn't import TPyDispatcher in the python session. Indeed, changing that line with import ROOT and then explicitly instantiating ROOT.TPyDispatcher solves this issue

Now in general from <package> import * is discouraged so I would change the tutorial, but it is true that ROOT also has its own machinery to decide which names are imported into the namespace in this case and I still don't know why TPyDispatcher is not loaded along all the other classes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants