Re: Generating sin/square waves sound

2011-12-30 Thread 88888 Dihedral
Please check PYGAME and Simple Directmedia library. 

Python is used as the director like role and functions in SDL 
do most of the jobs in Pygame. 

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


Re: pickling instances of metaclass generated classes

2011-12-30 Thread lars van gemerden
On Dec 29, 8:55 pm, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Thu, Dec 29, 2011 at 2:55 AM, lars van gemerden l...@rational-it.com 
 wrote:

  Hello,

  Can someone help me with the following:

  I am using metaclasses to make classes and these classes to make
  instances. Now I want to use multiprocessing, which needs to pickle
  these instances.

  Pickle cannot find the class definitions of the instances. I am trying
  to add a line to the __new__ of the metaclass to add the new class
  under the right name in the right module/place, so pickle can find
  it.

  Is this the right approach? Can anyone explain to me where/how to add
  these classes for pickle to find and maybe why?

 It sounds like you're trying to do something like this?

  class MetaClass(type):

 ...     pass
 ... instance = MetaClass('Anonymous', (object,), {})()
  instance

 __main__.Anonymous object at 0x00CC00F0 import pickle
  pickle.dumps(instance)

 Traceback (most recent call last):
   File stdin, line 1, in module
   File c:\python27\lib\pickle.py, line 1374, in dumps
     Pickler(file, protocol).dump(obj)
   File c:\python27\lib\pickle.py, line 224, in dump
     self.save(obj)
   File c:\python27\lib\pickle.py, line 331, in save
     self.save_reduce(obj=obj, *rv)
   File c:\python27\lib\pickle.py, line 401, in save_reduce
     save(args)
   File c:\python27\lib\pickle.py, line 286, in save
     f(self, obj) # Call unbound method with explicit self
   File c:\python27\lib\pickle.py, line 562, in save_tuple
     save(element)
   File c:\python27\lib\pickle.py, line 295, in save
     self.save_global(obj)
   File c:\python27\lib\pickle.py, line 748, in save_global
     (obj, module, name))
 pickle.PicklingError: Can't pickle class '__main__.Anonymous':
 it's not found as __main__.Anonymous

 Yeah, pickle's not going to work with anonymous classes.  As you
 suggest, you could dynamically add the classes to the module namespace
 so that pickle.dumps will find them, but bear in mind that they will
 also have to exist when calling pickle.loads, so you will need to be
 able to reconstruct the same anonymous classes before unpickling later
 on.

 Cheers,
 Ian

Thank you Ian for the minimal example. This is almost the case i was
trying to discribe, however the classes will be named at runtime and
the class definitions will be persisted in a database.

Can you help me with how to add the classes to the correct namespace?
The application spans multiple modules (or compared to the example,
the metaclass definition will be in another module then one where the
class and instance will be generated).

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


Re: Generating sin/square waves sound

2011-12-30 Thread Dave Angel

On 12/30/2011 02:17 AM, Paulo da Silva wrote:

Hi,
Sorry if this is a FAQ, but I have googled and didn't find any
satisfatory answer.

Is there a simple way, preferably multiplataform (or linux), of
generating sinusoidal/square waves sound in python?

Thanks for any answers/suggestions.
If you're willing to be Linux-only, then I believe you can do it without 
any extra libraries.


You build up a string (8 bit char, on Python 2.x)  of samples, and write 
it to  /dev/audio.  When i experimented, I was only interested in a 
few seconds, so a single write was all I needed.


Note that the samples are 8 bits, and they are offset by 128.  So a zero 
signal would be a string of 128 values.  A very quiet square wave might 
be a bunch of 126, followed by a bunch of 130.  and so on.  And the 
loudest might be a bunch of 2's followed by a bunch of 253's.


You'll have to experiment with data rate;   The data is sent out at a 
constant rate from your string, but I don't know what that rate is.



--

DaveA

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


Re: importing MySQLdb

2011-12-30 Thread Ned Deily
In article 4efb9d6d.3080...@gmail.com,
 Dilara Ally dilara.a...@gmail.com wrote:
 I'm trying to import the MySQLdb for python.  I downloaded the proper 
 setuptools egg (ver2.7) for a Mac with OSX10.6
 
 I then downloaded the MySQL-python-1.2.3 and ran the following commands
 
 python setup.py build
 sudo python setup.py install
 
 Then to test that the module was properly loaded I used the interactive 
 python prompt ad ran the following command:
 
 import MySQLdb
 
 The error message read:
 
 Traceback (most recent call last):
File stdin, line 1, in module
File MySQLdb/__init__.py, line 19, in module
  import _mysql
File build/bdist.macosx-10.6-intel/egg/_mysql.py, line 7, in module
File build/bdist.macosx-10.6-intel/egg/_mysql.py, line 6, in 
 __bootstrap__
 ImportError: 
 dlopen(/Users/dally/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.eg
 g-tmp/_mysql.so, 
 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: 
 /Users/dally/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_
 mysql.so
Reason: image not found
 
 Does anyone have any ideas on how to fix this problem?  Any help will be 
 greatly appreciated!

If you installed the MySQL client libraries from a MySQL binary 
installer, chances are that the library name in the client library does 
not contain the full path.  The MySQL project has a pretty dismal record 
for releasing faulty OS X binaries.  There are a few workarounds, the 
best being either to use install_name_tool to fix the path or to set the 
DYLD_LIBRARY_PATH environment variable.  See, for example, this blog 
post:

http://www.blog.bridgeutopiaweb.com/post/how-to-fix-mysql-load-issues-on-
mac-os-x/

-- 
 Ned Deily,
 n...@acm.org

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


Re: pickling instances of metaclass generated classes

2011-12-30 Thread lars van gemerden
On Dec 29, 8:55 pm, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Thu, Dec 29, 2011 at 2:55 AM, lars van gemerden l...@rational-it.com 
 wrote:

  Hello,

  Can someone help me with the following:

  I am using metaclasses to make classes and these classes to make
  instances. Now I want to use multiprocessing, which needs to pickle
  these instances.

  Pickle cannot find the class definitions of the instances. I am trying
  to add a line to the __new__ of the metaclass to add the new class
  under the right name in the right module/place, so pickle can find
  it.

  Is this the right approach? Can anyone explain to me where/how to add
  these classes for pickle to find and maybe why?

 It sounds like you're trying to do something like this?

  class MetaClass(type):

 ...     pass
 ... instance = MetaClass('Anonymous', (object,), {})()
  instance

 __main__.Anonymous object at 0x00CC00F0 import pickle
  pickle.dumps(instance)

 Traceback (most recent call last):
   File stdin, line 1, in module
   File c:\python27\lib\pickle.py, line 1374, in dumps
     Pickler(file, protocol).dump(obj)
   File c:\python27\lib\pickle.py, line 224, in dump
     self.save(obj)
   File c:\python27\lib\pickle.py, line 331, in save
     self.save_reduce(obj=obj, *rv)
   File c:\python27\lib\pickle.py, line 401, in save_reduce
     save(args)
   File c:\python27\lib\pickle.py, line 286, in save
     f(self, obj) # Call unbound method with explicit self
   File c:\python27\lib\pickle.py, line 562, in save_tuple
     save(element)
   File c:\python27\lib\pickle.py, line 295, in save
     self.save_global(obj)
   File c:\python27\lib\pickle.py, line 748, in save_global
     (obj, module, name))
 pickle.PicklingError: Can't pickle class '__main__.Anonymous':
 it's not found as __main__.Anonymous

 Yeah, pickle's not going to work with anonymous classes.  As you
 suggest, you could dynamically add the classes to the module namespace
 so that pickle.dumps will find them, but bear in mind that they will
 also have to exist when calling pickle.loads, so you will need to be
 able to reconstruct the same anonymous classes before unpickling later
 on.

 Cheers,
 Ian

Ian also wrote:

'''
Actually, I was wrong, you probably don't need to do that.  I suggest
going with Robert Kern's suggestion to either register the class with
the copy_reg module, or (perhaps better since it won't leak
registrations) implement a __reduce__ method on the class.  For
example, this seems to work:

 def reconstructor(*metaclass_args):
... cls = MetaClass.build_class(*metaclass_args)
... self = cls.__new__(cls)
... return self
...
 class MetaClass(type):
... @classmethod
... def build_class(mcs, arg1, arg2, arg3):
... # Do something useful with the args...
... class _AnonymousClass(object):
... __metaclass__ = mcs
... def __reduce__(self):
... return (reconstructor, ('foo', 'bar', 'baz'),
self.__dict__)
... return _AnonymousClass
...
 instance = MetaClass.build_class('foo', 'bar', 'baz')()
 instance
__main__._AnonymousClass object at 0x011DB410
 instance.banana = 42
 import pickle
 s = pickle.dumps(instance)
 s
c__main__\nreconstructor
\np0\n(S'foo'\np1\nS'bar'\np2\nS'baz'\np3\ntp4\nRp5\n(dp6\nS'banana'\np7\nI42\nsb.
 inst2 = pickle.loads(s)
 inst2
__main__._AnonymousClass object at 0x011DBE90
 inst2.banana
42
 inst2.__class__ is instance.__class__
False

Cheers,
Ian

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


Re: Generating sin/square waves sound

2011-12-30 Thread mblume
Am Fri, 30 Dec 2011 07:17:13 + schrieb Paulo da Silva:

 Hi,
 Sorry if this is a FAQ, but I have googled and didn't find any
 satisfatory answer.
 
 Is there a simple way, preferably multiplataform (or linux), of
 generating sinusoidal/square waves sound in python?
 
 Thanks for any answers/suggestions.

Have a look at the wave module, available under Windows and Linux,
which operates on .WAV files. The following snippet might get you going:

#!/usr/bin/python
import math, wave, struct

def signal(t, freq):
return math.sin(2.0*math.pi*freq*t)


wout  = wave.open(sample.wav, wb)
nchan = 1
sampwidth = 2
framerate = 8000
nframes   = 7 * framerate
comptype  = NONE
compname  = no compression


wout.setparams((nchan, sampwidth, framerate, nframes, comptype, compname))

ts = 1.0 / framerate
t  = 0.0
n  = 0
data = []
vals = []
while n  nframes:
vals.append(signal(t, 517.0))
n = n + 1
t = t + ts

mx   = max((abs(x) for x in vals))
vals = [ x/mx for x in vals ]   
data = 
for v in vals:
data = data + struct.pack(h, int(v*32766.0))
wout.writeframes(data)
wout.close()


Alternatively you might just generate (t,signal) samples, write them to 
a file and convert them using sox (under Linux, might also be available
under Windows) to another format.

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


Re: pickling instances of metaclass generated classes

2011-12-30 Thread Peter Otten
lars van gemerden wrote:

 On Dec 29, 8:55 pm, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Thu, Dec 29, 2011 at 2:55 AM, lars van gemerden l...@rational-it.com
 wrote:

  Hello,

  Can someone help me with the following:

  I am using metaclasses to make classes and these classes to make
  instances. Now I want to use multiprocessing, which needs to pickle
  these instances.

  Pickle cannot find the class definitions of the instances. I am trying
  to add a line to the __new__ of the metaclass to add the new class
  under the right name in the right module/place, so pickle can find
  it.

  Is this the right approach? Can anyone explain to me where/how to add
  these classes for pickle to find and maybe why?

 It sounds like you're trying to do something like this?

  class MetaClass(type):

 ... pass
 ... instance = MetaClass('Anonymous', (object,), {})()
  instance

 __main__.Anonymous object at 0x00CC00F0 import pickle
  pickle.dumps(instance)

 Traceback (most recent call last):
 File stdin, line 1, in module
 File c:\python27\lib\pickle.py, line 1374, in dumps
 Pickler(file, protocol).dump(obj)
 File c:\python27\lib\pickle.py, line 224, in dump
 self.save(obj)
 File c:\python27\lib\pickle.py, line 331, in save
 self.save_reduce(obj=obj, *rv)
 File c:\python27\lib\pickle.py, line 401, in save_reduce
 save(args)
 File c:\python27\lib\pickle.py, line 286, in save
 f(self, obj) # Call unbound method with explicit self
 File c:\python27\lib\pickle.py, line 562, in save_tuple
 save(element)
 File c:\python27\lib\pickle.py, line 295, in save
 self.save_global(obj)
 File c:\python27\lib\pickle.py, line 748, in save_global
 (obj, module, name))
 pickle.PicklingError: Can't pickle class '__main__.Anonymous':
 it's not found as __main__.Anonymous

 Yeah, pickle's not going to work with anonymous classes.  As you
 suggest, you could dynamically add the classes to the module namespace
 so that pickle.dumps will find them, but bear in mind that they will
 also have to exist when calling pickle.loads, so you will need to be
 able to reconstruct the same anonymous classes before unpickling later
 on.

 Cheers,
 Ian
 
 Thank you Ian for the minimal example. This is almost the case i was
 trying to discribe, however the classes will be named at runtime and
 the class definitions will be persisted in a database.
 
 Can you help me with how to add the classes to the correct namespace?
 The application spans multiple modules (or compared to the example,
 the metaclass definition will be in another module then one where the
 class and instance will be generated).

If the metaclass is global in whatever module you don't need to bother about 
that. The problem is that you cannot access the classes (metaclass 
instances) under a dotted name. One workaround is a pseudo-module that does 
whatever is needed to recreate the class:

import pickle
import sys

class MetaClass(type):
pass

class M(object):
def __init__(self, module):
self.__module = module
def __getattr__(self, name):
print creating class, name
class_ = MetaClass(name, (), {__module__: self.__module})
setattr(self, name, class_)
return class_

sys.modules[m] = M(m)
import m
c = m.x
s = pickle.dumps(c)
print repr(s)
d = pickle.loads(s)

assert c is d

sys.modules[m] = M(m)
e = pickle.loads(s)

assert c is not e

The official way is probably what Robert mentioned, via the copy_reg module, 
but I didn't get it to work.

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


Is python.org down?

2011-12-30 Thread Mario Menezes
Hi,

 I´m trying to access pypi.python.org as well as www.python.org and none of 
them is up?

  Anybody else having problems with python.org today? Is there a scheduled 
downtime?

  Thanks

Mario Menezes
Brazil
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is python.org down?

2011-12-30 Thread tistje
On 30 dec, 14:21, Mario Menezes mo.mene...@gmail.com wrote:
 Hi,

  I´m trying to access pypi.python.org as well as www.python.org and none of 
 them is up?

   Anybody else having problems with python.org today? Is there a scheduled 
 downtime?

   Thanks

 Mario Menezes
 Brazil

Seems like it is down ... I downloaded the 2.7.2 Windows installer a
couple of hours ago, but now even the download page isn't accessible.

Tist Verdonck
Belgium
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is python.org down?

2011-12-30 Thread Jérôme
Fri, 30 Dec 2011 05:39:37 -0800 (PST)
tistje a écrit:

 On 30 dec, 14:21, Mario Menezes mo.mene...@gmail.com wrote:
  Hi,
 
   I´m trying to access pypi.python.org as well as www.python.org and none
  of them is up?
 
    Anybody else having problems with python.org today? Is there a
  scheduled downtime?

 Seems like it is down ... I downloaded the 2.7.2 Windows installer a
 couple of hours ago, but now even the download page isn't accessible.

http://www.python.org seems to be working, now.

-- 
Jérôme
France
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is python.org down?

2011-12-30 Thread Chris Angelico
On Sat, Dec 31, 2011 at 12:21 AM, Mario Menezes mo.mene...@gmail.com wrote:
 Hi,

  I´m trying to access pypi.python.org as well as www.python.org and none of 
 them is up?

  Anybody else having problems with python.org today? Is there a scheduled 
 downtime?

  Thanks

Appears to be up now, for me at least. No reported troubles with DNS.
If you're still unable to get to it, try doing a DNS lookup, or try
pinging 82.94.164.162 (which is www.python.org according to my
lookup). Which one's out?

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


Re: Is python.org down?

2011-12-30 Thread Mario Menezes
Yeah! www.python.org is up now.

pypi.python.org still with problems (502 Bad Gateway).

will wait couple time. somebody seems to be working on this.

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


Re: Is python.org down?

2011-12-30 Thread python
A good tool for determining whether a site is down or just unavailable
to you:

http://downorisitjustme.com

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


Re: Is python.org down?

2011-12-30 Thread tistje
On 30 dec, 14:48, Chris Angelico ros...@gmail.com wrote:
 On Sat, Dec 31, 2011 at 12:21 AM, Mario Menezes mo.mene...@gmail.com wrote:
  Hi,

   I´m trying to access pypi.python.org as well aswww.python.organd none of 
  them is up?

   Anybody else having problems with python.org today? Is there a scheduled 
  downtime?

   Thanks

 Appears to be up now, for me at least. No reported troubles with DNS.
 If you're still unable to get to it, try doing a DNS lookup, or try
 pinging 82.94.164.162 (which iswww.python.orgaccording to my
 lookup). Which one's out?

 ChrisA

only pypi is still unaccessible (502 Bad Gateway).

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


Re: Is python.org down?

2011-12-30 Thread vikash agrawal
hi Everyone,

it seems http://in.pycon.org/2011/  is also down :(

Regards
Vikash Agrawal

-- 
sent via HTC Sensation
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickling instances of metaclass generated classes

2011-12-30 Thread lars van gemerden
On Dec 30, 12:16 pm, lars van gemerden l...@rational-it.com wrote:
 On Dec 29, 8:55 pm, Ian Kelly ian.g.ke...@gmail.com wrote:









  On Thu, Dec 29, 2011 at 2:55 AM, lars van gemerden l...@rational-it.com 
  wrote:

   Hello,

   Can someone help me with the following:

   I am using metaclasses to make classes and these classes to make
   instances. Now I want to use multiprocessing, which needs to pickle
   these instances.

   Pickle cannot find the class definitions of the instances. I am trying
   to add a line to the __new__ of the metaclass to add the new class
   under the right name in the right module/place, so pickle can find
   it.

   Is this the right approach? Can anyone explain to me where/how to add
   these classes for pickle to find and maybe why?

  It sounds like you're trying to do something like this?

   class MetaClass(type):

  ...     pass
  ... instance = MetaClass('Anonymous', (object,), {})()
   instance

  __main__.Anonymous object at 0x00CC00F0 import pickle
   pickle.dumps(instance)

  Traceback (most recent call last):
    File stdin, line 1, in module
    File c:\python27\lib\pickle.py, line 1374, in dumps
      Pickler(file, protocol).dump(obj)
    File c:\python27\lib\pickle.py, line 224, in dump
      self.save(obj)
    File c:\python27\lib\pickle.py, line 331, in save
      self.save_reduce(obj=obj, *rv)
    File c:\python27\lib\pickle.py, line 401, in save_reduce
      save(args)
    File c:\python27\lib\pickle.py, line 286, in save
      f(self, obj) # Call unbound method with explicit self
    File c:\python27\lib\pickle.py, line 562, in save_tuple
      save(element)
    File c:\python27\lib\pickle.py, line 295, in save
      self.save_global(obj)
    File c:\python27\lib\pickle.py, line 748, in save_global
      (obj, module, name))
  pickle.PicklingError: Can't pickle class '__main__.Anonymous':
  it's not found as __main__.Anonymous

  Yeah, pickle's not going to work with anonymous classes.  As you
  suggest, you could dynamically add the classes to the module namespace
  so that pickle.dumps will find them, but bear in mind that they will
  also have to exist when calling pickle.loads, so you will need to be
  able to reconstruct the same anonymous classes before unpickling later
  on.

  Cheers,
  Ian
 Ian also wrote:

 '''
 Actually, I was wrong, you probably don't need to do that.  I suggest
 going with Robert Kern's suggestion to either register the class with
 the copy_reg module, or (perhaps better since it won't leak
 registrations) implement a __reduce__ method on the class.  For
 example, this seems to work:

  def reconstructor(*metaclass_args):

 ...     cls = MetaClass.build_class(*metaclass_args)
 ...     self = cls.__new__(cls)
 ...     return self
 ... class MetaClass(type):

 ...     @classmethod
 ...     def build_class(mcs, arg1, arg2, arg3):
 ...         # Do something useful with the args...
 ...         class _AnonymousClass(object):
 ...             __metaclass__ = mcs
 ...             def __reduce__(self):
 ...                 return (reconstructor, ('foo', 'bar', 'baz'),
 self.__dict__)
 ...         return _AnonymousClass
 ... instance = MetaClass.build_class('foo', 'bar', 'baz')()
  instance

 __main__._AnonymousClass object at 0x011DB410 instance.banana = 42
  import pickle
  s = pickle.dumps(instance)
  s

 c__main__\nreconstructor
 \np0\n(S'foo'\np1\nS'bar'\np2\nS'baz'\np3\ntp4\nRp5\n(dp6\nS'banana'\np7\nI 
 42\nsb. inst2 = pickle.loads(s)
  inst2

 __main__._AnonymousClass object at 0x011DBE90 inst2.banana
 42
  inst2.__class__ is instance.__class__

 False

 Cheers,
 Ian

 '''

Interesting, though I cannot say I completely understand this solution
(looked up __reduce__, but still). I am trying to adapt this example
to a situation where the metaclass generated classes are named at
runtime (not anonymous), but cannot figure it out.

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


Re: pickling instances of metaclass generated classes

2011-12-30 Thread lars van gemerden
On Dec 30, 4:56 pm, lars van gemerden l...@rational-it.com wrote:
 On Dec 30, 12:16 pm, lars van gemerden l...@rational-it.com wrote:









  On Dec 29, 8:55 pm, Ian Kelly ian.g.ke...@gmail.com wrote:

   On Thu, Dec 29, 2011 at 2:55 AM, lars van gemerden l...@rational-it.com 
   wrote:

Hello,

Can someone help me with the following:

I am using metaclasses to make classes and these classes to make
instances. Now I want to use multiprocessing, which needs to pickle
these instances.

Pickle cannot find the class definitions of the instances. I am trying
to add a line to the __new__ of the metaclass to add the new class
under the right name in the right module/place, so pickle can find
it.

Is this the right approach? Can anyone explain to me where/how to add
these classes for pickle to find and maybe why?

   It sounds like you're trying to do something like this?

class MetaClass(type):

   ...     pass
   ... instance = MetaClass('Anonymous', (object,), {})()
instance

   __main__.Anonymous object at 0x00CC00F0 import pickle
pickle.dumps(instance)

   Traceback (most recent call last):
     File stdin, line 1, in module
     File c:\python27\lib\pickle.py, line 1374, in dumps
       Pickler(file, protocol).dump(obj)
     File c:\python27\lib\pickle.py, line 224, in dump
       self.save(obj)
     File c:\python27\lib\pickle.py, line 331, in save
       self.save_reduce(obj=obj, *rv)
     File c:\python27\lib\pickle.py, line 401, in save_reduce
       save(args)
     File c:\python27\lib\pickle.py, line 286, in save
       f(self, obj) # Call unbound method with explicit self
     File c:\python27\lib\pickle.py, line 562, in save_tuple
       save(element)
     File c:\python27\lib\pickle.py, line 295, in save
       self.save_global(obj)
     File c:\python27\lib\pickle.py, line 748, in save_global
       (obj, module, name))
   pickle.PicklingError: Can't pickle class '__main__.Anonymous':
   it's not found as __main__.Anonymous

   Yeah, pickle's not going to work with anonymous classes.  As you
   suggest, you could dynamically add the classes to the module namespace
   so that pickle.dumps will find them, but bear in mind that they will
   also have to exist when calling pickle.loads, so you will need to be
   able to reconstruct the same anonymous classes before unpickling later
   on.

   Cheers,
   Ian
  Ian also wrote:

  '''
  Actually, I was wrong, you probably don't need to do that.  I suggest
  going with Robert Kern's suggestion to either register the class with
  the copy_reg module, or (perhaps better since it won't leak
  registrations) implement a __reduce__ method on the class.  For
  example, this seems to work:

   def reconstructor(*metaclass_args):

  ...     cls = MetaClass.build_class(*metaclass_args)
  ...     self = cls.__new__(cls)
  ...     return self
  ... class MetaClass(type):

  ...     @classmethod
  ...     def build_class(mcs, arg1, arg2, arg3):
  ...         # Do something useful with the args...
  ...         class _AnonymousClass(object):
  ...             __metaclass__ = mcs
  ...             def __reduce__(self):
  ...                 return (reconstructor, ('foo', 'bar', 'baz'),
  self.__dict__)
  ...         return _AnonymousClass
  ... instance = MetaClass.build_class('foo', 'bar', 'baz')()
   instance

  __main__._AnonymousClass object at 0x011DB410 instance.banana = 42
   import pickle
   s = pickle.dumps(instance)
   s

  c__main__\nreconstructor
  \np0\n(S'foo'\np1\nS'bar'\np2\nS'baz'\np3\ntp4\nRp5\n(dp6\nS'banana'\np7\nI 
  42\nsb. inst2 = pickle.loads(s)
   inst2

  __main__._AnonymousClass object at 0x011DBE90 inst2.banana
  42
   inst2.__class__ is instance.__class__

  False

  Cheers,
  Ian

  '''

 Interesting, though I cannot say I completely understand this solution
 (looked up __reduce__, but still). I am trying to adapt this example
 to a situation where the metaclass generated classes are named at
 runtime (not anonymous), but cannot figure it out.

 Cheers, Lars

Found a way to name the classes:

def reconstructor(*metaclass_args):
cls = MetaClass2.build_class(*metaclass_args)
self = cls.__new__(cls)
return self

class MetaClass(type):
@classmethod
def build_class(mcs, name, arg1, arg2, arg3):
return mcs(name, (object,), {__reduce__: lambda e:
(reconstructor2, (name, arg1, arg2, arg3), e.__dict__)})

I still wonder whether it might be easier to add the class to the
namespace. Can anyone help me with that?

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


Doing a HTTP DELETE operation with urllib2?

2011-12-30 Thread Roy Smith
Is there some way to make urllib2.urlopen() perform a DELETE instead of a GET 
or POST?

 I'm hoping I don't have to dip way down into httplib.  I've got an application 
test framework built on top of urllib2.  It makes heavy use of 
HTTPCookieProcessor.  If I need to use the httplib calls directly, I'll have to 
re-implement a lot of that machinery.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickling instances of metaclass generated classes

2011-12-30 Thread Ian Kelly
On Fri, Dec 30, 2011 at 9:51 AM, lars van gemerden l...@rational-it.com wrote:
 I still wonder whether it might be easier to add the class to the
 namespace. Can anyone help me with that?

from mypackage import mymodule

setattr(mymodule, myclass.__name__, myclass)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Doing a HTTP DELETE operation with urllib2?

2011-12-30 Thread Douglas Landgraf

Hi,

On 12/30/2011 12:01 PM, Roy Smith wrote:

Is there some way to make urllib2.urlopen() perform a DELETE instead of a GET 
or POST?

  I'm hoping I don't have to dip way down into httplib.  I've got an 
application test framework built on top of urllib2.  It makes heavy use of 
HTTPCookieProcessor.  If I need to use the httplib calls directly, I'll have to 
re-implement a lot of that machinery.

You might want to look:
https://github.com/dougsland/rhev3-restapi-scripts/blob/master/sample-delete.py

--
Cheers
Douglas

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


Creating a binary only python distribution of a C extension module and including some additional python and c files in it

2011-12-30 Thread akhilesh singhania
Hi,

I have a extension module in C which I want to distribute in binary
format, ideally an rpm. Additionally, I want to include some python
files (examples on how to use the extension module) and source for a
library the module dynamically links to (c,h, and make files).

How do I specify the example python file in setup.py so that it will
be included in the rpm?

If I specify it as scripts, I get the following error:

$ python setup.py bdist --format=rpm

  running build_scripts
  creating build/scripts-2.6
  error: file 'foo.py' does not exist
  error: Bad exit status from /var/tmp/rpm-tmp.yjws9x (%build)
If I specify it as data_files, I get the following error:

$ python setup.py bdist --format=rpm

  error: Installed (but unpackaged) file(s) found:
 /usr/foo.pyc
 /usr/foo.pyo
If I specify it as py_modules, I do not get errors but it is not
included in the resulting rpm.

Specifying it as a script works if I use

$ python setup.py bdist --format=gztar
Additionally, can I control the hierarchy of how the files are laid
out in the rpm?

Currently, I am specifying the c,h,make files as data_files and they
get placed in /usr, which is not desirable.

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


Re: How to get function string name from i-th stack position?

2011-12-30 Thread Tim Chase

On 12/30/11 11:51, dmitrey wrote:

how to get string name of a function that is n levels above
the current Python interpreter position?


Use the results of traceback.extract_stack()

  from traceback import extract_stack
  def one(x):
print one, x
stk = extract_stack()
for mod, lineno, fun_name, call_code_text in stk:
  print [%s:%i] in %s % (mod, lineno, fun_name)
  def two(x):
print two, x
one(x)
  def three(x):
print three, x
two(x)
  three(Hi)


-tkc



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


Re: How to get function string name from i-th stack position?

2011-12-30 Thread dmitrey
On Dec 30, 8:35 pm, Tim Chase python.l...@tim.thechases.com wrote:
 On 12/30/11 11:51, dmitrey wrote:

  how to get string name of a function that is n levels above
  the current Python interpreter position?

 Use the results of traceback.extract_stack()

    from traceback import extract_stack
    def one(x):
      print one, x
      stk = extract_stack()
      for mod, lineno, fun_name, call_code_text in stk:
        print [%s:%i] in %s % (mod, lineno, fun_name)
    def two(x):
      print two, x
      one(x)
    def three(x):
      print three, x
      two(x)
    three(Hi)

 -tkc

Thank you. And what should I do to get function by itself instead of
its string name, e.g. I want to know does this function is my_func or
any other? For example, I would like to check is this function Python
sum(), or maybe numpy.sum(), or anything else?
Regards, D.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Doing a HTTP DELETE operation with urllib2?

2011-12-30 Thread Roy Smith
Ah, cool.  I didn't know you could do that.  Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Doing a HTTP DELETE operation with urllib2?

2011-12-30 Thread Steven D'Aprano
On Fri, 30 Dec 2011 10:57:06 -0800, Roy Smith wrote:

 Ah, cool.  I didn't know you could do that.  Thanks.

Who are you talking to, and what is that?

Replies with no context are somewhat less than useful. It might have made 
sense in your head when you wrote the reply, but to those reading, it is 
rather cryptic.


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


Re: Doing a HTTP DELETE operation with urllib2?

2011-12-30 Thread Dave Angel

On 12/30/2011 03:37 PM, Steven D'Aprano wrote:

On Fri, 30 Dec 2011 10:57:06 -0800, Roy Smith wrote:


Ah, cool.  I didn't know you could do that.  Thanks.

Who are you talking to, and what is that?

Replies with no context are somewhat less than useful. It might have made
sense in your head when you wrote the reply, but to those reading, it is
rather cryptic.


Actually I think he was replying to Roy Smith's message, which has a 
timestamp of 77 minutes later.  Interesting the effects you get when 
some clocks are allowed to drift.




--

DaveA

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


mutually exclusive arguments to a constructor

2011-12-30 Thread Adam Funk
(Warning: this question obviously reflects the fact that I am more
accustomed to using Java than Python.)

Suppose I'm creating a class that represents a bearing or azimuth,
created either from a string of traditional bearing notation
(N24d30mE) or from a number indicating the angle in degrees as
usually measured in trigonometry (65.5, measured counter-clockwise
from the x-axis).  The class will have methods to return the same
bearing in various formats.

In Java, I would write two constructors, one taking a single String
argument and one taking a single Double argument.  But in Python, a
class can have only one __init__ method, although it can have a lot of
optional arguments with default values.  What's the correct way to
deal with a situation like the one I've outlined above?


-- 
Unix is a user-friendly operating system. It's just very choosy about
its friends.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Günther Dietrich
Adam Funk a24...@ducksburg.com wrote:

Suppose I'm creating a class that represents a bearing or azimuth,
created either from a string of traditional bearing notation
(N24d30mE) or from a number indicating the angle in degrees as
usually measured in trigonometry (65.5, measured counter-clockwise
from the x-axis).  The class will have methods to return the same
bearing in various formats.

In Java, I would write two constructors, one taking a single String
argument and one taking a single Double argument.  But in Python, a
class can have only one __init__ method, although it can have a lot of
optional arguments with default values.  What's the correct way to
deal with a situation like the one I've outlined above?

You can determine the type of the input data by using isinstance() and 
take the appropriate actions depending on this decision:

 class MyClass(object):
... def __init__(self, input_data):
... if isinstance(input_data, basestring):
... print Do actions for string type input
... elif isinstance(input_data, float):
... print Do actions for float type input
... def get_output_data(self):
... return output data
... 
 a = MyClass(String)
Do actions for string type input
 b = MyClass(15.9)
Do actions for float type input



Best regards,

Günther
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Mel Wilson
Adam Funk wrote:

 (Warning: this question obviously reflects the fact that I am more
 accustomed to using Java than Python.)
 
 Suppose I'm creating a class that represents a bearing or azimuth,
 created either from a string of traditional bearing notation
 (N24d30mE) or from a number indicating the angle in degrees as
 usually measured in trigonometry (65.5, measured counter-clockwise
 from the x-axis).  The class will have methods to return the same
 bearing in various formats.
 
 In Java, I would write two constructors, one taking a single String
 argument and one taking a single Double argument.  But in Python, a
 class can have only one __init__ method, although it can have a lot of
 optional arguments with default values.  What's the correct way to
 deal with a situation like the one I've outlined above?

Cleanest from the point of view of the class source code would be factory 
functions at the module level, or special classmethods to deal with the less 
common cases.  You see this a lot in wxPython when they have to deal with 
overloaded C++ constructors.

Most like the Java would be to check within __init__ for a string argument 
that could be parsed as a bearing, and failing that fall back to treating 
the argument as a numeric angle.

Neither fish nor fowl would be to accept named arguments for the different 
kinds of values.

Mel.

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


Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Arnaud Delobelle
On 30 December 2011 20:40, Adam Funk a24...@ducksburg.com wrote:
 (Warning: this question obviously reflects the fact that I am more
 accustomed to using Java than Python.)

 Suppose I'm creating a class that represents a bearing or azimuth,
 created either from a string of traditional bearing notation
 (N24d30mE) or from a number indicating the angle in degrees as
 usually measured in trigonometry (65.5, measured counter-clockwise
 from the x-axis).  The class will have methods to return the same
 bearing in various formats.

 In Java, I would write two constructors, one taking a single String
 argument and one taking a single Double argument.  But in Python, a
 class can have only one __init__ method, although it can have a lot of
 optional arguments with default values.  What's the correct way to
 deal with a situation like the one I've outlined above?

(Using Python 3 below)

Method 1
--
Your __init__ method could take the angle as an argument (which seems
the most natural to me).  Then you could have a class method that
takes the string

i.e.

class Bearing:
def __init__(self, angle):
self.angle = angle
# or whatever your internal reprsentation is
@classmethod
def fromstring(cls, string):
# Here, work out the angle from the string
return cls(angle)

So you can do:

b = Bearing(65.5)

or

b = Bearing.fromstring(N24d30mE)

Method 2
--

You can test the type of the argument of the __init__ method

class Bearing:
def __init__(self, arg):
if isinstance(arg, str):
# here calculate the value of angle
else:
angle = float(angle)
self.angle = angle

Now you can do:

b = Bearing(65.5)

or

b = Bearing(N24d30mE)

Both methods are used for builtin types:

 int('12')
12
 int(12.5)
12
 dict([(1, 2), (3, 4)])
{1: 2, 3: 4}
 dict.fromkeys([1, 2])
{1: None, 2: None}

HTH

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


Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Jason Friedman
 Suppose I'm creating a class that represents a bearing or azimuth,
 created either from a string of traditional bearing notation
 (N24d30mE) or from a number indicating the angle in degrees as
 usually measured in trigonometry (65.5, measured counter-clockwise
 from the x-axis).  The class will have methods to return the same
 bearing in various formats.

 In Java, I would write two constructors, one taking a single String
 argument and one taking a single Double argument.  But in Python, a
 class can have only one __init__ method, although it can have a lot of
 optional arguments with default values.  What's the correct way to
 deal with a situation like the one I've outlined above?

Similar to other answers already posted:


#!/usr/bin/env python
class azimuth:
def __init__(self, bearing, heading):
self.bearing = bearing
self.heading = heading
if not bearing:
self.bearing = 30.5 # or, realistically, a calculation
based on the heading
if not heading:
self.heading = N... # or, realistically, a calculation
based on the bearing
@staticmethod
def getBearingInstance(bearing):
return azimuth(bearing, None)
@staticmethod
def getHeadingInstance(heading):
return azimuth(None, heading)

azimuth1 = azimuth.getBearingInstance(N24d30mE)
print azimuth1.heading

azimuth2 = azimuth.getHeadingInstance(30)
print azimuth2.bearing
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get function string name from i-th stack position?

2011-12-30 Thread Ian Kelly
On Fri, Dec 30, 2011 at 11:43 AM, dmitrey dmitre...@gmail.com wrote:
 Thank you. And what should I do to get function by itself instead of
 its string name, e.g. I want to know does this function is my_func or
 any other? For example, I would like to check is this function Python
 sum(), or maybe numpy.sum(), or anything else?

The Python stack only includes Python code objects.  Built-ins like
sum won't appear in it because they're basically C functions and don't
have associated code objects.  If you really want to see them, you
could probably do something with ctypes to inspect the C stack, but I
don't recommend it.

You can get the Python code objects from the stack by calling
inspect.stack(), which includes each frame object currently on the
stack as the first member of each tuple.  E.g.:

frames = map(operator.itemgetter(0), inspect.stack())

Each frame has an f_code attribute that stores the code object
associated with that frame.  Getting the actual function from the code
object is tricky, for two reasons.  One, not all code objects
represent functions.  There are also code objects for modules, class
definitions, and probably other thing as well.  Two, code objects
don't have associated functions. The relationship is the reverse:
functions have associated code objects.  You would have to iterate
over each function that you're interested in, looking for one with a
func_code attribute that is the frame's f_code attribute.

In any case, testing function identity is a rather large rabbit hole
that is best avoided.  These are mathematically the same function:

def plus1(value):
return value + 1

plus_one = lambda x: x + 1

But they are two distinct function objects, and there is no way
programmatically to determine that they are the same function except
by comparing the bytecode (which won't work generally because of the
halting problem).

What is it that you're trying to do?  Perhaps the helpful folks on the
list will be able to suggest a better solution if you can provide more
details.

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


Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Steven D'Aprano
On Fri, 30 Dec 2011 20:40:16 +, Adam Funk wrote:

 (Warning: this question obviously reflects the fact that I am more
 accustomed to using Java than Python.)
 
 Suppose I'm creating a class that represents a bearing or azimuth,
 created either from a string of traditional bearing notation
 (N24d30mE) or from a number indicating the angle in degrees as usually
 measured in trigonometry (65.5, measured counter-clockwise from the
 x-axis).  The class will have methods to return the same bearing in
 various formats.
 
 In Java, I would write two constructors, one taking a single String
 argument and one taking a single Double argument.  But in Python, a
 class can have only one __init__ method, although it can have a lot of
 optional arguments with default values.  What's the correct way to deal
 with a situation like the one I've outlined above?

The most idiomatic way to do this would be with named constructor 
functions, or by testing the argument type in __init__. For example:

# Method 1
class Azimuth(object):
def __init__(self, angle):
# Initialise an azimuth object from an angle (float)
self._angle = float(angle)
@classmethod
def from_bearing(cls, bearing):
# Create an azimuth object from a bearing (string).
angle = cls.bearing_to_angle(bearing)
return cls(angle)
@staticmethod
def bearing_to_angle(bearing):
# Convert a bearing (string) into a float.
return 0.0  # whatever...


Note some features of this version:

* Normal methods receive the instance as first argument, self.

* We use the classmethod and staticmethod decorators to create class 
  and static methods. Be warned that the meaning of these are NOT 
  the same as in Java!

* Class methods receive the class object as first argument, cls. 
  Hence the name. Note that in Python, classes are objects too.

* We make from_bearing a class method, so we can call it from either
  the class itself:

  ang = Azimuth.from_bearing(25N14E)

  or from an existing instance:

  ang2 = ang.from_bearing(17N31W)

* Static methods don't receive either the class or the instance. They
  are equivalent to a top level function, except encapsulated inside
  a class.


# Method 2
class Azimuth(object):
def __init__(self, arg):
# Initialise an azimuth object from arg, either an angle (float)
# or a bearing (string).
if isinstance(arg, str):
angle = bearing_to_angle(arg)
else:
angle = float(arg)
self._angle = float(angle)

def bearing_to_angle(bearing):
# Convert a bearing (string) into a float.
return 0.0  # whatever...


Note that in this example, I've turned bearing_to_angle into a regular 
function outside of the class instead of a static method. Just because I 
can. This is probably slightly more idiomatic than the use of static 
methods.


Either method is acceptable, although the first is slightly more pure 
because it doesn't use isinstance. The second may fail if the user passes 
a string-like object which behaves identically to strings, but doesn't 
inherit from str. If you care about that, you should prefer the first way 
with an explicit from_bearing method.



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


Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Steven D'Aprano
On Fri, 30 Dec 2011 21:18:29 +, Jason Friedman wrote:

 class azimuth:
 def __init__(self, bearing, heading):

It is conventional, and recommended, to use an initial capital letter for 
classes. (Yes, Python built-ins violate that rule, and indeed so do some 
non-built-ins.) See PEP 8 for the recommended style guide.


[...]
 @staticmethod
 def getBearingInstance(bearing):
 return azimuth(bearing, None)
 @staticmethod
 def getHeadingInstance(heading):
 return azimuth(None, heading)

In this case, you should use classmethod rather than staticmethod and 
avoid hard-coding the class:

@classmethod
def getBearingInstance(cls, bearing):
return cls(bearing, None)

That way subclassing will work correctly:


class MyAzimuth(azimuth):
pass

angle = MyAzimuth.getBearingInstance(N24d30mE)

will return a MyAzimuth instance instead of an azimuth instance.



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


Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Roy Smith
In article g6k1t8xg0a@news.ducksburg.com,
 Adam Funk a24...@ducksburg.com wrote:

 (Warning: this question obviously reflects the fact that I am more
 accustomed to using Java than Python.)
 
 Suppose I'm creating a class that represents a bearing or azimuth,
 created either from a string of traditional bearing notation
 (N24d30mE) or from a number indicating the angle in degrees as
 usually measured in trigonometry (65.5, measured counter-clockwise
 from the x-axis).

There's two ways to do this.

One would be to have the __init__ method switch on the type of its 
argument:

def __init__(self, bearing_or_azimuth):
   if isinstance(bearing_or_azimuth, basestring):
  # do the bearing thing
   else:
  # do the azimuth thing

I suspect many people would consider that unpythonic.  The other way 
would be what, in the C++/Java world, would be called the named 
constructor idiom.  Just write two factory functions:

class DirectionIndicatingThingie:
   @staticmethod
   def from_bearing(cls, bearing):
  dit = DirectionIndicatingThingie()
  dit.direction = whatever
  return dit

and likewise for from_azimuth()

But!, some C++/Java type bondage addicts might cry, there's nothing 
to prevent somebody from creating a DirectionIndicatingThingie directly, 
bypassing the factory functions.  There's no way to make the constructor 
private!.  To which the free-willed pythonistas would respond, If it 
hurts when you do that, don't do that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Chris Angelico
On Sat, Dec 31, 2011 at 10:24 AM, Roy Smith r...@panix.com wrote:
 But!, some C++/Java type bondage addicts might cry, there's nothing
 to prevent somebody from creating a DirectionIndicatingThingie directly,
 bypassing the factory functions.  There's no way to make the constructor
 private!.  To which the free-willed pythonistas would respond, If it
 hurts when you do that, don't do that.

You know a Python programmer's been at your C++ code when it opens:
#define class struct

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


Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Roy Smith
In article mailman.4256.1325288188.27778.python-l...@python.org,
 Chris Angelico ros...@gmail.com wrote:

 On Sat, Dec 31, 2011 at 10:24 AM, Roy Smith r...@panix.com wrote:
  But!, some C++/Java type bondage addicts might cry, there's nothing
  to prevent somebody from creating a DirectionIndicatingThingie directly,
  bypassing the factory functions.  There's no way to make the constructor
  private!.  To which the free-willed pythonistas would respond, If it
  hurts when you do that, don't do that.
 
 You know a Python programmer's been at your C++ code when it opens:
 #define class struct

Why stop there?

#define private public
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mutually exclusive arguments to a constructor

2011-12-30 Thread Chris Angelico
On Sat, Dec 31, 2011 at 10:39 AM, Roy Smith r...@panix.com wrote:
 In article mailman.4256.1325288188.27778.python-l...@python.org,
  Chris Angelico ros...@gmail.com wrote:

 You know a Python programmer's been at your C++ code when it opens:
 #define class struct

 Why stop there?

 #define private public

Probably yeah, do both. Anyway, life's so much easier when you don't
have to write trivial getter/setter methods (and then maintain them).
I've never had a situation where I've changed a private member while
keeping the getters and setters unchanged; the ONLY benefit accessor
methods have ever given to me personally has been logging (and
granted, that is hard to do without them - since you can't override
__getitem__ in C++ - but how often do you really need that facility?).

I used to believe in the separation of interface from implementation.
Then I realised that most of the separation was transparent anyway,
and gave up on it. And then realised why the separation is a good idea
after all. :)

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


Re: Which library for audio playback ?

2011-12-30 Thread K Richard Pixley

On 12/29/11 05:55 , Jérôme wrote:

I'm writing a small application that plays sound through the speakers. The
sounds are juste sine waves of arbitrary frequency I create in the code, not
sample .wav files.

I didn't expect the choice for an audio library to be that complicated. There
are several libraries, and none of them seems to be *the* reference.

Searching the web, I found these resources :

http://wiki.python.org/moin/Audio
http://wiki.python.org/moin/PythonInMusic

* I privileged ALSA to OSS as I read elsewhere that OSS is deprecated, or on
   its way to be. (And JACK is not widely installed, apart from specific
   applications (audio work).)

* Then, I picked the alsaaudio library (http://pyalsaaudio.sourceforge.net/).
   I don't remember exactly why. I think the project had the most recent
   updates. I don't think any project claims to be (let alone aims at being)
   complete.

I'm wondering if I made a sensible choice.

There are other libraries, including the following two that are platform
independent :

* PyAudiere (http://pyaudiere.org/), OSS , not packaged for debian
* PyAudio (http://people.csail.mit.edu/hubert/pyaudio/)

What solution would you recommend ?

Are there other criterions I should take into account ?

Thanks.



I made a similar survey of available libraries recently.  I'm interested 
in MIDI also, though, primarily on mac.


There doesn't seem to be any definitive audio library for linux, 
although several, (jack, oss, alsa), exist.  (My impression is similar 
to yours, OSS is obsolete. Jack may be the better library technically, 
but is not as widely ported or available as ALSA.)


There is a definitive library for both audio and MIDI on mac - core 
audio.  There really aren't any competitors.


There is also a definitive library for windows, although I don't use 
windows.  It's the open source one with low latency that everyone in the 
professional world uses to replace windows because, (surprise!), windows 
isn't capable of coping.


I have found python libraries for each of these, although some are very 
low level libraries, basically just wrapping something even lower.  If 
anyone has done an integrated full solution for linux or mac, I didn't 
find it.  The closest I found was PortMIDI and PortAudio which appear to 
have ports for all three platforms as well as one or two sets of python 
bindings and seem to be high enough level to be both useful and 
productive.  The hard part there is that PortMIDI and PortAudio come in 
source, which requires a bit of hunting to track down prerequisites, etc.


Please keep us posted as I'm chasing a similar problem.

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


Re: Generating sin/square waves sound

2011-12-30 Thread K Richard Pixley

On 12/29/11 23:17 , Paulo da Silva wrote:

Hi,
Sorry if this is a FAQ, but I have googled and didn't find any
satisfatory answer.

Is there a simple way, preferably multiplataform (or linux), of
generating sinusoidal/square waves sound in python?

Thanks for any answers/suggestions.


I just posted on this elsewhere.  Look for a thread titled: Which 
library for audio playback ?


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


InvalidResponseError: headers must be str

2011-12-30 Thread Niklas Rosencrantz
I'm upgrading from python 2.5 to python 2.7 and then I'm starting to get this 
error:

InvalidResponseError: headers must be str

I think it is because somewhere my HTTP headers are cast to unicode instead of 
string but I can't find where in the code? The example code I'm trying to 
upgrade to python 2.7 is 
https://github.com/supernifty/gae-paypal-online-market-example

class Pay( object ):
  def __init__( self, amount, return_url, cancel_url, remote_address, 
secondary_receiver=None, ipn_url=None, shipping=False ):
headers = {
  'X-PAYPAL-SECURITY-USERID': str(settings.PAYPAL_USERID), 
  'X-PAYPAL-SECURITY-PASSWORD': str(settings.PAYPAL_PASSWORD), 
  'X-PAYPAL-SECURITY-SIGNATURE': str(settings.PAYPAL_SIGNATURE), 
  'X-PAYPAL-REQUEST-DATA-FORMAT': str('JSON'),
  'X-PAYPAL-RESPONSE-DATA-FORMAT': str('JSON'),
  'X-PAYPAL-APPLICATION-ID': str(settings.PAYPAL_APPLICATION_ID),
  'X-PAYPAL-DEVICE-IPADDRESS': str(remote_address),
}

data = {
  'currencyCode': 'USD',
  'returnUrl': return_url,
  'cancelUrl': cancel_url,
  'requestEnvelope': { 'errorLanguage': 'en_US' },
} 

if shipping:
  data['actionType'] = 'CREATE'
else:
  data['actionType'] = 'PAY'

if secondary_receiver == None: # simple payment
  data['receiverList'] = { 'receiver': [ { 'email': settings.PAYPAL_EMAIL, 
'amount': '%f' % amount } ] }
else: # chained
  commission = amount * settings.PAYPAL_COMMISSION
  data['receiverList'] = { 'receiver': [ 
  { 'email': settings.PAYPAL_EMAIL, 'amount': '%0.2f' % amount, 
'primary': 'true' },
  { 'email': secondary_receiver, 'amount': '%0.2f' % ( amount - 
commission ), 'primary': 'false' },
] 
  }

if ipn_url != None:
  data['ipnNotificationUrl'] = str(ipn_url)

self.raw_request = json.dumps(data)
#request = urllib2.Request( %s%s % ( settings.PAYPAL_ENDPOINT, Pay ), 
data=self.raw_request, headers=headers )
#self.raw_response = urllib2.urlopen( request ).read() 
self.raw_response = url_request( %s%s % ( str(settings.PAYPAL_ENDPOINT), 
str(Pay) ), data=self.raw_request, headers=headers ).content() 
logging.info( response was: %s % self.raw_response )
self.response = json.loads( str(self.raw_response) )
-- 
http://mail.python.org/mailman/listinfo/python-list


dict_to_xml

2011-12-30 Thread Emeka
Hello All,


I have a dictionary object I would like to convert to xml.

Could some assist with the link to libs to use?  Or good examples.

Regards,
Janus

-- 
*Satajanus  Nig. Ltd


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


Re: InvalidResponseError: headers must be str

2011-12-30 Thread Steven D'Aprano
On Fri, 30 Dec 2011 20:58:10 -0800, Niklas Rosencrantz wrote:

 I'm upgrading from python 2.5 to python 2.7 and then I'm starting to get
 this error:
 
 InvalidResponseError: headers must be str

Please show the ENTIRE traceback, not just the error message. The 
traceback is very informative: it shows the actual line of code that 
causes the problem, plus the entire sequence of calls that lead to it. 
The error message on its own is almost useless.

Please COPY AND PASTE the traceback, do not re-type it from memory, 
summarize it, simplify it, or otherwise change it in any way.


 I think it is because somewhere my HTTP headers are cast to unicode

Why do you think that?


 instead of string but I can't find where in the code? 

Have you tried searching for any of these?

- direct calls to unicode()
- unicode literals u...
- calls to the decode method some_string.decode( ... )



 The example code
 I'm trying to upgrade to python 2.7 is
 https://github.com/supernifty/gae-paypal-online-market-example
 
 class Pay( object ):
   def __init__( self, amount, return_url, cancel_url, remote_address,
   secondary_receiver=None, ipn_url=None, shipping=False ):
 headers = {
   'X-PAYPAL-SECURITY-USERID': str(settings.PAYPAL_USERID),
   'X-PAYPAL-SECURITY-PASSWORD': str(settings.PAYPAL_PASSWORD),
   'X-PAYPAL-SECURITY-SIGNATURE': str(settings.PAYPAL_SIGNATURE),
   'X-PAYPAL-REQUEST-DATA-FORMAT': str('JSON'),
   'X-PAYPAL-RESPONSE-DATA-FORMAT': str('JSON'),
   'X-PAYPAL-APPLICATION-ID': str(settings.PAYPAL_APPLICATION_ID),
   'X-PAYPAL-DEVICE-IPADDRESS': str(remote_address),
 }


'JSON' is already a string. Calling str() on it is a waste of time.

What values do the various settings.* have? If they are already strings, 
calling str() again is a waste of time. I see you do this all through 
your class, needlessly calling str() on strings.



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


[issue13680] Aifc comptype write fix

2011-12-30 Thread Oleg Plakhotnyuk

New submission from Oleg Plakhotnyuk oleg...@gmail.com:

Two changes have been made to the library:
1. Lowercase compression type support have been added to the sample width 
validation routine during write operation. Everywhere else compression types 
are used in both lowercase and uppercase.
2. Redundant invalid compression type check has been removed. It cannot be 
executed using public module interface, therefore I think it is not necessary.

--
components: Library (Lib), Tests
files: aifc_comptypes.patch
keywords: patch
messages: 150365
nosy: Oleg.Plakhotnyuk, ezio.melotti, r.david.murray
priority: normal
severity: normal
status: open
title: Aifc comptype write fix
type: behavior
versions: Python 3.2, Python 3.3
Added file: http://bugs.python.org/file24110/aifc_comptypes.patch

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



[issue13394] Patch to increase aifc lib test coverage

2011-12-30 Thread Oleg Plakhotnyuk

Oleg Plakhotnyuk oleg...@gmail.com added the comment:

Fourth patch goes to issue 13680

--

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



[issue13676] sqlite3: Zero byte truncates string contents

2011-12-30 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

What? Don't you SEE that it works correctly? :)

Attached an updated patch with a test case.

FTR, I also tried to make it possible to have the SQL statement include a zero 
byte, but it seems that sqlite3_prepare() (and also the newer 
sqlite3_prepare_v2()) always stops reading at the zero byte. See:

http://www.sqlite.org/c3ref/prepare.html

--
Added file: http://bugs.python.org/file24111/sqlite3_zero_byte_v2.patch

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



[issue13674] crash in datetime.strftime

2011-12-30 Thread Tim Golden

Tim Golden m...@timgolden.me.uk added the comment:

Well, the code in 2.x is quite different from that in 3.x.
Specifically, the 2.x code assumes that, for Windows, no
year before 1900 is valid for any of the formats. So a
simple check throws a ValueError for tm_year  0. For 3.x
the assumption was that Windows can handle any year as far
back as 0; in fact that's not true for the %y format.

I'll propose a patch to timemodule.c but I'll have to take
it to python-dev as I'm not 100% sure of the best place for
it.

--

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



[issue13674] crash in datetime.strftime

2011-12-30 Thread patrick vrijlandt

patrick vrijlandt patrick.vrijla...@gmail.com added the comment:

Somewhere in the code is also/still a seperate check concerning strftime:

PythonWin 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on 
win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for 
further copyright information.
 import datetime
 datetime.datetime(-1, 1, 1)
Traceback (most recent call last):
  File interactive input, line 1, in module
ValueError: year is out of range
 datetime.datetime(0, 1, 1)
Traceback (most recent call last):
  File interactive input, line 1, in module
ValueError: year is out of range
 datetime.datetime(1, 1, 1)
datetime.datetime(1, 1, 1, 0, 0)
 datetime.datetime(1, 1, 1).strftime(Y)
Traceback (most recent call last):
  File interactive input, line 1, in module
ValueError: year=1 is before 1000; the datetime strftime() methods require year 
= 1000


--

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



[issue13679] Multiprocessing system crash

2011-12-30 Thread Antoine Pitrou

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

Well, have you read http://docs.python.org/library/multiprocessing.html#windows 
?
(especially Safe importing of main module)

--
nosy: +pitrou

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



[issue9260] A finer grained import lock

2011-12-30 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

 That's true. Do you think temptatively acquiring the lock (without
 blocking) would solve the issue?

I think it should work. Something along those lines:

while True:
if lock.acquire(0):
lock.tstate = tstate
return True
else:
if detect_circularity():
return False
global_lock.release()
saved = save_tstate()
yield()
restore_tstate(saved)
global_lock.acquire()

However, I find this whole mechanism somewhat complicated, so the
question really is: what are we trying to solve?
If we just wan't to avoid deadlocks, a trylock with the global import
lock will do the trick.
If, on the other hand, we really want to reduce the number of cases
where a deadlock would occur by increasing the locking granularity,
then it's the way to go. But I'm not sure it's worth the extra
complexity (increasing the locking granularity is usually a proven
recipe to introduce deadlocks).

 Isn't this limit only about named semaphores? Or does it apply to
 anonymous semaphores as well?

I'm no FreeBSD expert, but AFAICT, POSIX SEM_NSEMS_MAX limit doesn't
seem to make a distinction between named and anonymous semaphores.
From POSIX sem_init() man page:

[ENOSPC]
A resource required to initialise the semaphore has been exhausted, or
the limit on semaphores (SEM_NSEMS_MAX) has been reached.


Also, a quick search returned those links:
http://ftp.es.freebsd.org/pub/FreeBSD/development/FreeBSD-CVS/src/sys/sys/ksem.h,v
http://translate.google.fr/translate?hl=frsl=rutl=enu=http%3A%2F%2Fforum.nginx.org%2Fread.php%3F21%2C202865%2C202865
So it seems that sem_init() can fail when the max number of semaphores
is reached.

--

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



[issue13674] crash in datetime.strftime

2011-12-30 Thread Tim Golden

Tim Golden m...@timgolden.me.uk added the comment:

Yes, sorry. I wasn't clear enough. There *are* still checks
in the 3.x code (for the kind of thing you're showing). But
the checks assume 1000 = year = maxint is ok for all format
parameters on Windows. In fact, for %y, only 1900 = year is ok.

--

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



[issue13681] Aifc read compressed frames fix

2011-12-30 Thread Oleg Plakhotnyuk

New submission from Oleg Plakhotnyuk oleg...@gmail.com:

This patch resolves two issues:

1. ADPCM compressed audio files reading. Such files have frame size of 4 bits. 
Aifc lib cannot represent 4 bits frame size because it uses integer bytes count 
variable. I have replaced it with bits count.

2. ALAW/ULAW/ADPCM audio data decompression. According to documentation 
(http://docs.python.org/library/audioop.html), adpcm2lin, alaw2lin and ulaw2lin 
are using 'width' argument to represent output frames width. However, in 
audioop.c module there are checks that are raising exceptions if input frames 
length is not multiple of 'width'. I have replaced checking of 'len' to match 
'size' with checking of 'len*size' to match 'size' in order to retain only 
basic length validity checks.

--
components: Library (Lib), Tests
files: aifc_compression.patch
keywords: patch
messages: 150373
nosy: Oleg.Plakhotnyuk, ezio.melotti, r.david.murray
priority: normal
severity: normal
status: open
title: Aifc read compressed frames fix
type: behavior
versions: Python 3.2, Python 3.3
Added file: http://bugs.python.org/file24112/aifc_compression.patch

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



[issue13681] Aifc read compressed frames fix

2011-12-30 Thread Oleg Plakhotnyuk

Oleg Plakhotnyuk oleg...@gmail.com added the comment:

I have put changes to both aifc and audioop module in this single patch. The 
reason is that aifc test reading compressed frames will work properly only 
after audioop fix has been applied.

--

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



[issue13394] Patch to increase aifc lib test coverage

2011-12-30 Thread Oleg Plakhotnyuk

Oleg Plakhotnyuk oleg...@gmail.com added the comment:

The last, fifth, patch goes to issue 13681

--

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



[issue13682] Documentation of os.fdopen() refers to non-existing bufsize argument of builtin open()

2011-12-30 Thread Petri Lehtinen

New submission from Petri Lehtinen pe...@digip.org:

From the docs of os.fdopen():

Return an open file object connected to the file descriptor fd. The
mode and bufsize arguments have the same meaning as the corresponding
arguments to the built-in open() function.

However, there's no bufsize argument for builtin open() anymore in py3k.

--
assignee: docs@python
components: Documentation
messages: 150376
nosy: docs@python, petri.lehtinen
priority: normal
severity: normal
status: open
title: Documentation of os.fdopen() refers to non-existing bufsize argument of 
builtin open()
versions: Python 3.2, Python 3.3

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



[issue9260] A finer grained import lock

2011-12-30 Thread Antoine Pitrou

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

 If, on the other hand, we really want to reduce the number of cases
 where a deadlock would occur by increasing the locking granularity,
 then it's the way to go.

Yes, that's the point. Today you have to be careful when mixing imports
and threads. The problems is that imports can be implicit, inside a
library call for example (and putting imports inside functions is a way
of avoiding circular imports, or can also allow to reduce startup time).
Some C functions try to circumvent the problem by calling
PyImport_ModuleNoBlock, which is ugly and fragile in its own way (it
will fail if the import lock is taken, even if there wouldn't be a
deadlock: a very primitive kind of deadlock avoidance indeed).

 Also, a quick search returned those links:
 http://ftp.es.freebsd.org/pub/FreeBSD/development/FreeBSD-CVS/src/sys/sys/ksem.h,v
 http://translate.google.fr/translate?hl=frsl=rutl=enu=http%3A%2F%2Fforum.nginx.org%2Fread.php%3F21%2C202865%2C202865
 So it seems that sem_init() can fail when the max number of semaphores
 is reached.

As they say, Kritirii choice of the number 30 in the XXI century is
unclear. :-)

File objects also have a per-object lock, so I guess opening 30 files
under FreeBSD would fail. Perhaps we need to fallback on the other lock
implementation on certain platforms?

(our FreeBSD 8.2 buildbot looks pretty much stable, was the number of
semaphores tweaked on it?)

--

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



[issue13642] urllib incorrectly quotes username and password in https basic auth

2011-12-30 Thread Michele Orrù

Michele Orrù maker...@gmail.com added the comment:

 Joonas, this issue seems easy to solve. Do you want to try to post a 
 patch?. Extra credits for patching testsuite too :).
As far as I see, it would be sufficient to add unquote(passed) to 
_open_generic_http. Regarding unittests instead, there is already a method 
called test_userpass_inurl which could be extended with some tests on a 
password containing spaces ( Lib/test/test_urllib.py:263). But what I haven't 
yet understood is: does it really exists a user:pass in python.org?

--
nosy: +maker

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



[issue11812] transient socket failure to connect to 'localhost'

2011-12-30 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

Seems to be fixed now.

--
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

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



[issue13663] pootle.python.org is outdated.

2011-12-30 Thread Martin v . Löwis

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

I'd rather have you maintain poodle.python.org instead of maintaining Python 
translations off-site.

--

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



[issue8623] Aliasing warnings in socketmodule.c

2011-12-30 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

 This change probably should be backported to 3.2 branch.

I'm not sure about this, I don't feel comfortable backporting a such
path which doesn't solve a real world problem.

--

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



[issue13683] Docs in Python 3:raise statement mistake

2011-12-30 Thread maniram maniram

New submission from maniram maniram maniandra...@gmail.com:

In the Python 3 docs for the raise statement, 
http://docs.python.org/py3k/reference/simple_stmts.html#the-raise-statement,the 
docs say If no exception is active in the current scope, a TypeError exception 
is raised indicating that this is an error (if running under IDLE, a 
queue.Empty exception is raised instead).

This is wrong in Python 3 because raise raises a RuntimeError and IDLE does the 
same (does not raise a queue.Empty Exception).

The text should be If no exception is active in the current scope, a 
RuntimeError exception is raised indicating that this is an error.

--
assignee: docs@python
components: Documentation
messages: 150382
nosy: docs@python, maniram.maniram
priority: normal
severity: normal
status: open
title: Docs in Python 3:raise statement mistake
versions: Python 3.2

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



[issue13684] httplib tunnel infinite loop

2011-12-30 Thread luzakiru

New submission from luzakiru visco...@inbox.com:

readline() can return ''. This is handled in most places in httplib but not 
when a tunnel is used. It leads to a infinite loop that permanently blocks the 
program while wasting CPU cycles.

For the patch I simply copied the fix that is used elsewhere in the file where 
readline() is used. It can be fixed in the same way in 2.6.

--
components: Library (Lib)
files: httplib.patch
keywords: patch
messages: 150383
nosy: luzakiru
priority: normal
severity: normal
status: open
title: httplib tunnel infinite loop
type: crash
versions: Python 2.6, Python 2.7
Added file: http://bugs.python.org/file24113/httplib.patch

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



[issue13679] Multiprocessing system crash

2011-12-30 Thread Rock Achu

Rock Achu rockac...@gmail.com added the comment:

Erm.. No. I was unaware I had to do so.
Next time I'll be more careful.

Anyways, the docs say that python should throw a RuntimeError, but it didn't?
And would it be doable to add a warning at the top of the multiprocessing 
tutorial/page that section?

--

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



[issue9260] A finer grained import lock

2011-12-30 Thread Antoine Pitrou

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

I believe this new patch should be much more robust than the previous one.
It also adds a test for the improvement (it freezes an unpatched interpreter).

--
Added file: http://bugs.python.org/file24114/implock5.patch

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



[issue13679] Multiprocessing system crash

2011-12-30 Thread Antoine Pitrou

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

 Anyways, the docs say that python should throw a RuntimeError, but it
 didn't?

I think running it directly would raise a RuntimeError, but importing it 
wouldn't.

 And would it be doable to add a warning at the top of the
 multiprocessing tutorial/page that section?

In the introduction you have the following note, together with a link to the 
relevant section:

“Functionality within this package requires that the __main__ module be 
importable by the children. This is covered in Programming guidelines however 
it is worth pointing out here.”

--

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



[issue13679] Multiprocessing system crash

2011-12-30 Thread Antoine Pitrou

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

Ok, closing this issue.

--
resolution:  - invalid
status: open - closed

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



[issue12641] Remove -mno-cygwin from distutils

2011-12-30 Thread Reuben Garrett

Changes by Reuben Garrett reubengarr...@gmail.com:


--
nosy: +RubyTuesdayDONO

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



[issue13609] Add os.get_terminal_size() function

2011-12-30 Thread Antoine Pitrou

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

(review posted on http://bugs.python.org/review/13609/show )

--

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



[issue13684] httplib tunnel infinite loop

2011-12-30 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +orsenthil
stage:  - patch review
versions: +Python 3.2, Python 3.3 -Python 2.6

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



[issue13676] sqlite3: Zero byte truncates string contents

2011-12-30 Thread Antoine Pitrou

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

It would be nice to also have tests for the bytes and bytearray cases.
It also seems the generic case hasn't been fixed 
(PyObject_CallFunction(self-connection-text_factory, y, val_str)).

--

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



[issue13645] import machinery vulnerable to timestamp collisions

2011-12-30 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

Why change importlib's API and instead add to it? You could add the requisite 
path_size() method to get the value, and assume 0 means unsupported (at least 
until some future version where a deprecation warning about not requiring file 
size comes about). But I don't see how you can get around not exposing these 
details as stored in some API, whether it is by method or object attribute 
since you can't assume stat results since support for non-file storage 
back-ends would be unduly burdened.

--

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



[issue13641] decoding functions in the base64 module could accept unicode strings

2011-12-30 Thread Éric Araujo

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


--
nosy: +eric.araujo

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



[issue13508] ctypes' find_library breaks with ARM ABIs

2011-12-30 Thread Éric Araujo

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


--
nosy: +belopolsky

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



[issue13508] ctypes' find_library breaks with ARM ABIs

2011-12-30 Thread Éric Araujo

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


--
nosy: +eric.araujo

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



[issue12760] Add create mode to open()

2011-12-30 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

 This is not a duplicate issue. The openat solution is no easier than the 
 os.open
 solution.

Amaury did not suggest to use openat, but the new opener argument to open, 
which was especially added for use cases such as the one discussed here:

...
open_exclusive = lambda path, mode: os.open(path, 
mode|os.O_CREAT|os.O_EXCL))
...
fp = open(filename, 'w', opener=open_exclusive)
...

That’s why this bug was initially closed as duplicate.

--

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



[issue13659] Add a help() viewer for IDLE's Shell.

2011-12-30 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

I should like it if a separate window were either automatic or a configuration 
option for help on modules and classes, which should cover 'long' output.  The 
Windows workaround, which I will never remember, brings up an extraneous 
cmd.exe window in addition to notepad.

--
nosy: +terry.reedy
versions: +Python 3.3

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



[issue13656] Document ctypes.util and ctypes.wintypes.

2011-12-30 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

May I ask why you closed this?  From a quick glance, a few functions from 
ctypes.util are considered public and documented (albeit not with module 
directives, so I’m not sure the indexing works helpfully for people searching); 
I don’t know the status of wintypes.

--
nosy: +eric.araujo

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



[issue13664] UnicodeEncodeError in gzip when filename contains non-ascii

2011-12-30 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

The actual fix in the previous issue, as in Python 3, was to always write the 
filename, but with errors replaced with '?/.

--
nosy: +lars.gustaebel, terry.reedy

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



[issue13665] TypeError: string or integer address expected instead of str instance

2011-12-30 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
nosy: +amaury.forgeotdarc, meador.inge

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



[issue13655] Python SSL stack doesn't have a default CA Store

2011-12-30 Thread Éric Araujo

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


--
nosy: +eric.araujo, loewis
versions:  -Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.4

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



[issue13655] Python SSL stack doesn't have a default CA Store

2011-12-30 Thread Éric Araujo

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


--
nosy: +pitrou

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



[issue13666] datetime documentation typos

2011-12-30 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

2.6 only gets security updates.

I verified 'rzinfo' typo in x.1.6 in 2.7 and 3.2. Also in both, 
tzinfo.utcoffset begins as Stephen claims. I have not verified that this is 
error.

 Also in both, in x.1.4, class GMT1 has
... def utcoffset(self, dt):
... return timedelta(hours=1) + self.dst(dt)
... def dst(self, dt):
... if self.dston =  dt.replace(tzinfo=None)  self.dstoff:
... return timedelta(hours=1)
... else:
... return timedelta(0)

while GMT2 has
... def utcoffset(self, dt):
... return timedelta(hours=1) + self.dst(dt)
... def dst(self, dt):
... if self.dston =  dt.replace(tzinfo=None)  self.dstoff:
... return timedelta(hours=2)
... else:
... return timedelta(0)

Stephen is saying that 'hours=1' should here be 'hours=2'. Should '0' by 
'hours=1' to be just 1 off from 2?

--
nosy: +belopolsky, terry.reedy
stage:  - needs patch
versions: +Python 2.7, Python 3.2, Python 3.3 -Python 2.6

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



[issue8035] urllib.request.urlretrieve hangs waiting for connection close after a redirect

2011-12-30 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

 It could be possible to set up an ad-hoc httpserver for that purpose,
 but that sounds a bit overkill.

Oh, I assumed urllib already had a server for tests.  We have one in 
distutils2/packaging, otherwise we’d have to resort to manual testing against 
the real PyPI, and I’d feel much less confident about regressions.

--
versions:  -Python 3.1

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



[issue13443] wrong links and examples in the functional HOWTO

2011-12-30 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Hi Senthil.  I think you applied a patch that did not have consensus.

--

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



[issue13294] http.server: minor code style changes.

2011-12-30 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Just a note: “Incorporated Michele Orrù's code style changes into the trunk and 
other codelines.”

The policy is to apply only bug fixes and doc fixes and improvements to stable 
branches, not code cleanups (they’re usually compatible but are just not worth 
doing—at one point code is released and should stop being improved).  This is 
not worth reverting now, unless the commit was buggy (I didn’t read all 
messages), I just wanted to restate the policy to avoid such future code 
cleanups in bugfix branches.  Cheers

--

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



[issue13443] wrong links and examples in the functional HOWTO

2011-12-30 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Hm, it was actually Antoine who removed it.

--

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



[issue13614] setup.py register fails if long_description contains ReST

2011-12-30 Thread Éric Araujo

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


--
assignee: tarek - eric.araujo
components: +Distutils2
keywords: +easy
nosy: +alexis
stage:  - test needed
title: `setup.py register` fails if long_description contains RST - setup.py 
register fails if long_description contains ReST
type:  - behavior
versions: +3rd party, Python 3.2, Python 3.3

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



[issue13677] correct docstring for builtin compile

2011-12-30 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

Flags comment applies to 3.2.2 docs and 2.7.2 docs. There is only one 
additional flag: ast.PyCF_ONLY_AST, so 'flags' should be singular.

As for src and dst, doc has been updated to say 'Compile the source into a code 
or AST object. ... source can either be a string or an AST object.

'source' should be capitalized.

--
nosy: +terry.reedy
versions: +Python 2.7, Python 3.2, Python 3.3

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



[issue13683] Docs in Python 3:raise statement mistake

2011-12-30 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

Verified for 3.2.2 cmd window and idle. Fix looks good.

--
keywords: +patch
nosy: +terry.reedy
stage:  - needs patch
type:  - behavior
versions: +Python 3.3

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



[issue12760] Add create mode to open()

2011-12-30 Thread Devin Jeanpierre

Devin Jeanpierre jeanpierr...@gmail.com added the comment:

 Amaury did not suggest to use openat, but the new opener argument to open, 
 which was especially added for use cases such as the one discussed here:

Sorry, yes. Wrong words, same thought. We can implement this using opener, but 
we could implement this with os.open before. What's changed, except that 
there's more ways to do it? (There is slightly more versatility with the opener 
method, but no more obviousness and no less typing).

My understanding from reading the other thread is that this is not the primary 
use-case of the new parameter for open(). In fact, this ticket was not really 
mentioned at all there.

--

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



[issue13684] httplib tunnel infinite loop

2011-12-30 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

In 3.2, http.client.py, insertion would be at line 718.
However, only one statement is needed to break. 3.2 elsewhere has
if line in (b'\r\n', b'\n', b''):
break
But I note that at 512, there is the code luzakiru patched in. I think that 
should perhaps be changed to above also, unless bare \n from reading a server 
is really impossible.

At 313, i found this misformed code:

 if not line:
# Presumably, the server closed the connection before
# sending a valid response.
 raise BadStatusLine(line)

[I am curious -- is it really intended to simply throw away the tunnel server 
response after the first header?]

--
nosy: +terry.reedy

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



[issue13685] argparse does not sanitize help strings for % signs

2011-12-30 Thread Jeff Yurkiw

New submission from Jeff Yurkiw j...@cyan.com:

I discovered this while programming the command line interface for a python 
program that can take a passed argument and throw it into the 'where like' 
clause of a SQL expression (intended for a postgresql database).

The wildcard character for where-like statements is generally the percent sign, 
which is how I found this (WHERE %s LIKE '%--value%').

If you use any single '%' signs in an ArgumentParser.new_argument(help=)'s help 
description Python 3.2 will throw an error.

Workaround: You can avoid this issue by doubling up on all % signs that you 
want to display in your help text.

parser.add_argument(('--foo', action='store',help='%bar') throws an error.
parser.add_argument(('--foo', action='store',help='%%bar') displays '--foo FOO  
 %bar'.

Suggested fix:
When assigning help strings from add_argument(), throw them through a sanitizer 
and replace all occurrences of '%' with '%%' behind the scenes.

Example code (argparseBug.py):

from argparse import ArgumentParser

parser = ArgumentParser()
parser.add_argument('--foo', action='store', help='%bar')

args = parser.parse_args('-h'.split())

You get the following stacktrace:
Traceback (most recent call last):
  File /path/to/script/argparseBug.py, line 6, in module
args = parser.parse_args('-h'.split())
  File /usr/lib/python3.2/argparse.py, line 1701, in parse_args
args, argv = self.parse_known_args(args, namespace)
  File /usr/lib/python3.2/argparse.py, line 1733, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
  File /usr/lib/python3.2/argparse.py, line 1939, in _parse_known_args
start_index = consume_optional(start_index)
  File /usr/lib/python3.2/argparse.py, line 1879, in consume_optional
take_action(action, args, option_string)
  File /usr/lib/python3.2/argparse.py, line 1807, in take_action
action(self, namespace, argument_values, option_string)
  File /usr/lib/python3.2/argparse.py, line 994, in __call__
parser.print_help()
  File /usr/lib/python3.2/argparse.py, line 2331, in print_help
self._print_message(self.format_help(), file)
  File /usr/lib/python3.2/argparse.py, line 2305, in format_help
return formatter.format_help()
  File /usr/lib/python3.2/argparse.py, line 279, in format_help
help = self._root_section.format_help()
  File /usr/lib/python3.2/argparse.py, line 209, in format_help
func(*args)
  File /usr/lib/python3.2/argparse.py, line 209, in format_help
func(*args)
  File /usr/lib/python3.2/argparse.py, line 515, in _format_action
help_text = self._expand_help(action)
  File /usr/lib/python3.2/argparse.py, line 601, in _expand_help
return self._get_help_string(action) % params
ValueError: unsupported format character 'b' (0x62) at index 1

--
components: None
files: argparseBug.py
messages: 150404
nosy: Jeff.Yurkiw
priority: normal
severity: normal
status: open
title: argparse does not sanitize help strings for % signs
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file24115/argparseBug.py

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



[issue13685] argparse does not sanitize help strings for % signs

2011-12-30 Thread Eric V. Smith

Eric V. Smith e...@trueblade.com added the comment:

This is because the help text support substitution, as mentioned here: 
http://docs.python.org/dev/library/argparse.html#help

It's possible this documentation could be improved.

--
assignee:  - docs@python
components: +Documentation -None
nosy: +docs@python, eric.smith

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



[issue12760] Add create mode to open()

2011-12-30 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

 [...] There is slightly more versatility with the opener method, but no more 
 obviousness
 and no less typing.

I agree with your opinion.  I re-read this report:
- Antoine thinks this fills an important use case, namely avoiding race 
conditions
- Amaury then suggested the opener argument idea, which was implemented in the 
openat bug
- Antoine judged it would be better than what we had before

I don’t have a strong opinion on “opener is generic and good enough” vs. “not 
as ice as it could be”.  Antoine seems to agree with you, so your patch will 
get reviewed and eventually accepted.  Cheers

--

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



[issue13677] correct docstring for builtin compile

2011-12-30 Thread Jim Jewett

Jim Jewett jimjjew...@gmail.com added the comment:

I'm not sure we're looking at the same thing.  I was talking about the 
docstring that shows up at the interactive prompt in response to 
 help(compile)

Going to hg.python.org/cpython and selecting branches, then default, then 
browse, got me to
http://hg.python.org/cpython/file/7010fa9bd190/Python/bltinmodule.c
which still doesn't mention AST.  I also don't see any reference to src or 
dst, or any source that looks like it should be capitalized.

I agree that there is (to my knowledge, at this time) only one additional flag. 
 I figured ast or future was needed to get the compilation constants, so it 
made sense to delegate -- but you seem to be reading something newer than I am.

--

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



[issue13590] Prebuilt python-2.7.2 binaries for macosx can not compile c extensions

2011-12-30 Thread Éric Araujo

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


--
nosy: +eric.araujo

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



[issue13640] add mimetype for application/vnd.apple.mpegurl

2011-12-30 Thread Éric Araujo

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


--
nosy: +eric.araujo
stage:  - patch review
type: behavior - enhancement
versions:  -Python 2.7, Python 3.1, Python 3.2, Python 3.4

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



[issue13677] correct docstring for builtin compile

2011-12-30 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

I am aware that the docstring, shown at help(compile), is what you were talking 
about. The docstring and manuals should say the same thing, or at least not 
contradict each other, so it is common for both to be out of date and both to 
be updated at the same time. So I went and looked at the current py2 and py3 
docs to see if they also need change. And they do, though not quite as much. 
src and dst were unofficial abbreviations for source and output, in reference 
to what you said. Sorry for the confusion.

--

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



[issue13686] Some notes on the docs of multiprocessing

2011-12-30 Thread Eli Bendersky

New submission from Eli Bendersky eli...@gmail.com:

I've decided to study the multiprocessing module a bit, and carefully went over 
the docs (for 2.7). Some small fixes I will commit myself, but a few issues 
came up on which I'd like some opinion from others. In rough order of 
appearance in the doc:

1. In the documentation of the 'name' argument of the multiprocessing.Process 
constructor, it mentions that the length of the generated name depends on the 
generation, without elaborating. It could be better to briefly describe the 
algorithm in a sentence or two.
2. Section 16.6.2.1. is called Process and exceptions. It only documents one 
exception from multiprocessing: BufferTooShort. Other exception classes 
exported by the module aren't documented similarly: ProcessError, TiemoutError, 
AuthenticationError.
3. AuthenticationError is documented as 
multiprocessing.connection.AuthenticationError, although in reality it exists 
in the root multiprocessing module, and multiprocessing.connection just imports 
it
4. The doc of JoinableQueue.task_done() says Used by queue consumer threads. 
Shouldn't that be consumer processes?
5. The doc of active_children() should probably mention that it returns a list 
of Process objects (similarly to what current_process() says)
6. multiprocessing.freeze_support() says If the freeze_support() line is 
omitted then trying to run the frozen executable will raise RuntimeError.. 
*Who* will raise the error?
7. class multiprocessing.Event says This method returns... - what method? 
Seems like an irrelevant documentation piece was intermixed here
8. 16.6.2.7. Managers starts by saying that Managers provide a way to create 
data which can be shared between different processes. Since it comes right 
after the section about Shared objects, I think it would be nice to mention in 
a sentence or two what Managers give above normal synchonized objects in 
multiprocessing (i.e. sharing between different machines)
9. In the programming guidelines about Avoid shared state it says It is 
probably best to stick to using queues or pipes for communication between 
processes rather than using the lower level synchronization primitives from the 
threading module.. Surely not the threading module is meant here?

--
assignee: docs@python
components: Documentation
messages: 150409
nosy: docs@python, eli.bendersky, pitrou
priority: normal
severity: normal
status: open
title: Some notes on the docs of multiprocessing
type: behavior
versions: Python 2.7

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



[issue13687] parse incorrect command line on windows 7

2011-12-30 Thread baleno

New submission from baleno cui_...@126.com:

i just tested python2.7.2 and python 3.2.2 on windows 7,this bugs at all 
version.

my test code:
import sys
print(sys.argv)

command line:
test.py %cc%cd%bd

command result:
['E:\\Codes\\test.py', '%ccE:\\Codesbd']

--
components: None
files: error.png
messages: 150410
nosy: balenocui
priority: normal
severity: normal
status: open
title: parse incorrect command line on windows 7
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file24116/error.png

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



  1   2   >