[issue24731] Incorrect assert in str_subtype_new

2015-12-01 Thread Kevin Modzelewski

Kevin Modzelewski added the comment:

Awesome, thanks!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24731] Incorrect assert in str_subtype_new

2015-11-29 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 2ea1a3bf448f by Serhiy Storchaka in branch '2.7':
Fixed Py3k warnings in tests for issue #24731.
https://hg.python.org/cpython/rev/2ea1a3bf448f

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24731] Incorrect assert in str_subtype_new

2015-11-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you for your report Kevin and sorry for the delay. I confirm the bug and 
agree with your solution. The same bug exists for ints and floats.

Here are patches that fix crashes.

--
keywords: +patch
nosy: +mark.dickinson
stage: needs patch -> patch review
Added file: http://bugs.python.org/file41126/issue24731.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24731] Incorrect assert in str_subtype_new

2015-11-22 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


Added file: http://bugs.python.org/file41127/issue24731-2.7.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24731] Incorrect assert in str_subtype_new

2015-07-26 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
assignee:  - serhiy.storchaka
nosy: +serhiy.storchaka
stage:  - needs patch
type:  - crash
versions: +Python 3.4, Python 3.6

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



[issue24731] Incorrect assert in str_subtype_new

2015-07-26 Thread Kevin Modzelewski

New submission from Kevin Modzelewski:

(Using python 3 terminology)  str_subtype_new is the function that creates 
instances of any subtypes of bytes (ie is called by bytes_new if the requested 
type is not PyBytes_Type -- looks like this function's name comes from python 
2).  Its approach is to create a bytes object using the same arguments, and 
then copy the resulting data into the subclass-instance's memory.  It does

tmp = bytes_new(PyBytes_Type, args, kwds);
[error checking]
assert(PyBytes_CheckExact(tmp));

The problem is that bytes_new can return a subclass of bytes, if the argument 
provides a __bytes__ method that returns a bytes-subtype.  For example

class MyBytes(bytes):
pass
class C(object):
def __bytes__(self):
return MyBytes(bhello world)
MyBytes(C()) # fails the assert

This doesn't seem to cause any issues other than the failing assert in debug 
builds; it seems like the assert should just be relaxed from PyBytes_CheckExact 
to PyBytes_Check since that's enough to guarantee that the upcoming 
manipulation of the tmp variable is going to be valid.  Also, this would 
match how unicode_subtype_new behaves.

This bug also applies to Python 2, since I think the relevant code is the same, 
though in that case it applies to str instead of bytes.

--
components: Interpreter Core
messages: 247451
nosy: Kevin Modzelewski
priority: normal
severity: normal
status: open
title: Incorrect assert in str_subtype_new
versions: Python 2.7, Python 3.5

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