|
From: James M. <re...@bu...> - 2017-02-28 19:58:04
|
New submission from James Mudd: This is not a bug, but i wasn't sure where to put improvements? It would be nice if when calling a java method which takes a enum automatic type conversion from string could be done if possible. This would make calling enum methods more convenient. At the moment a call to a method taking a enum with a string fails, even if the enum valueOf(String) method would work e.g Jython 2.7.1b3 (, Feb 28 2017, 19:53:14) [Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_121 Type "help", "copyright", "credits" or "license" for more information. >>> import java.time.LocalDate >>> date = java.time.LocalDate.of(2015, 'DECEMBER', 3) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: of(): 2nd arg can't be coerced to int, java.time.Month >>> Since Jython already does other similar type coercion I think this would be a nice extension, but maybe i'm missing a reason why its a really bad idea? ---------- components: Core messages: 11142 nosy: jamesmudd severity: minor status: open title: Automatic string to enum coercion type: behaviour _______________________________________ Jython tracker <re...@bu...> <http://bugs.jython.org/issue2558> _______________________________________ |