Opened 15 years ago

Last modified 13 years ago

#1181 new Bugs

[boost.python] can modify enum value — at Version 1

Reported by: qiaozhiqiang@… Owned by: Dave Abrahams
Milestone: To Be Determined Component: python USE GITHUB
Version: Boost 1.34.0 Severity: Problem
Keywords: enum modify Cc:

Description (last modified by Dave Abrahams)

I use boost 1.34.0, python 2.5.1 User can modify the enum value, But enum should be a const value(read only).

enum my_enum{my_value};
struct my_s{ enum{ my_value2 };};

void my_export
{
    enum_< my_enum >("my_enum") .value("my_value", my_value);
    scope* my_s_scope = new scope(class_< my_s>("my_s", init<  >()));
    scope().attr("my_value2") = (int)my_value2;
    delete my_s_scope;
} 
#in python
module.my_enum.my_value = 1
print module.my_enum.my_value
module.my_s.my_value2 = 2
print module.my_s.my_value2
# we can modify the const value.
# output 
#  1
#  2

Change History (1)

comment:1 by Dave Abrahams, 14 years ago

Description: modified (diff)

Please try to use the WikiFormatting rules to create readable tickets.

Note: See TracTickets for help on using tickets.