classification
Title: xdrlib.Unpacker.unpack_string returns bytes (docs say should be str)
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.7, Python 3.6, Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: [doc] xdrlib.Packer().pack_fstring throws a TypeError when called with a str()
View: 9544
Assigned To: Nosy List: hnhn, rnash, serhiy.storchaka, vstinner, xiang.zhang
Priority: normal Keywords:

Created on 2017-04-30 11:12 by rnash, last changed 2017-05-29 16:20 by serhiy.storchaka. This issue is now closed.

Messages (5)
msg292624 - (view) Author: Rupert Nash (rnash) * Date: 2017-04-30 11:12
According to the docs this method should return a str, but it returns bytes
https://docs.python.org/3.6/library/xdrlib.html#xdrlib.Unpacker.unpack_string

I can see three options:
 a default encoding should be applied
 the documentation updated to make clear this returns bytes
 the method removed and just rely on the existing unpack_bytes which does what you'd expect (and in fact the two methods are aliases)
msg292629 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-04-30 12:59
xdrlib doc seems still remain in 2.x world. 'string' is used to represent 'bytes'. And some methods' names like pack_fstring, pack_string seem not suitable in 3.x world.
msg292635 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-04-30 15:46
The term "string" in names like "pack_string" refers to the XDR standard (RFC 1014). They have to stay, but the documentation must be updated to make clear that they work with bytes.
msg294696 - (view) Author: Jan Hnatek (hnhn) * Date: 2017-05-29 14:37
There's a patch for xdrlib documentation in Issue9544. Would that solve this issue?
msg294701 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-29 16:20
Partially. Thank you for pointing on the predecessor Jan.
History
Date User Action Args
2017-05-29 16:20:32serhiy.storchakasetmessages: + msg294701
2017-05-29 16:18:16serhiy.storchakasetstatus: open -> closed
superseder: [doc] xdrlib.Packer().pack_fstring throws a TypeError when called with a str()
resolution: duplicate
stage: needs patch -> resolved
2017-05-29 14:37:00hnhnsetnosy: + hnhn
messages: + msg294696
2017-04-30 15:57:25xiang.zhangsetstage: needs patch
versions: + Python 3.5, Python 3.7
2017-04-30 15:46:33serhiy.storchakasetmessages: + msg292635
2017-04-30 12:59:51xiang.zhangsetnosy: + xiang.zhang, vstinner, serhiy.storchaka
messages: + msg292629
2017-04-30 11:12:49rnashcreate