Re: pyWin32 attempted installation; Error message: Skipping exchdapi: No library 'Ex2KSdk'

2011-01-02 Thread Kev Dwyer
On Sat, 01 Jan 2011 20:53:47 -0800, marceepoo wrote:

 I just downloaded pyWin32 (https://sourceforge.net/projects/pywin32/)
 and started to install it.
 
 I get these error msgs:
 
 Skipping exchange: No library 'Ex2KSdk' Skipping exchdapi: No library
 'Ex2KSdk' Skipping directsound: The header 'dsound.h' can not be located
 
 Does anyone have any suggestions about how to address this?
 
 Thanks,Marceepoo

Are you using the binary installer or building from source?

Cf 
http://stackoverflow.com/questions/4476764/pywin32-support-trouble-while-building-syntax-error

Cheers,

Kev

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


Re: How to define a bytes literal in Python 2.x for porting to Python 3.x using 2to3?

2011-01-02 Thread Stefan Behnel

Terry Reedy, 01.01.2011 23:47:

1. Code running in multiple versions has to be syntactically correct in
every detail all versions in order to be compiled without error. However,
version specific syntax *can* be used in modules that are conditionally
imported and therefore conditionally compiled and executed.


This is something that might also be a suitable solution for the OP's 
problem. The format strings can be by externalised into an importable 
module, which can then be duplicated to use the 'b' bytes prefix for Python 3.


The obvious drawback is that this moves the strings out of the immediate 
sight of someone reading the sources, and that it requires the two string 
modules to be kept in sync. But at least for the synchronisation, a 
simplistic conversion tool run during installation could do the trick.


Stefan

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


list 2 dict?

2011-01-02 Thread Octavian Rasnita
Hi,

If I want to create a dictionary from a list, is there a better way than the 
long line below?

l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']

d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in 
range(len(l)) if x %2 == 1]))

print(d)

{8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'}

Thanks.

Octavian

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


Re: CPython on the Web

2011-01-02 Thread Katie T
On Sun, Jan 2, 2011 at 7:26 AM, azakai alonmozi...@gmail.com wrote:
 The idea is that by compiling CPython itself, all the features of the
 language are immediately present, and at the latest version, unlike
 writing a new implementation which takes time and tends to lag behind.
 As to why run it on the web, there could be various uses, for example
 it could allow a simple learning environment for Python, which since
 it's on the web can be entered immediately without any download (and
 would run even in places where Python normally can't, like say an
 iPad).

It looks pretty neat ! - most solutions I've seen involve running
Python in a sandbox environment on the server as opposed to on the
client desktop.

Katie
-- 
CoderStack
http://www.coderstack.co.uk/perl-jobs
The Software Developer Job Board
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list 2 dict?

2011-01-02 Thread Ian Kelly

On 1/2/2011 6:18 AM, Octavian Rasnita wrote:

Hi,

If I want to create a dictionary from a list, is there a better way than the 
long line below?

l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']

d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in 
range(len(l)) if x %2 == 1]))


d = dict(zip(l[0::2], l[1::2]))

Or, using the grouper function recipe from the itertools documentation:

d = dict(grouper(2, l))

Cheers,
Ian

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


Re: list 2 dict?

2011-01-02 Thread Stefan Sonnenberg-Carstens

Am 02.01.2011 14:18, schrieb Octavian Rasnita:

l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']

l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']
dict(zip(l[0::2],l[1::2]))
{8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'}
--
http://mail.python.org/mailman/listinfo/python-list


Re: CPython on the Web

2011-01-02 Thread python
Azakai,

WOW! That's incredible!! Thank you for sharing your work with the
community.

1. Are there plans to support IE 7 or 8?

2. I'm not sure what you mean by non-static modules? Can we use modules
such as json, pickle/cPickle, StringIO/cStringIO?

3. Is there a virtual file system we can take advantage of so calls to
open() would work?

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


Re: CPython on the Web

2011-01-02 Thread Octavian Rasnita
From: Katie T ka...@coderstack.co.uk
Subject: Re: CPython on the Web


 On Sun, Jan 2, 2011 at 7:26 AM, azakai alonmozi...@gmail.com wrote:
 The idea is that by compiling CPython itself, all the features of the
 language are immediately present, and at the latest version, unlike
 writing a new implementation which takes time and tends to lag behind.
 As to why run it on the web, there could be various uses, for example
 it could allow a simple learning environment for Python, which since
 it's on the web can be entered immediately without any download (and
 would run even in places where Python normally can't, like say an
 iPad).
 
 It looks pretty neat ! - most solutions I've seen involve running
 Python in a sandbox environment on the server as opposed to on the
 client desktop.
 
 Katie
 -- 


I don't understand what can be this program used for. Can anyone explain please?

Ok, I understand that it can be used for learning, which is pretty useless 
because I doubt that a Python newbie will start using Python and learning 
Python that way.

Then, how can the Python programs run on the desktop?
I suspect that the Python code is somehow translated to Javascript in order to 
run on the browser. Am I right?

If yes, then how can run a Python code that access a database or one that 
create a web server, or a WxPython GUI run?

If it can run just simple things that prints things in the browser, then why 
not writing that code directly in JS?


As you can see, there are many things I don't understand. :-)

Thank you.

BTW. I have tried that page, and it appeared a JS error window telling that the 
JS scripts run too slow and it asked me if I want to continue.
I have executed the default Python script, but nothing happend. Nothing was 
printed. I use Internet Explorer.

Octavian


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


Re: list 2 dict?

2011-01-02 Thread Rob Williscroft
Octavian Rasnita wrote in news:0db6c288b2274dbba5463e7771349...@teddy in
gmane.comp.python.general: 

 Hi,
 
 If I want to create a dictionary from a list, is there a better way
 than the long line below? 
 
 l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']
 
 d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x
 in range(len(l)) if x %2 == 1])) 
 
 print(d)
 
 {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'}

 dict( zip( l[ :: 2 ], l[ 1 :: 2 ] ) )
{8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'}

If you don't know about slice notation, the synatax I'm using above is:

list[ start : stop : step ]

where I have ommited the stop item, which defaults to the length of the
list.

http://docs.python.org/library/stdtypes.html#sequence-types-str-unicode-
list-tuple-bytearray-buffer-xrange

That will make 3 lists before it makes the dict thought, so if the
list is large:

 dict( ( l[ i ], l[ i + 1 ] ) for i in xrange( 0, len( l ), 2 ) )

may be better.

Rob.

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


Re: list 2 dict?

2011-01-02 Thread Hrvoje Niksic
Octavian Rasnita orasn...@gmail.com writes:

 If I want to create a dictionary from a list, is there a better way than the 
 long line below?

 l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']

 d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in 
 range(len(l)) if x %2 == 1]))

 print(d)

 {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'}

it = iter(l)
d = dict(izip(it, it))

izip is the iterator equivalent of zip, import it from itertools.  (Or, if
your list is short, just use zip instead.)

It can be written in a single short line, at the cost of additional
obfuscation:

d = dict(izip(*[iter(l)]*2))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list 2 dict?

2011-01-02 Thread Stefan Sonnenberg-Carstens

Am 02.01.2011 14:18, schrieb Octavian Rasnita:

Hi,

If I want to create a dictionary from a list, is there a better way than the 
long line below?

l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']

d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in 
range(len(l)) if x %2 == 1]))

print(d)

{8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'}

Thanks.

Octavian


Or so:

dict(zip((y for x,y in enumerate(l) if x%2==0),(y for x,y in 
enumerate(l) if not x%2==0)))

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


Re: list 2 dict?

2011-01-02 Thread Octavian Rasnita
From: Ian Kelly ian.g.ke...@gmail.com


 On 1/2/2011 6:18 AM, Octavian Rasnita wrote:
 Hi,

 If I want to create a dictionary from a list, is there a better way than the 
 long line below?

 l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']

 d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in 
 range(len(l)) if x %2 == 1]))
 
 d = dict(zip(l[0::2], l[1::2]))
 
 Or, using the grouper function recipe from the itertools documentation:
 
 d = dict(grouper(2, l))
 
 Cheers,
 Ian


The grouper-way looks nice, but I tried it and it didn't work:

from itertools import *
...
d = dict(grouper(2, l))

NameError: name 'grouper' is not defined

I use Python 2.7. Should it work with this version?
Octavian

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


Re: list 2 dict?

2011-01-02 Thread Octavian Rasnita
From: Rob Williscroft r...@rtw.me.uk

 Octavian Rasnita wrote in news:0db6c288b2274dbba5463e7771349...@teddy in
 gmane.comp.python.general: 
 
 Hi,
 
 If I want to create a dictionary from a list, is there a better way
 than the long line below? 
 
 l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']
 
 d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x
 in range(len(l)) if x %2 == 1])) 
 
 print(d)
 
 {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'}
 
 dict( zip( l[ :: 2 ], l[ 1 :: 2 ] ) )
 {8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'}
 
 If you don't know about slice notation, the synatax I'm using above is:
 
list[ start : stop : step ]
 
 where I have ommited the stop item, which defaults to the length of the
 list.
 
 
 http://docs.python.org/library/stdtypes.html#sequence-types-str-unicode-
 list-tuple-bytearray-buffer-xrange
 
 That will make 3 lists before it makes the dict thought, so if the
 list is large:
 
  dict( ( l[ i ], l[ i + 1 ] ) for i in xrange( 0, len( l ), 2 ) )
 
 may be better.


Thank you all.

I have also discovered that I can zip 2 lists made with range(0, len(l), 2) and 
range(1, len(l), 2) but I remembered about that the slice notation accepts that 
third argument and as Stefan suggested, looks to be a shorter way.

I have first thought to the solution you suggested, but I have forgotten to 
create a tuple from the pair of elements so it didn't work.
I wasn't thinking to performance, but yes, it may be important for large lists.

It seems that in some cases there are more ways to do it in Python than in 
Perl. :-)

Octavian

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


Re: list 2 dict?

2011-01-02 Thread Stefan Sonnenberg-Carstens

Am 02.01.2011 16:36, schrieb Octavian Rasnita:

From: Ian Kellyian.g.ke...@gmail.com



On 1/2/2011 6:18 AM, Octavian Rasnita wrote:

Hi,

If I want to create a dictionary from a list, is there a better way than the 
long line below?

l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']

d = dict(zip([l[x] for x in range(len(l)) if x %2 == 0], [l[x] for x in 
range(len(l)) if x %2 == 1]))

d = dict(zip(l[0::2], l[1::2]))

Or, using the grouper function recipe from the itertools documentation:

d = dict(grouper(2, l))

Cheers,
Ian


The grouper-way looks nice, but I tried it and it didn't work:

from itertools import *
...
d = dict(grouper(2, l))

NameError: name 'grouper' is not defined

I use Python 2.7. Should it work with this version?
Octavian


A last one:

l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']
dict((x[1],x[0]) for x in ((l.pop(),l.pop()) for x in xrange(len(l)/2)))
--
http://mail.python.org/mailman/listinfo/python-list


Python programming

2011-01-02 Thread Maurice Shih
Dear python-list@python.org,
I am making a program of the quadratic sieve on python 2.5.2. I am also 
using sympy to find linear dependencies in mod 2. For example matrix A is :
10110
01101
00011
1
And using sympy I can type in a command to solve ax=0, which is:
1=0
01002=0
0010-1=0
00011=0
To find the values of vector x is easy by hand if you assign one value as 1, 
but I was wondering if I could turn the numbers into letters ( variables) so I 
could run the solve command in sympy. Thank you for listening to by question 
and I hope that you can help me. Thank you again.


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


Re: String building using join

2011-01-02 Thread gervaz
On 31 Dic 2010, 16:43, Emile van Sebille em...@fenx.com wrote:
 On 12/31/2010 7:22 AM gervaz said...





  Hi all, I would like to ask you how I can use the more efficient join
  operation in a code like this:

  class Test:
  ...     def __init__(self, v1, v2):
  ...         self.v1 = v1
  ...         self.v2 = v2
  ...
  def prg(l):
  ...     txt = 
  ...     for x in l:
  ...         if x.v1 is not None:
  ...             txt += x.v1 + \n
  ...         if x.v2 is not None:
  ...             txt += x.v2 + \n
  ...     return txt
  ...
  t1 = Test(hello, None)
  t2 = Test(None, ciao)
  t3 = Test(salut, hallo)
  t = [t1, t2, t3]

  prg(t)
  'hello\nciao\nsalut\nhallo\n'

  The idea would be create a new list with the values not None and then
  use the join function... but I don't know if it is really worth it.
  Any hint?

  def prg2(l):

              return \n.join([x for x in l if x])

 Emile



  ...     e = []
  ...     for x in l:
  ...         if x.v1 is not None:
  ...             e.append(x.v1)
  ...         if x.v2 is not None:
  ...             e.append(x.v2)
  ...     return \n.join(e)
  ...
  prg2(t)
  'hello\nciao\nsalut\nhallo'

  Thanks, Mattia- Nascondi testo citato

 - Mostra testo citato -- Nascondi testo citato

 - Mostra testo citato -

Sorry, but it does not work

 def prg3(l):
... return \n.join([x for x in l if x])
...
 prg3(t)
Traceback (most recent call last):
  File stdin, line 1, in module
  File stdin, line 2, in prg3
TypeError: sequence item 0: expected str instance, Test found
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interrput a thread

2011-01-02 Thread gervaz
On 31 Dic 2010, 23:25, Alice Bevan–McGregor al...@gothcandy.com
wrote:
 On 2010-12-31 10:28:26 -0800, John Nagle said:

  Even worse, sending control-C to a multi-thread program
  is unreliable in CPython.  See http://blip.tv/file/2232410;
  for why.  It's painful.

 AFIK, that has been resolved in Python 3.2 with the introduction of an
 intelligent thread scheduler as part of the GIL release/acquire process.

         - Alice.

Ok, but then suppose I have multiple long running threads that I want
to delete/suspend because they are tooking too much time, which
solution do you propose?

Thanks,

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


Re: list 2 dict?

2011-01-02 Thread Alex Willmer
On Sunday, January 2, 2011 3:36:35 PM UTC, T wrote:
 The grouper-way looks nice, but I tried it and it didn't work:
 
 from itertools import *
 ...
 d = dict(grouper(2, l))
 
 NameError: name 'grouper' is not defined
 
 I use Python 2.7. Should it work with this version?

No. As Ian said grouper() is a receipe in the itertools documentation. 

http://docs.python.org/library/itertools.html#recipes

The module doesn't provide it directly
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String building using join

2011-01-02 Thread Emile van Sebille

On 1/2/2011 9:43 AM gervaz said...

On 31 Dic 2010, 16:43, Emile van Sebilleem...@fenx.com  wrote:

On 12/31/2010 7:22 AM gervaz said...






Hi all, I would like to ask you how I can use the more efficient join
operation in a code like this:



class Test:

... def __init__(self, v1, v2):
... self.v1 = v1
... self.v2 = v2
...

def prg(l):

... txt = 
... for x in l:
... if x.v1 is not None:
... txt += x.v1 + \n
... if x.v2 is not None:
... txt += x.v2 + \n
... return txt
...

t1 = Test(hello, None)
t2 = Test(None, ciao)
t3 = Test(salut, hallo)
t = [t1, t2, t3]



prg(t)

'hello\nciao\nsalut\nhallo\n'



The idea would be create a new list with the values not None and then
use the join function... but I don't know if it is really worth it.
Any hint?



def prg2(l):


  return \n.join([x for x in l if x])

Emile




... e = []
... for x in l:
... if x.v1 is not None:
... e.append(x.v1)
... if x.v2 is not None:
... e.append(x.v2)
... return \n.join(e)
...

prg2(t)

'hello\nciao\nsalut\nhallo'



Thanks, Mattia- Nascondi testo citato


- Mostra testo citato -- Nascondi testo citato

- Mostra testo citato -


Sorry, but it does not work


Oh -- you want a working solution, not a hint?  OK.

class Test:
 def __init__(self, v1, v2):
 self.v1 = v1
 self.v2 = v2


t1 = Test(hello, None)
t2 = Test(None, ciao)
t3 = Test(salut, hallo)
t = [t1, t2, t3]


\n.join([y for x in t for y in [x.v1,x.v2] if y])

Emile




def prg3(l):

... return \n.join([x for x in l if x])
...

prg3(t)

Traceback (most recent call last):
   File stdin, line 1, inmodule
   File stdin, line 2, in prg3
TypeError: sequence item 0: expected str instance, Test found



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


Re: String building using join

2011-01-02 Thread Alex Willmer
On Sunday, January 2, 2011 5:43:38 PM UTC, gervaz wrote:
 Sorry, but it does not work
 
  def prg3(l):
 ... return \n.join([x for x in l if x])
 ...
  prg3(t)
 Traceback (most recent call last):
   File stdin, line 1, in module
   File stdin, line 2, in prg3
 TypeError: sequence item 0: expected str instance, Test found

def prg3(l):
return '\n'.join([str(x) for x in l if x])

That should do it
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list 2 dict?

2011-01-02 Thread Emile van Sebille

On 1/2/2011 8:31 AM Stefan Sonnenberg-Carstens said...


A last one:

l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']
dict((x[1],x[0]) for x in ((l.pop(),l.pop()) for x in xrange(len(l)/2)))


This also works:


l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']

pop=l.pop

dict([(pop(),pop()) for i in l])

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


Re: list 2 dict?

2011-01-02 Thread Emile van Sebille

On 1/2/2011 8:31 AM Stefan Sonnenberg-Carstens said...

Nevermind -- my bad.

Emile


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


Re: list 2 dict?

2011-01-02 Thread Stefan Sonnenberg-Carstens

Am 02.01.2011 19:19, schrieb Emile van Sebille:

On 1/2/2011 8:31 AM Stefan Sonnenberg-Carstens said...


A last one:

l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']
dict((x[1],x[0]) for x in ((l.pop(),l.pop()) for x in xrange(len(l)/2)))


This also works:


l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']

pop=l.pop

dict([(pop(),pop()) for i in l])


No, it does not:

 l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']

 pop=l.pop

 dict([(pop(),pop()) for i in l])
{'a': 7, 'b': 8, 4: 3, 6: 5}

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


Where is win32service

2011-01-02 Thread catalinf...@gmail.com
I install Python 2.7 on Windows XP.
I try use :

import win32service
import win32serviceutil

But I got that error :

ImportError: No module named win32service
Where is this module ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where is win32service

2011-01-02 Thread Alex Willmer
On Sunday, January 2, 2011 6:40:45 PM UTC, catalinf...@gmail.com wrote:
 I install Python 2.7 on Windows XP.
 I try use :
 
 import win32service
 import win32serviceutil
 
 But I got that error :
 
 ImportError: No module named win32service
 Where is this module ?

It's part of the pywin32 (aka win32all) package

http://sourceforge.net/projects/pywin32/

The latest download for your Python version is

http://sourceforge.net/projects/pywin32/files/pywin32/Build%20214/pywin32-214.win32-py2.7.exe/download

Regards, Alex
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CPython on the Web

2011-01-02 Thread azakai
On Jan 2, 5:42 am, pyt...@bdurham.com wrote:

 1. Are there plans to support IE 7 or 8?

I think it might run slowly there, but otherwise sure, it should run -
the code is intended to be valid JavaScript (if it isn't, that's a
bug). Currently though a minor issue prevents it from running on IE, I
have been told (I don't have a Windows machine to test on myself),
http://code.google.com/p/emscripten/issues/detail?id=22


 2. I'm not sure what you mean by non-static modules? Can we use modules
 such as json, pickle/cPickle, StringIO/cStringIO?


Sorry, I should have been more clear. There isn't support for
dlopen(), which opens dynamically linked libraries. That means that
you can import libraries like sys, which are already linked into
python. But loading a module that exists as a separate file won't work
yet (but hopefully soon).

 3. Is there a virtual file system we can take advantage of so calls to
 open() would work?


No, not yet, the libc implementation used just has stubs for input/
output stuff so far. Work in progress ;)

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


Re: CPython on the Web

2011-01-02 Thread azakai
On Jan 2, 5:52 am, Octavian Rasnita orasn...@gmail.com wrote:

 Then, how can the Python programs run on the desktop?
 I suspect that the Python code is somehow translated to Javascript in order 
 to run on the browser. Am I right?

To clarify, in this demo, CPython itself - the C implementation of
Python - was translated from C to JavaScript (or more specifically, C
to LLVM, and LLVM to JavaScript). So your web browser is running the
same CPython that you would run on your computer normally.

That CPython executes Python by compiling it into bytecode, etc., and
that is exactly the same with CPython normally and CPython on the web
in this demo. So actual Python code is not translated into JavaScript
(which is the approach pyjamas takes), instead the entire interpreter
is.


 If yes, then how can run a Python code that access a database or one that 
 create a web server, or a WxPython GUI run?

By implementing whatever library functions and system calls CPython
needs, in the browser. For example, if the CPython code calls printf()
to print stuff, then we need to implement printf() in JavaScript, and
so forth.

Obviously there are limitations of the JS environment, so not
everything can be done.


 BTW. I have tried that page, and it appeared a JS error window telling that 
 the JS scripts run too slow and it asked me if I want to continue.
 I have executed the default Python script, but nothing happend. Nothing was 
 printed. I use Internet Explorer.


I've been told it doesn't run properly on IE, we have a bug open on
that, sorry. It will work on Firefox, Chrome and Safari right now.

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


Re: Tkinter: The good, the bad, and the ugly!

2011-01-02 Thread CM
On Jan 1, 7:39 pm, rantingrick rantingr...@gmail.com wrote:
 On Jan 1, 5:39 pm, CM cmpyt...@gmail.com wrote:

  And I don't see this as a problem anyway.  I wanted to do GUI
  programming in Python, so I read a bit, chose wxPython, downloaded it,
  and started learning it.  Done.

 I, I, I...Me,Me,Me.

 Seems you are only concerned about yourself CM. However this a
 community discussion. You must put your wants and needs in the
 backseat before you can see what is best for the Python community as a
 whole.

Must have been too many holiday baked goods that made me even try...





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


Re: list 2 dict?

2011-01-02 Thread Octavian Rasnita

Octavian

- Original Message - 
From: Alex Willmer a...@moreati.org.uk
Newsgroups: comp.lang.python
To: comp.lang.pyt...@googlegroups.com
Cc: python-list@python.org
Sent: Sunday, January 02, 2011 8:07 PM
Subject: Re: list 2 dict?


 On Sunday, January 2, 2011 3:36:35 PM UTC, T wrote:
 The grouper-way looks nice, but I tried it and it didn't work:
 
 from itertools import *
 ...
 d = dict(grouper(2, l))
 
 NameError: name 'grouper' is not defined
 
 I use Python 2.7. Should it work with this version?
 
 No. As Ian said grouper() is a receipe in the itertools documentation. 
 
 http://docs.python.org/library/itertools.html#recipes

I know that, that is why I used:

from itertools import *


Isn't enough?

Octavian

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


Re: list 2 dict?

2011-01-02 Thread Simon Brunning
On 2 January 2011 21:04, Octavian Rasnita orasn...@gmail.com wrote:
 No. As Ian said grouper() is a receipe in the itertools documentation.

 http://docs.python.org/library/itertools.html#recipes

 I know that, that is why I used:

 from itertools import *

 Isn't enough?

Did you follow the link? grouper() is a recipe, not part of the
itertools module.

-- 
Cheers,
Simon B.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String building using join

2011-01-02 Thread gervaz
On 2 Gen, 19:14, Emile van Sebille em...@fenx.com wrote:
 On 1/2/2011 9:43 AM gervaz said...





  On 31 Dic 2010, 16:43, Emile van Sebilleem...@fenx.com  wrote:
  On 12/31/2010 7:22 AM gervaz said...

  Hi all, I would like to ask you how I can use the more efficient join
  operation in a code like this:

  class Test:
  ...     def __init__(self, v1, v2):
  ...         self.v1 = v1
  ...         self.v2 = v2
  ...
  def prg(l):
  ...     txt = 
  ...     for x in l:
  ...         if x.v1 is not None:
  ...             txt += x.v1 + \n
  ...         if x.v2 is not None:
  ...             txt += x.v2 + \n
  ...     return txt
  ...
  t1 = Test(hello, None)
  t2 = Test(None, ciao)
  t3 = Test(salut, hallo)
  t = [t1, t2, t3]

  prg(t)
  'hello\nciao\nsalut\nhallo\n'

  The idea would be create a new list with the values not None and then
  use the join function... but I don't know if it is really worth it.
  Any hint?

  def prg2(l):

                return \n.join([x for x in l if x])

  Emile

  ...     e = []
  ...     for x in l:
  ...         if x.v1 is not None:
  ...             e.append(x.v1)
  ...         if x.v2 is not None:
  ...             e.append(x.v2)
  ...     return \n.join(e)
  ...
  prg2(t)
  'hello\nciao\nsalut\nhallo'

  Thanks, Mattia- Nascondi testo citato

  - Mostra testo citato -- Nascondi testo citato

  - Mostra testo citato -

  Sorry, but it does not work

 Oh -- you want a working solution, not a hint?  OK.

 class Test:
       def __init__(self, v1, v2):
           self.v1 = v1
           self.v2 = v2

 t1 = Test(hello, None)
 t2 = Test(None, ciao)
 t3 = Test(salut, hallo)
 t = [t1, t2, t3]

 \n.join([y for x in t for y in [x.v1,x.v2] if y])

 Emile





  def prg3(l):
  ...     return \n.join([x for x in l if x])
  ...
  prg3(t)
  Traceback (most recent call last):
     File stdin, line 1, inmodule
     File stdin, line 2, in prg3
  TypeError: sequence item 0: expected str instance, Test found- Nascondi 
  testo citato

 - Mostra testo citato -- Nascondi testo citato

 - Mostra testo citato -

Thanks Emile, despite that now the solution runs in quadratic time I
guess. I could also provide a __str__(self) representation, but in my
real code I don't have access to the class. Also using str() on an
empty object (i.e. None), the representation is 'None'.

Ciao,

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


Re: Multiple instances and wrong parental links

2011-01-02 Thread Josh English
Chas,

Thanks. The self in the setattr statement works sometimes, but what I'm 
adding most of the time is a property, and if I don't use the class when 
setting a property, nothing works. The property is returned instead of the 
value of the function the property returns. (yeah, it's complicated).

This is the same project I asked about at 
https://groups.google.com/d/topic/comp.lang.python/K9PinAbuCJk/discussion.

That's why this simple sample looks so incredibly complicated. I'm coding on 
the far edge of my learning curve.

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


Re: Multiple instances and wrong parental links

2011-01-02 Thread Josh English
Steven, 

This was simplified. The complete story is, well, tedious:

I have created a set of XML Validation and Normalization classes. With them I 
can define my data structures and make sure my data is good. These 
complications have come in wanting to take this tool and create a GUI (in 
wxPython) around these objects. Okay, really these complication come from me 
generalizing the problem, probably one step too far. I want a tool to take my 
structural definition and create the GUI. To use some of the easy tools like 
Validators that transfer data to the GUI and back, I need an interface.

I tried creating validators that went straight to the element, but that got 
complicated. 

Then I created a map from a dictionary to an element (as defined by the XML 
validation tool) and back again. This also bogged down and fixing one problem 
undid all the other progress I had made.

So this is my third attempt: create a Python object around the XML definition.

I've looked at pyxb. It doesn't make any sense to me. I looked at pysxer, that 
made even less sense. Hence, I try it on my own.

The Element List isn't a list, it has the same interface as a list, but always 
goes back to the original XML element (an elementree.Element object in this 
case.) 

Insanely complicated and just beyond my comprehension, I fear. I haven't found 
an easier way to wrap an object around these XML validators of mine.

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


Re: list 2 dict?

2011-01-02 Thread Benjamin Kaplan
On Jan 2, 2011 4:15 PM, Octavian Rasnita orasn...@gmail.com wrote:


 Octavian

 - Original Message -
 From: Alex Willmer a...@moreati.org.uk
 Newsgroups: comp.lang.python
 To: comp.lang.pyt...@googlegroups.com
 Cc: python-list@python.org
 Sent: Sunday, January 02, 2011 8:07 PM
 Subject: Re: list 2 dict?


  On Sunday, January 2, 2011 3:36:35 PM UTC, T wrote:
  The grouper-way looks nice, but I tried it and it didn't work:
 
  from itertools import *
  ...
  d = dict(grouper(2, l))
 
  NameError: name 'grouper' is not defined
 
  I use Python 2.7. Should it work with this version?
 
  No. As Ian said grouper() is a receipe in the itertools documentation.
 
  http://docs.python.org/library/itertools.html#recipes

 I know that, that is why I used:

 from itertools import *


 Isn't enough?

 Octavian


It would be, if, the function was actually a part of the itertools module.
It isn't. It's just a code example used in the documentation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CPython on the Web

2011-01-02 Thread Gerry Reno
On 01/02/2011 02:26 AM, azakai wrote:
 Hello, I hope this will be interesting to people here: CPython running
 on the web,

 http://syntensity.com/static/python.html

 That isn't a new implementation of Python, but rather CPython 2.7.1,
 compiled from C to JavaScript using Emscripten and LLVM. For more
 details on the conversion process, see http://emscripten.org

 This is a work in progress, main issues right now are that the code
 isn't optimized (so don't expect good performance), and importing non-
 static modules doesn't work. Otherwise, though, it seems to run
 properly, in particular it runs all the examples in
 http://wiki.python.org/moin/SimplePrograms that don't rely on
 importing modules or receiving input from the user (with perhaps some
 minor formatting errors). The demo runs fine on recent versions of
 Firefox, Chrome and Safari, but has problems on IE9 and Opera
 (hopefully those will be resolved soon).

 The idea is that by compiling CPython itself, all the features of the
 language are immediately present, and at the latest version, unlike
 writing a new implementation which takes time and tends to lag behind.
 As to why run it on the web, there could be various uses, for example
 it could allow a simple learning environment for Python, which since
 it's on the web can be entered immediately without any download (and
 would run even in places where Python normally can't, like say an
 iPad).

 Feedback would be very welcome!

 - azakai
   

Ok, visiting this page:

http://syntensity.com/static/python.html

I do not see anything happen when I click 'execute' button.  I'm running
Firefox 3.6.3.

Here is what I see both before and after clicking 'execute':
=

This is CPython, the standard Python http://www.python.org
implementation, compiled from C to JavaScript using Emscripten
http://emscripten.org, running in your browser (without any plugins).

* Most core language stuff should work, except for importing
  non-static modules (in other words, |import sys| will work, but
  other modules won't).
* Please report bugs if you find them!
* Tested on Firefox 4 and Chrome 10.
* The editor is Skywriter https://mozillalabs.com/skywriter/.


*Enter some Python*:
import sys print 'Hello world! This is Python {} on
{}'.format(sys.version, sys.platform) print 'Here are some numbers:',
[2*x for x in range(5)][:4]

=


So what is happening is that the whole Python interpreter has been
converted to Javascript and is running the browser, is that correct?

Ok, but the usual browser 'sandbox' constraints would still apply would
they not?

And what is the build toolchain that you need if you want to convert
your modules to be importable with this CPython on the Web?


Regards,
Gerry



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


Re: Tkinter: The good, the bad, and the ugly!

2011-01-02 Thread Tim Chase

On 01/01/2011 06:39 PM, rantingrick wrote:

On Jan 1, 5:39 pm, CMcmpyt...@gmail.com  wrote:


And I don't see this as a problem anyway.  I wanted to do GUI
programming in Python, so I read a bit, chose wxPython, downloaded it,
and started learning it.  Done.


I, I, I...Me,Me,Me.

Seems you are only concerned about yourself CM. However this a
community discussion. You must put your wants and needs in the
backseat before you can see what is best for the Python community as a
whole.


Pot? Meet Kettle...

Given that the community response has largely been an 
overwhelming meh, show me some code rather than an I 
whole-heartedly agree with rantingrick, your use of we in your 
emails sounds more like a royal we[1] than a community-based 
concern.


best for the Python community seems to be something that 
doesn't break backwards compat. with existing code-bases, works 
across a multitude of platforms, has a minimal install footprint, 
and a proven track-record of meeting those needs.  Tkinter and wx 
both seem to satisfy most of those requirements, except that wx 
seems to have a larger footprint and not have been 
production-ready at the time a decision needed to be made for 
inclusion of a gui-library in Python.  (I also don't know if 
there are licensing concerns with wx vs. tk and their interplay 
with the Python license).


-tkc


[1]
http://en.wikipedia.org/wiki/Royal_we



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


Re: String building using join

2011-01-02 Thread gervaz
On 2 Gen, 22:37, gervaz ger...@gmail.com wrote:
 On 2 Gen, 19:14, Emile van Sebille em...@fenx.com wrote:





  On 1/2/2011 9:43 AM gervaz said...

   On 31 Dic 2010, 16:43, Emile van Sebilleem...@fenx.com  wrote:
   On 12/31/2010 7:22 AM gervaz said...

   Hi all, I would like to ask you how I can use the more efficient join
   operation in a code like this:

   class Test:
   ...     def __init__(self, v1, v2):
   ...         self.v1 = v1
   ...         self.v2 = v2
   ...
   def prg(l):
   ...     txt = 
   ...     for x in l:
   ...         if x.v1 is not None:
   ...             txt += x.v1 + \n
   ...         if x.v2 is not None:
   ...             txt += x.v2 + \n
   ...     return txt
   ...
   t1 = Test(hello, None)
   t2 = Test(None, ciao)
   t3 = Test(salut, hallo)
   t = [t1, t2, t3]

   prg(t)
   'hello\nciao\nsalut\nhallo\n'

   The idea would be create a new list with the values not None and then
   use the join function... but I don't know if it is really worth it.
   Any hint?

   def prg2(l):

                 return \n.join([x for x in l if x])

   Emile

   ...     e = []
   ...     for x in l:
   ...         if x.v1 is not None:
   ...             e.append(x.v1)
   ...         if x.v2 is not None:
   ...             e.append(x.v2)
   ...     return \n.join(e)
   ...
   prg2(t)
   'hello\nciao\nsalut\nhallo'

   Thanks, Mattia- Nascondi testo citato

   - Mostra testo citato -- Nascondi testo citato

   - Mostra testo citato -

   Sorry, but it does not work

  Oh -- you want a working solution, not a hint?  OK.

  class Test:
        def __init__(self, v1, v2):
            self.v1 = v1
            self.v2 = v2

  t1 = Test(hello, None)
  t2 = Test(None, ciao)
  t3 = Test(salut, hallo)
  t = [t1, t2, t3]

  \n.join([y for x in t for y in [x.v1,x.v2] if y])

  Emile

   def prg3(l):
   ...     return \n.join([x for x in l if x])
   ...
   prg3(t)
   Traceback (most recent call last):
      File stdin, line 1, inmodule
      File stdin, line 2, in prg3
   TypeError: sequence item 0: expected str instance, Test found- Nascondi 
   testo citato

  - Mostra testo citato -- Nascondi testo citato

  - Mostra testo citato -

 Thanks Emile, despite that now the solution runs in quadratic time I
 guess. I could also provide a __str__(self) representation, but in my
 real code I don't have access to the class. Also using str() on an
 empty object (i.e. None), the representation is 'None'.

 Ciao,

 Mattia- Nascondi testo citato

 - Mostra testo citato -

And this one is another working solution...

 def prg4(l):
... s = []
... for x in l:
... s.extend(set([x.v1, x.v2]) - set([None]))
... return \n.join(s)
...
 prg4(t)
'hello\nciao\nhallo\nsalut'

My original question was just related to the fact that I read that the
string concatenation in expensive and it sould be used the join()
function but now probably it is better to stick with the first
implementation, the simplest one.

Ciao,

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


Re: CPython on the Web

2011-01-02 Thread azakai
On Jan 2, 1:01 pm, Gerry Reno gr...@verizon.net wrote:

 Ok, visiting this page:

 http://syntensity.com/static/python.html

 I do not see anything happen when I click 'execute' button.  I'm running
 Firefox 3.6.3.


I've only tested with Firefox 4. I'm surprised though that it wouldn't
work on 3.6.3. Can you see what errors appear in the error console
(control-shift-J)?

If no errors appear, it might be a failure due to limited script stack
space (which is fixed in FF4, and I guess is a problem in earlier
versions).


 So what is happening is that the whole Python interpreter has been
 converted to Javascript and is running the browser, is that correct?

Yes.


 Ok, but the usual browser 'sandbox' constraints would still apply would
 they not?

Yes, the JavaScript is limited in the usual ways. So Python is running
in a sandboxed manner.


 And what is the build toolchain that you need if you want to convert
 your modules to be importable with this CPython on the Web?


Note that loading modules isn't implemented yet, but I'll work on it
soon.

The toolchain will be to use your normal makefiles and such, but
replacing gcc with llvm-gcc or clang, so it generates LLVM bytecode
instead of a normal binary. Then one would run the generated LLVM
bytecode through Emscripten, which compiles it to JavaScript. So, the
process should be fairly simple.

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


Tiny4py [important update] a little python wrapper to make shorten urls and QRCodes

2011-01-02 Thread Andrea Stagi
Hi, I would announce you my new version of this python wrapper to make
shorten urls and QRCodes, using main used services: goo.gl, bit.ly and
tinyurl.
Please, visit http://code.google.com/p/tiny4py/
Bests
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CPython on the Web

2011-01-02 Thread Gerry Reno
On 01/02/2011 05:53 PM, azakai wrote:
 On Jan 2, 1:01 pm, Gerry Reno gr...@verizon.net wrote:
   
 Ok, visiting this page:

 http://syntensity.com/static/python.html

 I do not see anything happen when I click 'execute' button.  I'm running
 Firefox 3.6.3.

 
 I've only tested with Firefox 4. I'm surprised though that it wouldn't
 work on 3.6.3. Can you see what errors appear in the error console
 (control-shift-J)?

   

Errors when using Firefox 3.6.3:

script stack space quota is exhausted
Module is not defined  ...  line 56


Regards,
Gerry



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


Re: Interrput a thread

2011-01-02 Thread Tim Roberts
gervaz ger...@gmail.com wrote:

Ok, but then suppose I have multiple long running threads that I want
to delete/suspend because they are tooking too much time, which
solution do you propose?

The right solution is to write your threads so they have an escape hatch --
to periodically check a should I die? flag, and then commit suicide. That
is the ONLY clean way to handle this problem.  There is simply no clean way
to force another thread to die without its permission.
-- 
Tim Roberts, t...@probo.com
Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CPython on the Web

2011-01-02 Thread python
Azakai/Gerry,

 Errors when using Firefox 3.6.3:

I'm running Firefox 3.6.1.3 and the interpreter is running fine.

I'm on Windows 7 Pro 64-bit.

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


Re: CPython on the Web

2011-01-02 Thread azakai
On Jan 2, 3:14 pm, Gerry Reno gr...@verizon.net wrote:
 On 01/02/2011 05:53 PM, azakai wrote:

  On Jan 2, 1:01 pm, Gerry Reno gr...@verizon.net wrote:

  Ok, visiting this page:

 http://syntensity.com/static/python.html

  I do not see anything happen when I click 'execute' button.  I'm running
  Firefox 3.6.3.

  I've only tested with Firefox 4. I'm surprised though that it wouldn't
  work on 3.6.3. Can you see what errors appear in the error console
  (control-shift-J)?

 Errors when using Firefox 3.6.3:

 script stack space quota is exhausted

Ah, then yeah, it's the script stack issue I was afraid of. Then
there's not really a way to run the demo on Firefox 3.6.x. It will
work on Firefox 4 though, or other recent browsers.

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


Re: CPython on the Web

2011-01-02 Thread azakai
On Jan 2, 4:58 pm, pyt...@bdurham.com wrote:
 Azakai/Gerry,

  Errors when using Firefox 3.6.3:

 I'm running Firefox 3.6.1.3 and the interpreter is running fine.

 I'm on Windows 7 Pro 64-bit.

 Malcolm

Thanks for the info. To be honest I'm surprised it works there. I
guess the error Gerry ran into depends on additional factors.

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


Re: CPython on the Web

2011-01-02 Thread Gerry Reno
I tried printing sys.path and here is the output:

['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/',
'/usr/local/lib/python2.7/plat-linux2',
'/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old',
'/usr/local/lib/lib-dynload']

Now, those paths must be on your machine because they are not on my
client machine.  But the interpreter is now running on MY machine.  Well
in a sandbox really.  So how is that going to work?


Regards,
Gerry

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


Re: CPython on the Web

2011-01-02 Thread Wolfgang Strobl
azakai alonmozi...@gmail.com:

On Jan 2, 4:58 pm, pyt...@bdurham.com wrote:
 Azakai/Gerry,

  Errors when using Firefox 3.6.3:

 I'm running Firefox 3.6.1.3 and the interpreter is running fine.

I guess that meant FIrefox 3.6.13 (without the last dot), the current
stable version.

I'm using Firefox 3.6.13 (german) on Windowx XP (32bit, german) here,
and the interpreter is running fine, too.  Same for Chrome 8.0.552.224.


-- 
Wir danken für die Beachtung aller Sicherheitsbestimmungen
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue8350] Document lack of support for keyword arguments in C functions

2011-01-02 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 Isn't it kind of a CPython-specific detail, though?

If other implementations do provide proper keyword arguments,
I'd be skeptical that they all settled on the names that the
library documentation gives to the arguments.

--
title: Document lack of support for keyword arguments in C functions - 
Document lack of support for keyword arguments in C functions

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8350
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10802] python3.2 AFTER b2 release has subprocess.Popen broken under colinux/windows

2011-01-02 Thread Martin v . Löwis

Changes by Martin v. Löwis mar...@v.loewis.de:


--
nosy: +loewis

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10802
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-02 Thread Pierre Quentel

Pierre Quentel pierre.quen...@gmail.com added the comment:

Hi,

I have started working on the port of a simplified version of Karrigell (a web 
framework) to Python3. I experienced the same problem as the other posters : in 
the current version, file upload doesn't work. So I've been working on the cgi 
module for a few days and now have a version which correctly manages file 
uploads in the tests I made

The problem in the current version (3.2b2) is that all data is read from 
sys.stdin, which reads strings, not bytes. This obviously can't work properly 
to upload binary files. In the proposed version, for multipart/form-data type, 
all data is read as bytes from sys.stdin.buffer ; in the CGI script, the Python 
interpreter must be launched with the -u option, as suggested by Amaury, 
otherwise sys.stdin.buffer.read() only returns the beginning of the data stream

The headers inside the multipart/form-data are decoded to a string using 
sys.stdin.encoding and passed to a FeedParser (which requires strings) ; then 
the data is read from sys.stdin.buffer (bytes) until a boundary is found

If the field is a file, the file object in self.file stores bytes, and the 
attribute value is a byte string. If it is not a file, the value is decoded 
to a string, always using sys.stdin.encoding, as for all other fields for other 
types of forms

Other cosmetic changes :
- replaced while 1 by while True
- replaced if type(value) == type([]) by if isintance(value,list)

Attached file : zip with cgi_new.py and tests in a folder called http
Tested with Python 3.2b2 (r32b2:87398, Dec 19 2010, 22:51:00) [MSC v.1500 32 
bit (Intel)] on win32 ; files and CGI scripts served by Apache 2.2

--
nosy: +quentel
Added file: http://bugs.python.org/file20217/http.zip

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4953
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10802] python3.2 AFTER b2 release has subprocess.Popen broken under colinux/windows

2011-01-02 Thread kai zhu

kai zhu kaizhu...@gmail.com added the comment:

tested w/ following debug code.  looks like greg is correct - HAVE_PIPE2 should 
NOT b defined under colinux.

diff -r 6fa1e3b94d8f Modules/_posixsubprocess.c
--- a/Modules/_posixsubprocess.cSat Jan 01 22:18:46 2011 +0100
+++ b/Modules/_posixsubprocess.cSun Jan 02 03:48:47 2011 -0500
@@ -412,10 +412,12 @@
 int fds[2];
 int res;
 #ifdef HAVE_PIPE2
+PyErr_Format(PyExc_RuntimeError, HAVE_PIPE2 = %i, O_CLOEXEC = %i, 
HAVE_PIPE2, O_CLOEXEC); return NULL;
 Py_BEGIN_ALLOW_THREADS
 res = pipe2(fds, O_CLOEXEC);
 Py_END_ALLOW_THREADS
 #else
+PyErr_Format(PyExc_RuntimeError, HAVE_PIPE2 not defined, O_CLOEXEC = %i, 
O_CLOEXEC); return NULL;
 /* We hold the GIL which offers some protection from other code calling
  * fork() before the CLOEXEC flags have been set but we can't guarantee
  * anything without pipe2(). */



b2 release:
./python -c 'import _posixsubprocess; _posixsubprocess.cloexec_pipe()'
Traceback (most recent call last):
  File string, line 1, in module
RuntimeError: HAVE_PIPE2 not defined, O_CLOEXEC = 524288



latest hg:
./python -c 'import _posixsubprocess; _posixsubprocess.cloexec_pipe()'
Traceback (most recent call last):
  File string, line 1, in module
RuntimeError: HAVE_PIPE2 = 1, O_CLOEXEC = 524288

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10802
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10802] python3.2 AFTER b2 release has subprocess.Popen broken under colinux/windows

2011-01-02 Thread kai zhu

kai zhu kaizhu...@gmail.com added the comment:

i used the same almost vanilla configure for both:

$ ./configure --prefix=$USERPATH; make

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10802
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4662] posix module lacks several DeprecationWarning's

2011-01-02 Thread Sandro Tosi

Sandro Tosi sandro.t...@gmail.com added the comment:

I've refreshed the patch to only add DeprecationWarning for tempnam, tmpnam and 
tmpfile.

--
stage:  - patch review
Added file: http://bugs.python.org/file20218/issue4662-rel2.7.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4662
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10802] python3.2 AFTER b2 release has subprocess.Popen broken under colinux/windows

2011-01-02 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

Can you please run the script under strace, and report what system call is not 
implemented? I.e. put

  import subprocess
  subprocess.Popen('ls')

into a file (foo.py), then run

  strace -o trace.txt python foo.py

Please attach the output in case you cannot identify the problem.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10802
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1665333] Documentation missing for OptionGroup class in optparse

2011-01-02 Thread Sandro Tosi

Sandro Tosi sandro.t...@gmail.com added the comment:

Could someone give a look to this patch? I can work on fixing the missing stuff 
(if any :)).

--
stage:  - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1665333
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10788] test_logging failure

2011-01-02 Thread Vinay Sajip

Vinay Sajip vinay_sa...@yahoo.co.uk added the comment:

I think I've found the problem: test_concurrent_futures calls logging.critical, 
which registers a StreamHandler. This only happens when _wait_on_event and 
_signal_event fail on Win32.

There should be no reason to call logging.critical in a test, especially as the 
next line is assert False, message.

Perhaps the lines were left in by mistake: reassigning to Brian Quinlan.

--
assignee: vinay.sajip - bquinlan
nosy: +bquinlan

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10788
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10348] multiprocessing: use SysV semaphores on FreeBSD

2011-01-02 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

More info about FreeBSD.

sysctl p1003_1b.sem_nsems_max gives the maximum number of POSIX semaphores 
(per process? system wide?).

Since FreeBSD 8.1, sudo sysctl -w p1003_1b.sem_nsems_max=256 can be used to 
change this limit at runtime.

Before FreeBSD 8.1, SEM_MAX constant should be changed in the kernel source 
code, and the kernel have to be recompiled. (p1003_1b.sem_nsems_max is not 
configurable in /etc/sysctl.conf, it is an hardcoded limit).

Before FreeBSD 8.0, the POSIX semaphores are disabled by default: the kernel 
have to be compiled using P1003_1B_SEMAPHORES option. Extract of sys/conf/NOTES:

#
# POSIX P1003.1B

# Real time extensions added in the 1993 POSIX
# _KPOSIX_PRIORITY_SCHEDULING: Build in _POSIX_PRIORITY_SCHEDULING

options _KPOSIX_PRIORITY_SCHEDULING
# p1003_1b_semaphores are very experimental,
# user should be ready to assist in debugging if problems arise.
options P1003_1B_SEMAPHORES

# POSIX message queue
options P1003_1B_MQUEUE

#

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10348
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10348] multiprocessing: use SysV semaphores on FreeBSD

2011-01-02 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

NetBSD.

Extract of the sem_close() manpage
http://www.daemon-systems.org/man/sem_close.3.html
---
STANDARDS
 The sem_open(), sem_close(), and sem_unlink() functions conform to
 ISO/IEC 9945-1:1996 (``POSIX.1'').

HISTORY
 Support for named semaphores first appeared in NetBSD 2.0.
---

Martin wrote on the mailing list:
---
According to

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/uipc_sem.c?rev=1.22content-type=text/x-cvsweb-markuponly_with_tag=MAIN

SEM_MAX is 128 since 2007, and dynamically adjustable (no reboot).
---

It looks like the sysctl (read/write) option is kern.posix.semmax.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10348
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10804] Copy and paste error in _json.c

2011-01-02 Thread Torsten Landschoff

New submission from Torsten Landschoff t.landsch...@gmx.net:

There is a copy and paste error in _json.c: The pairs_hook field is assigned 
but object_hook is verified to be non-null. The same field is verified a few 
lines back to this is superfluous at least.

--
components: Library (Lib)
files: patch
messages: 125044
nosy: torsten
priority: normal
severity: normal
status: open
title: Copy and paste error in _json.c
versions: Python 2.7
Added file: http://bugs.python.org/file20219/patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10804
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10348] multiprocessing: use SysV semaphores on FreeBSD

2011-01-02 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Darwin (Mac OS X).

According to the following email (July 2010), Darwin supports POSIX semaphores 
and the default limit is 10,000 semaphores.
http://osdir.com/ml/darwin-dev/2010-07/msg00012.html

The limit is configurable via sysctl as kern.posix.sem.max.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10348
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10348] multiprocessing: use SysV semaphores on FreeBSD

2011-01-02 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

OpenBSD.

According to Martin, OpenBSD doesn't implement POSIX semaphores.
---
I don't have an installation of OpenBSD, but...

In FreeBSD, POSIX semaphores are implemented in sys/kern/uipc_sem.c.
In

http://www.openbsd.org/cgi-bin/cvsweb/src/sys/kern/

that file doesn't exist. Also, in FreeBSD's limits.h,
_POSIX_SEM_NSEMS_MAX is defined (surprisingly to 256);
in

http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/include/limits.h?rev=1.15;content-type=text/plain

this constant doesn't appear. So ISTM that OpenBSD doesn't implement
POSIX semaphores. IIUC, this means that the multiprocessing module
won't be fully functional, and its tests (and the concurrent.futures
tests) will be skipped.
---

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10348
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10804] Copy and paste error in _json.c

2011-01-02 Thread Torsten Landschoff

Torsten Landschoff t.landsch...@gmx.net added the comment:

FYI, this bug is not in Python 3.3 (as of svn r87615).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10804
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10802] python3.2 AFTER b2 release has subprocess.Popen broken under colinux/windows

2011-01-02 Thread kai zhu

kai zhu kaizhu...@gmail.com added the comment:

the culprit was my colinux kernel (2.6.26.8-co-0.7.7.1) did not have pipe2 
support (which libc erronenously assumed). updating the kernel fixed the 
problem.

the libc issue is partially discussed @ 
http://www.0x61.com/forum/linux-kernel-f109/popen2-popen-call-t1229012.html.  
according to manpage pipe2 was not added to the kernel til 2.6.27

my guess is this affects all unstable debian systems which are running kernels 
2.6.26 or older (u decide whether or not using old kernels for debian unstable 
is an edge case ;)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10802
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10716] Modernize pydoc to use CSS

2011-01-02 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

A few comments about css_v2.diff:
1) when the value is '0', there's no need to specify the unit (e.g. 0em);
2) when the color is specified the background-color should be specified as well 
(and vice versa);
3) hex colors (e.g. #00FF00) should be preferred to named colors (e.g. gray);
4) some selectors and properties don't work with older browsers (e.g. E  F or 
min-width);
5) there are a few empty dl.*{} that I would remove (unless you plan to fill 
them later);
6) the style I prefer for CSS is:
selector {
  property: value;
}

Regarding the HTML:
1) using an HTML 4.01 strict doctype would be better;
2) all the style-related attributes and elements should be removed (e.g 
bgcolor, valign, font);
3) using .red { color: red; } is not a good idea. Classes' names should 
describe the role of the element (e.g. header, entry) and not their style 
(otherwise when you want to change the page with a blue theme you'll end up 
with a .red { color: blue; }). If the colors are passed directly to the HTML 
they should be removed and left to the CSS(s) only. I don't know the code well 
enough to say if this is doable and/or if it requires a deprecation first;
4) the lis in html_header() should be closed, same for all the other elements 
that support a closing tag, even if optional (e.g. dt, dd);

There are also some minor incontinences in the indentantion, e.g.:
+link_list = ['a href=%s.html%s/a' % (name, name)
+for name in sys.builtin_module_names
+if name != '__main__']
+contents = [html.index_columns('Built-in modules',
+link_list, css_class='section modules')]
+link_list = ['a href=%s.html%s/a' % (name, name)
+  for name in sorted(Helper.keywords.keys())]
(the contents one is indented correctly), and some extra space after the '('.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10716
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9905] subprocess.Popen fails with stdout=PIPE, stderr=PIPE if standard descriptors (0, 1, 2) are closed.

2011-01-02 Thread Ross Lagerwall

Ross Lagerwall rosslagerw...@gmail.com added the comment:

OK here is a patch + tests. Basically, it makes sure that the fd that it is 
closing is not 0, 1 or 2.

I've set it for 2.7, 3.1 and 3.2.

--
keywords: +patch
nosy: +rosslagerwall
versions: +Python 2.7, Python 3.1, Python 3.2 -Python 2.6
Added file: http://bugs.python.org/file20220/i9905_v1.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9905
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10802] python3.2 AFTER b2 release has subprocess.Popen broken under colinux/windows

2011-01-02 Thread kai zhu

kai zhu kaizhu...@gmail.com added the comment:

hi martin, did an strace  the 'not implemented' system call was pipe2()

pipe2 exists in libc (checked w/ ctypes), but is broken for old linux kernels 
as mentioned previously.

--
Added file: http://bugs.python.org/file20221/trace2.txt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10802
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10802] python3.2 AFTER b2 release has subprocess.Popen broken under colinux/windows

2011-01-02 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Does not seem to be a Python problem then.  Thanks for diagnosing!

--
resolution:  - works for me
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10802
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10804] Copy and paste error in _json.c

2011-01-02 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Thanks, fixed in r87626.

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10804
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10805] traceback.print_exception throws AttributeError when exception is None

2011-01-02 Thread Austin Bingham

New submission from Austin Bingham austin.bing...@gmail.com:

traceback.print_exception() will throw an AttributeException if `value` is None 
and `chain` is True. This is because `_iter_chain` assumes that the exception 
object has a `__cause__` attribute. You can trigger this by trying for format a 
non-existent exception:

   import logging, sys
   logging.Formatter().formatException(sys.exc_info())
  Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python3.1/logging/__init__.py, line 418, in formatException
traceback.print_exception(ei[0], ei[1], ei[2], None, sio)
  File /usr/lib/python3.1/traceback.py, line 155, in print_exception
for value, tb in values:
  File /usr/lib/python3.1/traceback.py, line 122, in _iter_chain
cause = exc.__cause__

This is assuming that sys.exc_info() returns (None, None, None).

--
components: Library (Lib)
messages: 125054
nosy: abingham
priority: normal
severity: normal
status: open
title: traceback.print_exception throws AttributeError when exception is None
type: behavior
versions: Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10805
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1665333] Documentation missing for OptionGroup class in optparse

2011-01-02 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Looks good, applied in r87627 (after removing stray tabs).

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1665333
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8013] time.asctime segfaults when given a time in the far future

2011-01-02 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

The patch is wrong: it hardcodes the number of characters that the time string 
has, but it can be more than 24 if the year is  .  (Of course, the check 
for \n currently in the code is wrong too and must be fixed.)

Also, shouldn't the issue be handled as in ctime()?  There is a NULL check 
there, and by just doing that check we wouldn't depend on asctime_r().

--
assignee:  - belopolsky
nosy: +belopolsky, georg.brandl

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8013
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5870] subprocess.DEVNULL

2011-01-02 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Hmm, we don't like these open-for-eternity file descriptors; we had such a 
thing for os.urandom() but removed it (see #1177468).

I'm okay with DEVNULL (or even just NULL) as a shorthand, but it should open 
(and close) the devnull device each time just as if a normal fd was given.

--
nosy: +georg.brandl

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5870
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5870] subprocess.DEVNULL

2011-01-02 Thread Ross Lagerwall

Ross Lagerwall rosslagerw...@gmail.com added the comment:

I think if you look closely at the patch, the fd does not stay open the whole 
time. It is opened if necessary in _get_handles() with e.g.:

elif stdin == DEVNULL:
p2cread = self._get_devnull()

and then closed in _execute_child() with:

if hasattr(self, '_devnull'):
os.close(self._devnull)

which is executed from __init__(). So I don't think it stays open for eternity 
:-)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5870
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9074] subprocess closes standard file descriptors when it should not

2011-01-02 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

#9905 has a similar patch and adds tests as well.

--
nosy: +georg.brandl
resolution:  - duplicate
status: open - closed
superseder:  - subprocess.Popen fails with stdout=PIPE, stderr=PIPE if 
standard descriptors (0, 1, 2) are closed.

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9074
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8013] time.asctime segfaults when given a time in the far future

2011-01-02 Thread Andreas Stührk

Andreas Stührk andy-pyt...@hammerhartes.de added the comment:

The real problem with years =  is that it is undefined behaviour anyway 
(see e.g. 
http://pubs.opengroup.org/onlinepubs/9699919799/functions/asctime.html: the 
behavior is undefined if the above algorithm would attempt to generate more 
than 26 bytes of output (including the terminating null)).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8013
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8013] time.asctime segfaults when given a time in the far future

2011-01-02 Thread Andreas Stührk

Andreas Stührk andy-pyt...@hammerhartes.de added the comment:

Sorry, I meant  years   of course.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8013
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8013] time.asctime segfaults when given a time in the far future

2011-01-02 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Well, then I would have no problem with checking for that condition beforehand 
and raising ValueError.

On the other hand, it seems that implementations either return a correct string 
or NULL, so just erroring out in case of NULL would be fine as well.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8013
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5870] subprocess.DEVNULL

2011-01-02 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Right, sorry then :)

--
assignee:  - gregory.p.smith
nosy: +gregory.p.smith

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5870
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-02 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

I've tried the patch under OpenSolaris and the test fails (EAGAIN),
meaning that accept() semantics there are the same as under BSD:

==
ERROR: testInheritFlags (test.test_socket.NonBlockingTCPTests)
--
Traceback (most recent call last):
  File /home/antoine/vbox/py3k/cc/Lib/test/test_socket.py, line 983,
in testInheritFlags
message = conn.recv(len(MSG))
socket.error: [Errno 11] Resource temporarily unavailable

I think the code path in the patch should be opt-out rather than opt-in:
that is, it should be executed if HAVE_FCNTL, O_NONBLOCK are defined,
and if not under Linux.
(and I don't think O_ASYNC is useful here, is it?)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7995
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-02 Thread Etienne Robillard

Changes by Etienne Robillard e...@gthcfoundation.org:


--
nosy: +erob

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4953
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-02 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Thank you very much for working on this!  I'll try to take a look at the patch 
soon.  A couple quick comments based on your posting: first, the email module 
now has a BytesFeedparser that will accept a byte stream, which I hope might 
simplify your patch.  Second, it would be very helpful if you could upload your 
patch as an 'svn diff' against the current py3k trunk (see python.org/dev for 
details on how to do that).  That will make review and application of the patch 
much much simpler.  (This would be true even if more of the code in cgi.py has 
changed than not.)  If you don't want to set up an svn checkout, then a context 
diff against the copy of cgi.py you started with would be second best.  Please 
post any files individually as .patch or .diff or .txt files...these are 
preferred in the tracker over .zip files because they can be viewed without 
downloading.

--
stage: unit test needed - patch review
versions: +Python 3.3 -Python 3.0, Python 3.1, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4953
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-02 Thread Ross Lagerwall

Ross Lagerwall rosslagerw...@gmail.com added the comment:

OK try this one, it's now opt-out.

--
Added file: http://bugs.python.org/file20222/7995_v3.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7995
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10806] Subprocess error if fds 0,1,2 are closed

2011-01-02 Thread Ross Lagerwall

New submission from Ross Lagerwall rosslagerw...@gmail.com:

There is an issue where if a python program closes all the std. file 
descriptors (e.g. a daemon) and then uses the subprocess module, the file 
descriptors may not be set up properly in the subprocess. This may actually be 
a fairly common use case in a daemon program that needs to run a subprocess and 
set up pipes to it.

Here is an example:

import os, subprocess, sys

x=os.open('/dev/null', os.O_RDWR)
os.close(0)
os.close(1)
os.close(2)

res = subprocess.Popen([sys.executable, -c,
  'import sys;'
  'sys.stdout.write(apple);'
  'sys.stdout.flush();'
  'sys.stderr.write(orange)'],
   stdin=x,
   stdout=subprocess.PIPE,
   stderr=subprocess.PIPE).communicate()
with open('/tmp/out', 'w') as f:
f.write(repr(res) + '\n')
f.write(repr((b'apple', b'orange')) + '\n')

The expected output in /tmp/out is:
('apple', 'orange')
('apple', 'orange')

but we get:
(b'', bFatal Python error: Py_Initialize: can't initialize sys standard 
streams\nOSError: [Errno 9] Bad file descriptor\n)
(b'apple', b'orange')

The problem comes about where the calls are made (this applies to the python  
c versions):
 os.dup2(p2cread, 0)
 os.dup2(c2pwrite, 1)
 os.dup2(errwrite, 2)

if c2pwrite or p2cread or errwrite is the same as what it's being dupped() to 
(eg if c2pwrite == 1) then the dup2 call does nothing. But, if we're using 
pipes, the close-on-exec flags are set initially and the dup2() call would 
normally remove the flag but it doesn't.

Attached is a patch which basically uses fcntl if necessary to remove the 
close-on-exec flag, and tests.

--
components: Library (Lib)
files: subprocess.patch
keywords: patch
messages: 125067
nosy: georg.brandl, giampaolo.rodola, gregory.p.smith, pitrou, rosslagerwall
priority: normal
severity: normal
status: open
title: Subprocess error if fds 0,1,2 are closed
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file20223/subprocess.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10806
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10751] REMOTE_USER and Remote-User collision in wsgiref

2011-01-02 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
components: +Library (Lib) -Extension Modules
stage:  - needs patch
title: WSGIREF - REMOTE_USER and REMOTE-USER collision - REMOTE_USER and 
Remote-User collision in wsgiref
type: security - behavior
versions: +Python 3.1, Python 3.2 -Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10751
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10807] `b'dGVzdA==\n'.decode('base64')` raise exception

2011-01-02 Thread yihuang

New submission from yihuang yi.codepla...@gmail.com:

 b'dGVzdA==\n'.decode('base64')
Traceback (most recent call last):
  File stdin, line 1, in module
  File ../Lib/encodings/base64_codec.py, line 20, in base64_decode
return (base64.decodebytes(input), len(input))
  File ../Lib/base64.py, line 359, in decodebytes
raise TypeError(expected bytes, not %s % s.__class__.__name__)
TypeError: expected bytes, not memoryview

--
components: Unicode
messages: 125068
nosy: yi.codeplayer
priority: normal
severity: normal
status: open
title: `b'dGVzdA==\n'.decode('base64')` raise exception
type: behavior
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10807
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10806] Subprocess error if fds 0,1,2 are closed

2011-01-02 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

 Attached is a patch which basically uses fcntl if necessary to remove
 the close-on-exec flag, and tests.

Python adds extra output at the end of stderr when compiled in debug
mode. Therefore you first have to strip that output, like this:

out, err = subprocess.Popen(...).communicate()
err = support.strip_python_stderr(err)
self.assertEqual((out, err), (b'apple', b'orange'))

Otherwise, looks good, thank you.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10806
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10791] Wrapping TextIOWrapper around gzip files

2011-01-02 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10791
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8013] time.asctime segfaults when given a time in the far future

2011-01-02 Thread Alexander Belopolsky

Alexander Belopolsky alexander.belopol...@gmail.com added the comment:

On Sun, Jan 2, 2011 at 10:52 AM, Georg Brandl rep...@bugs.python.org wrote:
..
 Well, then I would have no problem with checking for that condition 
 beforehand and raising
 ValueError.


IIRC, there was a similar bug report about ctime where pre-condition
checking was required because platform ctime would crash for huge
values of time.  I'll try to find the ticket.

 On the other hand, it seems that implementations either return a correct 
 string or NULL,
 so just erroring out in case of NULL would be fine as well.

This is true on the platforms that I have access to: OSX, Linux, and
Solaris.  I think asctime_r is available and behaves this way on
Python supported platforms.  I'll check this in and watch the bots.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8013
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8013] time.asctime segfaults when given a time in the far future

2011-01-02 Thread Alexander Belopolsky

Alexander Belopolsky alexander.belopol...@gmail.com added the comment:

On Sun, Jan 2, 2011 at 1:52 PM, Alexander Belopolsky
rep...@bugs.python.org wrote:
..
 Well, then I would have no problem with checking for that condition 
 beforehand and raising
 ValueError.


 IIRC, there was a similar bug report about ctime where pre-condition
 checking was required because platform ctime would crash for huge
 values of time.  I'll try to find the ticket.

Hmm. My search brought up issue 10563, but the last message on that
issue says that a change has been recently made to time.asctime() to
reject year  .  See r85137 and issue6608.  I wonder if that
change made this issue moot.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8013
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10807] `b'dGVzdA==\n'.decode('base64')` raise exception

2011-01-02 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

base64, bz2, hex, quopri, rot13, uu and zlib codecs (reintroduced recently by 
r86934, issue #7475) cannot be used by str.encode/bytes.decode, but with 
.transform() and .untransform() methods of bytes and str objects. But these 
methods were removed by r87176.

The last solution to use base64 codec is:

 import codecs
 codecs.lookup('base64').decode(b'YWJj\n')[0]
b'abc'
 codecs.lookup('base64').encode(b'YWJj\n')[0]
b'abc'

Or simply use directly the base64 module:

 import base64
 base64.decodebytes(b'YWJj\n')
b'abc'
 base64.encodebytes(b'abc')
b'YWJj\n'

base64, bz2, hex, quopri, rot13, uu and zlib codecs should be removed from 
encodings.aliases (because they introduced a confusion for Python 2 users), or 
removed completly (because it's easier to use directly the related module, eg. 
base64 or zlib).

--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10807
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7475] codecs missing: base64 bz2 hex zlib hex_codec ...

2011-01-02 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

See issue #10807: 'base64' can be used with bytes.decode() (and str.encode()), 
but it raises a confusing exception (TypeError: expected bytes, not memoryview).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7475
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10807] `b'dGVzdA==\n'.decode('base64')` raise exception

2011-01-02 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
nosy: +georg.brandl
priority: normal - release blocker

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10807
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10807] `b'dGVzdA==\n'.decode('base64')` raise exception

2011-01-02 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

issue10807.patch just disables hex, base64, ... codecs in aliases (so it's 
still possible to use they through codecs.lookup()).

--
keywords: +patch
Added file: http://bugs.python.org/file20224/issue10780.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10807
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10807] `b'dGVzdA==\n'.decode('base64')` raise exception

2011-01-02 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

That does not look like the right patch...

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10807
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10807] `b'dGVzdA==\n'.decode('base64')` raise exception

2011-01-02 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


Removed file: http://bugs.python.org/file20224/issue10780.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10807
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10807] `b'dGVzdA==\n'.decode('base64')` raise exception

2011-01-02 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Ah yes :-)

--
Added file: http://bugs.python.org/file20225/issue10807.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10807
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10807] `b'dGVzdA==\n'.decode('base64')` raise exception

2011-01-02 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Looks good, please commit.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10807
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10807] `b'dGVzdA==\n'.decode('base64')` raise exception

2011-01-02 Thread Alexander Belopolsky

Changes by Alexander Belopolsky belopol...@users.sourceforge.net:


--
nosy: +belopolsky

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10807
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7995] On Mac / BSD sockets returned by accept inherit the parent's FD flags

2011-01-02 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

After further testing, it turns out that Windows exhibits BSD-like behaviour 
too. So instead of complicating the flag-setting code again, I suggest an 
alternative of doing it in the Python wrapper. Patch attached.

--
Added file: http://bugs.python.org/file20226/nonblock.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7995
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10475] hardcoded compilers for LDSHARED/LDCXXSHARED on NetBSD

2011-01-02 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Patch committed in r87639 (3.2), r87641 (3.1) and r87640 (2.7). Thank you!

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed
versions:  -Python 2.5, Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10475
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10798] test_concurrent_futures fails on FreeBSD

2011-01-02 Thread Brian Quinlan

Brian Quinlan br...@sweetapp.com added the comment:

Martin,

Could you commit this patch if you think that it is the right thing? I'm going 
to be restructuring the tests and don't want you to get caught in merge hell.

Cheers,
Brian

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10798
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >