This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: When xdrlib.Packer().pack_string() fails, the Packer is corrupted
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: ostcar, r.david.murray, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2015-03-27 13:05 by ostcar, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_value.patch ostcar, 2015-03-27 13:05 review
reset_buffer.patch ostcar, 2015-03-27 13:05 review
Messages (4)
msg239396 - (view) Author: Oskar Hahn (ostcar) * Date: 2015-03-27 13:05
When xdrlib.Packer().pack_string() is called with an unsupported value, it raises a TypeError. But it calles self.pack_uint(n) before it raises the exception so the buffer is changed.

There are two possible solutions to solve this behaviour. The argument s can be tested to be supported, or undo the call of self.pack_uint(n).

I added two alternative patches for this two solutions.

This is my first patch for cpython, I hope it is ok.
msg239410 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-03-27 15:06
Your patches are great, thanks.  Now we have to decide which to use :)
msg239418 - (view) Author: Oskar Hahn (ostcar) * Date: 2015-03-27 17:14
I would prefer the reset_buffer.patch because I do not like argument testing at the begin of a function/method.
msg239421 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-03-27 17:43
I doubt that this issue is worth fixing. It is common that when error is happen inside complex operation, the output can be incomplete. When you pickle a list containing non-pickleable data, resulting file content will be not unpickleable. When you write a number of lines in text file, and one of lines contains non-encodable characters, resulting file content will be incomplete and may even don't contain complete lines.

And when other xdrlib.Packer methods that write complex data (pack_uhyper, pack_list, pack_farray, pack_array) fail, they left incomplete output.
History
Date User Action Args
2022-04-11 14:58:14adminsetgithub: 67978
2015-05-27 08:58:31serhiy.storchakasetstatus: pending -> closed
resolution: rejected
stage: resolved
2015-04-04 19:19:55serhiy.storchakasetstatus: open -> pending
2015-03-27 17:43:09serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg239421
2015-03-27 17:14:14ostcarsetmessages: + msg239418
2015-03-27 15:06:13r.david.murraysetnosy: + r.david.murray
messages: + msg239410
2015-03-27 13:05:29ostcarsetfiles: + reset_buffer.patch
2015-03-27 13:05:10ostcarcreate