Nick Coghlan ncogh...@gmail.com added the comment:
People may use SystemError for other purposes, but the docs are pretty clear it
is only for internal errors that indicate an interpreter bug:
http://docs.python.org/dev/library/exceptions.html#SystemError
Extension modules or an embedding
Marc-Andre Lemburg m...@egenix.com added the comment:
Alexander Belopolsky wrote:
Alexander Belopolsky belopol...@users.sourceforge.net added the comment:
On Thu, Feb 24, 2011 at 3:54 PM, Antoine Pitrou rep...@bugs.python.org
wrote:
..
I've committed the part of the patch which
Alexander Belopolsky belopol...@users.sourceforge.net added the comment:
Committed in r88546 (3.3) and r88548 (3.2).
Note that a simple work-around before 3.2.1 is to spell encoding as 'latin-1'
or 'iso-8859-1' in pickle.loads().
--
components: +Extension Modules -Library (Lib)
Antoine Pitrou pit...@free.fr added the comment:
I've committed the part of the patch which disallows a NULL data pointer with
PyMemoryView_FromBuffer in r88550 and r88551.
--
___
Python tracker rep...@bugs.python.org
Alexander Belopolsky belopol...@users.sourceforge.net added the comment:
On Thu, Feb 24, 2011 at 3:54 PM, Antoine Pitrou rep...@bugs.python.org wrote:
..
I've committed the part of the patch which disallows a NULL data pointer
with PyMemoryView_FromBuffer in r88550 and r88551.
Is it possible
Antoine Pitrou pit...@free.fr added the comment:
I've committed the part of the patch which disallows a NULL data pointer
with PyMemoryView_FromBuffer in r88550 and r88551.
Is it possible to create such buffer in Python (other than by
exploiting a bug or writing a rogue extension
Alexander Belopolsky belopol...@users.sourceforge.net added the comment:
It seems appropriate to consult python-dev on this. I thought
ValueError was for values that are valid Python objects but out of
acceptable range of the function. Errors that can only be triggered
in C code normally
Antoine Pitrou pit...@free.fr added the comment:
It seems appropriate to consult python-dev on this. I thought
ValueError was for values that are valid Python objects but out of
acceptable range of the function. Errors that can only be triggered
in C code normally handled with either
Nick Coghlan ncogh...@gmail.com added the comment:
A SystemError indicates that an internal API was given bogus input or produces
bogus output (i.e. we screwed up somewhere, or a third party is messing with
interfaces they shouldn't be)
If data validation fails for part of the public C API
Marc-Andre Lemburg m...@egenix.com added the comment:
Alexander Belopolsky wrote:
I am not sure PyUnicode_Decode() should treat NULL as an empty string.
Definitely not. That would hide programming errors.
--
nosy: +lemburg
title: Some trivial python 2.x pickles fails to load in
Antoine Pitrou pit...@free.fr added the comment:
I am not sure PyUnicode_Decode() should treat NULL as an empty string.
Definitely not. That would hide programming errors.
Well, this could break some third-party code.
--
title: Some trivial python 2.x pickles fails to load in
Marc-Andre Lemburg m...@egenix.com added the comment:
Antoine Pitrou wrote:
Antoine Pitrou pit...@free.fr added the comment:
I am not sure PyUnicode_Decode() should treat NULL as an empty string.
Definitely not. That would hide programming errors.
Well, this could break some
Antoine Pitrou pit...@free.fr added the comment:
Antoine Pitrou wrote:
Antoine Pitrou pit...@free.fr added the comment:
I am not sure PyUnicode_Decode() should treat NULL as an empty string.
Definitely not. That would hide programming errors.
Well, this could break some
Marc-Andre Lemburg m...@egenix.com added the comment:
Antoine Pitrou wrote:
Antoine Pitrou pit...@free.fr added the comment:
Antoine Pitrou wrote:
Antoine Pitrou pit...@free.fr added the comment:
I am not sure PyUnicode_Decode() should treat NULL as an empty string.
Definitely not.
Antoine Pitrou pit...@free.fr added the comment:
PyUnicode_Decode() et al. are conversion functions and these
require valid content to work on. Passing in a NULL pointer
does not fit that specification and so allowing for this
would hide programming errors.
Valid content doesn't mean a lot
Marc-Andre Lemburg m...@egenix.com added the comment:
Antoine Pitrou wrote:
Antoine Pitrou pit...@free.fr added the comment:
PyUnicode_Decode() et al. are conversion functions and these
require valid content to work on. Passing in a NULL pointer
does not fit that specification and so
Antoine Pitrou pit...@free.fr added the comment:
So, IMO, practicality beats purity here. Especially since it is bound to
land in a bugfix release (3.2.1), which users don't expect to produce
regressions in their own code.
Nope. Your suggestion would be a new feature and those are not
Jesús Cea Avión j...@jcea.es added the comment:
What if we commit Antoine patch for 3.2.x, and the correct patch for py3k
trunk?.
I am actually +1 to Marc-Andre. I feel in my guts that the provided patch is
hidding a deeper issue. But avoiding surprises for third parties in 3.2.1 is a
good
Antoine Pitrou pit...@free.fr added the comment:
Nope. Your suggestion would be a new feature and those are not
allowed in patch level releases.
What new feature are you talking about? I think you misunderstood the
actual issue: NULL as an empty string *worked* in 3.1
And, with a very
Marc-Andre Lemburg m...@egenix.com added the comment:
Please go with Alexander's solution of fixing the higher level code rather than
silently trying to introduce a new feature in PyUnicode_Decode() that hides
programming errors.
Thanks.
--
___
Antoine Pitrou pit...@free.fr added the comment:
Please go with Alexander's solution of fixing the higher level code
rather than silently trying to introduce a new feature in
PyUnicode_Decode() that hides programming errors.
I'm sorry, I'm perfectly fine with my own patch, so someone else
Marc-Andre Lemburg m...@egenix.com added the comment:
Jesús Cea Avión wrote:
Jesús Cea Avión j...@jcea.es added the comment:
What if we commit Antoine patch for 3.2.x, and the correct patch for py3k
trunk?.
I am actually +1 to Marc-Andre. I feel in my guts that the provided patch is
Antoine Pitrou pit...@free.fr added the comment:
Oops, I hadn't seen Alexander's patch. Sorry.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11286
___
Antoine Pitrou pit...@free.fr added the comment:
So, about Alexander's patch:
- it lacks a test
- it doesn't solve the issue with PyUnicode_Decode's confusing error message
when a NULL is passed (ValueError: operation forbidden on released memoryview
object); if we want to disallow NULL, we
Alexander Belopolsky belopol...@users.sourceforge.net added the comment:
Antoine is right, my patch is only of discussion quality and if my approach
gets support, I will produce a more polished patch.
While I am fairly certain that this bug should be fixed where it was
introduced, namely in
Antoine Pitrou pit...@free.fr added the comment:
It may be better to modify _Unpickler_Read() so that it returns
self-input_buffer (or even self-input_buffer + self-next_read_idx)
for zero n.
I agree this would be better for readability and maintainability.
On the other hand, my patch also
Alexander Belopolsky belopol...@users.sourceforge.net added the comment:
On Wed, Feb 23, 2011 at 10:22 AM, Antoine Pitrou rep...@bugs.python.org wrote:
..
Well, a theoretical argument could be made that some codec could return
a non-empty string when asked to decode an empty bytestring, but
Changes by Alexander Belopolsky belopol...@users.sourceforge.net:
--
assignee: - belopolsky
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11286
___
Alexander Belopolsky belopol...@users.sourceforge.net added the comment:
I am attaching a new version of issue11286.diff which fixes the issue by
removing special handling of n == 0 case from _Unpickler_Read(). Note that
_Unpickler_Read() (formerly known as unpickler_read()) only started to
Changes by Alexander Belopolsky belopol...@users.sourceforge.net:
Removed file: http://bugs.python.org/file20856/issue11286.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11286
___
New submission from Jesús Cea Avión j...@jcea.es:
I have 10MB pickled structure generated in Python 2.7. I only use basic
types (no clases) like sets, dictionaries, lists, strings, etc.
The pickle stores a lot of strings. Some of them should be bytes,
while other should be unicode. My idea is
Jesús Cea Avión j...@jcea.es added the comment:
I got a trivial (41 bytes long) reproductable case:
Pickle the following structure in Python 2.7, and try to unpickle with Python
3.2, using a latin1 encoding:
{'ya_volcados': {'comment': ''}}
Load with:
#!/usr/local/bin/python3
import
Antoine Pitrou pit...@free.fr added the comment:
Ok, so it boils down to:
pickle.loads(b'\x80\x02}q\x00U\x00q\x01h\x01s.')
{'': ''}
pickle.loads(b'\x80\x02}q\x00U\x00q\x01h\x01s.', encoding='latin1')
Traceback (most recent call last):
File stdin, line 1, in module
ValueError: operation
Jesús Cea Avión j...@jcea.es added the comment:
Storing the pickle using protocol 0, it works OK.
Using protocol 1 or 2, it fails.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11286
___
Antoine Pitrou pit...@free.fr added the comment:
This is because of the buffer pointer passed to the codecs machinery being NULL
when the empty string is being decoded.
Quick patch follows (needs a test). Also, it is not clear whether it is allowed
to store a NULL pointer in the buf member of
Antoine Pitrou pit...@free.fr added the comment:
Here is a patch with tests.
--
keywords: +patch
stage: needs patch - patch review
Added file: http://bugs.python.org/file20842/null_ptr_buffer.patch
___
Python tracker rep...@bugs.python.org
Nick Coghlan ncogh...@gmail.com added the comment:
Antoine's patch looks good to me.
Given the assumptions in the memoryview code, disallowing NULL for the buf
pointer sounds like the right thing to do, even for zero-length buffers.
--
___
Python
Changes by Alexander Belopolsky belopol...@users.sourceforge.net:
--
nosy: +belopolsky
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11286
___
___
Alexander Belopolsky belopol...@users.sourceforge.net added the comment:
I am not sure PyUnicode_Decode() should treat NULL as an empty string.
Decoding empty string is wasteful and if the caller knows that the string is
empty, it should skip decoding because the result is empty. Providing
39 matches
Mail list logo