Antoine Pitrou pit...@free.fr added the comment:
The patches were committed in r84403. Thank you very much!
--
resolution: - fixed
stage: unit test needed - committed/rejected
status: open - closed
versions: -Python 3.1
___
Python tracker
Antoine Pitrou pit...@free.fr added the comment:
The patch shouldn't remove the tests for tostring()/fromstring() (they might be
deprecated, but they are still supported).
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8990
Thomas Jollans tho...@jollans.com added the comment:
That sounds reasonable. I've updated the patch to keep the old
test_tofromstring testcase.
I'll also attach another patch in a moment that removes what I'm reasonably
sure is all the uses of array.tostring and .fromstring in the standard
Changes by Thomas Jollans tho...@jollans.com:
Added file: http://bugs.python.org/file18698/tostring_usage.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8990
___
Changes by Thomas Jollans tho...@jollans.com:
Removed file: http://bugs.python.org/file18607/tofrombytes.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8990
___
Changes by Thomas Jollans tho...@jollans.com:
Added file: http://bugs.python.org/file18606/tofrombytes.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8990
___
Changes by Thomas Jollans tho...@jollans.com:
Removed file: http://bugs.python.org/file18606/tofrombytes.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8990
___
Thomas Jollans tho...@jollans.com added the comment:
Hello again, sorry for the absense.
Victor, thanks for the input. I've attached a new patch that checks the
PyErr_WarnEx return value.
--
Added file: http://bugs.python.org/file18607/tofrombytes.diff
Changes by Antoine Pitrou pit...@free.fr:
Removed file: http://bugs.python.org/file17828/tofrombytes.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8990
___
Antoine Pitrou pit...@free.fr added the comment:
From a quick glance, the latest patch looks ok.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8990
___
STINNER Victor victor.stin...@haypocalc.com added the comment:
I prefer the second solution (add to/frombytes, deprecate to/fromstring)
because I prefer the new method names and it keeps backward compatibility
(until we choose to remove the old methods, which should be in Python 3.3).
About
Thomas Jollans tho...@jollans.com added the comment:
Two more patches:
Firstly, this patch (array_3.2_fromstring.diff) is nearly identical to
array2.diff. y* would (again) have to be changed to s* to apply this to 3.1
--
Added file:
Thomas Jollans tho...@jollans.com added the comment:
Secondly, this is my attempt to add the more sensibly named {to|from}bytes
methods, and to deprecate {to|from}string.
I doubt it's perfect, maybe there's some policy on deprecating methods that I
didn't find? This may be better discussed
Changes by Thomas Jollans tho...@jollans.com:
Added file: http://bugs.python.org/file17828/tofrombytes.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8990
___
Changes by Thomas Jollans tho...@jollans.com:
Removed file: http://bugs.python.org/file17827/tofrombytes.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8990
___
STINNER Victor victor.stin...@haypocalc.com added the comment:
array2.diff:
- can you reindent the line Py_ssize_t old_size = Py_SIZE(self);?(even if
it's not part of your patch)
- you can avoid the char *str; variable (use directly buffer.buf)
--
I changed s# to y*. This means that str
Thomas Jollans tho...@jollans.com added the comment:
OK, here's the new patch. I added tests for array(typecode,
bytearray(b'abab')), a.extend(b'123') and a.extend(bytearray(b'123')).
@Victor: int itemsize is the array's item size, buffer.itemsize is the strings'
(and must be 1)
PROBLEM
Thomas Jollans tho...@jollans.com added the comment:
Thanks for the input. I'm going to re-work the patch a bit (releasing buffers
and such) and add a test within the next few days.
The question remains whether or not to accept other buffers with itemsize == 1.
The way I understand it,
STINNER Victor victor.stin...@haypocalc.com added the comment:
About the patch:
- Why not reading itemsize from buffer.itemsize?
- A test would be nice in Lib/test/test_array.py (in test_tofromstring?).
Please add also a.extend(bytearray(b'xjxjx')) to the test suite.
I agree that it is a
Antoine Pitrou pit...@free.fr added the comment:
On the principle the patch looks good. In practice, it lacks a call to
`PyBuffer_Release(buffer)` in the various error cases (before returning NULL).
It also lacks some tests in Lib/test/test_array.py.
In 3.x unicode type was renamed to str
Terry J. Reedy tjre...@udel.edu added the comment:
Summary: real bug, needs test, patch provided, looks plausible but I am not
qualified to even read-review it, let alone apply and test.
(I am removing 3.3 because that is only listed for syntax feature requests that
cannot go into 3.2 because
Alexander Belopolsky belopol...@users.sourceforge.net added the comment:
Thomas' patch does more than just allow bytearray. It allows any object that
can present itself as a buffer with byte-size items. It is a bit unfortunate
that such method will end up being called fromstring in 3.x.
Terry J. Reedy tjre...@udel.edu added the comment:
Whatever is done, I think a bytearray should be handled the same as bytes. It
must be that they give the same result. In basic operations, I believe that
bytearrays can *always* substitute for bytes. Bytes and bytearray objects
contain single
Alexander Belopolsky belopol...@users.sourceforge.net added the comment:
This, to me, implies that .fromstring should accept bytearray (though
probably not general buffer objects). In 2.x, I understand .fromstring
to initialize an array from machine bytes read into a string, but not
New submission from Thomas Jollans tho...@jollans.com:
Currently, the array constructor, if given a bytearray, detects this with
PyByteArray_Check, and hands it on to array_fromstring, which does not support
bytearray (by using s# with PyArg_ParseTuple) and raises TypeError.
array('h',
25 matches
Mail list logo