cpython: 7ef6e5f53418 (original) (raw)

Mercurial > cpython

changeset 92930:7ef6e5f53418 3.4

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

Petri Lehtinen petri@digip.org
date Fri, 10 Oct 2014 21:21:52 +0300
parents 72cff635a3ce
children 8e3387f566f6 b81443d9c64a
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(): support.run_unittest(XDRTest)

if name == "main": test_main()

--- a/Lib/xdrlib.py +++ b/Lib/xdrlib.py @@ -6,6 +6,7 @@ See: RFC 1014 import struct from io import BytesIO +from functools import wraps all = ["Error", "Packer", "Unpacker", "ConversionError"] @@ -31,6 +32,16 @@ class Error(Exception): class ConversionError(Error): pass +def raise_conversion_error(function):

+

class Packer: @@ -47,9 +58,11 @@ class Packer: # backwards compatibility get_buf = get_buffer

@@ -60,20 +73,24 @@ class Packer: else: self.__buf.write(b'\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 @@ -24,6 +24,9 @@ Core and Builtins Library ------- +- Issue #11694: Raise ConversionError in xdrlib as documented. Patch