Re: [Boost-bugs] [Boost C++ Libraries] #1181: [boost.python] can modify enum value

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #1181: [boost.python] can modify enum value
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-06-26 21:15:31


#1181: [boost.python] can modify enum value
-------------------------------------------+--------------------------------
  Reporter: qiaozhiqiang_at_[hidden] | Owner: dave
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: Python
   Version: Boost 1.34.0 | Severity: Problem
Resolution: | Keywords: enum modify
-------------------------------------------+--------------------------------
Old description:

> 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

New description:

 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).

 {{{
 #!cpp
 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;
 }
 }}}

 {{{
 #!python
 #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
 }}}

Comment (by dave):

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

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/1181#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC