[issue16355] inspect.getcomments() does not work in the interactive shell

2017-03-24 Thread Berker Peksag

Berker Peksag added the comment:


New changeset 3f2155ffe683080f2a1b28408fa48d43ba92f943 by Berker Peksag (Marco 
Buttu) in branch 'master':
bpo-16355: Clarify when inspect.getcomments() returns None  (#428)
https://github.com/python/cpython/commit/3f2155ffe683080f2a1b28408fa48d43ba92f943


--

___
Python tracker 

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2017-03-24 Thread Berker Peksag

Berker Peksag added the comment:


New changeset 41b4a2189f29daae008e57f799a30890643d191f by Berker Peksag in 
branch '3.5':
bpo-16355: Clarify when inspect.getcomments() returns None (#428) (#691)
https://github.com/python/cpython/commit/41b4a2189f29daae008e57f799a30890643d191f


--

___
Python tracker 

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2017-03-24 Thread Berker Peksag

Berker Peksag added the comment:


New changeset 948171bf999cf8b3e12048851041d2e04ae3a78c by Berker Peksag in 
branch '3.6':
bpo-16355: Clarify when inspect.getcomments() returns None (#428) (#690)
https://github.com/python/cpython/commit/948171bf999cf8b3e12048851041d2e04ae3a78c


--

___
Python tracker 

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2017-03-17 Thread Berker Peksag

Berker Peksag added the comment:

Now all PRs have been merged:

* master: 
https://github.com/python/cpython/commit/3f2155ffe683080f2a1b28408fa48d43ba92f943
* 3.6: 
https://github.com/python/cpython/commit/948171bf999cf8b3e12048851041d2e04ae3a78c
* 3.5: 
https://github.com/python/cpython/commit/41b4a2189f29daae008e57f799a30890643d191f

Thanks for the patches, Vajrasky and Marco!

--
resolution:  -> fixed
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



[issue16355] inspect.getcomments() does not work in the interactive shell

2017-03-17 Thread Berker Peksag

Changes by Berker Peksag :


--
pull_requests: +567

___
Python tracker 

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2017-03-17 Thread Berker Peksag

Berker Peksag added the comment:

Please don't close an issue while there are still open backport PRs on GitHub.

--
resolution: fixed -> 
stage: resolved -> 
status: closed -> open

___
Python tracker 

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2017-03-17 Thread Marco Buttu

Changes by Marco Buttu :


--
resolution:  -> fixed
stage: patch review -> 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



[issue16355] inspect.getcomments() does not work in the interactive shell

2017-03-17 Thread Berker Peksag

Changes by Berker Peksag :


--
pull_requests: +565

___
Python tracker 

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2017-03-03 Thread R. David Murray

R. David Murray added the comment:

Correct.  Tests are good, it's the fix I was rejecting.

--

___
Python tracker 

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2017-03-03 Thread Berker Peksag

Berker Peksag added the comment:

I think David's comment about tests was for the second patch. Looking at 
msg199395 and msg199397, my understanding is that tests are still needed.

--
nosy: +berker.peksag
versions: +Python 3.5, Python 3.6, Python 3.7 -Python 3.3, Python 3.4

___
Python tracker 

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2017-03-03 Thread Marco Buttu

Changes by Marco Buttu :


--
pull_requests: +356

___
Python tracker 

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2017-02-23 Thread Marco Buttu

Marco Buttu added the comment:

Hello Vajrasky, the doc patch LGTM. Looking at the David's comment in Rietveld, 
it seems that he does not want the test patch to be applyed. Can you please 
make a pull request? Thank you very much

--

___
Python tracker 

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2013-12-13 Thread Vajrasky Kok

Vajrasky Kok added the comment:

So, I just found out that imp has been deprecated. Here is the patch that uses 
importlib.machinery instead of imp.load_source.

--
Added file: http://bugs.python.org/file33127/issue16355_v5.diff

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2013-10-12 Thread Georg Brandl

Georg Brandl added the comment:

lives in the interactive shell is not precise; I would prefer has been 
defined in 

--
nosy: +georg.brandl

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2013-10-12 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Attached the patch to address Georg Brandl's concern (Thank you!). I also added 
test for checking the comment of the object defined in C (list, open, etc). I 
have given thought about testing the comment of the object in interactive 
shell. But it is too much hassle. So I skip it.

--
Added file: http://bugs.python.org/file32073/issue16355_v4.diff

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2013-10-11 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Added the doc fix and modified the test.

--
Added file: http://bugs.python.org/file32057/issue16355_v3.diff

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2013-10-10 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Only doc fix? What about unit test confirming that getcomments and getsource 
return None if inspect can not find the source code?

--

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2013-10-10 Thread R. David Murray

R. David Murray added the comment:

Yes, good point, those tests should definitely be added, which means the test 
work doesn't go to waste :)

Note, however, that getsource *does* raise.

--

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2013-10-09 Thread R. David Murray

R. David Murray added the comment:

Looking at the source, the suppression of errors is clearly intentional.  
Looking at the change that added the TypeError check, we see this from Jeremy 
Hilton in March 2002 (9c2ca37bdeec):

It appears that getcomments() can get called for classes defined in
C.  Since these don't have source code, it can't do anything useful.
A function buried many levels deep was raising a TypeError that was
not caught.

Who knows why this broke...

Which implies that getcomments was being called from somewhere in Python 
itself...at least back then.

The check for OSError (IOError, then) was from shortly after the module was 
first added, in February of 2001 by Ka-Ping Yee.

So, the motivation behind this behavior are shrouded in the mists of time :)

Should we really be changing something of that long standing, when it raising a 
TypeError previously clearly broke something?

I'm thinking not.  I'm thinking we should leave well enough alone.  It is, 
after all, working as documentedin the doc string, from the time Jeremy 
made the TypeError change.  So after all this work (sorry people, I do 
appreciate the work!), I think we should just make a doc fix that copies the 
line about returning None if source can't be found into the rst docs.

--

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2013-10-06 Thread Vajrasky Kok

Vajrasky Kok added the comment:

I pep-8 Phil Connell's work and revamped the unit test based on  R. David 
Murray's request.

--
nosy: +vajrasky
Added file: http://bugs.python.org/file31975/issue16355_v2.diff

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



[issue16355] inspect.getcomments() does not work in the interactive shell

2013-04-18 Thread Phil Connell

Phil Connell added the comment:

Here's a patch that updates getcomments to match the behaviour of getsource, 
raising OSError if the source file can't be found and TypeError when passed a 
built-in.

Since this is a backwards-incompatible change, presumably it can only be 
applied to 3.4.

This is ready for review.

--
keywords: +patch
nosy: +pconnell
Added file: http://bugs.python.org/file29926/issue16355.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2013-04-18 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
stage: needs patch - patch review
versions:  -Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2012-11-03 Thread Ezio Melotti

Ezio Melotti added the comment:

That's arguably a bug though.  If the pragma was critical the program will 
silently do the wrong thing by ignoring an existing pragma when the source is 
missing (e.g. in production, even after passing all the tests locally).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2012-11-03 Thread R. David Murray

R. David Murray added the comment:

It doesn't matter whether it is a bug or not (though it is not in the situation 
I described).  The point is that a working program would stop working.  That is 
the kind of breakage our backward compatibility policy is designed to protect 
against.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2012-11-03 Thread Ezio Melotti

Ezio Melotti added the comment:

 The point is that a working program would stop working.

My point is that the program might not be a working program, if the function 
fails silently.

Anyway this function is probably not widely used, so I'm fine either ways.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2012-10-29 Thread Marco Buttu

New submission from Marco Buttu:

The documentation for `inspect.getcomments()` says that it returns 
the lines of comments immediately preceding an object's source code.
It works fine for the comments that immediately preceded an object 
defined in a module:

$ more foo.py 
import inspect
# A dummy comment
def foo():
pass

print(inspect.getcomments(foo))
$ python3.3 foo.py 
# A dummy comment

But it does not work if we define an object interactively:

$ python3.3
Python 3.3.0 (default, Oct  9 2012, 18:20:32) 
[GCC 4.5.2] on linux
Type help, copyright, credits or license for more information.
 import inspect
 # A dummy comment
... def foo():
... pass
... 
 inspect.getcomments(foo)
 # A dummy comment
... 
 def foo():
... pass
... 
 inspect.getcomments(foo)


--
components: Library (Lib)
messages: 174108
nosy: marco.buttu
priority: normal
severity: normal
status: open
title: inspect.getcomments() does not work in the interactive shell
type: behavior
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2012-10-29 Thread R. David Murray

R. David Murray added the comment:

That's because inspecting source code requires that there be a source file to 
inspect.

--
nosy: +r.david.murray
resolution:  - invalid
stage:  - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2012-10-29 Thread R. David Murray

R. David Murray added the comment:

Hmm.  Reopening in case someone wants to see if we can generate an appropriate 
error message when there is no source file to inspect.

--
status: closed - open
versions: +Python 2.7, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2012-10-29 Thread Marco Buttu

Marco Buttu added the comment:

If inspect.getcomments() requires a source file to inspect, I think it would be 
better to indicate it in the doc.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2012-10-29 Thread R. David Murray

R. David Murray added the comment:

Yeah, this should be a doc bug.  After I thought about it some more I realized 
that changing the behavior to raise an error would not be a good idea.

--
assignee:  - docs@python
components: +Documentation -Library (Lib)
nosy: +docs@python

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2012-10-29 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
keywords: +easy
nosy: +ezio.melotti
stage: committed/rejected - needs patch
type: behavior - enhancement
versions: +Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2012-10-29 Thread Marco Buttu

Marco Buttu added the comment:

I saw there is the same lack of clarity in the doc of `inspect.getsource()`:

 import inspect
 print(inspect.getsource.__doc__)
Return the text of the source code for an object.

The argument may be a module, class, method, function, traceback, frame,
or code object.  The source code is returned as a single string.  An
IOError is raised if the source code cannot be retrieved.
 def foo():
... pass
... 
 inspect.getsource(foo)
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/local/lib/python3.3/inspect.py, line 726, in getsource
lines, lnum = getsourcelines(object)
  File /usr/local/lib/python3.3/inspect.py, line 715, in getsourcelines
lines, lnum = findsource(object)
  File /usr/local/lib/python3.3/inspect.py, line 563, in findsource
raise IOError('could not get source code')
OSError: could not get source code

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2012-10-29 Thread Ezio Melotti

Ezio Melotti added the comment:

 After I thought about it some more I realized that changing
 the behavior to raise an error would not be a good idea.

Can you elaborate more?
Failing silently doesn't seem much better than raising an error, especially if 
similar functions already raise.

--
components: +Library (Lib)
resolution: invalid - 
type: enhancement - behavior

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2012-10-29 Thread R. David Murray

R. David Murray added the comment:

If similar functions already raise, then changing it for 3.4 would be OK.  But 
to change it for earlier versions would risk breaking working programs.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2012-10-29 Thread Ezio Melotti

Ezio Melotti added the comment:

Not sure if they can be considered working programs if the function fails 
silently.  Do you have some specific example in mind?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16355] inspect.getcomments() does not work in the interactive shell

2012-10-29 Thread R. David Murray

R. David Murray added the comment:

Not a specific package, but a specific use case (assuming getcomments is in use 
at all :)

Consider a program that uses getcomments to look for a pragma-like comment 
before a function, but one that is not critical to the program's function 
(perhaps it has to do with testing or tracing infrastructure...).  If the 
source file does not exist, then that is equivalent to their being no pragma.  
So the program would work fine even if the source is deleted...until this 
getcomments starts to raise an error, when it promptly crashes (probably in a 
production system, since that is the most likely place for source to be 
absent...)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16355
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com