Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81560
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2014-11-26 03:29 -0800 |
| Message-ID | <1b49aa55-ba5f-4e70-8ddb-ae5dea3a40da@googlegroups.com> (permalink) |
| Subject | bug or feature in enum34 py2.7 backport? |
| From | Mark Summerfield <list@qtrac.plus.com> |
Hi,
Here are two programs both executed with Python 2.7 with the enum34 backport and their output. Is this a bug or intended behavior? (It may well be intended to help ensure that the class name is ASCII for Python 2; but maybe it would be nicer to check a unicode to see if it is ASCII and if so, use it, and otherwise raise a more helpful exception?)
# t1.py
from __future__ import print_function
import enum
print(enum.version)
A = enum.Enum("A", "b c")
print(A.b, A.c)
$ python2 t1.py
(1, 0, 3)
A.b A.c
# t2.py
from __future__ import print_function
from __future__ import unicode_literals
import enum
print(enum.version)
A = enum.Enum("A", "b c")
print(A.b, A.c)
$ python2 t2.py
(1, 0, 3)
Traceback (most recent call last):
File "t2.py", line 5, in <module>
A = enum.Enum("A", "b c")
File "/usr/local/lib/python2.7/dist-packages/enum/__init__.py", line 326, in __call__
return cls._create_(value, names, module=module, type=type)
File "/usr/local/lib/python2.7/dist-packages/enum/__init__.py", line 434, in _create_
enum_class = metacls.__new__(metacls, class_name, bases, classdict)
File "/usr/local/lib/python2.7/dist-packages/enum/__init__.py", line 188, in __new__
enum_class = super(EnumMeta, metacls).__new__(metacls, cls, bases, classdict)
TypeError: type() argument 1 must be string, not unicode
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
bug or feature in enum34 py2.7 backport? Mark Summerfield <list@qtrac.plus.com> - 2014-11-26 03:29 -0800
Re: bug or feature in enum34 py2.7 backport? random832@fastmail.us - 2014-11-26 09:05 -0500
Re: bug or feature in enum34 py2.7 backport? Chris Angelico <rosuav@gmail.com> - 2014-11-27 01:40 +1100
Re: bug or feature in enum34 py2.7 backport? Mark Summerfield <list@qtrac.plus.com> - 2014-11-26 07:14 -0800
Re: bug or feature in enum34 py2.7 backport? Chris Angelico <rosuav@gmail.com> - 2014-11-27 02:17 +1100
Re: bug or feature in enum34 py2.7 backport? random832@fastmail.us - 2014-11-26 10:32 -0500
Re: bug or feature in enum34 py2.7 backport? Chris Angelico <rosuav@gmail.com> - 2014-11-27 02:46 +1100
Re: bug or feature in enum34 py2.7 backport? Ethan Furman <ethan@stoneleaf.us> - 2014-11-26 08:58 -0800
Re: bug or feature in enum34 py2.7 backport? Terry Reedy <tjreedy@udel.edu> - 2014-11-26 16:16 -0500
csiph-web