PyDev 0.9.8.5 released

2005-11-17 Thread Fabio Zadrozny
Hi All,

PyDev - Python IDE (Python Development Enviroment for Eclipse) version 
0.9.8.5 has been released.

Check the homepage (http://pydev.sourceforge.net/) for more details.

Details for Release: 0.9.8.5

Major highlights:
---

* Removed the dependency on packages 'sun..Base64', so that 
other VMs can be targetted
* Some code-completion problems in the 'resolution order' regarding 
tokens in __init__ were solved
* Added option so that the user can choose whether to automatically 
add 'self' or not in method declarations

Cheers,

Fabio

-- 
Fabio Zadrozny
--
Software Developer

ESSS - Engineering Simulation and Scientific Software
www.esss.com.br

PyDev - Python Development Enviroment for Eclipse
pydev.sf.net
pydev.blogspot.com



-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: best way to discover this process's current memory usage, cross-platform?

2005-11-17 Thread Serge Orlov

Jack Diederich wrote:
 Electric Fence[1] uses the LD_PRELOAD method.  I've successfully used it to
 track down leaks in a python C extension.  If you look at the setup.py in
 probstat[2] you'll see
   #libraries = [efence] # uncomment to use ElectricFence
 which is a holdover from developing.

I've also successfully used Electric Fence many years ago to track down
leaks in a C/Linux program. Since that time Electric Fence has been
forked into DUMA project http://duma.sourceforge.net/ and was ported to
windows, perhaps it has become cross-platform? I've never tried it on
anything besides Linux.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Addressing the last element of a list

2005-11-17 Thread Antoon Pardon
Op 2005-11-16, Mike Meyer schreef [EMAIL PROTECTED]:
 Antoon Pardon [EMAIL PROTECTED] writes:
 Op 2005-11-15, Mike Meyer schreef [EMAIL PROTECTED]:
 Antoon Pardon [EMAIL PROTECTED] writes:
 Like having an assignment operator (let use @= for it) next to a
 (re)bind operator.
 We could then have something like the following.
 a = 5
 b = a
 a @= 7
 b == would result in 7.
 You've just overwritten the object referred to by the token 5 in the
 source code with the value 7, so you get:
 print 5
 7
 You have a valid point, but I think a different approach is possible.
 Don't make the distinction between mutable and immutable types but
 between mutable and immutable objects. So an int wouldn't be an
 immutable type, but 5 would be an immutable object.
 So the code above I gave would throw an exception, but the following
 might work.
 a @= 5
 b = a
 b @= 7
 a == would result in 7.

 Which solves that issue but brings up - well, more issues. What
 happens if the third line is 'b @= seven'? Does this require an
 extra level of indirection in the implementation? Avoiding that kind
 of thing was the reason for suggesting this:

 It depends on how far you want to go.

 I think one can argue that in case of an inplace replacement, this
 only makes sense if the two objects belong to the same class. So
 no extra level of indirection is then required.

 Now factor in inheritance. Do users of this facility have to worry
 about static OO typing? That is, two objects that are otherwise
 completely interchangeable will raise an exception if you try to
 assign one to a variable holding the other, because they have the
 wrong type. That seems unpythonic.

I don't care much about pythonic or not. It seems a very volatile
concept, that adapts as the language evolves. I wouldn't be
surprised if augmented arithmetic operations would have been
considered unpythonic at some point. You could see this
limitation as a wart, but IMO the idea would still be usefull
with that limitation.

The limitation would ensure for example that although the value
of an argument could change, it's class couldn't. I think that
is worthwhile.

 Otherwise it really depends on how the builtin objects are implemented.
 For user classes, a somewhat simplistic implementation could be
 something like:

   def '@=' (one, two):
 one.__dict__.clear()
 one.__dict__.update(two.__dict__)

 Wouldn't one.__dict__ = dict(**two.__dict__) be a bit better?

 Anyway, this won't' work if the class of one of the objects has
 slots.

So? I wrote it was a simplistic idea. but things like setattr and
getattr, still work with objects that have slots. So which attributes
are present for a particulare object has to be available in the
python interpreter. So my guess is that slots wont be the big stumbling
block, should one consider implementing something like this.

 The critical thing is that this doesn't introduce any new facilities
 into the language, just some new syntax, so there's no implementation
 impact. In fact, if you're willing to put up with some notational
 abuse, we can do this now:

 class Ref(object):
 _unbound = object()
 def __new__(cls, value = _unbound):
 We're an object, but need to ignore the optional argument.

 return object.__new__(cls)

 def __init__(self, value = _unbound):
 Bind the  optional value, if provided.
 if value is not self._unbound:
 self._value = value

 def __pos__(self):
 Return value, if bound.
 try:
 return self._value
 except AttributeError:
 raise ValueError, %s object does not have a value stored. % \
   self.__class__.__name__

 def __iadd__(self, value):
 self._value = value
 return self

 Usage:

 x = Ref.Ref()
 x += 23
 +x
 23
 a = x
 x += 25
 +a
 25
 a += this is a test
 +x
 'this is a test'

 Since it doesn't have real lannguage support, things like +x += 25
 don't work. That's the only obvious gotcha. Maybe ~ would be a better
 prefix.

 I'm a bit puzzled on how you would implement this as real language
 support. As far as I understand this only works with Ref objects.

 Correct. That's the point.

 You can't do something like the following.

 l = [3, 7]
 a = Ref(l[0])

 Instead you would have to do something like
 l = [Ref(3), Ref(7)]
 a = l[0]

 So it seems that if you want to use this idea for implementing langauge
 support you will have to wrap all objects in a Ref internally and this
 seems some kind of extra indirection too.

 No, the idea is to expose this class to the user. They would have to
 explicitly wrap objects that they want to be able to be get a
 reference to.

Well that seems less usefull to me.

Let me explain, what I would like it for.

Sometime I'm programming with tree like structures. Occasionaly such
a tree has to be restructured. Now of course I could write it like
this:

  def restruct(tr):

if ...:
  tr.left = restruct(tr.left)
  tr.right = 

Re: running functions

2005-11-17 Thread Cameron Laird
In article [EMAIL PROTECTED],
Gorlon the Impossible  [EMAIL PROTECTED] wrote:
.
.
.
the fly' so to speak. I checked out the threading module and its
working for what I am trying to do at the moment, but I am open to
suggestions and eager to learn all I can about other options. Thanks
.
.
.
If threading is already working for you, stay with it; it
certainly has the technical ability to do all you describe
for your eventual goal.  Apart from that, just keep reading
the standard documentation.  You might also consider
URL: http://www.unixreview.com/documents/s=7822/ur0303j/  and
URL: http://www.unixreview.com/documents/s=7750/uni1041364857773/ 
(except that the latter is now in its second edition--why hasn't
the reviewer addressed this yet!?).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A way for closing an app monitor

2005-11-17 Thread Daniel Crespo
Ok. Thanks for your answer :-)

I have implemented  this and works correctly.

Daniel

-- 
http://mail.python.org/mailman/listinfo/python-list


how to organize a module that requires a data file

2005-11-17 Thread Steven Bethard
Ok, so I have a module that is basically a Python wrapper around a big 
lookup table stored in a text file[1].  The module needs to provide a 
few functions::

 get_stem(word, pos, default=None)
 stem_exists(word, pos)
 ...

Because there should only ever be one lookup table, I feel like these 
functions ought to be module globals.  That way, you could just do 
something like::

 import morph
 assist = morph.get_stem('assistance', 'N')
 ...

My problem is with the text file.  Where should I keep it?  If I want to 
keep the module simple, I need to be able to identify the location of 
the file at module import time.  That way, I can read all the data into 
the appropriate Python structure, and all my module-level functions will 
work immediatly after import.

I can only think of a few obvious places where I could find the text 
file at import time -- in the same directory as the module (e.g. 
lib/site-packages), in the user's home directory, or in a directory 
indicated by an environment variable.  The first seems weird because the 
text file is large (about 10MB) and I don't really see any other 
packages putting data files into lib/site-packages.  The second seems 
weird because it's not a per-user configuration - it's a data file 
shared by all users.  And the the third seems weird because my 
experience with a configuration depending heavily on environment 
variables is that this is difficult to maintain.

If I don't mind complicating the module functions a bit (e.g. by 
starting each function with if _lookup_table is not None), I could 
allow users to specify a location for the file after the module is 
imported, e.g.::

 import morph
 morph.setfile(r'C:\resources\morph_english.flat')
 ...

Then all the module-level functions would have to raise Exceptions until 
setfile() was called.  I don't like that the user would have to 
configure the module each time they wanted to use it, but perhaps that's 
unaviodable.

Any suggestions?  Is there an obvious place to put the text file that 
I'm missing?

Thanks in advance,

STeVe

[1] In case you're curious, the file is a list of words and their 
morphological stems provided by the University of Pennsylvania.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.spawnl error

2005-11-17 Thread Fredrik Lundh
Salvatore wrote:

 Does someone already had ths problem ?

 os.spawnl(os.P_NOWAIT,'c:\windows\notepad.exe')
 Traceback (most recent call last):
  File stdin, line 1, in ?
  File C:\Python24\lib\os.py, line 565, in spawnl
return spawnv(mode, file, args)
 OSError: [Errno 22] Invalid argument

that string doesn't contain what you think:

 print c:\windows\notepad.exe
c:\windows
otepad.exe

you can use raw string literals to get around this:

 os.spawnl(os.P_NOWAIT, r'c:\windows\notepad.exe')

more here:

http://docs.python.org/tut/node5.html#SECTION00512

/F 



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: searching for files on Windows with Python

2005-11-17 Thread Kent Johnson
Shane wrote:
 I've been giving Google a good workout with no luck. I would like to
 be able to search a Windows filesystem for filenames, returning a
 list off absolute paths to the found files, something like: 
 def findFiles(filename, pathToSearch):
  ...
  ...
  return foundFileNames
 
 Is the os module where I should start?

I always use Jason Orendorff's path module for this kind of stuff. It's way 
easier to use than os.whatever:

import path
files = path.path(pathToSearch).walkfiles(filename)

will give a list of path.path objects in pathToSearch whose names match 
filename (which is a glob so wildcards are recognized).

path.path is a subclass of str so the results can be used wherever you want the 
full path.

http://www.jorendorff.com/articles/python/path/index.html

Kent
-- 
http://mail.python.org/mailman/listinfo/python-list


Stretching a bitmap

2005-11-17 Thread David Poundall
Is it possible to import a bitmap and stretch it to fit a defined area
with wxPython?  If so, could someone point me to any relevent web
reference on the subject?

Thanks in advance

David

-- 
http://mail.python.org/mailman/listinfo/python-list


Python and U3 devices

2005-11-17 Thread Philippe C. Martin
Dear all,

Has anyone attempted to compile Python for a U3 device ?

Regards,

Philippe

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Stretching a bitmap

2005-11-17 Thread Larry Bates
Python Imaging Library (PIL) can size bitmaps.  I use
it to create thumbnails or to size bitmaps quite often.
There may be a wxPython built-in for this also, but
I don't know what it would be.

-Larry Bates

David Poundall wrote:
 Is it possible to import a bitmap and stretch it to fit a defined area
 with wxPython?  If so, could someone point me to any relevent web
 reference on the subject?
 
 Thanks in advance
 
 David
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyQt layout question: QScrollView and QGridLayout?

2005-11-17 Thread dwelch
Volker Lenhardt wrote:
 Phil Thompson schrieb:
 
 On Thursday 17 November 2005 2:56 pm, Volker Lenhardt wrote:

 prefer to use QGridLayout, but cannot add it to the scroll view.

 sc=QScrollView(self)
 layout=QGridLayout(..., sc.viewport())
 sc.addChild(layout)

 results in a TypeError.

 Is there a way to get it to work? Filling a box viewport with lots of
 padding boxes and white space labels to establish grids is very
 cumbersome. And I need 4 different layouts to change places.



 QGridLayout is not a sub-class of QWidget, which is what addChild() is 
 expecting. You probably want QGrid.

 Phil
 
 
 I hoped to find a more assuring answer. There's no MultiCellWidget, no 
 Col/RowStretching, no Col/RowSpacing in QGrid. I've got to patch up one 
 VBox with a whole bunch of QV/QHBoxes and QGrids not to mention the 
 white space QLabels to fill not used grid cells.
 
 And I have to delete all of them to change to another data layout.
 
 Are you sure that there's no way to fill a QScrollView with the help of 
 some QLayout?
 
 Still hopefully
 Volker

I _think_ I have code that does waht you want. This creates multiple 
layouts that contain an icon, a button, and some text on a scrollview. 
The code is awkward and ugly, but it works.


class ScrollToolView(QScrollView):
 def __init__(self,parent = None,name = None,fl = 0):
 QScrollView.__init__(self,parent,name,fl)
 self.items = {}
 self.setStaticBackground(True)
 self.enableClipper(True)
 
self.viewport().setPaletteBackgroundColor(qApp.palette().color(QPalette.Active, 
QColorGroup.Background))
 self.row_height = 120

 def viewportResizeEvent(self, e):
 for x in self.items:
 self.items[x].resize(e.size().width(), self.row_height)

 def addItem(self, name, title, pix, text, button_text, button_func):
 num_items = len(self.items)
 LayoutWidget = QWidget(self.viewport(),layoutwidget)
 LayoutWidget.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, 
QSizePolicy.Minimum))
 LayoutWidget.setGeometry(QRect(0, 0, self.width(), 
self.row_height))
 self.addChild(LayoutWidget)

 if num_items:
 self.moveChild(LayoutWidget, 0, self.row_height*num_items)

 layout = QGridLayout(LayoutWidget,1,1,10,10,layout)

 pushButton = QPushButton(LayoutWidget,pushButton)
 
pushButton.setSizePolicy(QSizePolicy(QSizePolicy.Maximum,QSizePolicy.Fixed,0,0,
 
pushButton.sizePolicy().hasHeightForWidth()))
 self.connect(pushButton,SIGNAL(clicked()), button_func)

 layout.addWidget(pushButton,2,2)

 textLabel = QLabel(LayoutWidget,textLabel)

 layout.addWidget(textLabel,1,1)

 pixmap = QLabel(LayoutWidget,pixmapLabel2)
 
pixmap.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,
  pixmap.sizePolicy().hasHeightForWidth()))
 pixmap.setMinimumSize(QSize(32,32))
 pixmap.setMaximumSize(QSize(32,32))
 pixmap.setPixmap(pix)
 pixmap.setScaledContents(1)

 layout.addWidget(pixmap,1,0)

 textLabel2 = QLabel(LayoutWidget,textLabel2)
 textLabel2.setAlignment(QLabel.WordBreak | QLabel.AlignTop)
 
textLabel2.setSizePolicy(QSizePolicy(QSizePolicy.Minimum,QSizePolicy.Expanding))

 layout.addWidget(textLabel2,2,1)

 if num_items:
 line = QFrame(LayoutWidget,line)
 line.setFrameShadow(QFrame.Sunken)
 line.setFrameShape(QFrame.HLine)
 layout.addMultiCellWidget(line,0,0,0,2)

 textLabel.setText(title)
 textLabel2.setText(text)
 pushButton.setText(button_text)
 self.resizeContents(self.width(), num_items*self.row_height*2)

 LayoutWidget.show()

 try:
 self.items[name]
 except KeyError:
 self.items[name] = LayoutWidget
 else:
 print ERROR: Duplicate button name:, name

 def clear(self):
 if len(self.items):
 for x in self.items:
 self.removeChild(self.items[x])
 self.items[x].hide()

 self.items.clear()
 self.resizeContents(self.width(), 0)



-Don
-- 
http://mail.python.org/mailman/listinfo/python-list


Importing a class without knowing the module

2005-11-17 Thread Franck PEREZ
Hello,

I'm developing a small XML marshaller and I'm facing an annoying
issue. Here's some sample code:

### My test application 
class Foo(object):
  #The class I'd like to serialize
  pass

import myMarshaller
foo = Foo()
s = myMarshaller.dumps(foo) #works fine, spits something like object
class = Foo...
another_foo = loads(s) #fails, see below

### My marshaller (in its own module) 
def loads(s):
  #First, get class name (here Foo)
  klass = eval(className) #fails because Foo is not in the
marshaller's namespace !

How could I tell the marshaller to locate the Foo class and any other
class I try to deserialize ? I've tried to pass my test application's
globals() to the marshaller, it works but it's dirty IMHO... I've
tried also to locate the class (here Foo) somewhere in sys.modules
in the loads method, but it was heavy and unsuccessful.

Thanks a lot for your help !
Franck
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: about try and exception

2005-11-17 Thread Carl J. Van Arsdall
I would think that when the exception occurs the interpreter exits the 
block of code it is currently in and enters the exception block.

Thus the line n = 1/2 would never get executed.


-Carl

Ben Bush wrote:
 I wrote the following code to test the use of try...exception,
 and I want n to be printed out. However, the following code's output is:
 Traceback (most recent call last):
   File 
 C:\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py, 
 line 310, in RunScript
 exec codeObject in __main__.__dict__
   File C:\py\use\tryExVa.py, line 7, in ?
 print n
 NameError: name 'n' is not defined
  
 the code is here:
  
 try:
 m=2/0
 n=1/2
 except ZeroDivisionError:
 pass
 print Yes!!! This line will always print
 print n

-- 
http://mail.python.org/mailman/listinfo/python-list


line order

2005-11-17 Thread Ben Bush
I run the following code and the red line and black line show at the same time. is there anyway to show the red line first, then the black line? for example, after I click the 'enter' key?

from Tkinter import *tk = Tk()canvas = Canvas(tk, bg=white, bd=0, highlightthickness=0)canvas.pack(fill=BOTH, expand=YES)canvas.create_line(100, 200, 350, 200, arrow=LAST,fill='red')canvas.create_line
(100, 0, 100, 200, arrow=FIRST)tk.mainloop()
-- 
http://mail.python.org/mailman/listinfo/python-list

Socket Error

2005-11-17 Thread Chad Everett
Does anyone know why you get socket error while trying to run IDLE and the
module.  Is says something about a Subprocess Startup Error.   I know that
it always says something about a personal firewall.  I have all that shut
off.  About 50% of the time when I try and test code by running the module
it will pop up.  Any suggestions?

thanks,


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Zope vs Php

2005-11-17 Thread Fernando Lujan
Jorge Godoy wrote:

Mike Meyer [EMAIL PROTECTED] writes:
  

That said, I have to confess that lately I've been using Cheetah
templates, because the syntax for inserting values is simpler, and the
way Cheetah templates work naturally in the Python inheritance
hierarchy.

In this article you will have a great overview about Zope and Zope 3.

http://www.zopemag.com/Issue010/Section_Articles/article_WhyZope3.html

Fernando Lujan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: searching for files on Windows with Python

2005-11-17 Thread Peter Hansen
Kent Johnson wrote:
 I always use Jason Orendorff's path module for this kind of stuff. It's 
 way easier to use than os.whatever:
 
 import path
 files = path.path(pathToSearch).walkfiles(filename)

A minor enhancement (IMHO) (though I certainly agree with Kent's 
recommendation here): since there is nothing else of interest in the 
path module, it seems to be a fairly common idiom to do from path 
import path and skip the doubled path.path bit.

-Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


[ python-Feature Requests-1353344 ] python.desktop

2005-11-17 Thread SourceForge.net
Feature Requests item #1353344, was opened at 2005-11-10 19:22
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1353344group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Installation
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Björn Lindqvist (sonderblade)
Assigned to: Nobody/Anonymous (nobody)
Summary: python.desktop

Initial Comment:
I would very much like a
/usr/share/applications/python.desktop file so that
Python can be started from the Program-menu in Linux,
just like you can from the Start-menu in Windows. I
think it would be very neat and good for beginners.

--

Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-11-17 14:43

Message:
Logged In: YES 
user_id=1188172

I added German translation. Regarding the icon: I do not
like that very much. Isn't there another Python icon
available in the standard sizes?

--

Comment By: Björn Lindqvist (sonderblade)
Date: 2005-11-16 19:16

Message:
Logged In: YES 
user_id=51702

I have attached a .desktop file and an icon. python.desktop
goes into /usr/share/applications and pycon.png into
/usr/share/pixmaps. It's only translated to Swedish because
I don't know other languages to well.

--

Comment By: Martin v. Löwis (loewis)
Date: 2005-11-13 23:41

Message:
Logged In: YES 
user_id=21627

Would you be willing to provide one?

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1353344group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1358527 ] subprocess.py fails on Windows when there is no console

2005-11-17 Thread SourceForge.net
Bugs item #1358527, was opened at 2005-11-16 22:59
Message generated for change (Comment added) made by blais
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1358527group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Martin Blais (blais)
Assigned to: Nobody/Anonymous (nobody)
Summary: subprocess.py fails on Windows when there is no console

Initial Comment:
Under Windows XP, using Python 2.4.2, calling a
subprocess from subprocess.py from a script that does
not have a console, with stdin=None (the default) fails.

Since there is a check for stdin=stdout=stderr=None
that just returns, to exhibit this problem you need to
at least set stdout=PIPE (just to get it to run past
the check for that special case).

The problem is that in _get_handles(), l581-582:

if stdin == None:
p2cread = GetStdHandle(STD_INPUT_HANDLE)


GetStdHandle returns None if there is no console.  This
is rather nasty bugger of a bug, since I suppose it
breaks most GUI applications that start without the
console (i.e. most) and that eventually invoke
subprocesses and capture their output.  I'm surprised
to find this.


To reproduce the problem, do this:

1. save the attached script to C:/temp/bug.py and
C:/temp/bug.pyw
2. create two shortcuts on your desktop to invoke those
scripts
3. open a shell and tail C:/temp/out.log


For bug.py, the log file should display:

2005-11-16 17:38:11,661 INFO 0


For bug.pyw (no console), the log file should show the
following exception:

2005-11-16 17:38:13,084 ERROR Traceback (most recent
call last):

  File C:\Temp\bug.pyw, line 20, in ?
out = call(['C:/Cygwin/bin/ls.exe'], stdout=PIPE)
#, stderr=PIPE)
  File C:\Python24\lib\subprocess.py, line 412, in call
return Popen(*args, **kwargs).wait()
  File C:\Python24\lib\subprocess.py, line 533, in
__init__
(p2cread, p2cwrite,
  File C:\Python24\lib\subprocess.py, line 593, in
_get_handles
p2cread = self._make_inheritable(p2cread)
  File C:\Python24\lib\subprocess.py, line 634, in
_make_inheritable
DUPLICATE_SAME_ACCESS)
TypeError: an integer is required

This is the bug.


Note: in this test program, I'm invoking Cygwin's
ls.exe.  Feel free to change it

--

Comment By: Martin Blais (blais)
Date: 2005-11-17 13:41

Message:
Logged In: YES 
user_id=10996

Here is an example of a workaround:

p = Popen(ps2pdf,
  stdin=PIPE, stdout=PIPE, stderr=PIPE,
  cwd=tempfile.gettempdir())
p.stdin.close() # FIXME: we need to specify and close
stdin explicitly
# because of a bug I found and reported
in subprocess.py
# when the program is launched without a
console, see SF bug
# tracker for the Python project for
details.  When the bug
# gets fixed we should be able to remove
this.


Basically I just specify stdin=PIPE and close it by hand.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1358527group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1358527 ] subprocess.py fails on Windows when there is no console

2005-11-17 Thread SourceForge.net
Bugs item #1358527, was opened at 2005-11-16 23:59
Message generated for change (Settings changed) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1358527group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Martin Blais (blais)
Assigned to: Peter Åstrand (astrand)
Summary: subprocess.py fails on Windows when there is no console

Initial Comment:
Under Windows XP, using Python 2.4.2, calling a
subprocess from subprocess.py from a script that does
not have a console, with stdin=None (the default) fails.

Since there is a check for stdin=stdout=stderr=None
that just returns, to exhibit this problem you need to
at least set stdout=PIPE (just to get it to run past
the check for that special case).

The problem is that in _get_handles(), l581-582:

if stdin == None:
p2cread = GetStdHandle(STD_INPUT_HANDLE)


GetStdHandle returns None if there is no console.  This
is rather nasty bugger of a bug, since I suppose it
breaks most GUI applications that start without the
console (i.e. most) and that eventually invoke
subprocesses and capture their output.  I'm surprised
to find this.


To reproduce the problem, do this:

1. save the attached script to C:/temp/bug.py and
C:/temp/bug.pyw
2. create two shortcuts on your desktop to invoke those
scripts
3. open a shell and tail C:/temp/out.log


For bug.py, the log file should display:

2005-11-16 17:38:11,661 INFO 0


For bug.pyw (no console), the log file should show the
following exception:

2005-11-16 17:38:13,084 ERROR Traceback (most recent
call last):

  File C:\Temp\bug.pyw, line 20, in ?
out = call(['C:/Cygwin/bin/ls.exe'], stdout=PIPE)
#, stderr=PIPE)
  File C:\Python24\lib\subprocess.py, line 412, in call
return Popen(*args, **kwargs).wait()
  File C:\Python24\lib\subprocess.py, line 533, in
__init__
(p2cread, p2cwrite,
  File C:\Python24\lib\subprocess.py, line 593, in
_get_handles
p2cread = self._make_inheritable(p2cread)
  File C:\Python24\lib\subprocess.py, line 634, in
_make_inheritable
DUPLICATE_SAME_ACCESS)
TypeError: an integer is required

This is the bug.


Note: in this test program, I'm invoking Cygwin's
ls.exe.  Feel free to change it

--

Comment By: Martin Blais (blais)
Date: 2005-11-17 14:41

Message:
Logged In: YES 
user_id=10996

Here is an example of a workaround:

p = Popen(ps2pdf,
  stdin=PIPE, stdout=PIPE, stderr=PIPE,
  cwd=tempfile.gettempdir())
p.stdin.close() # FIXME: we need to specify and close
stdin explicitly
# because of a bug I found and reported
in subprocess.py
# when the program is launched without a
console, see SF bug
# tracker for the Python project for
details.  When the bug
# gets fixed we should be able to remove
this.


Basically I just specify stdin=PIPE and close it by hand.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1358527group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com