We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Test failures and docs don't build on Mac OS X Lion
I have installed the latest ipython from github (f30a572977be51a1b928788540e323ab9bc9c58f) via `python setup.py install --user`.

There are a few test failures and the docs don't build:
http://dl.dropbox.com/u/4923986/bug_reports/ipython-tests.log
http://dl.dropbox.com/u/4923986/bug_reports/ipython-docs.log

Let me know if I should create separate tickets for some of these issues. It's hard for me to tell which are known and which are new. I know that the docs v3 problem wasn't there a few weeks ago. 

Note that I am using iterm2 (http://www.iterm2.com/, Build 1.0.0.20110821) instead of the default Apple terminal, in case it matters.


--- 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/sysinfo.py`
Content:
```
1 # encoding: utf-8
2 """
3 Utilities for getting information about IPython and the system it's running in.
4 """
5 
6 #-----------------------------------------------------------------------------
7 #  Copyright (C) 2008-2011  The IPython Development Team
8 #
9 #  Distributed under the terms of the BSD License.  The full license is in
10 #  the file COPYING, distributed as part of this software.
11 #-----------------------------------------------------------------------------
12 
13 #-----------------------------------------------------------------------------
14 # Imports
15 #-----------------------------------------------------------------------------
16 
17 import os
18 import platform
19 import pprint
20 import sys
21 import subprocess
22 
23 from ConfigParser import ConfigParser
24 
25 from IPython.core import release
26 from IPython.utils import py3compat, _sysinfo
27 
28 #-----------------------------------------------------------------------------
29 # Code
30 #-----------------------------------------------------------------------------
31 
32 def pkg_commit_hash(pkg_path):
33     """Get short form of commit hash given directory `pkg_path`
34 
35     We get the commit hash from (in order of preference):
36 
37     * IPython.utils._sysinfo.commit
38     * git output, if we are in a git repository
39 
40     If these fail, we return a not-found placeholder tuple
41 
42     Parameters
43     ----------
44     pkg_path : str
45        directory containing package
46        only used for getting commit from active repo
47 
48     Returns
49     -------
50     hash_from : str
51        Where we got the hash from - description
52     hash_str : str
53        short form of hash
54     """
55     # Try and get commit from written commit text file
56     if _sysinfo.commit:
57         return "installation", _sysinfo.commit
58 
59     # maybe we are in a repository
60     proc = subprocess.Popen('git rev-parse --short HEAD',
61                             stdout=subprocess.PIPE,
62                             stderr=subprocess.PIPE,
63                             cwd=pkg_path, shell=True)
64     repo_commit, _ = proc.communicate()
65     if repo_commit:
66         return 'repository', repo_commit.strip()
67     return '(none found)', '<not found>'
68 
69 
70 def pkg_info(pkg_path):
71     """Return dict describing the context of this package
72 
73     Parameters
74     ----------
75     pkg_path : str
76        path containing __init__.py for package
77 
78     Returns
79     -------
80     context : dict
81        with named parameters of interest
82     """
83     src, hsh = pkg_commit_hash(pkg_path)
84     return dict(
85         ipython_version=release.version,
86         ipython_path=pkg_path,
87         commit_source=src,
88         commit_hash=hsh,
89         sys_version=sys.version,
90         sys_executable=sys.executable,
91         sys_platform=sys.platform,
92         platform=platform.platform(),
93         os_name=os.name,
94         )
95 
96 
97 @py3compat.doctest_refactor_print
98 def sys_info():
99     """Return useful information about IPython and the system, as a string.
100 
101     Example
102     -------
103     In [2]: print sys_info()
104     {'commit_hash': '144fdae',      # random
105      'commit_source': 'repository',
106      'ipython_path': '/home/fperez/usr/lib/python2.6/site-packages/IPython',
107      'ipython_version': '0.11.dev',
108      'os_name': 'posix',
109      'platform': 'Linux-2.6.35-22-generic-i686-with-Ubuntu-10.10-maverick',
110      'sys_executable': '/usr/bin/python',
111      'sys_platform': 'linux2',
112      'sys_version': '2.6.6 (r266:84292, Sep 15 2010, 15:52:39) \\n[GCC 4.4.5]'}
113    """
114     p = os.path
115     path = p.dirname(p.abspath(p.join(__file__, '..')))
116     return pprint.pformat(pkg_info(path))
117 
118 
119 def _num_cpus_unix():
120     """Return the number of active CPUs on a Unix system."""
121     return os.sysconf("SC_NPROCESSORS_ONLN")
122 
123 
124 def _num_cpus_darwin():
125     """Return the number of active CPUs on a Darwin system."""
126     p = subprocess.Popen(['sysctl','-n','hw.ncpu'],stdout=subprocess.PIPE)
127     return p.stdout.read()
128 
129 
130 def _num_cpus_windows():
131     """Return the number of active CPUs on a Windows system."""
132     return os.environ.get("NUMBER_OF_PROCESSORS")
133 
134 
135 def num_cpus():
136    """Return the effective number of CPUs in the system as an integer.
137 
138    This cross-platform function makes an attempt at finding the total number of
139    available CPUs in the system, as returned by various underlying system and
140    python calls.
141 
142    If it can't find a sensible answer, it returns 1 (though an error *may* make
143    it return a large positive number that's actually incorrect).
144    """
145 
146    # Many thanks to the Parallel Python project (http://www.parallelpython.com)
147    # for the names of the keys we needed to look up for this function.  This
148    # code was inspired by their equivalent function.
149 
150    ncpufuncs = {'Linux':_num_cpus_unix,
151                 'Darwin':_num_cpus_darwin,
152                 'Windows':_num_cpus_windows,
153                 # On Vista, python < 2.5.2 has a bug and returns 'Microsoft'
154                 # See http://bugs.python.org/issue1082 for details.
155                 'Microsoft':_num_cpus_windows,
156                 }
157 
158    ncpufunc = ncpufuncs.get(platform.system(),
159                             # default to unix version (Solaris, AIX, etc)
160                             _num_cpus_unix)
161 
162    try:
163        ncpus = max(1,int(ncpufunc()))
164    except:
165        ncpus = 1
166    return ncpus
167 
168
```
--- 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/sysinfo.py b/IPython/utils/sysinfo.py
--- a/IPython/utils/sysinfo.py
+++ b/IPython/utils/sysinfo.py
@@ -23,7 +23,7 @@
 from ConfigParser import ConfigParser
 
 from IPython.core import release
-from IPython.utils import py3compat, _sysinfo
+from IPython.utils import py3compat, _sysinfo, encoding
 
 #-----------------------------------------------------------------------------
 # Code
@@ -91,6 +91,7 @@
         sys_platform=sys.platform,
         platform=platform.platform(),
         os_name=os.name,
+        default_encoding=encoding.DEFAULT_ENCODING,
         )

{"golden_diff": "diff --git a/IPython/utils/sysinfo.py b/IPython/utils/sysinfo.py\n--- a/IPython/utils/sysinfo.py\n+++ b/IPython/utils/sysinfo.py\n@@ -23,7 +23,7 @@\n from ConfigParser import ConfigParser\n \n from IPython.core import release\n-from IPython.utils import py3compat, _sysinfo\n+from IPython.utils import py3compat, _sysinfo, encoding\n \n #-----------------------------------------------------------------------------\n # Code\n@@ -91,6 +91,7 @@\n         sys_platform=sys.platform,\n         platform=platform.platform(),\n         os_name=os.name,\n+        default_encoding=encoding.DEFAULT_ENCODING,\n         )\n", "issue": "Test failures and docs don't build on Mac OS X Lion\nI have installed the latest ipython from github (f30a572977be51a1b928788540e323ab9bc9c58f) via `python setup.py install --user`.\n\nThere are a few test failures and the docs don't build:\nhttp://dl.dropbox.com/u/4923986/bug_reports/ipython-tests.log\nhttp://dl.dropbox.com/u/4923986/bug_reports/ipython-docs.log\n\nLet me know if I should create separate tickets for some of these issues. It's hard for me to tell which are known and which are new. I know that the docs v3 problem wasn't there a few weeks ago. \n\nNote that I am using iterm2 (http://www.iterm2.com/, Build 1.0.0.20110821) instead of the default Apple terminal, in case it matters.\n\n", "before_files": [{"content": "# encoding: utf-8\n\"\"\"\nUtilities for getting information about IPython and the system it's running in.\n\"\"\"\n\n#-----------------------------------------------------------------------------\n#  Copyright (C) 2008-2011  The IPython Development Team\n#\n#  Distributed under the terms of the BSD License.  The full license is in\n#  the file COPYING, distributed as part of this software.\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\n\nimport os\nimport platform\nimport pprint\nimport sys\nimport subprocess\n\nfrom ConfigParser import ConfigParser\n\nfrom IPython.core import release\nfrom IPython.utils import py3compat, _sysinfo\n\n#-----------------------------------------------------------------------------\n# Code\n#-----------------------------------------------------------------------------\n\ndef pkg_commit_hash(pkg_path):\n    \"\"\"Get short form of commit hash given directory `pkg_path`\n\n    We get the commit hash from (in order of preference):\n\n    * IPython.utils._sysinfo.commit\n    * git output, if we are in a git repository\n\n    If these fail, we return a not-found placeholder tuple\n\n    Parameters\n    ----------\n    pkg_path : str\n       directory containing package\n       only used for getting commit from active repo\n\n    Returns\n    -------\n    hash_from : str\n       Where we got the hash from - description\n    hash_str : str\n       short form of hash\n    \"\"\"\n    # Try and get commit from written commit text file\n    if _sysinfo.commit:\n        return \"installation\", _sysinfo.commit\n\n    # maybe we are in a repository\n    proc = subprocess.Popen('git rev-parse --short HEAD',\n                            stdout=subprocess.PIPE,\n                            stderr=subprocess.PIPE,\n                            cwd=pkg_path, shell=True)\n    repo_commit, _ = proc.communicate()\n    if repo_commit:\n        return 'repository', repo_commit.strip()\n    return '(none found)', '<not found>'\n\n\ndef pkg_info(pkg_path):\n    \"\"\"Return dict describing the context of this package\n\n    Parameters\n    ----------\n    pkg_path : str\n       path containing __init__.py for package\n\n    Returns\n    -------\n    context : dict\n       with named parameters of interest\n    \"\"\"\n    src, hsh = pkg_commit_hash(pkg_path)\n    return dict(\n        ipython_version=release.version,\n        ipython_path=pkg_path,\n        commit_source=src,\n        commit_hash=hsh,\n        sys_version=sys.version,\n        sys_executable=sys.executable,\n        sys_platform=sys.platform,\n        platform=platform.platform(),\n        os_name=os.name,\n        )\n\n\n@py3compat.doctest_refactor_print\ndef sys_info():\n    \"\"\"Return useful information about IPython and the system, as a string.\n\n    Example\n    -------\n    In [2]: print sys_info()\n    {'commit_hash': '144fdae',      # random\n     'commit_source': 'repository',\n     'ipython_path': '/home/fperez/usr/lib/python2.6/site-packages/IPython',\n     'ipython_version': '0.11.dev',\n     'os_name': 'posix',\n     'platform': 'Linux-2.6.35-22-generic-i686-with-Ubuntu-10.10-maverick',\n     'sys_executable': '/usr/bin/python',\n     'sys_platform': 'linux2',\n     'sys_version': '2.6.6 (r266:84292, Sep 15 2010, 15:52:39) \\\\n[GCC 4.4.5]'}\n   \"\"\"\n    p = os.path\n    path = p.dirname(p.abspath(p.join(__file__, '..')))\n    return pprint.pformat(pkg_info(path))\n\n\ndef _num_cpus_unix():\n    \"\"\"Return the number of active CPUs on a Unix system.\"\"\"\n    return os.sysconf(\"SC_NPROCESSORS_ONLN\")\n\n\ndef _num_cpus_darwin():\n    \"\"\"Return the number of active CPUs on a Darwin system.\"\"\"\n    p = subprocess.Popen(['sysctl','-n','hw.ncpu'],stdout=subprocess.PIPE)\n    return p.stdout.read()\n\n\ndef _num_cpus_windows():\n    \"\"\"Return the number of active CPUs on a Windows system.\"\"\"\n    return os.environ.get(\"NUMBER_OF_PROCESSORS\")\n\n\ndef num_cpus():\n   \"\"\"Return the effective number of CPUs in the system as an integer.\n\n   This cross-platform function makes an attempt at finding the total number of\n   available CPUs in the system, as returned by various underlying system and\n   python calls.\n\n   If it can't find a sensible answer, it returns 1 (though an error *may* make\n   it return a large positive number that's actually incorrect).\n   \"\"\"\n\n   # Many thanks to the Parallel Python project (http://www.parallelpython.com)\n   # for the names of the keys we needed to look up for this function.  This\n   # code was inspired by their equivalent function.\n\n   ncpufuncs = {'Linux':_num_cpus_unix,\n                'Darwin':_num_cpus_darwin,\n                'Windows':_num_cpus_windows,\n                # On Vista, python < 2.5.2 has a bug and returns 'Microsoft'\n                # See http://bugs.python.org/issue1082 for details.\n                'Microsoft':_num_cpus_windows,\n                }\n\n   ncpufunc = ncpufuncs.get(platform.system(),\n                            # default to unix version (Solaris, AIX, etc)\n                            _num_cpus_unix)\n\n   try:\n       ncpus = max(1,int(ncpufunc()))\n   except:\n       ncpus = 1\n   return ncpus\n\n", "path": "IPython/utils/sysinfo.py"}], "after_files": [{"content": "# encoding: utf-8\n\"\"\"\nUtilities for getting information about IPython and the system it's running in.\n\"\"\"\n\n#-----------------------------------------------------------------------------\n#  Copyright (C) 2008-2011  The IPython Development Team\n#\n#  Distributed under the terms of the BSD License.  The full license is in\n#  the file COPYING, distributed as part of this software.\n#-----------------------------------------------------------------------------\n\n#-----------------------------------------------------------------------------\n# Imports\n#-----------------------------------------------------------------------------\n\nimport os\nimport platform\nimport pprint\nimport sys\nimport subprocess\n\nfrom ConfigParser import ConfigParser\n\nfrom IPython.core import release\nfrom IPython.utils import py3compat, _sysinfo, encoding\n\n#-----------------------------------------------------------------------------\n# Code\n#-----------------------------------------------------------------------------\n\ndef pkg_commit_hash(pkg_path):\n    \"\"\"Get short form of commit hash given directory `pkg_path`\n\n    We get the commit hash from (in order of preference):\n\n    * IPython.utils._sysinfo.commit\n    * git output, if we are in a git repository\n\n    If these fail, we return a not-found placeholder tuple\n\n    Parameters\n    ----------\n    pkg_path : str\n       directory containing package\n       only used for getting commit from active repo\n\n    Returns\n    -------\n    hash_from : str\n       Where we got the hash from - description\n    hash_str : str\n       short form of hash\n    \"\"\"\n    # Try and get commit from written commit text file\n    if _sysinfo.commit:\n        return \"installation\", _sysinfo.commit\n\n    # maybe we are in a repository\n    proc = subprocess.Popen('git rev-parse --short HEAD',\n                            stdout=subprocess.PIPE,\n                            stderr=subprocess.PIPE,\n                            cwd=pkg_path, shell=True)\n    repo_commit, _ = proc.communicate()\n    if repo_commit:\n        return 'repository', repo_commit.strip()\n    return '(none found)', '<not found>'\n\n\ndef pkg_info(pkg_path):\n    \"\"\"Return dict describing the context of this package\n\n    Parameters\n    ----------\n    pkg_path : str\n       path containing __init__.py for package\n\n    Returns\n    -------\n    context : dict\n       with named parameters of interest\n    \"\"\"\n    src, hsh = pkg_commit_hash(pkg_path)\n    return dict(\n        ipython_version=release.version,\n        ipython_path=pkg_path,\n        commit_source=src,\n        commit_hash=hsh,\n        sys_version=sys.version,\n        sys_executable=sys.executable,\n        sys_platform=sys.platform,\n        platform=platform.platform(),\n        os_name=os.name,\n        default_encoding=encoding.DEFAULT_ENCODING,\n        )\n\n\n@py3compat.doctest_refactor_print\ndef sys_info():\n    \"\"\"Return useful information about IPython and the system, as a string.\n\n    Example\n    -------\n    In [2]: print sys_info()\n    {'commit_hash': '144fdae',      # random\n     'commit_source': 'repository',\n     'ipython_path': '/home/fperez/usr/lib/python2.6/site-packages/IPython',\n     'ipython_version': '0.11.dev',\n     'os_name': 'posix',\n     'platform': 'Linux-2.6.35-22-generic-i686-with-Ubuntu-10.10-maverick',\n     'sys_executable': '/usr/bin/python',\n     'sys_platform': 'linux2',\n     'sys_version': '2.6.6 (r266:84292, Sep 15 2010, 15:52:39) \\\\n[GCC 4.4.5]'}\n   \"\"\"\n    p = os.path\n    path = p.dirname(p.abspath(p.join(__file__, '..')))\n    return pprint.pformat(pkg_info(path))\n\n\ndef _num_cpus_unix():\n    \"\"\"Return the number of active CPUs on a Unix system.\"\"\"\n    return os.sysconf(\"SC_NPROCESSORS_ONLN\")\n\n\ndef _num_cpus_darwin():\n    \"\"\"Return the number of active CPUs on a Darwin system.\"\"\"\n    p = subprocess.Popen(['sysctl','-n','hw.ncpu'],stdout=subprocess.PIPE)\n    return p.stdout.read()\n\n\ndef _num_cpus_windows():\n    \"\"\"Return the number of active CPUs on a Windows system.\"\"\"\n    return os.environ.get(\"NUMBER_OF_PROCESSORS\")\n\n\ndef num_cpus():\n   \"\"\"Return the effective number of CPUs in the system as an integer.\n\n   This cross-platform function makes an attempt at finding the total number of\n   available CPUs in the system, as returned by various underlying system and\n   python calls.\n\n   If it can't find a sensible answer, it returns 1 (though an error *may* make\n   it return a large positive number that's actually incorrect).\n   \"\"\"\n\n   # Many thanks to the Parallel Python project (http://www.parallelpython.com)\n   # for the names of the keys we needed to look up for this function.  This\n   # code was inspired by their equivalent function.\n\n   ncpufuncs = {'Linux':_num_cpus_unix,\n                'Darwin':_num_cpus_darwin,\n                'Windows':_num_cpus_windows,\n                # On Vista, python < 2.5.2 has a bug and returns 'Microsoft'\n                # See http://bugs.python.org/issue1082 for details.\n                'Microsoft':_num_cpus_windows,\n                }\n\n   ncpufunc = ncpufuncs.get(platform.system(),\n                            # default to unix version (Solaris, AIX, etc)\n                            _num_cpus_unix)\n\n   try:\n       ncpus = max(1,int(ncpufunc()))\n   except:\n       ncpus = 1\n   return ncpus\n\n", "path": "IPython/utils/sysinfo.py"}]}