[ 
https://issues.apache.org/jira/browse/THRIFT-2059?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jens Geyer resolved THRIFT-2059.
--------------------------------
    Fix Version/s: 0.17.0
         Assignee: Kevin Wojniak
       Resolution: Fixed

> Support for Python 3.4 enums
> ----------------------------
>
>                 Key: THRIFT-2059
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2059
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Python - Compiler
>    Affects Versions: 0.9
>            Reporter: James Haggerty
>            Assignee: Kevin Wojniak
>            Priority: Minor
>             Fix For: 0.17.0
>
>         Attachments: thrift-0001-Python3.4-style-enum-support.patch
>
>          Time Spent: 2h 50m
>  Remaining Estimate: 0h
>
> Currently enums are represented in Python by classes (see [#THRIFT-546]) but 
> those classes are not referenced by the actual values (which are simply 
> i32s). This means that it's impossible to find out whether something is an 
> enum or an i32 by inspection.
> e.g. I want to be able to look at the number 1 and realise it's an 
> Operation.ADD or similar.
> I propose adding an option 'enum' to the generator to support Python 3.4 
> style enums (see enum34 package on pypi). Any I32 that should be an enum is 
> automatically converted into an IntEnum derived object on deserialising, and 
> constants are also constructed with the correct type. If one chooses to 
> enable the option, it's almost backwards compatible with existing code due to 
> IntEnum, except that the dicts _VALUES_FOR_NAME/_NAMES_FOR_VALUES have been 
> removed (no longer necessary, and don't play nicely with the Enum class).



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to