EnumProperty cannot be accessed like data['property_name']
Closed, InvalidPublic

Description

System Info
Ubuntu 16.10 Linux version 4.8.0-32-generic (buildd@lcy01-34)

Blender Version
Broken: fc185fb1d2 (newest daily build)

Apart from the classical access data.property_name, all bpy.props can also be accessed like data['property_name']. This allows us to skip an update callback.
The bug is that it does not work until the first modification of the property.

>>> bpy.types.Scene.enum_prop = bpy.props.EnumProperty(items=[('ONE', "1", "One"), ('TWO', "2", "Two")], update=lambda x,y: print("update"))
>>> C.scene['enum_prop']
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
KeyError: 'bpy_struct[key]: key "enum_prop" not found'

Surprisingly enough, __setitem__ can do the job.

>>> C.scene.__setitem__("enum_prop", 'TWO')
>>> C.scene['enum_prop']
'TWO'

Details

Type
Bug
Bastien Montagne (mont29) claimed this task.

There is no bug at all here, you are confusing to completely different things:

  1. Properties define using bpy.props are “real” RNA properties, they behave like built-in native properties of RNA structures. It changes the definition of the class itself, since it’s available in all its instances.
  2. Properties defined/accessed with the 'dict' interface are IDProperties (a.k.a. Custom Properties), only usable with some limited type of data (IDs mostly, plus a few other ones like Bone). It only affects an instance of the RNA class, others won't have it.

In your example, C.scene['enum_prop'] is absolutely not an Enum property of the RNA class Scene, but an string IDProperty defined on current scene only.