Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

axes3d.py: Several docstrings concatenate with NoneType #5018

Closed
CfKu opened this issue Sep 3, 2015 · 4 comments
Closed

axes3d.py: Several docstrings concatenate with NoneType #5018

CfKu opened this issue Sep 3, 2015 · 4 comments

Comments

@CfKu
Copy link

CfKu commented Sep 3, 2015

If I run a python application which uses axes3d

from mpl_toolkits.mplot3d import Axes3D

with

python -OO myscript.py

I get several type errors like

TypeError: unsupported operand type(s) for +=: 'NoneType' and 'unicode'

where docstrings are concatenated.

 - near line 730: get_xlim.__doc__ += ...
 - near line 739: get_ylim.__doc__ += ...
 - near line 764: set_xscale.__doc__ = ...
 - near line 774: set_yscale.__doc__ = ...

Python 2.7.9 :: Continuum Analytics, Inc.
matplotlib 1.4.3

@CfKu CfKu changed the title axes3d.py: Docstrings concatenates with None when aaxes3d.py: Several Docstrings concatenates with None Sep 3, 2015
@CfKu CfKu changed the title aaxes3d.py: Several Docstrings concatenates with None aaxes3d.py: Several docstrings concatenates with NoneType Sep 3, 2015
@CfKu CfKu changed the title aaxes3d.py: Several docstrings concatenates with NoneType aaxes3d.py: Several docstrings concatenate with NoneType Sep 3, 2015
@CfKu CfKu changed the title aaxes3d.py: Several docstrings concatenate with NoneType axes3d.py: Several docstrings concatenate with NoneType Sep 3, 2015
@WeatherGod
Copy link
Member

In order for that to happen, something has to be seriously wrong with your install. Here is the full codeblock for one of those docstring concatenations:

    get_xlim3d.__doc__ = maxes.Axes.get_xlim.__doc__
    get_xlim = get_xlim3d
    get_xlim.__doc__ += """
        .. versionchanged :: 1.1.0
            This function now correctly refers to the 3D x-limits
        """

where maxes is matplotlib.axes. In order for get_xlim.__doc__ to be None, maxes.Axes.get_xlim.__doc__ has to be None as well. I just don't know how that could possibly happen in normal circumstances. You wouldn't happen to be running this script in a directory that has a folder called "matplotlib", would you?

@CfKu
Copy link
Author

CfKu commented Sep 7, 2015

I don't think that there is something wrong with my install.
The error does not occur, if I run that script normally. It just occurs if I run the script with the python -OO options:

python --help
...
-O     : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x
-OO    : remove doc-strings in addition to the -O optimizations
...

So here is a minimal myscript.py:

# -*- coding: utf-8 -*-

from mpl_toolkits.mplot3d import Axes3D

No error:

$ python myscript.py

Error:

$ python -OO myscript.py

@WeatherGod
Copy link
Member

Well, that would explain the problem, then.

Don't do -OO. It only helps to reduce the memory footprint of your program
and possibly make the initial loading slightly faster. There are other
aspects of matplotlib that will dominate the overhead of loading an
mpl-based script (font loading, back end loading, config parsing &
validation).

Note that matplotlib itself requires access to its own docstrings for other
functionality, so even if we were to fix the "problem" in mplot3d, other
parts of mpl will likely break during runtime.
On Sep 7, 2015 2:15 AM, "CfKu" notifications@github.com wrote:

I don't think that there is something wrong with my install.
The error does not occur, if I run that script normally. It just occurs if
I run the script with the python -OO options:

python --help
...
-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x
-OO : remove doc-strings in addition to the -O optimizations
...

So here is a minimal myscript.py:

-- coding: utf-8 --

from mpl_toolkits.mplot3d import Axes3D

No error:

$ python myscript.py

Error:

$ python -OO myscript.py


Reply to this email directly or view it on GitHub
#5018 (comment)
.

@CfKu
Copy link
Author

CfKu commented Sep 8, 2015

Thanks for the hint!

A hint from me, for all people who work with py2exe (http://www.py2exe.org/index.cgi/ListOfOptions):
Don't use optimize: 2 or 1 (for avoiding -OO and -O)

optimize: 0

@CfKu CfKu closed this as completed Sep 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants