[IronPython] Compiler error for invalid field access
Ori - Gmail
oorrii at gmail.com
Sun Aug 5 22:23:47 CEST 2007
Well yes, *somewhere*, but there is a big difference between writing the
code and executing it.
It is not easy to create and manage the context in my case
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: א 05 אוגוסט 2007 23:11
To: Discussion of IronPython
Subject: Re: [IronPython] Compiler error for invalid field access
> Executing the code to know if there is a problem or not is not what I wish
> for. I really can't do it because in my case the context does not exist.
> I will try to create a 'fake' context in order to run the code, but I'm
> sure it is a good idea..
I presume you are executing the code *somewhere*. What about catching
the error there? (Or creating a 'safe execution' method that does the
error trapping and routing all calls through that?)
> Chip Norkus wrote:
>> On Sun Aug 05, 2007; 12:51PM -0700, Ori wrote:
>>> I'm using the following code to compile python code:
>>> SystemState state = new SystemState();
>>> MyCompilerSink sink = new MyCompilerSink();
>>> CompilerContext context = new CompilerContext(string.Empty, sink);
>>> Parser parser = Parser.FromString(state, context, "my code");
>>> it works find for finding syntax mistakes - but I also wan to know about
>>> invalid property names / method names. If for example the code uses the
>>> expression 'self.Name' I would like to see a compilation error if the
>>> does not have a 'Name' property.
>> Because objects are mutable Python by its nature does not resolve
>> member/property references until they occur within the code. Consider
>> the following example (which is valid functional Python):
>> class foo(object):
>> setup = False
>> f = foo()
>> def bar(f):
>> if f.setup:
>> f.baz = "hi"
>> print f.baz
>> f.setup = True
>> print "setup"
>>> Is there a way to do it?
>>> View this message in context:
>>> Sent from the IronPython mailing list archive at Nabble.com.
>>> Users mailing list
>>> Users at lists.ironpython.com
>> personal: chip norkus; irc: wd; wd at teleri.net
>> info: finger wd at teleri.net for plan or keys; http://telekinesis.org
>> Users mailing list
>> Users at lists.ironpython.com
Users mailing list
Users at lists.ironpython.com
More information about the Ironpython-users