[issue12603] pydoc.synopsis breaks if filesystem returns mtime of 0

2011-07-27 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 2229b0422369 by Charles-François Natali in branch '2.7':
- Issue #12603: Fix pydoc.synopsis() on files with non-negative st_mtime.
http://hg.python.org/cpython/rev/2229b0422369

--
nosy: +python-dev

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



[issue12603] pydoc.synopsis breaks if filesystem returns mtime of 0

2011-07-27 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 2bc740a83010 by Charles-François Natali in branch '3.2':
Issue #12603: Fix pydoc.synopsis() on files with non-negative st_mtime.
http://hg.python.org/cpython/rev/2bc740a83010

--

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



[issue12603] pydoc.synopsis breaks if filesystem returns mtime of 0

2011-07-27 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 5f003d725619 by Charles-François Natali in branch 'default':
Issue #12603: Fix pydoc.synopsis() on files with non-negative st_mtime.
http://hg.python.org/cpython/rev/5f003d725619

--

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



[issue12603] pydoc.synopsis breaks if filesystem returns mtime of 0

2011-07-27 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

Committed.
Josh, thanks for the report.

--
resolution:  - fixed
stage: patch review - committed/rejected

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



[issue12603] pydoc.synopsis breaks if filesystem returns mtime of 0

2011-07-27 Thread Charles-François Natali

Changes by Charles-François Natali neolo...@free.fr:


--
status: open - closed

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



[issue12603] pydoc.synopsis breaks if filesystem returns mtime of 0

2011-07-23 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +neologix

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



[issue12603] pydoc.synopsis breaks if filesystem returns mtime of 0

2011-07-23 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

Demo:


cf@neobox:~/cpython$ ./python -c import pydoc; 
print(pydoc.synopsis('Lib/os.py'))
OS routines for Mac, NT, or Posix depending on what system we're on.
[51835 refs]
cf@neobox:~/cpython$ touch -t 19700101 Lib/os.py 
cf@neobox:~/cpython$ ./python -c import pydoc; 
print(pydoc.synopsis('Lib/os.py'))
None
[51833 refs]


 I'd suggest using the fix of changing the .get call to return a default of 
 (None,
 None) and changing the conditional to lastupdate is not None and
 lastupdate  mtime.

You mean lastupdate is None or lastupdate  mtime? Otherwise, a file not 
present in the cache would never be looked-up.

Here's a patch.
It's obvious, but note that if the filesystem doesn't provide mtime, then once 
the metadata has been cached, it won't be refreshed if the file is updated.

I'll take a look around the standard library for similar issues.

Note: it would of course be simpler to use -1 as the default mtime value, but a 
negative time_t is possible.

--
keywords: +needs review, patch
stage: needs patch - patch review
Added file: http://bugs.python.org/file22730/pydoc_mtime.diff

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



[issue12603] pydoc.synopsis breaks if filesystem returns mtime of 0

2011-07-23 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Patch looks good.  Does this require a doc update, or is it entirely an 
internal function?

--

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



[issue12603] pydoc.synopsis breaks if filesystem returns mtime of 0

2011-07-23 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

Well, the function is part of pydoc's public API, but the inner
working of the cache mechanism is completely private: this won't have
any impact, other than fixing the bug :-)

--

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



[issue12603] pydoc.synopsis breaks if filesystem returns mtime of 0

2011-07-22 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Hi!  Thanks for the report and patch ideas.  Would both of your fix ideas 
preserve backward compatibility?  If yes, we should take the one that makes the 
code easier to read; if no, we should take the most compatible.  Would you be 
interested in making a patch?  If so, helpful guidelines are available under 
http://docs.python.org/devguide; if not, someone else will do it.

--
nosy: +eric.araujo, haypo, ncoghlan, ron_adam
stage:  - needs patch
title: pydoc.synopsis breaks if filesystem returns mtime of 0 (common for 
filesystems without mtime) - pydoc.synopsis breaks if filesystem returns mtime 
of 0
versions: +Python 3.2, Python 3.3

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



[issue12603] pydoc.synopsis breaks if filesystem returns mtime of 0

2011-07-22 Thread Josh Triplett

Josh Triplett j...@joshtriplett.org added the comment:

The current behavior of pydoc will cause synopsis to always incorrectly return 
None as the synopsis for any module with mtime == 0.  Both of the proposed 
fixes will fix that bug without affecting any case where mtime != 0, so I don't 
think either one has backward-compatibility issues.

I'd suggest using the fix of changing the .get call to return a default of 
(None, None) and changing the conditional to lastupdate is not None and 
lastupdate  mtime.  That variant seems like more obvious code (since None 
clearly means no lastupdate time), and it avoids special-casing an mtime of 0 
and bypassing the synopsis cache.

I don't mind writing a patch if that would help this fix get in.  I'll try to 
write onein the near future, but I certainly won't mind if someone else beats 
me to it. :)

--

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



[issue12603] pydoc.synopsis breaks if filesystem returns mtime of 0 (common for filesystems without mtime)

2011-07-21 Thread Josh Triplett

New submission from Josh Triplett j...@joshtriplett.org:

In Python 2.7.2, pydoc.py's synopsis contains this code implementing a cache:

mtime = os.stat(filename).st_mtime
lastupdate, result = cache.get(filename, (0, None))
if lastupdate  mtime:

Many filesystems don't have any concept of mtime or don't have it available, 
including many FUSE filesystems, as well as our implementation of stat for GRUB 
in BITS.  Such systems typically return an mtime of 0.  (In addition, 0 
represents a valid mtime.)  Since the cache in pydoc.synopsis initializes 
lastupdate to 0 for entries not found in the cache, this causes synopsis to 
always return None.  I'd suggest either extending the conditional to check 
lastupdate != 0 and lastupdate  mtime (which would always treat an mtime of 
0 as requiring an update, which would make sense for filesystems without valid 
mtimes) or changing the .get to return (None, None) and checking lastupdate is 
not None and lastupdate  mtime, which would treat an mtime of 0 as valid but 
still handle the case of not having a cache entry the first time.

--
components: Library (Lib)
messages: 140826
nosy: joshtriplett
priority: normal
severity: normal
status: open
title: pydoc.synopsis breaks if filesystem returns mtime of 0 (common for 
filesystems without mtime)
versions: Python 2.7

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