[issue14889] PyBytes_FromObject(bytes_object) fails

2012-05-24 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

I also wonder how the buffer interface section can fail.
PyBuffer_ToContiguous() should translate to a simple memcpy()
for a bytes object. What is going on?

--
nosy: +skrah

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14889] PyBytes_FromObject(bytes_object) fails

2012-05-24 Thread Larry Hastings

Larry Hastings la...@hastings.org added the comment:

I can't reproduce this, and it was pretty late in my day when I saw it, so 
let's assume I was mistaken and PyBytes_CheckBuffer() works fine.  Nevertheless 
I think the patch is a good idea--why create a new object when you don't have 
to?  Unless I hear otherwise I'll check it in in the next day or so.

As for what I saw, I suspect it was a deliberate TypeError from the regression 
test suite, passing in an integer 0 as a filename to os.rename().  Naturally 
PyBytes_FromObject() fails to convert that to a bytes object.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14889] PyBytes_FromObject(bytes_object) fails

2012-05-23 Thread Larry Hastings

New submission from Larry Hastings la...@hastings.org:

If you pass a valid PyUnicodeObject into PyUnicode_AsObject(), it incref's the 
original object and returns it.

If you pass a valid PyBytesObject into PyBytes_AsObject()... it fails.

I assert that in the PyBytes_AsObject() should behave like PyUnicode_AsObject() 
when faced with an identity transformation.

(Brett: I tagged you because I saw your name in the comments, so I figured you 
were a good candidate.)

--
assignee: larry
messages: 161414
nosy: brett.cannon, larry
priority: normal
severity: normal
stage: needs patch
status: open
title: PyBytes_FromObject(bytes_object) fails
type: behavior
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14889] PyBytes_FromObject(bytes_object) fails

2012-05-23 Thread Hynek Schlawack

Changes by Hynek Schlawack h...@ox.cx:


--
nosy: +hynek

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14889] PyBytes_FromObject(bytes_object) fails

2012-05-23 Thread Larry Hastings

Larry Hastings la...@hastings.org added the comment:

The appropriate four line patch.  (Six with whitespace.)

--
keywords: +patch
stage: needs patch - patch review
Added file: 
http://bugs.python.org/file25682/larry.pybytes_fromobject.identity.1.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14889] PyBytes_FromObject(bytes_object) fails

2012-05-23 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

I suppose you are referring to PyUnicode_FromObject() and 
PyBytes_FromObject()...
And by it fails did you simply mean it fails to return the same object?

--
nosy: +amaury.forgeotdarc

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14889] PyBytes_FromObject(bytes_object) fails

2012-05-23 Thread Larry Hastings

Larry Hastings la...@hastings.org added the comment:

1) Yes, whoopsies.  It's late.

2) It fails, as in, it returns NULL.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14889] PyBytes_FromObject(bytes_object) fails

2012-05-23 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

 2) It fails, as in, it returns NULL.
It's not my experience. Do you have an example?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14889] PyBytes_FromObject(bytes_object) fails

2012-05-23 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Well, the patch is nice but the PyObject_CheckBuffer(...) part should have 
succeeded, so it's a bit mysterious why it doesn't.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14889] PyBytes_FromObject(bytes_object) fails

2012-05-23 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14889
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com