.
D 2026-06-04T02:23:15.799
J assignee nobody
J closer nobody
J cmimetype text/plain
J comment In\sthe\sfollowing\sexample,\sthe\sclassvariable\sm_columns\sstatement\sinside\sof\sclassmethod\ssetit\screates\sa\svariable\sthat\sis\sunusable\sin\sthe\sordinary\sway\sin\sa\snew\snamespace\sin\sthe\s::oo\sspace\srather\sthan\slink\sto\sthe\sclass-wide\svariable\sas\sone\swould\sexpect.\sThis\sproduces\sa\sbug\swhich\sis\shard\sto\sdiagnose.\r\n\r\nNote\sthat\sif\sone\sdoes\sthe\ssame\sthing\sin\sthe\sinitialize\ssection,\san\serror\sis\sthrown:\s\s"self\smay\sonly\sbe\scalled\sfrom\sinside\sa\smethod".\sThat\serror\sseems\sto\sbe\sbased\son\sthe\simlementation\sof\sinitialize\sand\scould\sprobably\sbe\smore\shelpful\sand\sdirect\swith\sdifferent\swording,\sbut\sat\sleast\sit\sdoesn't\ssilently\screate\san\sunreachable\svariable.\r\n\r\nThe\sworkaround\sis\sto\suse\svariable\sinstead\sof\sclassvariable\sinside\sthe\sclassmethod.\sBut\sthis\sis\slikely\sto\sbe\sforgotten\ssince\sit\sdoesn't\sseem\sconsistent.\r\n\r\n\soo::class\screate\stest1\s{\r\n\s\s\s\sinitialize\s{\r\n\s\s\s\s\s\s\s\svariable\sm_columns\s[dict\screate\sinitial\s{value1\svalue2\svalue3}]\r\n\s\s\s\s}\r\n\s\s\s\s\r\n\s\s\s\sclassmethod\ssetit\s{}\s{\r\n\s\s\s\s\s\s\s\sclassvariable\sm_columns\r\n\s\s\s\s\s\s\s\sdict\sset\sm_columns\sfoo\s{garp\sparp\ssnarp}\r\n\s\s\s\s\s\s\s\sputs\s[format\s{in\ssetit:\sself=%s\sm_columns=%s}\s[self]\s$m_columns]\r\n\s\s\s\s}\r\n\s\s\s\s\r\n\s\s\s\sconstructor\s{}\s{\r\n\s\s\s\s\s\s\s\sclassvariable\sm_columns\r\n\s\s\s\s\s\s\s\sputs\s[format\s{in\sconstructor:\sself=%s\sm_columns=%s}\s[self]\s$m_columns]\r\n\s\s\s\s}\r\n\r\n\s\s\s\smethod\sshowit\s{}\s{\r\n\s\s\s\s\s\s\s\sclassvariable\sm_columns\r\n\s\s\s\s\s\s\s\sputs\s[format\s{in\sshowit:\sself=%s\sm_columns=%s}\s[self]\s$m_columns]\r\n\s\s\s\s}\r\n}\r\n\r\n\r\n%\stest1\ssetit\r\nin\ssetit:\sself=::test1\sm_columns=foo\s{garp\sparp\ssnarp}\r\n\s%\sinfo\sobject\snamespace\s::test1\r\n::oo::Obj106\r\n\s%\sset\sr\s[test1\snew]\r\nin\sconstructor:\sself=::oo::Obj108\sm_columns=initial\s{value1\svalue2\svalue3}\r\n::oo::Obj108\r\n\s%\s$r\sshowit\r\nin\sshowit:\sself=::oo::Obj108\sm_columns=initial\s{value1\svalue2\svalue3}\r\n\s%\s\r\n\s%\sinfo\svars\s::oo::Obj106::*\r\n::oo::Obj106::m_columns\r\n\s%\sinfo\svars\s::oo::Obj107::*\r\n::oo::Obj107::m_columns\r\n\s%\sinfo\svars\s::oo::Obj108::*\r\n\s%\s\r\n\s%\sset\s::oo::Obj106::m_columns\r\ninitial\s{value1\svalue2\svalue3}\r\n\s%\sset\s::oo::Obj107::m_columns\r\nfoo\s{garp\sparp\ssnarp}\r\n\s%
J foundin 9.1a0
J is_private 0
J login anonymous
J priority 5\sMedium
J resolution None
J severity Minor
J status Open
J submitter anonymous
J subsystem 35.\sTclOO\sPackage
J title classvariable\sinside\sclassmethod\screates\sunusable\svariable
J type Bug
K 477e96c250ba11df6cd4e8f548a0d06da078b0ed
U anonymous
Z ce42defcb35683fd4530dbc44e855fb0