Re: [PATCH] Fix execution of when executing via "python -m xxx meld"



On Sat, Apr 14, 2012 at 3:11 PM, Kai Willadsen <kai willadsen gmail com> wrote:
> On 11 April 2012 16:48, Peter Tyser <ptyser gmail com> wrote:
>> Previously Meld would fail if python was invoked with other modules
>> called out on the command line.  For example if using the "trace"
>> module:
> <snip>
>
> This looks like a problem that's specific to certain modules... maybe
> just those using runpy? I know, for example, that (c)profile works
> fine as I use it all the time.
>
> For that matter, I can't get your test case to fail on my machine
> running 2.7. I see that some additions were made to runpy that look
> like they're aimed at addressing this kind of case, so I'm guessing
> it's just the python version at work here.

I see the same behavior - 2.6 exhibits the problem, 2.7 doesn't.

>> bin/meld previously used the "__file__" variable to find out where the
>> meld source was located.  However when using the "-m" parameter to
>> Python, the "__file__" variable would point to Python's module loader
>> "runpy" which resulted in the above error.  Using argv[0] to determine
>> Meld's location should be more flexible and fixes the error.
>
> I'm not a fan of the argv[0] thing to be honest. Using __file__ feels
> like the Right Way to do it, and absent evidence to the contrary I'd
> like to stick to it. I might be open to adding a runpy-specific
> workaround, but given that this is only a problem for some modules and
> it doesn't even seem to be a problem from 2.7 on, I'm not convinced
> that it's worth it.

OK.  I don't think its too big of a deal either, especially since it
only affect developers with older software installed.  Potentially a
check of "if os.path.basename(__file__) != "meld" could be added with
an error message, or fallback to using argv[0].  In any case, feel
free to ignore this patch, or let me know if you want some
check/workaround added and I'll respin.

I like the new website for what its worth!

Peter


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]