[issue43945] [Enum] standardize format() behavior

2021-06-29 Thread Barry A. Warsaw


Change by Barry A. Warsaw :


--
nosy: +barry

___
Python tracker 

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



[issue43945] [Enum] standardize format() behavior

2021-06-18 Thread Ethan Furman


Change by Ethan Furman :


--
resolution:  -> fixed
stage: patch 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



[issue43945] [Enum] standardize format() behavior

2021-06-18 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 1b4addf3cbd0ef424939681ee67c802328d567ba by Ethan Furman in 
branch '3.10':
[3.10] bpo-43945: [Enum] reduce scope of new format() behavior (GH-26752) 
https://github.com/python/cpython/commit/1b4addf3cbd0ef424939681ee67c802328d567ba


--

___
Python tracker 

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



[issue43945] [Enum] standardize format() behavior

2021-06-18 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +25375
pull_request: https://github.com/python/cpython/pull/26791

___
Python tracker 

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



[issue43945] [Enum] standardize format() behavior

2021-06-18 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset f60b07ab6c943fce084772c3c7731ab3bbd213ff by Ethan Furman in 
branch 'main':
bpo-43945: [Enum] reduce scope of new format() behavior (GH-26752)
https://github.com/python/cpython/commit/f60b07ab6c943fce084772c3c7731ab3bbd213ff


--

___
Python tracker 

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



[issue43945] [Enum] standardize format() behavior

2021-06-15 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +25337
pull_request: https://github.com/python/cpython/pull/26752

___
Python tracker 

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



[issue43945] [Enum] standardize format() behavior

2021-06-15 Thread Ethan Furman


Ethan Furman  added the comment:

Thinking about this some more I am partially reversing course.  The idea behind 
`IntEnum` and `IntFlag` is to be, as close as possible, drop-in replacements 
for existing integer-based constants.  If the format() of those two change then 
they become much less attractive.

So it won't.  Instead, any user-mixed enumerations will get the new behavior:

class Grades(int, Enum):
A = 5
F = 0

will emit a DeprecationWarning now, and in 3.12 `format(Grades.A)` will product 
'A' instead of '5'.

--

___
Python tracker 

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



[issue43945] [Enum] standardize format() behavior

2021-04-26 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 5987b8c463892e0ab7a63cdae92f34b5eb79732d by Ethan Furman in 
branch 'master':
bpo-43945: [Enum] Deprecate non-standard mixin format() behavior (GH-25649)
https://github.com/python/cpython/commit/5987b8c463892e0ab7a63cdae92f34b5eb79732d


--

___
Python tracker 

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



[issue43945] [Enum] standardize format() behavior

2021-04-26 Thread Ethan Furman


Change by Ethan Furman :


--
keywords: +patch
pull_requests: +24340
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/25649

___
Python tracker 

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



[issue43945] [Enum] standardize format() behavior

2021-04-26 Thread Ethan Furman


New submission from Ethan Furman :

Currently, an enum with a mixed-in data type, such as IntEnum, will use that 
data type's `__format__` -- unless the user provides their own `__str__`, in 
which case the `str()` of the enum member will be used in the `format()` call.

This behavior will be deprecated in 3.10, and in 3.12 the default `__format__` 
will use the default `__str__`, which is the standard behavior for Python 
objects

For those that were relying on, for example,

class Color(IntEnum):
RED = 1

f'{Color.RED}' # -> '2'

They will need to add ":d" to ensure the integer output:

f'{Color.RED:d}'

This change does work now.

--
assignee: ethan.furman
messages: 391995
nosy: ethan.furman
priority: normal
severity: normal
stage: needs patch
status: open
title: [Enum] standardize format() behavior
type: behavior
versions: Python 3.10, Python 3.11

___
Python tracker 

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