Skip to content

Fix running astropy with python -OO - #3923

Merged
embray merged 3 commits into
astropy:masterfrom
embray:optimized-docstrings
Jul 13, 2015
Merged

embray merged 3 commits into
astropy:masterfrom
embray:optimized-docstrings

Conversation

@embray

@embray embray commented Jul 7, 2015

Copy link
Copy Markdown
Member

Motivated by this stack overflow question, fixes as many cases as I could find of code that assumes a method, class, or module's docstring will always be there, since when compiling the modules with python's -OO flag the docstrings can be removed, rendering Astropy inoperable due to these cases.

I tested this manually on Python 2 and 3 by running (in clean repos) python -OO setup.py test.

There is also an associated change to astropy-helpers that is needed. I would like to get that in first, then this PR can also include an update to the astropy-helpers submodule (which is overdue anyways).

Related: #960

@embray embray added this to the v1.0.4 milestone Jul 7, 2015
embray added a commit to embray/astropy_helpers that referenced this pull request Jul 7, 2015
…ll; even if we expect the docstring to exist it may not due to optimized compilation (see astropy/astropy#3923)
@mdboom

mdboom commented Jul 7, 2015

Copy link
Copy Markdown
Contributor

Why sometimes:

if isinstance(Foo.__doc__, six.string_types):

and sometimes:

if Foo.__doc__ is not None:

@embray

embray commented Jul 7, 2015

Copy link
Copy Markdown
Member Author

I wondered that myself, and I wrote the patch...

I guess in principle any knucklehead can assign anything they want to obj.__doc__, as unlikely as it seems. so the isinstance test makes sense. In places where I didn't use it I was just being lazy I think. It doesn't matter a whole lot but if it bugs you or anyone else I'll make it consistently one way or the other.

@mdboom

mdboom commented Jul 7, 2015

Copy link
Copy Markdown
Contributor

No -- doesn't bug me, just curious, really.

@embray

embray commented Jul 7, 2015

Copy link
Copy Markdown
Member Author

Temporary insanity, I guess.

@embray embray self-assigned this Jul 8, 2015
@embray

embray commented Jul 8, 2015

Copy link
Copy Markdown
Member Author

Updated the astropy_helpers submodule, and added a changelog entry.
Note to self: When backporting this patch to the v1.0.4 branch, the submodule should instead point to a backport of the astropy-helpers fix into astropy-helpers' v1.0.x branch, I guess...

embray added 3 commits July 13, 2015 10:44
…s, or module's docstring will always be there, since when compiling the modules with python's -OO flag the docstrings can be removed, rendering Astropy inoperable due to these cases.
@embray
embray force-pushed the optimized-docstrings branch from 36b9bd8 to fc6bf70 Compare July 13, 2015 14:44
embray added a commit that referenced this pull request Jul 13, 2015
Fix running astropy with python -OO
@embray
embray merged commit 2c51364 into astropy:master Jul 13, 2015
@embray
embray deleted the optimized-docstrings branch July 13, 2015 14:46
embray added a commit that referenced this pull request Aug 5, 2015
Fix running astropy with python -OO
Conflicts:
	astropy/units/function/units.py
	astropy_helpers
embray added a commit that referenced this pull request Aug 7, 2015
Fix running astropy with python -OO
Conflicts:
	astropy/units/function/units.py
	astropy_helpers
embray added a commit that referenced this pull request Aug 11, 2015
Fix running astropy with python -OO
Conflicts:
	astropy/units/function/units.py
	astropy_helpers
embray added a commit that referenced this pull request Aug 11, 2015
Fix running astropy with python -OO
Conflicts:
	astropy/units/function/units.py
	astropy_helpers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants