[Python-checkins] cpython (merge 3.2 -> default): Fixes #12637: Merged fix from 3.2 and added test.

Terry Reedy tjreedy at udel.edu
Mon Jul 25 21:25:18 CEST 2011



On 7/25/2011 2:58 PM, vinay.sajip wrote:
> http://hg.python.org/cpython/rev/de13ce98ca3b
> changeset:   71501:de13ce98ca3b
> parent:      71499:8d67fd820627
> parent:      71500:d11a1a373f58
> user:        Vinay Sajip<vinay_sajip at yahoo.co.uk>
> date:        Mon Jul 25 19:58:13 2011 +0100
> summary:
>    Fixes #12637: Merged fix from 3.2 and added test.
>
> files:
>    Lib/logging/__init__.py  |  3 ++-
>    Lib/test/test_logging.py |  2 ++
>    2 files changed, 4 insertions(+), 1 deletions(-)
>
>
> diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
> --- a/Lib/logging/__init__.py
> +++ b/Lib/logging/__init__.py
> @@ -1442,7 +1442,8 @@
>                   c = c.parent
>           if (found == 0):
>               if lastResort:
> -                lastResort.handle(record)
> +                if record.levelno>= lastResort.level:
> +                    lastResort.handle(record)
>               elif raiseExceptions and not self.manager.emittedNoHandlerWarning:
>                   sys.stderr.write("No handlers could be found for logger"
>                                    " \"%s\"\n" % self.name)
> diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
> --- a/Lib/test/test_logging.py
> +++ b/Lib/test/test_logging.py
> @@ -2923,6 +2923,8 @@
>           old_raise_exceptions = logging.raiseExceptions
>           try:
>               sys.stderr = sio = io.StringIO()
> +            root.debug('This should not appear')
> +            self.assertEqual(sio.getvalue(), '')

If this fails, and sio is not reset
sio.seek(0); sio.truncate() # as I remember

>               root.warning('This is your final chance!')
>               self.assertEqual(sio.getvalue(), 'This is your final chance!\n')

this will fail even if it should not.

>               #No handlers and no last resort, so 'No handlers' message


More information about the Python-checkins mailing list