Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81560

bug or feature in enum34 py2.7 backport?

X-Received by 10.236.70.100 with SMTP id o64mr33316720yhd.9.1417001384041; Wed, 26 Nov 2014 03:29:44 -0800 (PST)
X-Received by 10.140.27.214 with SMTP id 80mr5571qgx.23.1417001384023; Wed, 26 Nov 2014 03:29:44 -0800 (PST)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!s7no1982602qap.1!news-out.google.com!m4ni572qag.1!nntp.google.com!s7no1982593qap.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Wed, 26 Nov 2014 03:29:43 -0800 (PST)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=91.125.54.111; posting-account=C1gZvwoAAAAojE_ZgHdwZjGSuZg6QpNd
NNTP-Posting-Host 91.125.54.111
User-Agent G2/1.0
MIME-Version 1.0
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>
Injection-Date Wed, 26 Nov 2014 11:29:44 +0000
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-Received-Bytes 2442
X-Received-Body-CRC 2482032385
Xref csiph.com comp.lang.python:81560

Show key headers only | View raw


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


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