We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
IPython/utils/py3compat.py unused `with_metaclass` function. 
The function `with_metaclass` seem to be unused; 

we should :  check if it is used, if not remove the function .

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `IPython/utils/py3compat.py`
Content:
```
1 # coding: utf-8
2 """Compatibility tricks for Python 3. Mainly to do with unicode.
3 
4 This file is deprecated and will be removed in a future version.
5 """
6 import functools
7 import os
8 import sys
9 import re
10 import shutil
11 import types
12 import platform
13 
14 from .encoding import DEFAULT_ENCODING
15 
16 
17 def decode(s, encoding=None):
18     encoding = encoding or DEFAULT_ENCODING
19     return s.decode(encoding, "replace")
20 
21 def encode(u, encoding=None):
22     encoding = encoding or DEFAULT_ENCODING
23     return u.encode(encoding, "replace")
24 
25 
26 def cast_unicode(s, encoding=None):
27     if isinstance(s, bytes):
28         return decode(s, encoding)
29     return s
30 
31 def cast_bytes(s, encoding=None):
32     if not isinstance(s, bytes):
33         return encode(s, encoding)
34     return s
35 
36 def buffer_to_bytes(buf):
37     """Cast a buffer object to bytes"""
38     if not isinstance(buf, bytes):
39         buf = bytes(buf)
40     return buf
41 
42 def _modify_str_or_docstring(str_change_func):
43     @functools.wraps(str_change_func)
44     def wrapper(func_or_str):
45         if isinstance(func_or_str, (str,)):
46             func = None
47             doc = func_or_str
48         else:
49             func = func_or_str
50             doc = func.__doc__
51 
52         # PYTHONOPTIMIZE=2 strips docstrings, so they can disappear unexpectedly
53         if doc is not None:
54             doc = str_change_func(doc)
55 
56         if func:
57             func.__doc__ = doc
58             return func
59         return doc
60     return wrapper
61 
62 def safe_unicode(e):
63     """unicode(e) with various fallbacks. Used for exceptions, which may not be
64     safe to call unicode() on.
65     """
66     try:
67         return str(e)
68     except UnicodeError:
69         pass
70 
71     try:
72         return repr(e)
73     except UnicodeError:
74         pass
75 
76     return u'Unrecoverably corrupt evalue'
77 
78 # shutil.which from Python 3.4
79 def _shutil_which(cmd, mode=os.F_OK | os.X_OK, path=None):
80     """Given a command, mode, and a PATH string, return the path which
81     conforms to the given mode on the PATH, or None if there is no such
82     file.
83 
84     `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result
85     of os.environ.get("PATH"), or can be overridden with a custom search
86     path.
87 
88     This is a backport of shutil.which from Python 3.4
89     """
90     # Check that a given file can be accessed with the correct mode.
91     # Additionally check that `file` is not a directory, as on Windows
92     # directories pass the os.access check.
93     def _access_check(fn, mode):
94         return (os.path.exists(fn) and os.access(fn, mode)
95                 and not os.path.isdir(fn))
96 
97     # If we're given a path with a directory part, look it up directly rather
98     # than referring to PATH directories. This includes checking relative to the
99     # current directory, e.g. ./script
100     if os.path.dirname(cmd):
101         if _access_check(cmd, mode):
102             return cmd
103         return None
104 
105     if path is None:
106         path = os.environ.get("PATH", os.defpath)
107     if not path:
108         return None
109     path = path.split(os.pathsep)
110 
111     if sys.platform == "win32":
112         # The current directory takes precedence on Windows.
113         if not os.curdir in path:
114             path.insert(0, os.curdir)
115 
116         # PATHEXT is necessary to check on Windows.
117         pathext = os.environ.get("PATHEXT", "").split(os.pathsep)
118         # See if the given file matches any of the expected path extensions.
119         # This will allow us to short circuit when given "python.exe".
120         # If it does match, only test that one, otherwise we have to try
121         # others.
122         if any(cmd.lower().endswith(ext.lower()) for ext in pathext):
123             files = [cmd]
124         else:
125             files = [cmd + ext for ext in pathext]
126     else:
127         # On other platforms you don't have things like PATHEXT to tell you
128         # what file suffixes are executable, so just pass on cmd as-is.
129         files = [cmd]
130 
131     seen = set()
132     for dir in path:
133         normdir = os.path.normcase(dir)
134         if not normdir in seen:
135             seen.add(normdir)
136             for thefile in files:
137                 name = os.path.join(dir, thefile)
138                 if _access_check(name, mode):
139                     return name
140     return None
141 
142 PY3 = True
143 
144 # keep reference to builtin_mod because the kernel overrides that value
145 # to forward requests to a frontend.
146 def input(prompt=''):
147     return builtin_mod.input(prompt)
148 
149 builtin_mod_name = "builtins"
150 import builtins as builtin_mod
151 
152 
153 which = shutil.which
154 
155 def isidentifier(s, dotted=False):
156     if dotted:
157         return all(isidentifier(a) for a in s.split("."))
158     return s.isidentifier()
159 
160 getcwd = os.getcwd
161 
162 MethodType = types.MethodType
163 
164 def execfile(fname, glob, loc=None, compiler=None):
165     loc = loc if (loc is not None) else glob
166     with open(fname, 'rb') as f:
167         compiler = compiler or compile
168         exec(compiler(f.read(), fname, 'exec'), glob, loc)
169 
170 # Refactor print statements in doctests.
171 _print_statement_re = re.compile(r"\bprint (?P<expr>.*)$", re.MULTILINE)
172 def _print_statement_sub(match):
173     expr = match.groups('expr')
174     return "print(%s)" % expr
175 
176 # Abstract u'abc' syntax:
177 @_modify_str_or_docstring
178 def u_format(s):
179     """"{u}'abc'" --> "'abc'" (Python 3)
180 
181     Accepts a string or a function, so it can be used as a decorator."""
182     return s.format(u='')
183 
184 def get_closure(f):
185     """Get a function's closure attribute"""
186     return f.__closure__
187 
188 
189 PY2 = not PY3
190 PYPY = platform.python_implementation() == "PyPy"
191 
192 
193 
194 
195 # Parts below taken from six:
196 # Copyright (c) 2010-2013 Benjamin Peterson
197 #
198 # Permission is hereby granted, free of charge, to any person obtaining a copy
199 # of this software and associated documentation files (the "Software"), to deal
200 # in the Software without restriction, including without limitation the rights
201 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
202 # copies of the Software, and to permit persons to whom the Software is
203 # furnished to do so, subject to the following conditions:
204 #
205 # The above copyright notice and this permission notice shall be included in all
206 # copies or substantial portions of the Software.
207 #
208 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
209 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
210 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
211 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
212 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
213 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
214 # SOFTWARE.
215 
216 def with_metaclass(meta, *bases):
217     """Create a base class with a metaclass."""
218     return meta("_NewBase", bases, {})
219
```
--- 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/IPython/utils/py3compat.py b/IPython/utils/py3compat.py
--- a/IPython/utils/py3compat.py
+++ b/IPython/utils/py3compat.py
@@ -189,30 +189,3 @@
 PY2 = not PY3
 PYPY = platform.python_implementation() == "PyPy"
 
-
-
-
-# Parts below taken from six:
-# Copyright (c) 2010-2013 Benjamin Peterson
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-
-def with_metaclass(meta, *bases):
-    """Create a base class with a metaclass."""
-    return meta("_NewBase", bases, {})

{"golden_diff": "diff --git a/IPython/utils/py3compat.py b/IPython/utils/py3compat.py\n--- a/IPython/utils/py3compat.py\n+++ b/IPython/utils/py3compat.py\n@@ -189,30 +189,3 @@\n PY2 = not PY3\n PYPY = platform.python_implementation() == \"PyPy\"\n \n-\n-\n-\n-# Parts below taken from six:\n-# Copyright (c) 2010-2013 Benjamin Peterson\n-#\n-# Permission is hereby granted, free of charge, to any person obtaining a copy\n-# of this software and associated documentation files (the \"Software\"), to deal\n-# in the Software without restriction, including without limitation the rights\n-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n-# copies of the Software, and to permit persons to whom the Software is\n-# furnished to do so, subject to the following conditions:\n-#\n-# The above copyright notice and this permission notice shall be included in all\n-# copies or substantial portions of the Software.\n-#\n-# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n-# SOFTWARE.\n-\n-def with_metaclass(meta, *bases):\n-    \"\"\"Create a base class with a metaclass.\"\"\"\n-    return meta(\"_NewBase\", bases, {})\n", "issue": "IPython/utils/py3compat.py unused `with_metaclass` function. \nThe function `with_metaclass` seem to be unused; \r\n\r\nwe should :  check if it is used, if not remove the function .\n", "before_files": [{"content": "# coding: utf-8\n\"\"\"Compatibility tricks for Python 3. Mainly to do with unicode.\n\nThis file is deprecated and will be removed in a future version.\n\"\"\"\nimport functools\nimport os\nimport sys\nimport re\nimport shutil\nimport types\nimport platform\n\nfrom .encoding import DEFAULT_ENCODING\n\n\ndef decode(s, encoding=None):\n    encoding = encoding or DEFAULT_ENCODING\n    return s.decode(encoding, \"replace\")\n\ndef encode(u, encoding=None):\n    encoding = encoding or DEFAULT_ENCODING\n    return u.encode(encoding, \"replace\")\n\n\ndef cast_unicode(s, encoding=None):\n    if isinstance(s, bytes):\n        return decode(s, encoding)\n    return s\n\ndef cast_bytes(s, encoding=None):\n    if not isinstance(s, bytes):\n        return encode(s, encoding)\n    return s\n\ndef buffer_to_bytes(buf):\n    \"\"\"Cast a buffer object to bytes\"\"\"\n    if not isinstance(buf, bytes):\n        buf = bytes(buf)\n    return buf\n\ndef _modify_str_or_docstring(str_change_func):\n    @functools.wraps(str_change_func)\n    def wrapper(func_or_str):\n        if isinstance(func_or_str, (str,)):\n            func = None\n            doc = func_or_str\n        else:\n            func = func_or_str\n            doc = func.__doc__\n\n        # PYTHONOPTIMIZE=2 strips docstrings, so they can disappear unexpectedly\n        if doc is not None:\n            doc = str_change_func(doc)\n\n        if func:\n            func.__doc__ = doc\n            return func\n        return doc\n    return wrapper\n\ndef safe_unicode(e):\n    \"\"\"unicode(e) with various fallbacks. Used for exceptions, which may not be\n    safe to call unicode() on.\n    \"\"\"\n    try:\n        return str(e)\n    except UnicodeError:\n        pass\n\n    try:\n        return repr(e)\n    except UnicodeError:\n        pass\n\n    return u'Unrecoverably corrupt evalue'\n\n# shutil.which from Python 3.4\ndef _shutil_which(cmd, mode=os.F_OK | os.X_OK, path=None):\n    \"\"\"Given a command, mode, and a PATH string, return the path which\n    conforms to the given mode on the PATH, or None if there is no such\n    file.\n\n    `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result\n    of os.environ.get(\"PATH\"), or can be overridden with a custom search\n    path.\n\n    This is a backport of shutil.which from Python 3.4\n    \"\"\"\n    # Check that a given file can be accessed with the correct mode.\n    # Additionally check that `file` is not a directory, as on Windows\n    # directories pass the os.access check.\n    def _access_check(fn, mode):\n        return (os.path.exists(fn) and os.access(fn, mode)\n                and not os.path.isdir(fn))\n\n    # If we're given a path with a directory part, look it up directly rather\n    # than referring to PATH directories. This includes checking relative to the\n    # current directory, e.g. ./script\n    if os.path.dirname(cmd):\n        if _access_check(cmd, mode):\n            return cmd\n        return None\n\n    if path is None:\n        path = os.environ.get(\"PATH\", os.defpath)\n    if not path:\n        return None\n    path = path.split(os.pathsep)\n\n    if sys.platform == \"win32\":\n        # The current directory takes precedence on Windows.\n        if not os.curdir in path:\n            path.insert(0, os.curdir)\n\n        # PATHEXT is necessary to check on Windows.\n        pathext = os.environ.get(\"PATHEXT\", \"\").split(os.pathsep)\n        # See if the given file matches any of the expected path extensions.\n        # This will allow us to short circuit when given \"python.exe\".\n        # If it does match, only test that one, otherwise we have to try\n        # others.\n        if any(cmd.lower().endswith(ext.lower()) for ext in pathext):\n            files = [cmd]\n        else:\n            files = [cmd + ext for ext in pathext]\n    else:\n        # On other platforms you don't have things like PATHEXT to tell you\n        # what file suffixes are executable, so just pass on cmd as-is.\n        files = [cmd]\n\n    seen = set()\n    for dir in path:\n        normdir = os.path.normcase(dir)\n        if not normdir in seen:\n            seen.add(normdir)\n            for thefile in files:\n                name = os.path.join(dir, thefile)\n                if _access_check(name, mode):\n                    return name\n    return None\n\nPY3 = True\n\n# keep reference to builtin_mod because the kernel overrides that value\n# to forward requests to a frontend.\ndef input(prompt=''):\n    return builtin_mod.input(prompt)\n\nbuiltin_mod_name = \"builtins\"\nimport builtins as builtin_mod\n\n\nwhich = shutil.which\n\ndef isidentifier(s, dotted=False):\n    if dotted:\n        return all(isidentifier(a) for a in s.split(\".\"))\n    return s.isidentifier()\n\ngetcwd = os.getcwd\n\nMethodType = types.MethodType\n\ndef execfile(fname, glob, loc=None, compiler=None):\n    loc = loc if (loc is not None) else glob\n    with open(fname, 'rb') as f:\n        compiler = compiler or compile\n        exec(compiler(f.read(), fname, 'exec'), glob, loc)\n\n# Refactor print statements in doctests.\n_print_statement_re = re.compile(r\"\\bprint (?P<expr>.*)$\", re.MULTILINE)\ndef _print_statement_sub(match):\n    expr = match.groups('expr')\n    return \"print(%s)\" % expr\n\n# Abstract u'abc' syntax:\n@_modify_str_or_docstring\ndef u_format(s):\n    \"\"\"\"{u}'abc'\" --> \"'abc'\" (Python 3)\n\n    Accepts a string or a function, so it can be used as a decorator.\"\"\"\n    return s.format(u='')\n\ndef get_closure(f):\n    \"\"\"Get a function's closure attribute\"\"\"\n    return f.__closure__\n\n\nPY2 = not PY3\nPYPY = platform.python_implementation() == \"PyPy\"\n\n\n\n\n# Parts below taken from six:\n# Copyright (c) 2010-2013 Benjamin Peterson\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\ndef with_metaclass(meta, *bases):\n    \"\"\"Create a base class with a metaclass.\"\"\"\n    return meta(\"_NewBase\", bases, {})\n", "path": "IPython/utils/py3compat.py"}], "after_files": [{"content": "# coding: utf-8\n\"\"\"Compatibility tricks for Python 3. Mainly to do with unicode.\n\nThis file is deprecated and will be removed in a future version.\n\"\"\"\nimport functools\nimport os\nimport sys\nimport re\nimport shutil\nimport types\nimport platform\n\nfrom .encoding import DEFAULT_ENCODING\n\n\ndef decode(s, encoding=None):\n    encoding = encoding or DEFAULT_ENCODING\n    return s.decode(encoding, \"replace\")\n\ndef encode(u, encoding=None):\n    encoding = encoding or DEFAULT_ENCODING\n    return u.encode(encoding, \"replace\")\n\n\ndef cast_unicode(s, encoding=None):\n    if isinstance(s, bytes):\n        return decode(s, encoding)\n    return s\n\ndef cast_bytes(s, encoding=None):\n    if not isinstance(s, bytes):\n        return encode(s, encoding)\n    return s\n\ndef buffer_to_bytes(buf):\n    \"\"\"Cast a buffer object to bytes\"\"\"\n    if not isinstance(buf, bytes):\n        buf = bytes(buf)\n    return buf\n\ndef _modify_str_or_docstring(str_change_func):\n    @functools.wraps(str_change_func)\n    def wrapper(func_or_str):\n        if isinstance(func_or_str, (str,)):\n            func = None\n            doc = func_or_str\n        else:\n            func = func_or_str\n            doc = func.__doc__\n\n        # PYTHONOPTIMIZE=2 strips docstrings, so they can disappear unexpectedly\n        if doc is not None:\n            doc = str_change_func(doc)\n\n        if func:\n            func.__doc__ = doc\n            return func\n        return doc\n    return wrapper\n\ndef safe_unicode(e):\n    \"\"\"unicode(e) with various fallbacks. Used for exceptions, which may not be\n    safe to call unicode() on.\n    \"\"\"\n    try:\n        return str(e)\n    except UnicodeError:\n        pass\n\n    try:\n        return repr(e)\n    except UnicodeError:\n        pass\n\n    return u'Unrecoverably corrupt evalue'\n\n# shutil.which from Python 3.4\ndef _shutil_which(cmd, mode=os.F_OK | os.X_OK, path=None):\n    \"\"\"Given a command, mode, and a PATH string, return the path which\n    conforms to the given mode on the PATH, or None if there is no such\n    file.\n\n    `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result\n    of os.environ.get(\"PATH\"), or can be overridden with a custom search\n    path.\n\n    This is a backport of shutil.which from Python 3.4\n    \"\"\"\n    # Check that a given file can be accessed with the correct mode.\n    # Additionally check that `file` is not a directory, as on Windows\n    # directories pass the os.access check.\n    def _access_check(fn, mode):\n        return (os.path.exists(fn) and os.access(fn, mode)\n                and not os.path.isdir(fn))\n\n    # If we're given a path with a directory part, look it up directly rather\n    # than referring to PATH directories. This includes checking relative to the\n    # current directory, e.g. ./script\n    if os.path.dirname(cmd):\n        if _access_check(cmd, mode):\n            return cmd\n        return None\n\n    if path is None:\n        path = os.environ.get(\"PATH\", os.defpath)\n    if not path:\n        return None\n    path = path.split(os.pathsep)\n\n    if sys.platform == \"win32\":\n        # The current directory takes precedence on Windows.\n        if not os.curdir in path:\n            path.insert(0, os.curdir)\n\n        # PATHEXT is necessary to check on Windows.\n        pathext = os.environ.get(\"PATHEXT\", \"\").split(os.pathsep)\n        # See if the given file matches any of the expected path extensions.\n        # This will allow us to short circuit when given \"python.exe\".\n        # If it does match, only test that one, otherwise we have to try\n        # others.\n        if any(cmd.lower().endswith(ext.lower()) for ext in pathext):\n            files = [cmd]\n        else:\n            files = [cmd + ext for ext in pathext]\n    else:\n        # On other platforms you don't have things like PATHEXT to tell you\n        # what file suffixes are executable, so just pass on cmd as-is.\n        files = [cmd]\n\n    seen = set()\n    for dir in path:\n        normdir = os.path.normcase(dir)\n        if not normdir in seen:\n            seen.add(normdir)\n            for thefile in files:\n                name = os.path.join(dir, thefile)\n                if _access_check(name, mode):\n                    return name\n    return None\n\nPY3 = True\n\n# keep reference to builtin_mod because the kernel overrides that value\n# to forward requests to a frontend.\ndef input(prompt=''):\n    return builtin_mod.input(prompt)\n\nbuiltin_mod_name = \"builtins\"\nimport builtins as builtin_mod\n\n\nwhich = shutil.which\n\ndef isidentifier(s, dotted=False):\n    if dotted:\n        return all(isidentifier(a) for a in s.split(\".\"))\n    return s.isidentifier()\n\ngetcwd = os.getcwd\n\nMethodType = types.MethodType\n\ndef execfile(fname, glob, loc=None, compiler=None):\n    loc = loc if (loc is not None) else glob\n    with open(fname, 'rb') as f:\n        compiler = compiler or compile\n        exec(compiler(f.read(), fname, 'exec'), glob, loc)\n\n# Refactor print statements in doctests.\n_print_statement_re = re.compile(r\"\\bprint (?P<expr>.*)$\", re.MULTILINE)\ndef _print_statement_sub(match):\n    expr = match.groups('expr')\n    return \"print(%s)\" % expr\n\n# Abstract u'abc' syntax:\n@_modify_str_or_docstring\ndef u_format(s):\n    \"\"\"\"{u}'abc'\" --> \"'abc'\" (Python 3)\n\n    Accepts a string or a function, so it can be used as a decorator.\"\"\"\n    return s.format(u='')\n\ndef get_closure(f):\n    \"\"\"Get a function's closure attribute\"\"\"\n    return f.__closure__\n\n\nPY2 = not PY3\nPYPY = platform.python_implementation() == \"PyPy\"\n\n", "path": "IPython/utils/py3compat.py"}]}