check for non-integerness before range

This commit is contained in:
Mark Pilgrim
2010-09-16 21:44:12 -04:00
parent dc45dd3265
commit 76a14e4290
4 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -240,10 +240,10 @@ FAILED (errors=3)</samp></pre>
def to_roman(n):
'''convert integer to Roman numeral'''
<a> if not (0 &lt; n &lt; 5000): <span class=u>&#x2461;</span></a>
raise OutOfRangeError('number out of range (must be 1..4999)')
if not isinstance(n, int):
raise NotIntegerError('non-integers can not be converted')
<a> if not (0 &lt; n &lt; 5000): <span class=u>&#x2461;</span></a>
raise OutOfRangeError('number out of range (must be 1..4999)')
result = ''
for numeral, integer in roman_numeral_map: