[omniORB] omniidl python backend is generating name-clashing code

Duncan Grisby duncan at grisby.org
Wed Oct 11 19:51:22 BST 2006


On Tuesday 10 October, Alexander Haarer wrote:

> There seems to be no mechanism that maps python reserved words with a
> prefix (like for c++)

It does escape keywords, by prefixing them with a single underscore.

The problem you have found is that Python doesn't consider None to be a
keyword, but there is some magic that prevents you from assigning to
None. omniidl uses the standard Python keyword module to ask if an
identifier is a keyword, and Python that doesn't claim that None is one:

Python 2.4.1 (#1, May 16 2005, 15:19:29) 
[GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import keyword
>>> keyword.iskeyword("def")
True
>>> keyword.iskeyword("None")
False

The simple fix is to add None as a special case so it gets escaped even
though it isn't claimed to be a keyword. I've checked the change in to
cvs in both omniORBpy 2 and 3.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the omniORB-list mailing list