Skip to content

[PyROOT] ROOT package import method changes gDirectory.pwd() result #21693

@kdrazyk

Description

@kdrazyk

Check duplicate issues.

  • Checked for duplicates

Description

import ROOT and from ROOT import TFile, gDirectory yield different results on our systems running ROOT 6.36.04, 6.36.10 and 6.38.0.
On systems with ROOT 6.34.04 and 6.34.10 both methods produce the same results.
I expected the package to work the same way no matter the import syntax.

Python 3.12.12 (main, Feb 27 2026, 00:00:00) [GCC 11.5.0 20240719 (Red Hat 11.5.0-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TFile, gDirectory, gROOT
>>> TFile("Hybrid.root")
<cppyy.gbl.TFile object at 0x556042225510>
>>> gDirectory.pwd()
PyROOT:/
>>> gROOT.GetVersion()
'6.36.10'

Python 3.12.12 (main, Feb 27 2026, 00:00:00) [GCC 11.5.0 20240719 (Red Hat 11.5.0-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>> ROOT.TFile("Hybrid.root")
<cppyy.gbl.TFile object at 0x563f2d4c3870>
>>> ROOT.gDirectory.pwd()
Hybrid.root:/
>>> ROOT.gROOT.GetVersion()
'6.36.10'

I expected both cases to produce: Hybrid.root:/

Reproducer

To be run from Python REPL

from ROOT import TFile, gDirectory
TFile("Hybrid.root")
gDirectory.pwd()
import ROOT
ROOT.TFile("Hybrid.root")
ROOT.gDirectory.pwd()

I can't attach the ROOT file, but it's small and simple.

>>> import ROOT
>>> f = ROOT.TFile("Hybrid.root")
>>> f.ls()
TFile**		Hybrid.root	
 TFile*		Hybrid.root	
  KEY: TTree	summaryTree;1	Most relevant results
  KEY: TTree	tI2CMaster0;1	I2C Master 0 Test Tree
  KEY: TTree	tI2CMaster2;1	I2C Master 2 Test Tree

ROOT version

   ------------------------------------------------------------------
  | Welcome to ROOT 6.36.10                        https://root.cern |
  | (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Mar 13 2026, 14:55:50                 |
  | From tags/v6-36-10@v6-36-10                                      |
  | With c++ (GCC) 11.5.0 20240719 (Red Hat 11.5.0-11)               |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

Installation method

Pre-built binary: https://root.cern/download/root_v6.36.10.Linux-almalinux9.7-x86_64-gcc11.5.tar.gz

Operating system

CERN Alma Linux 9

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions