[Orbit-python-list] Spec non-compliance re unions
Status: Inactive
Brought to you by:
tack
From: Chip R. <ch...@ni...> - 2001-10-29 10:28:38
|
Tack requested that I send details about comments I made on IRC, so here they are. Copying the union example in the spec (v1.0, dated February 2001), section 1.3.5, I created this IDL: module Onion { interface OnionIF { union MyUnion switch (long) { case 1: string s; default: long x; }; }; }; To test it, I copied the Python code in the same section of the spec, giving this: #! /usr/bin/env python import CORBA from Onion import OnionIF u = OnionIF.MyUnion (17, 42) print u.x u = OnionIF.MyUnion (s = 'string') print u._d, u._v (As an aside, I know of no way with o-p to code simply "MyUnion", because "OnionIF" is not a valid import source. Is this just not possible, or am I missing something? I probably wouldn't code it that way anyway, but was just curious.) When run, using o-p 0.3.0, that returns this error message: Traceback (innermost last): File "./onion-clnt", line 7, in ? print u.x AttributeError: x Commenting out the first "print" and running again gives this: Traceback (innermost last): File "./onion-clnt", line 8, in ? u = OnionIF.MyUnion (s = 'string') TypeError: this function takes no keyword arguments What actually works is this code: #! /usr/bin/env python import CORBA from Onion import OnionIF u = OnionIF.MyUnion (17, 42) print u.v u = OnionIF.MyUnion (1, 'string') print u.d, u.v Which prints this: 42 1 string Which is the form I'm currently using in my application. Earlier, I had found a similar situation related to structures, which I'll describe in a subsequent message. -- Chip |