Skip to content

functions without docstrings display encoding information #578

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

Closed
thomasballinger opened this issue Nov 29, 2015 · 3 comments
Closed

functions without docstrings display encoding information #578

thomasballinger opened this issue Nov 29, 2015 · 3 comments
Labels

Comments

@thomasballinger
Copy link
Member

(bpython)tomb@tom-mba ~$ bpython
bpython version 0.15.dev177 on top of Python 2.7.10 /Users/tomb/.�
virtualenvs/bpython/bin/python2.7
>>> def foo(): pass
...
>>> foo(
┌──────────────────────────────────────────────────┐
│ foo: ()                                          │
│ # coding: UTF-8                                  │
└──────────────────────────────────────────────────┘

in master, functions without docstrings are showing "# coding: UTF-8" as their docstring. Their foo.__doc__ property is None, so it must be a display issue. This isn't a problem in 0.14.2.

@sebastinas
Copy link
Contributor

This seems to be a Python 2.7 only issue. Can't reproduce it with Python 3.

@sebastinas
Copy link
Contributor

Adding a second newline in bpython.reply.Interpreter.runsource fixes this (but breaks a test case that relies on some line numbers).

@thomasballinger thomasballinger changed the title functions without docstrings display functions without docstrings display encoding information Dec 7, 2015
@thomasballinger
Copy link
Member Author

Ah I didn't understand this before but now see now why that helps, because

If there is no docstring, pydoc tries to obtain a description from the block of comment lines just above the definition of the class, function or method in the source file, or at the top of the module (see inspect.getcomments()).

from https://docs.python.org/2/library/pydoc.html

This seems like a good way to fix this, as it just requires subtracting two lines instead of one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants