Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(15)

#16382: Better warnings exception for bad category

Can't Edit
Can't Publish+Mail
Start Review
Created:
7 years, 5 months ago by pelson.pub
Modified:
5 years, 9 months ago
Reviewers:
berker.peksag, ezio.melotti
CC:
brett.cannon, ezio.melotti, r.david.murray, devnull_psf.upfronthosting.co.za, berkerpeksag, pelson
Visibility:
Public.

Patch Set 1 #

Total comments: 20

Patch Set 2 #

Total comments: 5

Patch Set 3 #

Total comments: 2

Patch Set 4 #

Total comments: 1

Patch Set 5 #

Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Lib/test/test_warnings.py View 1 2 3 4 1 chunk +29 lines, -0 lines 0 comments Download
Lib/warnings.py View 1 2 3 4 1 chunk +5 lines, -1 line 0 comments Download
Python/_warnings.c View 1 2 3 4 1 chunk +6 lines, -6 lines 0 comments Download

Messages

Total messages: 10
berkerpeksag
http://bugs.python.org/review/16382/diff/6461/Lib/warnings.py File Lib/warnings.py (right): http://bugs.python.org/review/16382/diff/6461/Lib/warnings.py#newcode175 Lib/warnings.py:175: 'Got {!r}'.format(Warning, category)) from None How about this? if ...
7 years, 5 months ago #1
pelson
http://bugs.python.org/review/16382/diff/6461/Lib/warnings.py File Lib/warnings.py (right): http://bugs.python.org/review/16382/diff/6461/Lib/warnings.py#newcode175 Lib/warnings.py:175: 'Got {!r}'.format(Warning, category)) from None On 2012/11/01 18:04:13, berkerpeksag ...
7 years, 5 months ago #2
ezio.melotti
http://bugs.python.org/review/16382/diff/6461/Lib/test/test_warnings.py File Lib/test/test_warnings.py (right): http://bugs.python.org/review/16382/diff/6461/Lib/test/test_warnings.py#newcode378 Lib/test/test_warnings.py:378: self.assertEqual(str(w[-1].message), 'good warning category') You can also use self.assertWarns ...
7 years, 5 months ago #3
pelson
http://bugs.python.org/review/16382/diff/6461/Lib/warnings.py File Lib/warnings.py (right): http://bugs.python.org/review/16382/diff/6461/Lib/warnings.py#newcode172 Lib/warnings.py:172: raise TypeError('') On 2012/11/04 05:11:48, ezio.melotti wrote: > Why ...
7 years, 4 months ago #4
berkerpeksag
http://bugs.python.org/review/16382/diff/6461/Lib/warnings.py File Lib/warnings.py (right): http://bugs.python.org/review/16382/diff/6461/Lib/warnings.py#newcode175 Lib/warnings.py:175: 'Got {!r}'.format(Warning, category)) from None On 2012/11/20 17:58:04, pelson ...
7 years, 4 months ago #5
pelson
http://bugs.python.org/review/16382/diff/6461/Lib/test/test_warnings.py File Lib/test/test_warnings.py (right): http://bugs.python.org/review/16382/diff/6461/Lib/test/test_warnings.py#newcode378 Lib/test/test_warnings.py:378: self.assertEqual(str(w[-1].message), 'good warning category') On 2012/11/04 05:11:48, ezio.melotti wrote: ...
7 years, 4 months ago #6
berkerpeksag
http://bugs.python.org/review/16382/diff/6461/Lib/warnings.py File Lib/warnings.py (right): http://bugs.python.org/review/16382/diff/6461/Lib/warnings.py#newcode175 Lib/warnings.py:175: 'Got {!r}'.format(Warning, category)) from None On 2012/11/21 10:54:55, pelson ...
7 years, 4 months ago #7
pelson
http://bugs.python.org/review/16382/diff/6461/Lib/warnings.py File Lib/warnings.py (right): http://bugs.python.org/review/16382/diff/6461/Lib/warnings.py#newcode175 Lib/warnings.py:175: 'Got {!r}'.format(Warning, category)) from None On 2012/11/21 21:22:54, berkerpeksag ...
7 years, 4 months ago #8
berkerpeksag
http://bugs.python.org/review/16382/diff/6461/Lib/warnings.py File Lib/warnings.py (right): http://bugs.python.org/review/16382/diff/6461/Lib/warnings.py#newcode175 Lib/warnings.py:175: 'Got {!r}'.format(Warning, category)) from None On 2012/11/22 11:46:08, pelson ...
7 years, 4 months ago #9
ezio.melotti
7 years, 1 month ago #10
http://bugs.python.org/review/16382/diff/7520/Lib/warnings.py
File Lib/warnings.py (right):

http://bugs.python.org/review/16382/diff/7520/Lib/warnings.py#newcode172
Lib/warnings.py:172: 'Got {!r}.'.format(category))
Just a minor nit, but this could be changed to:
'category must be a Warning subclass, '
'not {!r}'.format(category)

This will match the same format used for other built-in types, e.g.:
>>> int([])
TypeError: int() argument must be a string or a number, not 'list'
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+