New submission from dariusp <dari...@internode.on.net>: Apologies for the duplicate issue, but I wanted to supply two patches (one for release30-maint and one for py3k) and appears that each issue can only have one file.
pydoc -k fails for both release30-maint and py3k. In release30-maint the python io module (or more accurately the underlying codecs module used by the io module) raises a LookupError if the encoding is invalid. There is a test module with a deliberate encoding misspelled as "uft-8". In py3k the C io module doesn't raise this exception. In addition both release30-maint and py3k raise a SyntaxError if the BOM is invalid. Again there is a test module with an invalid BOM. The only difference between the patch for release30-maint and the patch for py3k is that py3k doesn't catch LookupError since the C io module doesn't raise it. Apart from that, pkgutil.py handles SyntaxError the same as ImportError and returns None. pydoc.py handles receiving the None and also handles the LookupError the same as UnicodeDecodeError. A test was added to test_pydoc.py to ensure that a keyword search sends text to stdout and nothing to stderr. Before (release30-maint): $ pydoc -k sys errno - This module makes available standard errno system symbols. posix - This module provides access to operating system functionality that is sys - This module provides access to some objects used or maintained by the colorsys - Conversion functions between RGB and other color systems. distutils.sysconfig - Provide access to Python's configuration information. The specific distutils.tests.test_sysconfig - Tests for distutils.dist. lib2to3.fixes.fix_sys_exc - Fixer for sys.exc_{type, value, traceback} os - OS routines for Mac, NT, or Posix depending on what system we're on. site - Append module search paths for third-party packages to sys.path. Traceback (most recent call last): File "/usr/local/bin/pydoc", line 5, in <module> pydoc.cli() File "/usr/local/lib/python3.0/pydoc.py", line 2260, in cli apropos(val) File "/usr/local/lib/python3.0/pydoc.py", line 1966, in apropos ModuleScanner().run(callback, key, onerror=onerror) File "/usr/local/lib/python3.0/pydoc.py", line 1928, in run source = loader.get_source(modname) File "/usr/local/lib/python3.0/pkgutil.py", line 293, in get_source self.source = self.file.read() File "/usr/local/lib/python3.0/io.py", line 1724, in read decoder = self._decoder or self._get_decoder() File "/usr/local/lib/python3.0/io.py", line 1509, in _get_decoder make_decoder = codecs.getincrementaldecoder(self._encoding) File "/usr/local/lib/python3.0/codecs.py", line 960, in getincrementaldecoder decoder = lookup(encoding).incrementaldecoder LookupError: unknown encoding: uft-8 After (release30-maint): $ pydoc -k sys errno - This module makes available standard errno system symbols. posix - This module provides access to operating system functionality that is sys - This module provides access to some objects used or maintained by the colorsys - Conversion functions between RGB and other color systems. distutils.sysconfig - Provide access to Python's configuration information. The specific distutils.tests.test_sysconfig - Tests for distutils.dist. lib2to3.fixes.fix_sys_exc - Fixer for sys.exc_{type, value, traceback} os - OS routines for Mac, NT, or Posix depending on what system we're on. site - Append module search paths for third-party packages to sys.path. test.test_colorsys test.test_largefile - Test largefile support on system where this makes sense. test.test_sys test.test_syslog warnings - Python part of the warnings subsystem. syslog Before (py3k): $ pydoc -k sys errno - This module makes available standard errno system symbols. posix - This module provides access to operating system functionality that is sys - This module provides access to some objects used or maintained by the colorsys - Conversion functions between RGB and other color systems. distutils.sysconfig - Provide access to Python's configuration information. The specific distutils.tests.test_sysconfig - Tests for distutils.dist. importlib.test.import_.test_caching - Test that sys.modules is used properly by import. lib2to3.fixes.fix_sys_exc - Fixer for sys.exc_{type, value, traceback} os - OS routines for Mac, NT, or Posix depending on what system we're on. site - Append module search paths for third-party packages to sys.path. Traceback (most recent call last): File "/usr/local/bin/pydoc", line 5, in <module> pydoc.cli() File "/usr/local/lib/python3.1/pydoc.py", line 2260, in cli apropos(val) File "/usr/local/lib/python3.1/pydoc.py", line 1966, in apropos ModuleScanner().run(callback, key, onerror=onerror) File "/usr/local/lib/python3.1/pydoc.py", line 1925, in run loader = importer.find_module(modname) File "/usr/local/lib/python3.1/pkgutil.py", line 183, in find_module file, filename, etc = imp.find_module(subname, path) SyntaxError: encoding problem: with BOM After (py3k): $ pydoc -k sys errno - This module makes available standard errno system symbols. posix - This module provides access to operating system functionality that is sys - This module provides access to some objects used or maintained by the colorsys - Conversion functions between RGB and other color systems. distutils.sysconfig - Provide access to Python's configuration information. The specific distutils.tests.test_sysconfig - Tests for distutils.dist. importlib.test.import_.test_caching - Test that sys.modules is used properly by import. lib2to3.fixes.fix_sys_exc - Fixer for sys.exc_{type, value, traceback} os - OS routines for Mac, NT, or Posix depending on what system we're on. site - Append module search paths for third-party packages to sys.path. test.test_colorsys test.test_largefile - Test largefile support on system where this makes sense. test.test_sys test.test_syslog warnings - Python part of the warnings subsystem. syslog ---------- components: Library (Lib) files: pydoc-keyword-search-patch-py3k.diff keywords: patch message_count: 1.0 messages: 83349 nosy: dariusp nosy_count: 1.0 severity: normal status: open title: pydoc -k fails (py3k patch) type: crash versions: Python 3.0, Python 3.1 Added file: http://bugs.python.org/file13278/pydoc-keyword-search-patch-py3k.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5454> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com