Repository: pandas-dev/pandas

Issue:
Can't run in optimized mode on Ubuntu 
If I start python with a -O flag, I get an error as soon as I import pandas

``` python
python -O
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/username/.virtualenvs/thm/local/lib/python2.7/site-packages/pandas/__init__.py", line 45, in <module>
    from pandas.io.api import *
  File "/home/username/.virtualenvs/thm/local/lib/python2.7/site-packages/pandas/io/api.py", line 11, in <module>
    from pandas.io.sql import read_sql, read_sql_table, read_sql_query
  File "/home/username/.virtualenvs/thm/local/lib/python2.7/site-packages/pandas/io/sql.py", line 1243, in <module>
    read_frame.__doc__ += read_sql.__doc__
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'NoneType'
```

The lines causing the issue are:

``` python
# Append wrapped function docstrings
read_frame.__doc__ += read_sql.__doc__
frame_query.__doc__ += read_sql.__doc__
```

It appears as if python is stripping the docstrings, which then causes issues. Commenting the lines out fixes the problem.

I'm on Ubuntu 14.04.1 LTS, my version info is:

``` python

>>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-29-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.14.1
nose: 1.3.0
Cython: None
numpy: 1.8.0
scipy: 0.9.0
statsmodels: None
IPython: None
sphinx: None
patsy: None
scikits.timeseries: None
dateutil: 2.2
pytz: 2013.9
bottleneck: 0.8.0
tables: None
numexpr: 2.4
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
rpy2: None
sqlalchemy: 0.9.7
pymysql: None
psycopg2: None
```



Discussion:
I'm on OS X and have the same issue with python3.

## INSTALLED VERSIONS

commit: None
python: 3.4.2.final.0
python-bits: 64
OS: Darwin
OS-release: 14.0.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.15.1
nose: None
Cython: None
numpy: 1.9.1
scipy: 0.14.0
statsmodels: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.2
pytz: 2014.9
bottleneck: 0.8.0
tables: None
numexpr: 2.4
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
rpy2: None
sqlalchemy: None
pymysql: None
psycopg2: None

I suppose that these doc strings should use the Appender decorator which deals this issue iirc

pull requests welcome!


Resolving patch:
diff --git a/pandas/io/sql.py b/pandas/io/sql.py
--- a/pandas/io/sql.py
+++ b/pandas/io/sql.py
@@ -19,6 +19,7 @@
 from pandas.core.common import isnull
 from pandas.core.base import PandasObject
 from pandas.tseries.tools import to_datetime
+from pandas.util.decorators import Appender
 
 from contextlib import contextmanager
 
@@ -1533,6 +1534,7 @@ def get_schema(frame, name, flavor='sqlite', keys=None, con=None):
 
 # legacy names, with depreciation warnings and copied docs
 
+@Appender(read_sql.__doc__, join='\n')
 def read_frame(*args, **kwargs):
     """DEPRECATED - use read_sql
     """
@@ -1540,6 +1542,7 @@ def read_frame(*args, **kwargs):
     return read_sql(*args, **kwargs)
 
 
+@Appender(read_sql.__doc__, join='\n')
 def frame_query(*args, **kwargs):
     """DEPRECATED - use read_sql
     """
@@ -1587,8 +1590,3 @@ def write_frame(frame, name, con, flavor='sqlite', if_exists='fail', **kwargs):
     index = kwargs.pop('index', False)
     return to_sql(frame, name, con, flavor=flavor, if_exists=if_exists,
                   index=index, **kwargs)
-
-
-# Append wrapped function docstrings
-read_frame.__doc__ += read_sql.__doc__
-frame_query.__doc__ += read_sql.__doc__


Test patch: