cpython: 9cee201388c9 (original) (raw)

Mercurial > cpython

changeset 92929:9cee201388c9 2.7

Issue #11694: Raise ConversionError in xdrlib as documented [#11694]

Petri Lehtinen petri@digip.org
date Fri, 10 Oct 2014 21:11:34 +0300
parents 0c75819f1d86
children 05274a517b37
files Lib/test/test_xdrlib.py Lib/xdrlib.py Misc/NEWS
diffstat 3 files changed, 52 insertions(+), 8 deletions(-)[+] [-] Lib/test/test_xdrlib.py 24 Lib/xdrlib.py 33 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/test/test_xdrlib.py +++ b/Lib/test/test_xdrlib.py @@ -51,8 +51,32 @@ class XDRTest(unittest.TestCase): up.done() self.assertRaises(EOFError, up.unpack_uint) +class ConversionErrorTest(unittest.TestCase): +

+

+

+

+

+

+

+ def test_main(): test_support.run_unittest(XDRTest)

if name == "main": test_main()

--- a/Lib/xdrlib.py +++ b/Lib/xdrlib.py @@ -9,6 +9,7 @@ try: from cStringIO import StringIO as _StringIO except ImportError: from StringIO import StringIO as _StringIO +from functools import wraps all = ["Error", "Packer", "Unpacker", "ConversionError"] @@ -34,6 +35,16 @@ class Error(Exception): class ConversionError(Error): pass +def raise_conversion_error(function):

+

class Packer: @@ -50,9 +61,11 @@ class Packer: # backwards compatibility get_buf = get_buffer

@@ -63,20 +76,24 @@ class Packer: else: self.__buf.write('\0\0\0\0') def pack_uhyper(self, x):

pack_hyper = pack_uhyper

def pack_fstring(self, n, s): if n < 0:

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -34,6 +34,9 @@ Core and Builtins Library ------- +- Issue #11694: Raise ConversionError in xdrlib as documented. Patch