Windows: using hg executable from an IDE results in python errors

Alexander Belchenko bialix at ukr.net
Fri Mar 21 00:58:03 CDT 2008


Patrick Mézard пишет:
> Alexander Belchenko a écrit :
>> Patrick Mézard пишет:
>>> Alexander Belchenko a écrit :
>>>> I'm not Patrick but you need to test is fd hasattr fileno. When
>>>> program running as
>>>> subprocess then pipes fd never had fileno. Because they're not real
>>>> files.
>>> Testing for fileno() availability cannot harm but I am not sure it
>>> will solved the issue here since we get a bad file descriptor issue
>>> rather than a missing attribute. I don't know how to check fileno() is
>>> valid, maybe it should be positive ? Do you know an easy way to test
>>> these kind of setup ?
>> Sorry, forgot to say about testing.
>> IIRC, for testing this issue I'm launching bzr as subprocess via
>> python's std lib subprocess module.
>> I don't remember exactly where this test resides in our test suite though.
>> I fixed this issue in December 2006, so I don't remember all details
>> about testing.
> 
> Thanks for the tip, a fix is in crew.
> 
> I found your fix in bzr but cannot grep the test right now. I am a bit surprised it's reproductible with subprocess, some tests use it heavily and I never had any problems with it. Anyway, reading fileno() like that was clearly wrong.

Patrick,

I'm VERY VERY VERY sorry. Please, don't bite me for wrong tip.
I don't need to wrote that without checking my old work first.
I apologize for this too much.

I just looked at my e-mail back in december 2006 and I wrote that:

"""...Because some tests
use StringIO file-like object instead of real sys.stdout
so I need to explicitly check for presence of fileno attribute..."

It seems like it's not the case for original problem.

But I did experiments for you, and now I can reproduce problem. When python script running with 
pythonw without *real* console and probably without real pipes connected to stdin/stdout/stderr
it still has fileno but fileno is wrong (-1).

Attached script illustrates problem. If you running it with C:\Python25\python.exe you'll
get good result without any error and filenos on my machine is 0,1,2 for in/out/err respectively.
If you running it with C:\Python25\pythonw.exe then all three filenos are -1 and original error
raised.

So I think in the case of PHPed IDE hg utility launched without stdin pipe, and therefore
hg crashed. I think it's usual to launch external script without stdin, because IDE is not
supposed to write anything there.

And therefore suggestion of Steve Borho is right right right.
Guys I apologize too much, I just need not to send any e-mails in the deep night.
I never will do that. I really sorry. You commit too fast.

/me going hide out somewhere.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.pyw
Url: http://selenic.com/pipermail/mercurial/attachments/20080321/48a478c8/attachment.txt 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pythonw.png
Type: image/png
Size: 7270 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial/attachments/20080321/48a478c8/attachment.png 


More information about the Mercurial mailing list