[issue46466] help function reads comments

2022-01-21 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

That's not a bug.

https://docs.python.org/3/library/pydoc.html

"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())."

--
nosy: +dam1784, steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46466] help function reads comments

2022-01-21 Thread David Mc Dougall


Change by David Mc Dougall :


--
nosy:  -dam1784

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46466] help function reads comments

2022-01-21 Thread David Mc Dougall


New submission from David Mc Dougall :

My inline comment ('#') got picked up by the help command.

Write the following code to a file (I named it "reproducer.py"):

"""

class Foo:
# Hello docstring, I'm a '#' comment!
def bar(self):
pass

assert Foo.bar.__doc__ is None
help(Foo.bar)

"""

The bug only happens when the file is executed.
$ python3 reproducer.py

Help on function bar in module __main__:

bar(self)
# Hello docstring, I'm a '#' comment!


Evaluating it at the interactive prompt does not reproduce the bug.
$ cat reproducer.py | python3

Help on function bar in module __main__:

bar(self)

--
messages: 411218
nosy: dam1784
priority: normal
severity: normal
status: open
title: help function reads comments
type: behavior
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com