[issue26984] int() can return not exact int instance

2016-08-21 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: commit review -> resolved
status: open -> closed

___
Python tracker 

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



[issue26984] int() can return not exact int instance

2016-08-21 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 81f229262921 by Serhiy Storchaka in branch 'default':
Issue #26984: int() now always returns an instance of exact int.
https://hg.python.org/cpython/rev/81f229262921

--
nosy: +python-dev

___
Python tracker 

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



[issue26984] int() can return not exact int instance

2016-08-21 Thread Mark Dickinson

Changes by Mark Dickinson :


--
assignee: mark.dickinson -> serhiy.storchaka
stage: patch review -> commit review

___
Python tracker 

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



[issue26984] int() can return not exact int instance

2016-08-21 Thread Mark Dickinson

Mark Dickinson added the comment:

The patch LGTM. I'm still in two minds about whether `__trunc__` should be 
required to return a strict `int`, but for now it's probably better to go with 
the status quo.

--

___
Python tracker 

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



[issue26984] int() can return not exact int instance

2016-08-18 Thread Mark Dickinson

Mark Dickinson added the comment:

> Could you please make a review Mark?

Sorry, Serhiy. I missed this. I've got some time off coming up, so I plan to 
look at this in the next few days.

--

___
Python tracker 

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



[issue26984] int() can return not exact int instance

2016-08-18 Thread Mark Dickinson

Changes by Mark Dickinson :


--
assignee:  -> mark.dickinson

___
Python tracker 

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



[issue26984] int() can return not exact int instance

2016-07-17 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Could you please make a review Mark?

--

___
Python tracker 

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



[issue26984] int() can return not exact int instance

2016-07-01 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Proposed patch makes int() always returning exact int.

--
keywords: +patch
stage:  -> patch review
Added file: http://bugs.python.org/file43600/int_exact.patch

___
Python tracker 

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



[issue26984] int() can return not exact int instance

2016-05-09 Thread Mark Dickinson

Mark Dickinson added the comment:

> But I think that the int constructor should convert its result to exact int.

Agreed. See also issue 17576 and previous discussions on python-dev (thread 
started in March, but most of the messages in April):

- https://mail.python.org/pipermail/python-dev/2013-March/125022.html
- https://mail.python.org/pipermail/python-dev/2013-April/125042.html

I don't have strong feelings about `__trunc__` (or `__floor__` and `__ceil__`); 
it seems fine to me for those to be returning something other than a strict int.

--

___
Python tracker 

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



[issue26984] int() can return not exact int instance

2016-05-09 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

The int constructor can return an instance of int subclass.

>>> class BadTrunc:
... def __trunc__(self):
... return True
... 
>>> int(BadTrunc())
True

When __int__ returns non-exact int, at least a warning is emitted:

>>> class BadInt:
... def __int__(self):
... return True
... 
>>> int(BadInt())
__main__:1: DeprecationWarning: __int__ returned non-int (type bool).  The 
ability to return an instance of a strict subclass of int is deprecated, and 
may be removed in a future version of Python.
True

The constructor of int subclass always return an instance of correct type:

>>> class IntSubclass(int):
... pass
... 
>>> type(IntSubclass(BadTrunc()))

>>> type(IntSubclass(BadInt()))
__main__:1: DeprecationWarning: __int__ returned non-int (type bool).  The 
ability to return an instance of a strict subclass of int is deprecated, and 
may be removed in a future version of Python.


I don't know if it is worth to deprecate __trunc__ returning non-exact int, 
since this special method is used in math.trunc(). But I think that the int 
constructor should convert its result to exact int. If some preparatory period 
is needed, it can first start to emit FutureWarning.

--
components: Interpreter Core
messages: 265196
nosy: mark.dickinson, serhiy.storchaka
priority: normal
severity: normal
status: open
title: int() can return not exact int instance
type: behavior
versions: Python 3.6

___
Python tracker 

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