We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
many 'no dictionary for class' warnings using get_file()
Using get_file() results in many 'no dictionary for class' warnings:

``` python
>>> from rootpy.testdata import get_file
>>> get_file()
INFO:rootpy.logger] | No default log handler configured. See `logging` module |
INFO:rootpy.logger] \    To suppress: 'rootpy.log.basic_config_colorized()'   /
WARNING:ROOT.TClass.TClass] no dictionary for class TH1F is available
WARNING:ROOT.TClass.TClass] no dictionary for class TH1 is available
WARNING:ROOT.TClass.TClass] no dictionary for class TAxis is available
WARNING:ROOT.TClass.TClass] no dictionary for class TH2F is available
WARNING:ROOT.TClass.TClass] no dictionary for class TH2 is available
WARNING:ROOT.TClass.TClass] no dictionary for class TH3F is available
WARNING:ROOT.TClass.TClass] no dictionary for class TH3 is available
WARNING:ROOT.TClass.TClass] no dictionary for class TGraphAsymmErrors is available
WARNING:ROOT.TClass.TClass] no dictionary for class TGraph is available
WARNING:ROOT.TClass.TClass] no dictionary for class TGraphErrors is available
WARNING:ROOT.TClass.TClass] no dictionary for class TGraph2D is available
File('/home/sschmitt/.local/lib/python2.7/site-packages/rootpy-dev-py2.7.egg/rootpy/testdata/test_file.root')
```

Everything works nonetheless.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `rootpy/io/file.py`
Content:
```
1 # Copyright 2012 the rootpy developers
2 # distributed under the terms of the GNU General Public License
3 """
4 This module enhances IO-related ROOT functionality
5 """
6 import ROOT
7 
8 from ..core import Object
9 from ..decorators import snake_case_methods
10 from .. import asrootpy, QROOT
11 from . import utils, DoesNotExist
12 from ..util import path
13 
14 import tempfile
15 import os
16 import warnings
17 
18 
19 __all__ = [
20     'Directory',
21     'File',
22     'TemporaryFile',
23     'root_open',
24     'open', # deprecated
25 ]
26 
27 
28 VALIDPATH = '^(?P<file>.+.root)(?:[/](?P<path>.+))?$'
29 GLOBALS = {}
30 
31 
32 def wrap_path_handling(f):
33 
34     def get(self, name, **kwargs):
35 
36         _name = os.path.normpath(name)
37         if _name == '.':
38             return self
39         if _name == '..':
40             return self._parent
41         try:
42             dir, _, path = _name.partition(os.path.sep)
43             if path:
44                 if dir == '..':
45                     return self._parent.Get(path, **kwargs)
46                 else:
47                     _dir = f(self, dir)
48                     if not isinstance(_dir, _DirectoryBase):
49                         raise DoesNotExist
50                     _dir._parent = self
51                     _dir._path = os.path.join(self._path, dir)
52                     thing = _dir.Get(path, **kwargs)
53             else:
54                 thing = f(self, _name, **kwargs)
55                 if isinstance(thing, _DirectoryBase):
56                     thing._parent = self
57             if isinstance(thing, _DirectoryBase):
58                 if isinstance(self, File):
59                     thing._path = os.path.normpath(
60                             (':' + os.path.sep).join([self._path, _name]))
61                 else:
62                     thing._path = os.path.normpath(
63                             os.path.join(self._path, _name))
64             return thing
65         except DoesNotExist:
66             raise DoesNotExist("requested path '%s' does not exist in %s" %
67                     (name, self._path))
68     return get
69 
70 
71 class _DirectoryBase(Object):
72     """
73     A mixin (can't stand alone).
74     """
75     def walk(self, top=None, class_pattern=None):
76         """
77         Calls :func:`rootpy.io.utils.walk`.
78         """
79         return utils.walk(self, top, class_pattern=class_pattern)
80 
81     def __getattr__(self, attr):
82         """
83         Natural naming support. Now you can get an object from a
84         File/Directory with::
85 
86             myfile.somedir.otherdir.histname
87         """
88         # Be careful! If ``__getattr__`` ends up being called again here,
89         # this can end up in an "infinite" recursion and stack overflow.
90 
91         # Directly call ROOT's Get() here since ``attr`` must anyway be a valid
92         # identifier (not a path including subdirectories).
93         thing = super(_DirectoryBase, self).Get(attr)
94         if not thing:
95             raise AttributeError
96         thing = asrootpy(thing)
97         if isinstance(thing, Directory):
98             thing._path = os.path.join(self._path, thing.GetName())
99             thing._parent = self
100         return thing
101 
102     def __getitem__(self, name):
103 
104         return self.Get(name)
105 
106     def __iter__(self):
107 
108         return self.walk()
109 
110     def keys(self):
111 
112         return self.GetListOfKeys()
113 
114     def unique_keys(self):
115 
116         keys = {}
117         for key in self.keys():
118             keys[key.GetName()] = key
119         return keys.values()
120 
121     @wrap_path_handling
122     def Get(self, name, **kwargs):
123         """
124         Attempt to convert requested object into rootpy form
125         """
126         thing = super(_DirectoryBase, self).Get(name)
127         if not thing:
128             raise DoesNotExist
129         return asrootpy(thing, **kwargs)
130 
131     def GetRaw(self, name):
132         """
133         Raw access without conversion into rootpy form
134         """
135         thing = super(_DirectoryBase, self).Get(name)
136         if not thing:
137             raise DoesNotExist
138         return thing
139 
140     @wrap_path_handling
141     def GetDirectory(self, name, **kwargs):
142         """
143         Return a Directory object rather than TDirectory
144         """
145         rdir = super(_DirectoryBase, self).GetDirectory(name)
146         if not rdir:
147             raise DoesNotExist
148         return asrootpy(rdir, **kwargs)
149 
150 
151 @snake_case_methods
152 class Directory(_DirectoryBase, QROOT.TDirectoryFile):
153     """
154     Inherits from TDirectory
155     """
156     def __init__(self, name, title, *args, **kwargs):
157 
158         super(Directory, self).__init__(name, title, *args, **kwargs)
159         self._post_init()
160 
161     def _post_init(self):
162 
163         self._path = self.GetName()
164         self._parent = ROOT.gDirectory.func()
165 
166     def __str__(self):
167 
168         return "%s('%s')" % (self.__class__.__name__, self._path)
169 
170     def __repr__(self):
171 
172         return self.__str__()
173 
174 
175 @snake_case_methods
176 class File(_DirectoryBase, QROOT.TFile):
177     """
178     Wrapper for TFile that adds various convenience functions.
179 
180     >>> from rootpy.test import filename
181     >>> f = File(filename, 'read')
182 
183     """
184     def __init__(self, name, *args, **kwargs):
185 
186         super(File, self).__init__(name, *args, **kwargs)
187         self._path = self.GetName()
188         self._parent = self
189 
190     def __enter__(self):
191 
192         return self
193 
194     def __exit__(self, type, value, traceback):
195 
196         self.Close()
197         return False
198 
199     def __str__(self):
200 
201         return "%s('%s')" % (self.__class__.__name__, self._path)
202 
203     def __repr__(self):
204 
205         return self.__str__()
206 
207 
208 @snake_case_methods
209 class TemporaryFile(File, QROOT.TFile):
210     """
211     A temporary ROOT file that is automatically deleted when closed.
212     Uses Python's :func:`tempfile.mkstemp` to obtain a temporary file
213     in the most secure manner possible.
214 
215     Positional and keyword arguments are passed directly to
216     :func:`tempfile.mkstemp`
217     """
218     def __init__(self, *args, **kwargs):
219 
220         self.__fd, self.__tmp_path = tempfile.mkstemp(*args, **kwargs)
221         File.__init__(self, self.__tmp_path, 'recreate')
222 
223     def Close(self):
224 
225         super(TemporaryFile, self).Close()
226         os.close(self.__fd)
227         os.remove(self.__tmp_path)
228 
229     def __exit__(self, type, value, traceback):
230 
231         self.Close()
232         return False
233 
234 
235 def root_open(filename, mode=""):
236 
237     filename = path.expand(filename)
238     root_file = ROOT.TFile.Open(filename, mode)
239     # fix evil segfault after attempt to open bad file in 5.30
240     # this fix is not needed in 5.32
241     # GetListOfClosedObjects() does not appear until 5.30
242     if ROOT.gROOT.GetVersionInt() >= 53000:
243         GLOBALS['CLOSEDOBJECTS'] = ROOT.gROOT.GetListOfClosedObjects()
244     if not root_file:
245         raise IOError("Could not open file: '%s'" % filename)
246     root_file.__class__ = File
247     root_file._path = filename
248     root_file._parent = root_file
249     return root_file
250 
251 
252 def open(filename, mode=""):
253 
254     warnings.warn("Use root_open instead; open is deprecated.",
255                   DeprecationWarning)
256     return root_open(filename, mode)
257
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/rootpy/io/file.py b/rootpy/io/file.py
--- a/rootpy/io/file.py
+++ b/rootpy/io/file.py
@@ -183,6 +183,8 @@
     """
     def __init__(self, name, *args, **kwargs):
 
+        # trigger finalSetup
+        ROOT.kTRUE
         super(File, self).__init__(name, *args, **kwargs)
         self._path = self.GetName()
         self._parent = self
@@ -218,7 +220,7 @@
     def __init__(self, *args, **kwargs):
 
         self.__fd, self.__tmp_path = tempfile.mkstemp(*args, **kwargs)
-        File.__init__(self, self.__tmp_path, 'recreate')
+        super(TemporaryFile, self).__init__(self.__tmp_path, 'recreate')
 
     def Close(self):

{"golden_diff": "diff --git a/rootpy/io/file.py b/rootpy/io/file.py\n--- a/rootpy/io/file.py\n+++ b/rootpy/io/file.py\n@@ -183,6 +183,8 @@\n     \"\"\"\n     def __init__(self, name, *args, **kwargs):\n \n+        # trigger finalSetup\n+        ROOT.kTRUE\n         super(File, self).__init__(name, *args, **kwargs)\n         self._path = self.GetName()\n         self._parent = self\n@@ -218,7 +220,7 @@\n     def __init__(self, *args, **kwargs):\n \n         self.__fd, self.__tmp_path = tempfile.mkstemp(*args, **kwargs)\n-        File.__init__(self, self.__tmp_path, 'recreate')\n+        super(TemporaryFile, self).__init__(self.__tmp_path, 'recreate')\n \n     def Close(self):\n", "issue": "many 'no dictionary for class' warnings using get_file()\nUsing get_file() results in many 'no dictionary for class' warnings:\n\n``` python\n>>> from rootpy.testdata import get_file\n>>> get_file()\nINFO:rootpy.logger] | No default log handler configured. See `logging` module |\nINFO:rootpy.logger] \\    To suppress: 'rootpy.log.basic_config_colorized()'   /\nWARNING:ROOT.TClass.TClass] no dictionary for class TH1F is available\nWARNING:ROOT.TClass.TClass] no dictionary for class TH1 is available\nWARNING:ROOT.TClass.TClass] no dictionary for class TAxis is available\nWARNING:ROOT.TClass.TClass] no dictionary for class TH2F is available\nWARNING:ROOT.TClass.TClass] no dictionary for class TH2 is available\nWARNING:ROOT.TClass.TClass] no dictionary for class TH3F is available\nWARNING:ROOT.TClass.TClass] no dictionary for class TH3 is available\nWARNING:ROOT.TClass.TClass] no dictionary for class TGraphAsymmErrors is available\nWARNING:ROOT.TClass.TClass] no dictionary for class TGraph is available\nWARNING:ROOT.TClass.TClass] no dictionary for class TGraphErrors is available\nWARNING:ROOT.TClass.TClass] no dictionary for class TGraph2D is available\nFile('/home/sschmitt/.local/lib/python2.7/site-packages/rootpy-dev-py2.7.egg/rootpy/testdata/test_file.root')\n```\n\nEverything works nonetheless.\n\n", "before_files": [{"content": "# Copyright 2012 the rootpy developers\n# distributed under the terms of the GNU General Public License\n\"\"\"\nThis module enhances IO-related ROOT functionality\n\"\"\"\nimport ROOT\n\nfrom ..core import Object\nfrom ..decorators import snake_case_methods\nfrom .. import asrootpy, QROOT\nfrom . import utils, DoesNotExist\nfrom ..util import path\n\nimport tempfile\nimport os\nimport warnings\n\n\n__all__ = [\n    'Directory',\n    'File',\n    'TemporaryFile',\n    'root_open',\n    'open', # deprecated\n]\n\n\nVALIDPATH = '^(?P<file>.+.root)(?:[/](?P<path>.+))?$'\nGLOBALS = {}\n\n\ndef wrap_path_handling(f):\n\n    def get(self, name, **kwargs):\n\n        _name = os.path.normpath(name)\n        if _name == '.':\n            return self\n        if _name == '..':\n            return self._parent\n        try:\n            dir, _, path = _name.partition(os.path.sep)\n            if path:\n                if dir == '..':\n                    return self._parent.Get(path, **kwargs)\n                else:\n                    _dir = f(self, dir)\n                    if not isinstance(_dir, _DirectoryBase):\n                        raise DoesNotExist\n                    _dir._parent = self\n                    _dir._path = os.path.join(self._path, dir)\n                    thing = _dir.Get(path, **kwargs)\n            else:\n                thing = f(self, _name, **kwargs)\n                if isinstance(thing, _DirectoryBase):\n                    thing._parent = self\n            if isinstance(thing, _DirectoryBase):\n                if isinstance(self, File):\n                    thing._path = os.path.normpath(\n                            (':' + os.path.sep).join([self._path, _name]))\n                else:\n                    thing._path = os.path.normpath(\n                            os.path.join(self._path, _name))\n            return thing\n        except DoesNotExist:\n            raise DoesNotExist(\"requested path '%s' does not exist in %s\" %\n                    (name, self._path))\n    return get\n\n\nclass _DirectoryBase(Object):\n    \"\"\"\n    A mixin (can't stand alone).\n    \"\"\"\n    def walk(self, top=None, class_pattern=None):\n        \"\"\"\n        Calls :func:`rootpy.io.utils.walk`.\n        \"\"\"\n        return utils.walk(self, top, class_pattern=class_pattern)\n\n    def __getattr__(self, attr):\n        \"\"\"\n        Natural naming support. Now you can get an object from a\n        File/Directory with::\n\n            myfile.somedir.otherdir.histname\n        \"\"\"\n        # Be careful! If ``__getattr__`` ends up being called again here,\n        # this can end up in an \"infinite\" recursion and stack overflow.\n\n        # Directly call ROOT's Get() here since ``attr`` must anyway be a valid\n        # identifier (not a path including subdirectories).\n        thing = super(_DirectoryBase, self).Get(attr)\n        if not thing:\n            raise AttributeError\n        thing = asrootpy(thing)\n        if isinstance(thing, Directory):\n            thing._path = os.path.join(self._path, thing.GetName())\n            thing._parent = self\n        return thing\n\n    def __getitem__(self, name):\n\n        return self.Get(name)\n\n    def __iter__(self):\n\n        return self.walk()\n\n    def keys(self):\n\n        return self.GetListOfKeys()\n\n    def unique_keys(self):\n\n        keys = {}\n        for key in self.keys():\n            keys[key.GetName()] = key\n        return keys.values()\n\n    @wrap_path_handling\n    def Get(self, name, **kwargs):\n        \"\"\"\n        Attempt to convert requested object into rootpy form\n        \"\"\"\n        thing = super(_DirectoryBase, self).Get(name)\n        if not thing:\n            raise DoesNotExist\n        return asrootpy(thing, **kwargs)\n\n    def GetRaw(self, name):\n        \"\"\"\n        Raw access without conversion into rootpy form\n        \"\"\"\n        thing = super(_DirectoryBase, self).Get(name)\n        if not thing:\n            raise DoesNotExist\n        return thing\n\n    @wrap_path_handling\n    def GetDirectory(self, name, **kwargs):\n        \"\"\"\n        Return a Directory object rather than TDirectory\n        \"\"\"\n        rdir = super(_DirectoryBase, self).GetDirectory(name)\n        if not rdir:\n            raise DoesNotExist\n        return asrootpy(rdir, **kwargs)\n\n\n@snake_case_methods\nclass Directory(_DirectoryBase, QROOT.TDirectoryFile):\n    \"\"\"\n    Inherits from TDirectory\n    \"\"\"\n    def __init__(self, name, title, *args, **kwargs):\n\n        super(Directory, self).__init__(name, title, *args, **kwargs)\n        self._post_init()\n\n    def _post_init(self):\n\n        self._path = self.GetName()\n        self._parent = ROOT.gDirectory.func()\n\n    def __str__(self):\n\n        return \"%s('%s')\" % (self.__class__.__name__, self._path)\n\n    def __repr__(self):\n\n        return self.__str__()\n\n\n@snake_case_methods\nclass File(_DirectoryBase, QROOT.TFile):\n    \"\"\"\n    Wrapper for TFile that adds various convenience functions.\n\n    >>> from rootpy.test import filename\n    >>> f = File(filename, 'read')\n\n    \"\"\"\n    def __init__(self, name, *args, **kwargs):\n\n        super(File, self).__init__(name, *args, **kwargs)\n        self._path = self.GetName()\n        self._parent = self\n\n    def __enter__(self):\n\n        return self\n\n    def __exit__(self, type, value, traceback):\n\n        self.Close()\n        return False\n\n    def __str__(self):\n\n        return \"%s('%s')\" % (self.__class__.__name__, self._path)\n\n    def __repr__(self):\n\n        return self.__str__()\n\n\n@snake_case_methods\nclass TemporaryFile(File, QROOT.TFile):\n    \"\"\"\n    A temporary ROOT file that is automatically deleted when closed.\n    Uses Python's :func:`tempfile.mkstemp` to obtain a temporary file\n    in the most secure manner possible.\n\n    Positional and keyword arguments are passed directly to\n    :func:`tempfile.mkstemp`\n    \"\"\"\n    def __init__(self, *args, **kwargs):\n\n        self.__fd, self.__tmp_path = tempfile.mkstemp(*args, **kwargs)\n        File.__init__(self, self.__tmp_path, 'recreate')\n\n    def Close(self):\n\n        super(TemporaryFile, self).Close()\n        os.close(self.__fd)\n        os.remove(self.__tmp_path)\n\n    def __exit__(self, type, value, traceback):\n\n        self.Close()\n        return False\n\n\ndef root_open(filename, mode=\"\"):\n\n    filename = path.expand(filename)\n    root_file = ROOT.TFile.Open(filename, mode)\n    # fix evil segfault after attempt to open bad file in 5.30\n    # this fix is not needed in 5.32\n    # GetListOfClosedObjects() does not appear until 5.30\n    if ROOT.gROOT.GetVersionInt() >= 53000:\n        GLOBALS['CLOSEDOBJECTS'] = ROOT.gROOT.GetListOfClosedObjects()\n    if not root_file:\n        raise IOError(\"Could not open file: '%s'\" % filename)\n    root_file.__class__ = File\n    root_file._path = filename\n    root_file._parent = root_file\n    return root_file\n\n\ndef open(filename, mode=\"\"):\n\n    warnings.warn(\"Use root_open instead; open is deprecated.\",\n                  DeprecationWarning)\n    return root_open(filename, mode)\n", "path": "rootpy/io/file.py"}], "after_files": [{"content": "# Copyright 2012 the rootpy developers\n# distributed under the terms of the GNU General Public License\n\"\"\"\nThis module enhances IO-related ROOT functionality\n\"\"\"\nimport ROOT\n\nfrom ..core import Object\nfrom ..decorators import snake_case_methods\nfrom .. import asrootpy, QROOT\nfrom . import utils, DoesNotExist\nfrom ..util import path\n\nimport tempfile\nimport os\nimport warnings\n\n\n__all__ = [\n    'Directory',\n    'File',\n    'TemporaryFile',\n    'root_open',\n    'open', # deprecated\n]\n\n\nVALIDPATH = '^(?P<file>.+.root)(?:[/](?P<path>.+))?$'\nGLOBALS = {}\n\n\ndef wrap_path_handling(f):\n\n    def get(self, name, **kwargs):\n\n        _name = os.path.normpath(name)\n        if _name == '.':\n            return self\n        if _name == '..':\n            return self._parent\n        try:\n            dir, _, path = _name.partition(os.path.sep)\n            if path:\n                if dir == '..':\n                    return self._parent.Get(path, **kwargs)\n                else:\n                    _dir = f(self, dir)\n                    if not isinstance(_dir, _DirectoryBase):\n                        raise DoesNotExist\n                    _dir._parent = self\n                    _dir._path = os.path.join(self._path, dir)\n                    thing = _dir.Get(path, **kwargs)\n            else:\n                thing = f(self, _name, **kwargs)\n                if isinstance(thing, _DirectoryBase):\n                    thing._parent = self\n            if isinstance(thing, _DirectoryBase):\n                if isinstance(self, File):\n                    thing._path = os.path.normpath(\n                            (':' + os.path.sep).join([self._path, _name]))\n                else:\n                    thing._path = os.path.normpath(\n                            os.path.join(self._path, _name))\n            return thing\n        except DoesNotExist:\n            raise DoesNotExist(\"requested path '%s' does not exist in %s\" %\n                    (name, self._path))\n    return get\n\n\nclass _DirectoryBase(Object):\n    \"\"\"\n    A mixin (can't stand alone).\n    \"\"\"\n    def walk(self, top=None, class_pattern=None):\n        \"\"\"\n        Calls :func:`rootpy.io.utils.walk`.\n        \"\"\"\n        return utils.walk(self, top, class_pattern=class_pattern)\n\n    def __getattr__(self, attr):\n        \"\"\"\n        Natural naming support. Now you can get an object from a\n        File/Directory with::\n\n            myfile.somedir.otherdir.histname\n        \"\"\"\n        # Be careful! If ``__getattr__`` ends up being called again here,\n        # this can end up in an \"infinite\" recursion and stack overflow.\n\n        # Directly call ROOT's Get() here since ``attr`` must anyway be a valid\n        # identifier (not a path including subdirectories).\n        thing = super(_DirectoryBase, self).Get(attr)\n        if not thing:\n            raise AttributeError\n        thing = asrootpy(thing)\n        if isinstance(thing, Directory):\n            thing._path = os.path.join(self._path, thing.GetName())\n            thing._parent = self\n        return thing\n\n    def __getitem__(self, name):\n\n        return self.Get(name)\n\n    def __iter__(self):\n\n        return self.walk()\n\n    def keys(self):\n\n        return self.GetListOfKeys()\n\n    def unique_keys(self):\n\n        keys = {}\n        for key in self.keys():\n            keys[key.GetName()] = key\n        return keys.values()\n\n    @wrap_path_handling\n    def Get(self, name, **kwargs):\n        \"\"\"\n        Attempt to convert requested object into rootpy form\n        \"\"\"\n        thing = super(_DirectoryBase, self).Get(name)\n        if not thing:\n            raise DoesNotExist\n        return asrootpy(thing, **kwargs)\n\n    def GetRaw(self, name):\n        \"\"\"\n        Raw access without conversion into rootpy form\n        \"\"\"\n        thing = super(_DirectoryBase, self).Get(name)\n        if not thing:\n            raise DoesNotExist\n        return thing\n\n    @wrap_path_handling\n    def GetDirectory(self, name, **kwargs):\n        \"\"\"\n        Return a Directory object rather than TDirectory\n        \"\"\"\n        rdir = super(_DirectoryBase, self).GetDirectory(name)\n        if not rdir:\n            raise DoesNotExist\n        return asrootpy(rdir, **kwargs)\n\n\n@snake_case_methods\nclass Directory(_DirectoryBase, QROOT.TDirectoryFile):\n    \"\"\"\n    Inherits from TDirectory\n    \"\"\"\n    def __init__(self, name, title, *args, **kwargs):\n\n        super(Directory, self).__init__(name, title, *args, **kwargs)\n        self._post_init()\n\n    def _post_init(self):\n\n        self._path = self.GetName()\n        self._parent = ROOT.gDirectory.func()\n\n    def __str__(self):\n\n        return \"%s('%s')\" % (self.__class__.__name__, self._path)\n\n    def __repr__(self):\n\n        return self.__str__()\n\n\n@snake_case_methods\nclass File(_DirectoryBase, QROOT.TFile):\n    \"\"\"\n    Wrapper for TFile that adds various convenience functions.\n\n    >>> from rootpy.test import filename\n    >>> f = File(filename, 'read')\n\n    \"\"\"\n    def __init__(self, name, *args, **kwargs):\n\n        # trigger finalSetup\n        ROOT.kTRUE\n        super(File, self).__init__(name, *args, **kwargs)\n        self._path = self.GetName()\n        self._parent = self\n\n    def __enter__(self):\n\n        return self\n\n    def __exit__(self, type, value, traceback):\n\n        self.Close()\n        return False\n\n    def __str__(self):\n\n        return \"%s('%s')\" % (self.__class__.__name__, self._path)\n\n    def __repr__(self):\n\n        return self.__str__()\n\n\n@snake_case_methods\nclass TemporaryFile(File, QROOT.TFile):\n    \"\"\"\n    A temporary ROOT file that is automatically deleted when closed.\n    Uses Python's :func:`tempfile.mkstemp` to obtain a temporary file\n    in the most secure manner possible.\n\n    Positional and keyword arguments are passed directly to\n    :func:`tempfile.mkstemp`\n    \"\"\"\n    def __init__(self, *args, **kwargs):\n\n        self.__fd, self.__tmp_path = tempfile.mkstemp(*args, **kwargs)\n        super(TemporaryFile, self).__init__(self.__tmp_path, 'recreate')\n\n    def Close(self):\n\n        super(TemporaryFile, self).Close()\n        os.close(self.__fd)\n        os.remove(self.__tmp_path)\n\n    def __exit__(self, type, value, traceback):\n\n        self.Close()\n        return False\n\n\ndef root_open(filename, mode=\"\"):\n\n    filename = path.expand(filename)\n    root_file = ROOT.TFile.Open(filename, mode)\n    # fix evil segfault after attempt to open bad file in 5.30\n    # this fix is not needed in 5.32\n    # GetListOfClosedObjects() does not appear until 5.30\n    if ROOT.gROOT.GetVersionInt() >= 53000:\n        GLOBALS['CLOSEDOBJECTS'] = ROOT.gROOT.GetListOfClosedObjects()\n    if not root_file:\n        raise IOError(\"Could not open file: '%s'\" % filename)\n    root_file.__class__ = File\n    root_file._path = filename\n    root_file._parent = root_file\n    return root_file\n\n\ndef open(filename, mode=\"\"):\n\n    warnings.warn(\"Use root_open instead; open is deprecated.\",\n                  DeprecationWarning)\n    return root_open(filename, mode)\n", "path": "rootpy/io/file.py"}]}