msg113386 - (view) |
Author: Paul Arnold (arnoldp) |
Date: 2010-08-09 05:51 |
In Python 3.1, xdrlib.Packer().pack_fstring() throws a TypeError if called with a str() (an encoded string bytes() works just fine).
>>> xdrlib.Packer().pack_fstring(6, "foobar")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.1/xdrlib.py", line 81, in pack_fstring
data = data + (n - len(data)) * b'\0'
TypeError: Can't convert 'bytes' object to str implicitly
|
msg113387 - (view) |
Author: Éric Araujo (eric.araujo) *  |
Date: 2010-08-09 05:53 |
Thanks for the report. Can you tell if it applies to 3.2? Also, is the doc unclear on this point?
|
msg113388 - (view) |
Author: Éric Araujo (eric.araujo) *  |
Date: 2010-08-09 05:54 |
Editing type. (FYI, you can follow the link to see some descriptions.)
|
msg113390 - (view) |
Author: Paul Arnold (arnoldp) |
Date: 2010-08-09 06:09 |
It will apply to 3.2 also, checking in SVN there have been no changes to xdrlib.py for a couple of years.
The documentation makes no mention of the need to encode strings.
|
msg132306 - (view) |
Author: Filip Gruszczyński (gruszczy) |
Date: 2011-03-27 10:43 |
Here is a simple patch with a test. Depending o bytes in this library seems strange, maybe it should be changed somehow? Anyway, this simple patch should be a quick fix to the problem.
|
msg133700 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2011-04-13 22:05 |
This doesn't really make sense, since XDR doesn't seem to say anything about unicode strings, just bytes.
|
msg133719 - (view) |
Author: Filip Gruszczyński (gruszczy) |
Date: 2011-04-14 10:19 |
Actually documentation doesn't say that it supports only bytes, but:
"The following methods support packing strings, bytes, and opaque data:"
Also under python2 you can easily do this:
In [1]: import xdrlib
In [2]: p = xdrlib.Packer()
In [3]: p.pack_string('some str')
In [4]: p.pack_string(u'some str')
So to conclude I believe either docs for python3 should be changed to say that only bytes are allowed or it should be changed to work as in python2. It's clear that in python2 some unicode string are accepted and I think we should allow such strings to be accepted in python3 too.
|
msg133735 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2011-04-14 13:03 |
2011/4/14 Filip Gruszczyński <report@bugs.python.org>:
>
> Filip Gruszczyński <gruszczy@gmail.com> added the comment:
>
> Actually documentation doesn't say that it supports only bytes, but:
>
> "The following methods support packing strings, bytes, and opaque data:"
>
> Also under python2 you can easily do this:
>
> In [1]: import xdrlib
>
> In [2]: p = xdrlib.Packer()
>
> In [3]: p.pack_string('some str')
>
> In [4]: p.pack_string(u'some str')
I doubt u"美", will, though.
|
msg133736 - (view) |
Author: Filip Gruszczyński (gruszczy) |
Date: 2011-04-14 13:11 |
I am well aware of this, Benjamin. I am not trying to force any solution, but rather trying to point out, that current documentation is misleading. There might be no need for patching the code, but rather updating the docs to say, that only bytes are allowed and that will be sufficient.
|
msg133737 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2011-04-14 13:15 |
2011/4/14 Filip Gruszczyński <report@bugs.python.org>:
>
> Filip Gruszczyński <gruszczy@gmail.com> added the comment:
>
> I am well aware of this, Benjamin. I am not trying to force any solution, but rather trying to point out, that current documentation is misleading. There might be no need for patching the code, but rather updating the docs to say, that only bytes are allowed and that will be sufficient.
Yes, I think a doc patch is the correct thing to do.
|
msg133739 - (view) |
Author: Filip Gruszczyński (gruszczy) |
Date: 2011-04-14 13:22 |
I'll provide docs patch.
|
msg162419 - (view) |
Author: Petri Lehtinen (petri.lehtinen) *  |
Date: 2012-06-06 18:28 |
Attached a patch against 3.2. It reflects the facts that pack_fstring and pack_fopaque are the same methd, and pack_string, pack_opaque and pack_bytes are the same method.
|
msg294700 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2017-05-29 16:17 |
issue9544.patch LGTM as the first step. There are other mentions of strings in the documentation.
|
msg294746 - (view) |
Author: Jan Hnatek (hnhn) * |
Date: 2017-05-30 09:37 |
Attached an updated patch against 3.7 fixing the remaining mentions of string.
|
msg415051 - (view) |
Author: Irit Katriel (iritkatriel) *  |
Date: 2022-03-13 17:21 |
xdrlib is deprecated as per PEP 594, so there won't be further enhancements to it.
|
|
Date |
User |
Action |
Args |
2022-04-11 14:57:05 | admin | set | github: 53753 |
2022-03-13 17:21:41 | iritkatriel | set | status: open -> closed
nosy:
+ iritkatriel messages:
+ msg415051
resolution: wont fix stage: needs patch -> resolved |
2021-12-03 23:42:33 | iritkatriel | set | title: xdrlib.Packer().pack_fstring throws a TypeError when called with a str() -> [doc] xdrlib.Packer().pack_fstring throws a TypeError when called with a str() versions:
+ Python 3.9, Python 3.10, Python 3.11, - Python 3.5, Python 3.6, Python 3.7 |
2017-05-30 09:37:36 | hnhn | set | files:
+ issue9544.2.patch
messages:
+ msg294746 |
2017-05-29 16:18:16 | serhiy.storchaka | link | issue30216 superseder |
2017-05-29 16:17:47 | serhiy.storchaka | set | versions:
+ Python 3.5, Python 3.6, Python 3.7, - Python 3.2, Python 3.3 nosy:
+ serhiy.storchaka
messages:
+ msg294700
stage: needs patch |
2017-05-29 14:37:52 | hnhn | set | nosy:
+ hnhn
|
2012-06-06 18:29:37 | petri.lehtinen | set | files:
+ issue9544.patch |
2012-06-06 18:28:44 | petri.lehtinen | set | messages:
+ msg162419 versions:
+ Python 3.2, Python 3.3, - Python 3.1 |
2012-06-01 08:23:46 | petri.lehtinen | set | nosy:
+ petri.lehtinen
|
2011-04-14 13:22:05 | gruszczy | set | nosy:
+ docs@python messages:
+ msg133739
assignee: docs@python components:
+ Documentation, - None |
2011-04-14 13:15:39 | benjamin.peterson | set | messages:
+ msg133737 |
2011-04-14 13:11:55 | gruszczy | set | messages:
+ msg133736 |
2011-04-14 13:03:46 | benjamin.peterson | set | messages:
+ msg133735 |
2011-04-14 10:19:42 | gruszczy | set | messages:
+ msg133719 |
2011-04-13 22:05:24 | benjamin.peterson | set | nosy:
+ benjamin.peterson messages:
+ msg133700
|
2011-03-28 16:19:48 | gruszczy | set | nosy:
+ mark.dickinson
|
2011-03-27 10:43:15 | gruszczy | set | files:
+ 9544.patch
nosy:
+ gruszczy messages:
+ msg132306
keywords:
+ patch |
2010-08-09 06:09:12 | arnoldp | set | messages:
+ msg113390 |
2010-08-09 05:54:46 | eric.araujo | set | type: crash -> behavior messages:
+ msg113388 |
2010-08-09 05:53:34 | eric.araujo | set | nosy:
+ eric.araujo messages:
+ msg113387
|
2010-08-09 05:51:25 | arnoldp | create | |