Convenience API illegal identifiers should raise SyntaxError - maybe

Bug #1167054 reported by Barry Warsaw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
flufl.enum
Won't Fix
Undecided
Unassigned

Bug Description

Class syntax with invalid identifiers raises a SyntaxError:

class X(Enum):
   a-1 = 3

but the convenience API raises a ValueError. This latter should also raise SyntaxError for consistency.

OTOH, should we be consistent with namedtuples?

http://docs.python.org/3/library/collections.html?highlight=namedtuple#collections.namedtuple

>>> namedtuple('X', ('x-1', 'y-2'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/py33/lib/python3.3/collections/__init__.py", line 334, in namedtuple
    'identifiers: %r' % name)
ValueError: Type names and field names must be valid identifiers: 'x-1'

Barry Warsaw (barry)
summary: - Convenience API illegal identifiers should raise SyntaxError
+ Convenience API illegal identifiers should raise SyntaxError - maybe
Revision history for this message
Barry Warsaw (barry) wrote :

After further consideration, it makes sense to be consistent with namedtuples, so ValueError it will be for now.

Changed in flufl.enum:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.