We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
maximum recursion depth exceeded
Dear rootpyers,
(adding @taroni and @ekfriis who might be interested)

I just updated rootpy to the following commit:
99aaea62f16e7db8d2215c50831d85d798026db6 and I started getting a bunch of errors when retrieving an histogram from a view

Exception RuntimeError: 'maximum recursion depth exceeded in **subclasscheck**' in <type 'exceptions.RuntimeError'> ignored

the problem persist updating to the current head but was not there in 44eedc1265023bb366324f134584c76d999a1631

Can you help me sorting this thing out?

Thank you


--- 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). To be improved.
74     """
75 
76     def walk(self, top=None, class_pattern=None):
77         """
78         Calls :func:`rootpy.io.utils.walk`.
79         """
80         return utils.walk(self, top, class_pattern=class_pattern)
81 
82     def __getattr__(self, attr):
83         """
84         Natural naming support.
85         Now you can get an object from a File/Directory with
86         myfile.somedir.otherdir.histname
87 
88         Must be careful here... if __getattr__ ends up being called
89         in Get this can end up in an "infinite" recursion and stack overflow
90         """
91         return self.Get(attr)
92 
93     def __getitem__(self, name):
94 
95         return self.Get(name)
96 
97     def __iter__(self):
98 
99         return self.walk()
100 
101     def keys(self):
102 
103         return self.GetListOfKeys()
104 
105     def unique_keys(self):
106 
107         keys = {}
108         for key in self.keys():
109             keys[key.GetName()] = key
110         return keys.values()
111 
112     @wrap_path_handling
113     def Get(self, name, **kwargs):
114         """
115         Attempt to convert requested object into rootpy form
116         """
117         thing = self.ROOT_base.Get(self, name)
118         if not thing:
119             raise DoesNotExist
120         return asrootpy(thing, **kwargs)
121 
122     def GetRaw(self, name):
123         """
124         Raw access without conversion into rootpy form
125         """
126         thing = self.ROOT_base.Get(self, name)
127         if not thing:
128             raise DoesNotExist
129         return thing
130 
131     @wrap_path_handling
132     def GetDirectory(self, name, **kwargs):
133         """
134         Return a Directory object rather than TDirectory
135         """
136         dir = self.ROOT_base.GetDirectory(self, name)
137         if not dir:
138             raise DoesNotExist
139         return asrootpy(dir, **kwargs)
140 
141     def cd(self, *args):
142 
143         self.ROOT_base.cd(self, *args)
144 
145 
146 @snake_case_methods
147 class Directory(_DirectoryBase, QROOT.TDirectoryFile):
148     """
149     Inherits from TDirectory
150     """
151 
152     def __init__(self, name, title, *args, **kwargs):
153 
154         ROOT.TDirectoryFile.__init__(self, name, title, *args)
155         self._path = name
156         self._parent = None
157 
158     def __str__(self):
159 
160         return "%s('%s')" % (self.__class__.__name__, self._path)
161 
162     def __repr__(self):
163 
164         return self.__str__()
165 
166 
167 @snake_case_methods
168 class File(_DirectoryBase, QROOT.TFile):
169     """
170     Wrapper for TFile that adds various convenience functions.
171 
172     >>> from rootpy.test import filename
173     >>> f = File(filename, 'read')
174 
175     """
176 
177     def __init__(self, *args, **kwargs):
178 
179         ROOT.TFile.__init__(self, *args, **kwargs)
180         self._path = self.GetName()
181         self._parent = self
182 
183     def __enter__(self):
184 
185         return self
186 
187     def __exit__(self, type, value, traceback):
188 
189         self.Close()
190         return False
191 
192     def __str__(self):
193 
194         return "%s('%s')" % (self.__class__.__name__, self._path)
195 
196     def __repr__(self):
197 
198         return self.__str__()
199 
200 
201 @snake_case_methods
202 class TemporaryFile(File, QROOT.TFile):
203     """
204     A temporary ROOT file that is automatically deleted when closed.
205     Uses Python's :func:`tempfile.mkstemp` to obtain a temporary file
206     in the most secure manner possible.
207 
208     Positional and keyword arguments are passed directly to
209     :func:`tempfile.mkstemp`
210     """
211     def __init__(self, *args, **kwargs):
212 
213         self.__fd, self.__tmp_path = tempfile.mkstemp(*args, **kwargs)
214         super(TemporaryFile, self).__init__(self.__tmp_path, 'recreate')
215 
216     def Close(self):
217 
218         super(TemporaryFile, self).Close()
219         os.close(self.__fd)
220         os.remove(self.__tmp_path)
221 
222     def __exit__(self, type, value, traceback):
223 
224         self.Close()
225         return False
226 
227 
228 def root_open(filename, mode=""):
229 
230     filename = path.expand(filename)
231     root_file = ROOT.TFile.Open(filename, mode)
232     # fix evil segfault after attempt to open bad file in 5.30
233     # this fix is not needed in 5.32
234     # GetListOfClosedObjects() does not appear until 5.30
235     if ROOT.gROOT.GetVersionInt() >= 53000:
236         GLOBALS['CLOSEDOBJECTS'] = ROOT.gROOT.GetListOfClosedObjects()
237     if not root_file:
238         raise IOError("Could not open file: '%s'" % filename)
239     root_file.__class__ = File
240     root_file._path = filename
241     root_file._parent = root_file
242     return root_file
243 
244 
245 def open(filename, mode=""):
246 
247     warnings.warn("Use root_open instead; open is deprecated.",
248                   DeprecationWarning)
249     return root_open(filename, mode)
250
```
--- 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
@@ -70,9 +70,8 @@
 
 class _DirectoryBase(Object):
     """
-    A mixin (can't stand alone). To be improved.
+    A mixin (can't stand alone).
     """
-
     def walk(self, top=None, class_pattern=None):
         """
         Calls :func:`rootpy.io.utils.walk`.
@@ -81,14 +80,20 @@
 
     def __getattr__(self, attr):
         """
-        Natural naming support.
-        Now you can get an object from a File/Directory with
-        myfile.somedir.otherdir.histname
+        Natural naming support. Now you can get an object from a
+        File/Directory with::
 
-        Must be careful here... if __getattr__ ends up being called
-        in Get this can end up in an "infinite" recursion and stack overflow
+            myfile.somedir.otherdir.histname
         """
-        return self.Get(attr)
+        # Be careful! If ``__getattr__`` ends up being called again here,
+        # this can end up in an "infinite" recursion and stack overflow.
+
+        # Directly call ROOT's Get() here since ``attr`` must anyway be a valid
+        # identifier (not a path including subdirectories).
+        thing = self.ROOT_base.Get(self, attr)
+        if not thing:
+            raise AttributeError
+        return asrootpy(thing)
 
     def __getitem__(self, name):
 
@@ -148,10 +153,9 @@
     """
     Inherits from TDirectory
     """
-
     def __init__(self, name, title, *args, **kwargs):
 
-        ROOT.TDirectoryFile.__init__(self, name, title, *args)
+        ROOT.TDirectoryFile.__init__(self, name, title, *args, **kwargs)
         self._path = name
         self._parent = None
 
@@ -173,10 +177,9 @@
     >>> f = File(filename, 'read')
 
     """
+    def __init__(self, name, *args, **kwargs):
 
-    def __init__(self, *args, **kwargs):
-
-        ROOT.TFile.__init__(self, *args, **kwargs)
+        ROOT.TFile.__init__(self, name, *args, **kwargs)
         self._path = self.GetName()
         self._parent = self
 
@@ -211,7 +214,7 @@
     def __init__(self, *args, **kwargs):
 
         self.__fd, self.__tmp_path = tempfile.mkstemp(*args, **kwargs)
-        super(TemporaryFile, self).__init__(self.__tmp_path, 'recreate')
+        File.__init__(self, 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@@ -70,9 +70,8 @@\n \n class _DirectoryBase(Object):\n     \"\"\"\n-    A mixin (can't stand alone). To be improved.\n+    A mixin (can't stand alone).\n     \"\"\"\n-\n     def walk(self, top=None, class_pattern=None):\n         \"\"\"\n         Calls :func:`rootpy.io.utils.walk`.\n@@ -81,14 +80,20 @@\n \n     def __getattr__(self, attr):\n         \"\"\"\n-        Natural naming support.\n-        Now you can get an object from a File/Directory with\n-        myfile.somedir.otherdir.histname\n+        Natural naming support. Now you can get an object from a\n+        File/Directory with::\n \n-        Must be careful here... if __getattr__ ends up being called\n-        in Get this can end up in an \"infinite\" recursion and stack overflow\n+            myfile.somedir.otherdir.histname\n         \"\"\"\n-        return self.Get(attr)\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 = self.ROOT_base.Get(self, attr)\n+        if not thing:\n+            raise AttributeError\n+        return asrootpy(thing)\n \n     def __getitem__(self, name):\n \n@@ -148,10 +153,9 @@\n     \"\"\"\n     Inherits from TDirectory\n     \"\"\"\n-\n     def __init__(self, name, title, *args, **kwargs):\n \n-        ROOT.TDirectoryFile.__init__(self, name, title, *args)\n+        ROOT.TDirectoryFile.__init__(self, name, title, *args, **kwargs)\n         self._path = name\n         self._parent = None\n \n@@ -173,10 +177,9 @@\n     >>> f = File(filename, 'read')\n \n     \"\"\"\n+    def __init__(self, name, *args, **kwargs):\n \n-    def __init__(self, *args, **kwargs):\n-\n-        ROOT.TFile.__init__(self, *args, **kwargs)\n+        ROOT.TFile.__init__(self, name, *args, **kwargs)\n         self._path = self.GetName()\n         self._parent = self\n \n@@ -211,7 +214,7 @@\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+        File.__init__(self, self.__tmp_path, 'recreate')\n \n     def Close(self):\n", "issue": "maximum recursion depth exceeded\nDear rootpyers,\n(adding @taroni and @ekfriis who might be interested)\n\nI just updated rootpy to the following commit:\n99aaea62f16e7db8d2215c50831d85d798026db6 and I started getting a bunch of errors when retrieving an histogram from a view\n\nException RuntimeError: 'maximum recursion depth exceeded in **subclasscheck**' in <type 'exceptions.RuntimeError'> ignored\n\nthe problem persist updating to the current head but was not there in 44eedc1265023bb366324f134584c76d999a1631\n\nCan you help me sorting this thing out?\n\nThank you\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). To be improved.\n    \"\"\"\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.\n        Now you can get an object from a File/Directory with\n        myfile.somedir.otherdir.histname\n\n        Must be careful here... if __getattr__ ends up being called\n        in Get this can end up in an \"infinite\" recursion and stack overflow\n        \"\"\"\n        return self.Get(attr)\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 = self.ROOT_base.Get(self, 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 = self.ROOT_base.Get(self, 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        dir = self.ROOT_base.GetDirectory(self, name)\n        if not dir:\n            raise DoesNotExist\n        return asrootpy(dir, **kwargs)\n\n    def cd(self, *args):\n\n        self.ROOT_base.cd(self, *args)\n\n\n@snake_case_methods\nclass Directory(_DirectoryBase, QROOT.TDirectoryFile):\n    \"\"\"\n    Inherits from TDirectory\n    \"\"\"\n\n    def __init__(self, name, title, *args, **kwargs):\n\n        ROOT.TDirectoryFile.__init__(self, name, title, *args)\n        self._path = name\n        self._parent = None\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\n    def __init__(self, *args, **kwargs):\n\n        ROOT.TFile.__init__(self, *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"}], "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 = self.ROOT_base.Get(self, attr)\n        if not thing:\n            raise AttributeError\n        return asrootpy(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 = self.ROOT_base.Get(self, 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 = self.ROOT_base.Get(self, 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        dir = self.ROOT_base.GetDirectory(self, name)\n        if not dir:\n            raise DoesNotExist\n        return asrootpy(dir, **kwargs)\n\n    def cd(self, *args):\n\n        self.ROOT_base.cd(self, *args)\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        ROOT.TDirectoryFile.__init__(self, name, title, *args, **kwargs)\n        self._path = name\n        self._parent = None\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        ROOT.TFile.__init__(self, 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"}]}