Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue11694

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:xdrlib raises ConversionError in inconsistent way
Type:behaviorStage:resolved
Components:Library (Lib)Versions:Python 3.4, Python 3.5, Python 2.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: Claudiu.Popa, georg.brandl, gruszczy, petri.lehtinen, python-dev
Priority:normalKeywords:patch

Created on2011-03-27 11:12 bygruszczy, last changed2022-04-11 14:57 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
11694.patchgruszczy,2011-09-17 10:59review
issue11694.patchClaudiu.Popa,2014-10-09 19:16review
Messages (10)
msg132309 -(view)Author: Filip Gruszczyński (gruszczy)Date: 2011-03-27 11:12
xdrlib defines ConversionError, but very seldom uses it. For example:    def pack_float(self, x):        try: self.__buf.write(struct.pack('>f', x))        except struct.error as msg:            raise ConversionError(msg)But it doesn't do so here:    def pack_uint(self, x):        self.__buf.write(struct.pack('>L', x))Shouldn't that be more consistent?I am happy to write a patch, that will make xdrlib raise ConversionError, as well as write proper test (I believe xdrlib tests should get some love altogether, so I would add a separate test case for this).
msg138783 -(view)Author: Petri Lehtinen (petri.lehtinen)*(Python committer)Date: 2011-06-21 12:30
This seems like a bug worth fixing. The ConversionError exception has been documented, an there's an example in the docs that suggest that at least all packing fails with a ConversionError.
msg144180 -(view)Author: Filip Gruszczyński (gruszczy)Date: 2011-09-17 10:59
Patch with tests.
msg151291 -(view)Author: Filip Gruszczyński (gruszczy)Date: 2012-01-15 15:50
Bump! It's almost 3 months since I posted the patch, so I would like to remind about this bug.
msg151293 -(view)Author: Georg Brandl (georg.brandl)*(Python committer)Date: 2012-01-15 16:54
Looks good to me.
msg162367 -(view)Author: Petri Lehtinen (petri.lehtinen)*(Python committer)Date: 2012-06-05 19:24
I see one obvious issue with the patch: The ConversionErrors it creates are passed the struct.error or TypeError instance as a parameter. The first argument of these exceptions would be better, i.e.try:   ...except struct.error as e:   raise ConversionError(e.args[0])Furthermore, my ear thinks that raises_conversion_error would be a better name for the decorator than raising_conversion_error.Anyway, I think the whole ConversionError is a bit problematic, as either TypeError or ValueError would be the most appropriate exception, depending on the situation. For example:p = Packer()p.pack_int('foo')  # should raise a TypeErrorp.pack_int(2**100) # should raise a ValueErrorThis would be slightly harder to implement, though, as struct.error has exactly the same problem.
msg228893 -(view)Author: PCManticore (Claudiu.Popa)*(Python triager)Date: 2014-10-09 19:16
Here's a refreshed patch:- raising_conversion_error is now raise_conversion_error- the decorator uses functools.wraps- the ConversionError is instantiated with the first argument of the caught expression- the reraising of ConversionError has the exception context supressed.
msg228951 -(view)Author: Petri Lehtinen (petri.lehtinen)*(Python committer)Date: 2014-10-10 05:23
LGTM
msg229020 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2014-10-10 18:30
New changeset9cee201388c9 by Petri Lehtinen in branch '2.7':Issue#11694: Raise ConversionError in xdrlib as documentedhttps://hg.python.org/cpython/rev/9cee201388c9New changeset7ef6e5f53418 by Petri Lehtinen in branch '3.4':Issue#11694: Raise ConversionError in xdrlib as documentedhttps://hg.python.org/cpython/rev/7ef6e5f53418New changeset8e3387f566f6 by Petri Lehtinen in branch 'default':#11694: merge with 3.4https://hg.python.org/cpython/rev/8e3387f566f6
msg229021 -(view)Author: Petri Lehtinen (petri.lehtinen)*(Python committer)Date: 2014-10-10 18:33
Applied, thanks!
History
DateUserActionArgs
2022-04-11 14:57:15adminsetgithub: 55903
2014-10-10 18:33:54petri.lehtinensetstatus: open -> closed
resolution: fixed
messages: +msg229021

stage: patch review -> resolved
2014-10-10 18:30:41python-devsetnosy: +python-dev
messages: +msg229020
2014-10-10 05:23:31petri.lehtinensetmessages: +msg228951
2014-10-09 19:16:06Claudiu.Popasetfiles: +issue11694.patch

messages: +msg228893
versions: + Python 3.4, Python 3.5, - Python 3.2, Python 3.3
2014-10-04 18:27:34Claudiu.Popasetnosy: +Claudiu.Popa
2012-06-05 19:24:15petri.lehtinensetmessages: +msg162367
2012-01-15 16:54:32georg.brandlsetstage: test needed -> patch review
2012-01-15 16:54:21georg.brandlsetnosy: +georg.brandl
messages: +msg151293
2012-01-15 15:50:39gruszczysetmessages: +msg151291
2011-09-17 10:59:26gruszczysetfiles: +11694.patch
keywords: +patch
messages: +msg144180
2011-07-24 18:26:12petri.lehtinensetstage: test needed
versions: + Python 2.7, Python 3.2
2011-06-21 12:30:42petri.lehtinensetnosy: +petri.lehtinen
messages: +msg138783
2011-03-27 11:12:16gruszczycreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp