pure/base85: align exception type/msg on base85.c stable
authorPatrick Mezard <patrick@mezard.eu>
Mon, 07 May 2012 21:49:45 +0200
branchstable
changeset 16598 20a9d823f242
parent 16597 b767382a8675
child 16603 ddd4996740c7
child 16604 48e42f984074
child 16677 b490be1fec06
pure/base85: align exception type/msg on base85.c brendan mentioned on IRC that b64decode raises a TypeError too, but while the previous exception type may be better in general, it is much easier to make it behave like the related C code and changes nothing for mercurial itself.
mercurial/pure/base85.py
tests/test-check-code-hg.t
--- a/mercurial/pure/base85.py	Mon May 07 15:40:50 2012 -0500
+++ b/mercurial/pure/base85.py	Mon May 07 21:49:45 2012 +0200
@@ -54,9 +54,10 @@
             try:
                 acc = acc * 85 + _b85dec[c]
             except KeyError:
-                raise TypeError('Bad base85 character at byte %d' % (i + j))
+                raise ValueError('bad base85 character at position %d'
+                                 % (i + j))
         if acc > 4294967295:
-            raise OverflowError('Base85 overflow in hunk starting at byte %d' % i)
+            raise ValueError('Base85 overflow in hunk starting at byte %d' % i)
         out.append(acc)
 
     # Pad final chunk if necessary
--- a/tests/test-check-code-hg.t	Mon May 07 15:40:50 2012 -0500
+++ b/tests/test-check-code-hg.t	Mon May 07 21:49:45 2012 +0200
@@ -496,9 +496,6 @@
   mercurial/patch.py:0:
    >     except:
    warning: naked except clause
-  mercurial/pure/base85.py:0:
-   >             raise OverflowError('Base85 overflow in hunk starting at byte %d' % i)
-   warning: line over 80 characters
   mercurial/pure/mpatch.py:0:
    >         frags.extend(reversed(new))                    # what was left at the end
    warning: line over 80 characters