Twisted 11.1.0 Released

2011-11-18 Thread Thomas Hervé

On behalf of Twisted Matrix Laboratories, I am pleased to announce the
release of Twisted 11.1.

Highlights of the 185 tickets closed include:

 * The poll reactor as default where applicable, instead of select
   everywhere.

 * A new SSL implementation only relying on OpenSSL for cryptography,
   (not I/O) making it more robust.

 * Several improvements to the fresh HTTP/1.1 client implementation,
   including proxy and cookie support.

 * My personal favorite: a new howto has been published on test-driven
   development with Twisted.

 * A special mention to the new abortConnection support on TCP and SSL
   connections, heroically pushed by Itamar and Jean-Paul, and the
   oldest ticket closed by this release.

This is the last release supporting Python 2.4 (the support on Windows stopped 
with 11.0).

For more information, see the NEWS file here:

 http://twistedmatrix.com/Releases/Twisted/11.1/NEWS.txt

Download it now from:

 http://pypi.python.org/packages/source/T/Twisted/Twisted-11.1.0.tar.bz2 or
 http://pypi.python.org/packages/2.5/T/Twisted/Twisted-11.1.0.win32-py2.5.msi or
 http://pypi.python.org/packages/2.6/T/Twisted/Twisted-11.1.0.win32-py2.6.msi or
 http://pypi.python.org/packages/2.7/T/Twisted/Twisted-11.1.0.win32-py2.7.msi

Thanks to the supporters of the Twisted Software Foundation and to the many 
contributors for this release.

--
Thomas

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

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


[ANN] Data Plotting Library Dislin 10.2

2011-11-18 Thread Helmut Michels

Dear Python programmers,

I am pleased to announce version 10.2 of the data plotting software
Dislin.

Dislin is a high-level and easy to use plotting library for
displaying data as curves, bar graphs, pie charts, 3D-colour plots,
surfaces, contours and maps. Several output formats are supported
such as X11, VGA, OpenGL, PostScript, PDF, CGM, WMF, HPGL, TIFF, GIF, 
PNG, BMP and SVG.


The software is available for the most C, Fortran 77 and Fortran 90/95
compilers. Plotting extensions for the interpreting languages Perl,
Python and Java are also supported.

Dislin is available from the site

 http://www.dislin.de

and via FTP from the server

 ftp://ftp.gwdg.de/pub/grafik/dislin

All Dislin distributions are free for non-commercial use. Licenses
for commercial use are available from http://www.dislin.de.

 ---
  Helmut Michels
  Max Planck Institute for
  Solar System Research  Phone: +49 5556 979-334
  Max-Planck-Str. 2  Fax  : +49 5556 979-240
  D-37191 Katlenburg-Lindau  Mail : mich...@mps.mpg.de
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


useless python - term rewriter

2011-11-18 Thread Sean McIlroy

## term rewriter (python 3.1.1)

def gettokens(string):
spaced = string.replace('(',' ( ').replace(')',' ) ')
return spaced.split()

def getterm(tokens):
if tokens[0] in '()':
term = []
assert tokens[0] == '('
tokens.pop(0)
while not tokens[0] == ')': term.append(getterm(tokens))
tokens.pop(0)
return term
return tokens.pop(0)

def parse(strg):
tokens = gettokens(strg)
term = getterm(tokens)
assert not tokens
return term

def unparse(term):
if type(term) == str: return term
subterms = [unparse(subterm) for subterm in term]
return '({})'.format(' '.join(subterms))

def atom(term):
return type(term) == str

def compound(term):
return type(term) == list

def variable(term):
return atom(term) and term[0].isupper()

def constant(term):
return atom(term) and not term[0].isupper()

def conformable(term1,term2):
return compound(term1) and compound(term2) and len(term1) ==
len(term2)

def getrule(string):
left, right = string.split('=')
return [parse(left), parse(right)]

def getrules(string):
nonblank = lambda substring: substring and not substring.isspace()
return [getrule(substring) for substring in string.splitlines() if
nonblank(substring)]

def substitute(bindings,term):
if constant(term): return term
if variable(term): return bindings.get(term,term)
return [substitute(bindings,subterm) for subterm in term]

def match(term,pattern):
from operator import concat
from functools import reduce
if variable(pattern): return [[pattern, term]]
if constant(pattern) and pattern == term: return []
if conformable(pattern,term):
matches = [match(subterm,subpattern) for subterm, subpattern
in zip(term,pattern)]
return reduce(concat,matches)
raise Exception

def rewrite(term,rule):
if type(rule) == dict:
function = rule[term[0]]
arguments = [int(subterm) for subterm in term[1:]]
return str(function(*arguments))
left, right = rule
bindings = dict(match(term,left))
return substitute(bindings,right)

def apply(rule,term):
try: return [rewrite(term,rule), True]
except:
if atom(term): return [term, False]
applications = [apply(rule,subterm) for subterm in term]
subterms = [subterm for subterm, change in applications]
changes  = [change  for subterm, change in applications]
return [subterms, any(changes)]

def normalize(term,rules):
while True:
changes = []
for rule in rules:
term, change = apply(rule,term)
changes.append(change)
if not any(changes): break
return term

def translate(rules):
string = input(' ')
if string and not string.isspace():
try:
term = parse(string)
normal = normalize(term,rules)
string = unparse(normal)
print(string)
except: print('parse error')

def interpret(equations):
import operator
rules = [vars(operator)] + getrules(equations)
while True:
try: translate(rules)
except KeyboardInterrupt:
print('end session')
break

example = 

(factorial 0) = 1
(factorial N) = (mul N (factorial (sub N 1)))

(fibonacci 0) = 0
(fibonacci 1) = 1
(fibonacci N) = (add (fibonacci (sub N 1)) (fibonacci (sub N 2)))



interpret(example)

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


Re: Passing DLL handle as an argument (in Windows)

2011-11-18 Thread Ulrich Eckhardt

Am 18.11.2011 08:51, schrieb Pekka Kytölä:

Is it possible to pass my own dll's (already loaded) handle as an
argument to load/attach to the very same instance of dll? Thing is
that I've done plugin (dll) to a host app and the SDK's function
pointers are assigned once the dll is loaded in the host process.


DLL handles are valid anywhere in a process, but...


I'd like to fire up python code with ShellExecuteEx from my plugin
dll and expose (wrap) these SDK funcs to that script. If I just load
the dll in python it will be different instance and the SDK function
pointers are all NULL. I tried passing the dll handle as lpParameter
but in vain.


...ShellExecuteEx will create a new process, where the DLL handle is not 
valid. A new process has a separate memory space, so the function 
pointers are different etc. This is so by design, it shouldn't matter to 
one process when a DLL it uses is loaded into another process, too.




Is this ShellExecute + dll handle passing even possible or do I need
to take a totally different route? What route that would be? Doesn't
have to be portable, just so it works in Windows environment.


If all you want is to run Python code inside your application, you can 
link in a Python interpreter and run it from there. This is called 
embedding Python (docs.python.org/extending/embedding.html), as opposed 
to writing Python modules, don't confuse those two Python C APIs.


Another way to get both into the same process is to convert your host 
application into a Python module, which you then import into Python. 
This would use the other Python C API 
(docs.python.org/extending/extending.html).



It depends a bit on what you want to achieve, so you might want to 
elaborate on that. This is often better than asking for a way to achieve 
a solution that is impossible.



Good luck!

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


Re: What exactly is pass? What should it be?

2011-11-18 Thread Thomas Rachel

Am 18.11.2011 05:34 schrieb Dennis Lee Bieber:
 def _pass(*args):
  pass

 def long_running_process(arg1, arg2, arg_etc, report = _pass):
  result1 = do_stuff()
  report(result1)

 So this is a call to a function that just returns a None, which is
 dropped by the interpreter...

I'm not sure about this. I think, the call will be executed, but the 
callee will return immediately. It is different from call being dropped.


Another optimized alternative could be to do

def long_running_process(arg1, arg2, arg_etc, report=None):
result1 = do_stuff()
if report: report(result1)

but I think that is too low benefit at the cost of too much readability.

Such a function call is

  2   0 LOAD_FAST0 (a)
  3 POP_JUMP_IF_FALSE   16
  6 LOAD_FAST0 (a)
  9 CALL_FUNCTION0
 12 POP_TOP
 13 JUMP_FORWARD 0 (to 16)

  316 ...

as opposed to just

  2   0 LOAD_FAST0 (a)
  3 CALL_FUNCTION0
  6 POP_TOP

with a call target of

  1   0 LOAD_CONST   0 (None)
  3 RETURN_VALUE

I don't think that a call is sooo expensive that it would make any 
noticeable difference.



Thomas

BTW: Sorry, Dennis, for the private mail - I am incapable to use 
Thunderbird correctly :-(

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


Why sock.bind is always report 10048 error when in a script with multiprocessing

2011-11-18 Thread Junfeng Hu
Hi All, I'm trying to leverage my core i5 to send more UDP packets with 
multiprocssing, but I found a interesting thing is that the socket.bind is 
always reporting 10048 error even the process didn't do anything about the 
socket.
Here is the script

import threading,socket,random,pp,os
import time
from multiprocessing import Process
import multiprocessing.reduction

localIP='10.80.2.24'
localPort=2924
remoteIP='10.80.5.143'
remotePort=2924
sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
#sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind((localIP,localPort))
sock.connect((remoteIP,remotePort))

addRequest=MEGACO/1 [+localIP+]:+str(localPort)+\r\nTRANSACTION = 100 
{\r\n \
\tCONTEXT = $ {\r\n \
\t\tADD = TDMs15c1f1/11{ \r\n \
 Media { LocalControl { Mode=SendReceive,tdmc/ec=on  }}  \
\t}\r\n}}\r\n

def sendAddRequest(sock,addRequst):
#for i in range(2500):
#sock.send(addRequest)
print hello



if __name__ == '__main__':
reader = Process(target=sendAddRequest,args=(sock,addRequest))
reader.start()


Here is the output

D:\Python testmythread2.py
Traceback (most recent call last):
  File string, line 1, in module
  File C:\Python27\lib\multiprocessing\forking.py, line 346, in main
prepare(preparation_data)
  File C:\Python27\lib\multiprocessing\forking.py, line 461, in prepare
'__parents_main__', file, path_name, etc
  File D:\Python test\mythread2.py, line 12, in module
sock.bind((localIP,localPort))
  File C:\Python27\lib\socket.py, line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 10048] Only one usage of each socket address (protocol/netw
ork address/port) is normally permitted
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Passing DLL handle as an argument (in Windows)

2011-11-18 Thread Pekka Kytölä
On Nov 18, 10:27 am, Ulrich Eckhardt ulrich.eckha...@dominolaser.com
wrote:
 Am 18.11.2011 08:51, schrieb Pekka Kytölä:

  Is it possible to pass my own dll's (already loaded) handle as an
  argument to load/attach to the very same instance of dll? Thing is
  that I've done plugin (dll) to a host app and the SDK's function
  pointers are assigned once the dll is loaded in the host process.

 DLL handles are valid anywhere in a process, but...

  I'd like to fire up python code with ShellExecuteEx from my plugin
  dll and expose (wrap) these SDK funcs to that script. If I just load
  the dll in python it will be different instance and the SDK function
  pointers are all NULL. I tried passing the dll handle as lpParameter
  but in vain.

 ...ShellExecuteEx will create a new process, where the DLL handle is not
 valid. A new process has a separate memory space, so the function
 pointers are different etc. This is so by design, it shouldn't matter to
 one process when a DLL it uses is loaded into another process, too.

  Is this ShellExecute + dll handle passing even possible or do I need
  to take a totally different route? What route that would be? Doesn't
  have to be portable, just so it works in Windows environment.

 If all you want is to run Python code inside your application, you can
 link in a Python interpreter and run it from there. This is called
 embedding Python (docs.python.org/extending/embedding.html), as opposed
 to writing Python modules, don't confuse those two Python C APIs.

 Another way to get both into the same process is to convert your host
 application into a Python module, which you then import into Python.
 This would use the other Python C API
 (docs.python.org/extending/extending.html).

 It depends a bit on what you want to achieve, so you might want to
 elaborate on that. This is often better than asking for a way to achieve
 a solution that is impossible.

 Good luck!

 Uli

Thanks for reply, I'll try to elaborate a bit :)

I should have included this bit from:

http://docs.python.org/library/ctypes.html#loading-shared-libraries

All these classes can be instantiated by calling them with at least
one argument, the pathname of the shared library. If you have an
existing handle to an already loaded shared library, it can be passed
as the handle named parameter, otherwise the underlying platforms
dlopen or LoadLibrary function is used to load the library into the
process, and to get a handle to it.

So, I've got this handle to my .dll and would want to get that passed
as an argument when firing up .py via ShellExecute and use one of the
dll load functions that take in handle. What I don't know if these
windows/python dll handles are interchangable at all. Think it would
be quite nice if they were. But if they aren't I need to forget about
it and just #include Python.h
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to insert my own module in front of site eggs?

2011-11-18 Thread Hans Mulder

On 18/11/11 03:58:46, alex23 wrote:

On Nov 18, 11:36 am, Roy Smithr...@panix.com  wrote:

What if the first import of a module is happening inside some code you
don't have access to?



No import will happen until you import something.


That would be the case if you use the '-S' command line option.

Otherwise, site.py is imported before you get a chance to alter
sys.path, and by default site.py imports other modules.

-- HansM

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


[ANN] Data Plotting Library Dislin 10.2

2011-11-18 Thread Helmut Michels

Dear Python programmers,

I am pleased to announce version 10.2 of the data plotting software
Dislin.

Dislin is a high-level and easy to use plotting library for
displaying data as curves, bar graphs, pie charts, 3D-colour plots,
surfaces, contours and maps. Several output formats are supported
such as X11, VGA, OpenGL, PostScript, PDF, CGM, WMF, HPGL, TIFF, GIF, 
PNG, BMP and SVG.


The software is available for the most C, Fortran 77 and Fortran 90/95
compilers. Plotting extensions for the interpreting languages Perl,
Python and Java are also supported.

Dislin is available from the site

 http://www.dislin.de

and via FTP from the server

 ftp://ftp.gwdg.de/pub/grafik/dislin

All Dislin distributions are free for non-commercial use. Licenses
for commercial use are available from http://www.dislin.de.

 ---
  Helmut Michels
  Max Planck Institute for
  Solar System Research  Phone: +49 5556 979-334
  Max-Planck-Str. 2  Fax  : +49 5556 979-240
  D-37191 Katlenburg-Lindau  Mail : mich...@mps.mpg.de
--
http://mail.python.org/mailman/listinfo/python-list


Re: Passing DLL handle as an argument (in Windows)

2011-11-18 Thread Pekka Kytölä
Hmm. Let me describe what is going a bit more carefully:

What I build is a dll file that has exported function that gets called
when the host application/dll loads my dll. In this function the
function pointers to the actual SDK functions are fetched. After this
my dll's registers some plugins that have callbacks. After that it's
all about reacting to an event/callback. What I'd like to do is that
after fetching those SDK function pointers I'd like to fire
up .py/.pyc that snoops for possible plugins written in python and
registers those plugins and callbacks and let them react to events.
Obviously this python code needs access to those SDK functions.
Essentially it would show for the host app as one .dll but registers
multiple plugins from different python files.

I don't mind if it's not ShellExecute route, but I'd prefer
approaching this so that I don't need to compile different dll's to
different versions of python but let the python code take care of that
stuff.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What exactly is pass? What should it be?

2011-11-18 Thread MRAB

On 18/11/2011 04:34, Dennis Lee Bieber wrote:

On Thu, 17 Nov 2011 18:18:11 -0800 (PST), John Ladasky
lada...@my-deja.com  declaimed the following in
gmane.comp.python.general:


I'm trying to write tidy, modular code which includes a long-running process.  
From time to time I MIGHT like to check in on the progress being made by that 
long-running process, in various ways.  Other times, I'll just want to let it 
run.  So I have a section of code which, generally, looks like this:

def _pass(*args):
 pass


This is the equivalent of

def _pass(*args):
return None


Wouldn't pass_ be a more Pythonic name?


(functions with no explicit return statement implicitly return None)


def long_running_process(arg1, arg2, arg_etc, report = _pass):
 result1 = do_stuff()
 report(result1)


So this is a call to a function that just returns a None, which is
dropped by the interpreter...



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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-18 Thread Neil Cerutti
On 2011-11-18, W. eWatson wolftra...@invalid.com wrote:
 On 11/17/2011 4:24 PM, Steven D'Aprano wrote:
 On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote:

 I have not found any successful way to get to IDLE. It's on on the
 right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails
 with a invalid Win32 app msg.

 If you associate .pyw files with pythonw.exe, and then open idle.pyw,
 does it work?

 Failing that, go to your laptop where the associations are right, and see
 what they are, then duplicate the settings on your Windows 7 machine.

 Sounds like a good idea except I've not used associations in so
 long under XP, I have no idea where to start. Control Panel. My
 Computer Tools?

Open Windows Explorer.
With the menu, to to Tools-Folder Options
Click the File Types tab in the Folder Options menu.

There will be an upper view with registered filed types, and some
buttons below far making changes to them.

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


Re: Passing DLL handle as an argument (in Windows)

2011-11-18 Thread Ulrich Eckhardt

Am 18.11.2011 12:49, schrieb Pekka Kytölä:

What I'd like to do is that after fetching those SDK function
pointers I'd like to fire up .py/.pyc that snoops for possible
plugins written in python and registers those plugins and callbacks
and let them react to events. Obviously this python code needs access
to those SDK functions. Essentially it would show for the host app as
one .dll but registers multiple plugins from different python files.


Okay, so you want to export functions from your host application (it 
doesn't matter if that is inside a DLL or not) to a bunch of Python 
plugins. This is actually the embedding that I hinted at and documented, 
but here's some example code (stripped of any error handling and 
reference counting, so beware!):


// append line to debug log
static PyObject*
log_string(PyObject *self, PyObject *args)
{
char const* arg = 0;
if(!PyArg_ParseTuple(args, s, arg))
return NULL;

fprintf(debug_output, %s, arg);
Py_RETURN_NONE;
}

// exported API
static PyMethodDef host_api[] =
{
{log_string, log_string, METH_VARARGS,
log_string(string) - None\n
Write text to debug output.},
{NULL, NULL, 0, NULL}
};

Py_Initialize();
PyObject* host_api_module = Py_InitModule(host, host_api);
PyObject* test_module = PyImport_ImportModule(./test.py);
PyObject* main_function = PyObject_GetAttrString(test_module, main);
PyObject* res = PyObject_CallObject(main_function, NULL);
Py_Finalize();


This has the disadvantage that it blocks, for multiple Python threads, 
you need to program a dispatcher. Also, you can only have a single 
interpreter loaded, so other parts of your program may not call 
Py_Initialize().


It does the job for my uses, so I hope it helps!

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


Dynamically Generate Methods

2011-11-18 Thread GZ
Hi,

I have a class Record and a list key_attrs that specifies the names of
all attributes that correspond to a primary key.

I can write a function like this to get the primary key:

def get_key(instance_of_record):
   return tuple(instance_of_record.__dict__[k] for k in key_attrs)

However, since key_attrs are determined at the beginning of the
program while get_key() will be called over and over again, I am
wondering if there is a way to dynamically generate a get_ley method
with the key attributes expanded to avoid the list comprehension/
generator.

For example, if key_attrs=['A','B'], I want the generated function to
be equivalent to the following:

def get_key(instance_of_record):
   return (instance_of_record['A'],instance_of_record['B'] )

I realize I can use eval or exec to do this. But is there any other
way to do this?

Thanks,
gz




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


Re: Why sock.bind is always report 10048 error when in a script with multiprocessing

2011-11-18 Thread Junfeng Hu
I did a test on linux, it works well, so the issue is related to os.

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


Re: Why sock.bind is always report 10048 error when in a script with multiprocessing

2011-11-18 Thread Chris Angelico
On Fri, Nov 18, 2011 at 9:23 PM, Junfeng Hu hujunf...@gmail.com wrote:
 Hi All, I'm trying to leverage my core i5 to send more UDP packets with 
 multiprocssing, but I found a interesting thing is that the socket.bind is 
 always reporting 10048 error even the process didn't do anything about the 
 socket.
 sock.bind((localIP,localPort))
 socket.error: [Errno 10048] Only one usage of each socket address 
 (protocol/netw
 ork address/port) is normally permitted

Try setting the socket to SO_REUSEADDR.

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-18 Thread W. eWatson

On 11/18/2011 5:11 AM, Neil Cerutti wrote:

On 2011-11-18, W. eWatsonwolftra...@invalid.com  wrote:

On 11/17/2011 4:24 PM, Steven D'Aprano wrote:

On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote:


I have not found any successful way to get to IDLE. It's on on the
right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails
with a invalid Win32 app msg.


If you associate .pyw files with pythonw.exe, and then open idle.pyw,
does it work?

Failing that, go to your laptop where the associations are right, and see
what they are, then duplicate the settings on your Windows 7 machine.


Sounds like a good idea except I've not used associations in so
long under XP, I have no idea where to start. Control Panel. My
Computer Tools?


Open Windows Explorer.
With the menu, to to Tools-Folder Options
Click the File Types tab in the Folder Options menu.

There will be an upper view with registered filed types, and some
buttons below far making changes to them.


OK, I've found that. I see
Py
Pyc
Pyo
Pyw
If I click on each, it basically it gives a short description of each. 
If I click advanced, there's more info. For example for py, Actions are 
IDLE and Open.


What does this tell me that's relevant to Win7?

If on Win7, I go to Default Programs I see under associations various 
python items. Py shows Unknown application. Since installing 2.7.2 I 
have not messed with these associations. If I right-click on Unknown, I 
see Notepad and python.exe for choices to open the file. I want neither. 
Why isn't IDLE listed there?


If I right-click on junk.py, I see Open with.  Notepad and python.exe 
are choices. However, that menu allows me to choose something else. For 
example, Adobe Reader, or Internet Explorer. I suppose the next question 
is should I use the browse there and try to connect to IDLE in 
...\Lib\idlelib?  My guess is that if I do, I will run into the invalid 
Win32 app, when I try to use it.



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


Re: Why sock.bind is always report 10048 error when in a script with multiprocessing

2011-11-18 Thread Junfeng Hu
Thanks 
Yes, I had tried this before, so you could find that I comment the line 
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
Here is the results.
D:\Python testmythread2.py
Traceback (most recent call last):
  File string, line 1, in module
  File C:\Python27\lib\multiprocessing\forking.py, line 347, in main
self = load(from_parent)
  File C:\Python27\lib\pickle.py, line 1378, in load
return Unpickler(file).load()
  File C:\Python27\lib\pickle.py, line 858, in load
dispatch[key](self)
  File C:\Python27\lib\pickle.py, line 1133, in load_reduce
value = func(*args)
  File C:\Python27\lib\multiprocessing\reduction.py, line 167, in rebuild_sock
et
_sock = fromfd(fd, family, type_, proto)
  File C:\Python27\lib\multiprocessing\reduction.py, line 156, in fromfd
s = socket.fromfd(fd, family, type_, proto)
AttributeError: 'module' object has no attribute 'fromfd'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why sock.bind is always report 10048 error when in a script with multiprocessing

2011-11-18 Thread Junfeng Hu
And actually ,the socket hadn't been used in this script.

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-18 Thread W. eWatson

On 11/17/2011 8:34 PM, Dennis Lee Bieber wrote:

On Thu, 17 Nov 2011 08:55:36 -0800, W. eWatson
wolftra...@invalid.com  declaimed the following in
gmane.comp.python.general:


Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I
uninstalled and installed. Same problem. If one right-clicks on a py
file, IDLE is not shown in the menu as Edit with IDLE. After playing
with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same
results.

If I look at a 2.4 install on my laptop, I get the desired reference to
Edit with IDLE.


Fine... so open a directory window, follow

Tools/Folder Options/File Types

Scroll down to PYW, click [Advanced]

You should get an Edit File Type dialog. Mine shows just one
action open, yours probably has open and edit. Select edit and
then click [Edit] button. See what it says for the application to be
used.

Do the same on the Win7 machine -- it probably doesn't have edit
as an action, so you'll be picking the [New] button. Define the new
action to look like the action on the laptop (use the correct path to
the python executable, and maybe to IDLE).

Heck, check what those actions show for PY files too... The only
difference between PY and PYW should be the application used in the
open action.
PY =  .../python.exe
PYW =  .../pythonw.exe

Also make sure that the open action is the defined default (select
the action, and click the default button); when there are more than one
action, the default will be in bold.







My guess is that Win 7 is behind this. If so, it's good-bye Python.

Comments?

See my response to Neil Cerutii a few msgs above this one.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-18 Thread W. eWatson

On 11/17/2011 8:34 PM, Dennis Lee Bieber wrote:

On Thu, 17 Nov 2011 08:55:36 -0800, W. eWatson
wolftra...@invalid.com  declaimed the following in
gmane.comp.python.general:


Months ago 2.5.2 stopped functioning on my Win7 PC, so a few days ago I
uninstalled and installed. Same problem. If one right-clicks on a py
file, IDLE is not shown in the menu as Edit with IDLE. After playing
with matters I gave up, and uninstalled 2.5.2 and turned to 2.7.2. Same
results.

If I look at a 2.4 install on my laptop, I get the desired reference to
Edit with IDLE.


Fine... so open a directory window, follow

Tools/Folder Options/File Types

Scroll down to PYW, click [Advanced]

You should get an Edit File Type dialog. Mine shows just one
action open, yours probably has open and edit. Select edit and
then click [Edit] button. See what it says for the application to be
used.

Do the same on the Win7 machine -- it probably doesn't have edit
as an action, so you'll be picking the [New] button. Define the new
action to look like the action on the laptop (use the correct path to
the python executable, and maybe to IDLE).

Heck, check what those actions show for PY files too... The only
difference between PY and PYW should be the application used in the
open action.
PY =  .../python.exe
PYW =  .../pythonw.exe

Also make sure that the open action is the defined default (select
the action, and click the default button); when there are more than one
action, the default will be in bold.







My guess is that Win 7 is behind this. If so, it's good-bye Python.

Comments?

See my response to Neil Cerutti a few msgs above this one.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why sock.bind is always report 10048 error when in a script with multiprocessing

2011-11-18 Thread Chris Angelico
On Sat, Nov 19, 2011 at 2:51 AM, Junfeng Hu hujunf...@gmail.com wrote:
 And actually ,the socket hadn't been used in this script.

Doesn't matter that you haven't used it; you're binding to the port,
that's what causes the 10048.

I think the main problem is that you're trying to share sockets across
processes, but I haven't used the Python multiprocessing module with
sockets before. I would recommend, if you can, creating separate
sockets in each subprocess; that might make things a bit easier.

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


Re: Why sock.bind is always report 10048 error when in a script with multiprocessing

2011-11-18 Thread Junfeng Hu
Hi Chris.
The socket only binded once. That's the problem I'm puzzleing, I think it may a 
bug of multiprocessing in windows, or something I missed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why sock.bind is always report 10048 error when in a script with multiprocessing

2011-11-18 Thread Chris Angelico
On Sat, Nov 19, 2011 at 3:11 AM, Junfeng Hu hujunf...@gmail.com wrote:
 Hi Chris.
 The socket only binded once. That's the problem I'm puzzleing, I think it may 
 a bug of multiprocessing in windows, or something I missed.

I don't know how multiprocessing goes about initializing those
subprocesses; I suspect that's where it creates the additional
sockets.

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


Re: Why sock.bind is always report 10048 error when in a script with multiprocessing

2011-11-18 Thread MRAB

On 18/11/2011 15:48, Junfeng Hu wrote:

Thanks
Yes, I had tried this before, so you could find that I comment the line
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
Here is the results.
D:\Python testmythread2.py
Traceback (most recent call last):
   File string, line 1, inmodule
   File C:\Python27\lib\multiprocessing\forking.py, line 347, in main
 self = load(from_parent)
   File C:\Python27\lib\pickle.py, line 1378, in load
 return Unpickler(file).load()
   File C:\Python27\lib\pickle.py, line 858, in load
 dispatch[key](self)
   File C:\Python27\lib\pickle.py, line 1133, in load_reduce
 value = func(*args)
   File C:\Python27\lib\multiprocessing\reduction.py, line 167, in 
rebuild_sock
et
 _sock = fromfd(fd, family, type_, proto)
   File C:\Python27\lib\multiprocessing\reduction.py, line 156, in fromfd
 s = socket.fromfd(fd, family, type_, proto)
AttributeError: 'module' object has no attribute 'fromfd'


The documentation for socket.fromfd says:

Availability: Unix.

You're using Microsoft Windows.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamically Generate Methods

2011-11-18 Thread Jean-Michel Pichavant

GZ wrote:

Hi,

I have a class Record and a list key_attrs that specifies the names of
all attributes that correspond to a primary key.

I can write a function like this to get the primary key:

def get_key(instance_of_record):
   return tuple(instance_of_record.__dict__[k] for k in key_attrs)

However, since key_attrs are determined at the beginning of the
program while get_key() will be called over and over again, I am
wondering if there is a way to dynamically generate a get_ley method
with the key attributes expanded to avoid the list comprehension/
generator.

For example, if key_attrs=['A','B'], I want the generated function to
be equivalent to the following:

def get_key(instance_of_record):
   return (instance_of_record['A'],instance_of_record['B'] )

I realize I can use eval or exec to do this. But is there any other
way to do this?

Thanks,
gz



  

Hi,

you may want to do something like

class Record(object):
 PRIMARY_KEY = []
 def __init__(self):
   for key in self.PRIMARY_KEY:
 setattr(self, key, None)

 def getPrimaryKeyValues(self):
   return [ getattr(self, key) for key in self.PRIMARY_KEY]


class FruitRecord(Record):
 PRIMARY_KEY = ['fruit_id', 'fruit_name']



JM

PS : there's a high chance that a python module already exists to access 
your database with python objects.

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-18 Thread MRAB

On 18/11/2011 15:29, W. eWatson wrote:

On 11/18/2011 5:11 AM, Neil Cerutti wrote:

On 2011-11-18, W. eWatsonwolftra...@invalid.com wrote:

On 11/17/2011 4:24 PM, Steven D'Aprano wrote:

On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote:


I have not found any successful way to get to IDLE. It's on on the
right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails
with a invalid Win32 app msg.


If you associate .pyw files with pythonw.exe, and then open idle.pyw,
does it work?

Failing that, go to your laptop where the associations are right,
and see
what they are, then duplicate the settings on your Windows 7 machine.


Sounds like a good idea except I've not used associations in so
long under XP, I have no idea where to start. Control Panel. My
Computer Tools?


Open Windows Explorer.
With the menu, to to Tools-Folder Options
Click the File Types tab in the Folder Options menu.

There will be an upper view with registered filed types, and some
buttons below far making changes to them.


OK, I've found that. I see
Py
Pyc
Pyo
Pyw
If I click on each, it basically it gives a short description of each.
If I click advanced, there's more info. For example for py, Actions are
IDLE and Open.

What does this tell me that's relevant to Win7?

If on Win7, I go to Default Programs I see under associations various
python items. Py shows Unknown application. Since installing 2.7.2 I
have not messed with these associations. If I right-click on Unknown, I
see Notepad and python.exe for choices to open the file. I want neither.
Why isn't IDLE listed there?

If I right-click on junk.py, I see Open with. Notepad and python.exe
are choices. However, that menu allows me to choose something else. For
example, Adobe Reader, or Internet Explorer. I suppose the next question
is should I use the browse there and try to connect to IDLE in
...\Lib\idlelib? My guess is that if I do, I will run into the invalid
Win32 app, when I try to use it.


You can't associate .py with Idle because Idle is a Python script, not
an executable (an .exe).

Have a look here:
http://superuser.com/questions/68852/change-windows-7-explorer-edit-context-menu-action-for-jpg-and-other-image-fil

In my PC's registry (Windows XP, but Windows 7 should be similar or the
same) it has the entry:

Key: HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command
Value: C:\Python31\pythonw.exe C:\Python31\Lib\idlelib\idle.pyw -n 
-e %1


Note how it actually associates the Edit action of Python files with an
.exe file.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-18 Thread rusi
On Nov 18, 10:12 pm, MRAB pyt...@mrabarnett.plus.com wrote:
 On 18/11/2011 15:29, W. eWatson wrote:







  On 11/18/2011 5:11 AM, Neil Cerutti wrote:
  On 2011-11-18, W. eWatsonwolftra...@invalid.com wrote:
  On 11/17/2011 4:24 PM, Steven D'Aprano wrote:
  On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote:

  I have not found any successful way to get to IDLE. It's on on the
  right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails
  with a invalid Win32 app msg.

  If you associate .pyw files with pythonw.exe, and then open idle.pyw,
  does it work?

  Failing that, go to your laptop where the associations are right,
  and see
  what they are, then duplicate the settings on your Windows 7 machine.

  Sounds like a good idea except I've not used associations in so
  long under XP, I have no idea where to start. Control Panel. My
  Computer Tools?

  Open Windows Explorer.
  With the menu, to to Tools-Folder Options
  Click the File Types tab in the Folder Options menu.

  There will be an upper view with registered filed types, and some
  buttons below far making changes to them.

  OK, I've found that. I see
  Py
  Pyc
  Pyo
  Pyw
  If I click on each, it basically it gives a short description of each.
  If I click advanced, there's more info. For example for py, Actions are
  IDLE and Open.

  What does this tell me that's relevant to Win7?

  If on Win7, I go to Default Programs I see under associations various
  python items. Py shows Unknown application. Since installing 2.7.2 I
  have not messed with these associations. If I right-click on Unknown, I
  see Notepad and python.exe for choices to open the file. I want neither.
  Why isn't IDLE listed there?

  If I right-click on junk.py, I see Open with. Notepad and python.exe
  are choices. However, that menu allows me to choose something else. For
  example, Adobe Reader, or Internet Explorer. I suppose the next question
  is should I use the browse there and try to connect to IDLE in
  ...\Lib\idlelib? My guess is that if I do, I will run into the invalid
  Win32 app, when I try to use it.

 You can't associate .py with Idle because Idle is a Python script, not
 an executable (an .exe).

 Have a look 
 here:http://superuser.com/questions/68852/change-windows-7-explorer-edit-c...

 In my PC's registry (Windows XP, but Windows 7 should be similar or the
 same) it has the entry:

 Key: HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command
 Value: C:\Python31\pythonw.exe C:\Python31\Lib\idlelib\idle.pyw -n
 -e %1

 Note how it actually associates the Edit action of Python files with an
 .exe file.

The tools - folder options approach is the user-friendly approach --
when it works.
The 'Correct the registry' is the muscular approach -- it will set
right everything iff you are a wizard.

In between the two is assoc and ftype see
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ftype.mspx?mfr=true
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/assoc.mspx?mfr=true
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-18 Thread W. eWatson

On 11/18/2011 9:12 AM, MRAB wrote:

On 18/11/2011 15:29, W. eWatson wrote:

On 11/18/2011 5:11 AM, Neil Cerutti wrote:

On 2011-11-18, W. eWatsonwolftra...@invalid.com wrote:

On 11/17/2011 4:24 PM, Steven D'Aprano wrote:

On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote:


I have not found any successful way to get to IDLE. It's on on the
right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails
with a invalid Win32 app msg.


If you associate .pyw files with pythonw.exe, and then open idle.pyw,
does it work?

Failing that, go to your laptop where the associations are right,
and see
what they are, then duplicate the settings on your Windows 7 machine.


Sounds like a good idea except I've not used associations in so
long under XP, I have no idea where to start. Control Panel. My
Computer Tools?


Open Windows Explorer.
With the menu, to to Tools-Folder Options
Click the File Types tab in the Folder Options menu.

There will be an upper view with registered filed types, and some
buttons below far making changes to them.


OK, I've found that. I see
Py
Pyc
Pyo
Pyw
If I click on each, it basically it gives a short description of each.
If I click advanced, there's more info. For example for py, Actions are
IDLE and Open.

What does this tell me that's relevant to Win7?

If on Win7, I go to Default Programs I see under associations various
python items. Py shows Unknown application. Since installing 2.7.2 I
have not messed with these associations. If I right-click on Unknown, I
see Notepad and python.exe for choices to open the file. I want neither.
Why isn't IDLE listed there?

If I right-click on junk.py, I see Open with. Notepad and python.exe
are choices. However, that menu allows me to choose something else. For
example, Adobe Reader, or Internet Explorer. I suppose the next question
is should I use the browse there and try to connect to IDLE in
...\Lib\idlelib? My guess is that if I do, I will run into the invalid
Win32 app, when I try to use it.


You can't associate .py with Idle because Idle is a Python script, not
an executable (an .exe).


Odd, but OK.



Have a look here:
http://superuser.com/questions/68852/change-windows-7-explorer-edit-context-menu-action-for-jpg-and-other-image-fil

Are you suggesting that I use the default program mentioned there?



In my PC's registry (Windows XP, but Windows 7 should be similar or the
same) it has the entry:

Key: HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command
Value: C:\Python31\pythonw.exe C:\Python31\Lib\idlelib\idle.pyw -n
-e %1

Note how it actually associates the Edit action of Python files with an
.exe file.

So pythonw.exe and idle.pyw are not scripts but somehow can fire up idle?

Are you suggesting I modify my registry?  I still find it bizarre the 
install did not put it IDLE choice on the menu for py. It's there on XP.

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-18 Thread W. eWatson

On 11/18/2011 9:19 AM, rusi wrote:

On Nov 18, 10:12 pm, MRABpyt...@mrabarnett.plus.com  wrote:

On 18/11/2011 15:29, W. eWatson wrote:








On 11/18/2011 5:11 AM, Neil Cerutti wrote:

On 2011-11-18, W. eWatsonwolftra...@invalid.com  wrote:

On 11/17/2011 4:24 PM, Steven D'Aprano wrote:

On Thu, 17 Nov 2011 16:03:14 -0800, W. eWatson wrote:



I have not found any successful way to get to IDLE. It's on on the
right-click of a py menu, and, if I go the ...lib/idle.pyw, it fails
with a invalid Win32 app msg.



If you associate .pyw files with pythonw.exe, and then open idle.pyw,
does it work?



Failing that, go to your laptop where the associations are right,
and see
what they are, then duplicate the settings on your Windows 7 machine.



Sounds like a good idea except I've not used associations in so
long under XP, I have no idea where to start. Control Panel. My
Computer Tools?



Open Windows Explorer.
With the menu, to to Tools-Folder Options
Click the File Types tab in the Folder Options menu.



There will be an upper view with registered filed types, and some
buttons below far making changes to them.



OK, I've found that. I see
Py
Pyc
Pyo
Pyw
If I click on each, it basically it gives a short description of each.
If I click advanced, there's more info. For example for py, Actions are
IDLE and Open.



What does this tell me that's relevant to Win7?



If on Win7, I go to Default Programs I see under associations various
python items. Py shows Unknown application. Since installing 2.7.2 I
have not messed with these associations. If I right-click on Unknown, I
see Notepad and python.exe for choices to open the file. I want neither.
Why isn't IDLE listed there?



If I right-click on junk.py, I see Open with. Notepad and python.exe
are choices. However, that menu allows me to choose something else. For
example, Adobe Reader, or Internet Explorer. I suppose the next question
is should I use the browse there and try to connect to IDLE in
...\Lib\idlelib? My guess is that if I do, I will run into the invalid
Win32 app, when I try to use it.


You can't associate .py with Idle because Idle is a Python script, not
an executable (an .exe).

Have a look 
here:http://superuser.com/questions/68852/change-windows-7-explorer-edit-c...

In my PC's registry (Windows XP, but Windows 7 should be similar or the
same) it has the entry:

Key: HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command
Value: C:\Python31\pythonw.exe C:\Python31\Lib\idlelib\idle.pyw -n
-e %1

Note how it actually associates the Edit action of Python files with an
.exe file.


The tools -  folder options approach is the user-friendly approach --
when it works.
The 'Correct the registry' is the muscular approach -- it will set
right everything iff you are a wizard.

In between the two is assoc and ftype see
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ftype.mspx?mfr=true
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/assoc.mspx?mfr=true
These two seem equally muscular. I shudder to think where these choices 
might lead me.

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


Re: Dynamically Generate Methods

2011-11-18 Thread Duncan Booth
GZ zyzhu2...@gmail.com wrote:

 For example, if key_attrs=['A','B'], I want the generated function to
 be equivalent to the following:
 
 def get_key(instance_of_record):
return (instance_of_record['A'],instance_of_record['B'] )
 
 I realize I can use eval or exec to do this. But is there any other
 way to do this?
 

Use operator.itemgetter:

 key_attrs = ['A', 'B']
 import operator
 get_key = operator.itemgetter(*key_attrs)
 d = {'A': 42, 'B': 63, 'C': 99}
 get_key(d)
(42, 63)

-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-18 Thread W. eWatson

On 11/17/2011 11:35 PM, Terry Reedy wrote:

On 11/17/2011 7:03 PM, W. eWatson wrote:


I have not found any successful way to get to IDLE.


Use the start menu to start IDLE once. Then pin it to your taskbar.
If you do not have STart/ all programs / Python / IDLE, then your
installation is bad.

As for the right click problem, you probably have something screwy in
the registry. The python installer (or uninstaller) will not fix it (my
experience on my old xp machine). You will have to do so manually.

IDLE is a choice on the Start menu (All Programs). Pressing it does 
nothing. I see nothing that suggests it's open.


The IDLE entry is pointing at c:\Python27\ (shortcut)

A post above yours suggests IDLE is a script, and somehow needs a 
boost to use it. An exe file, apparently.  Beats the heck out of me.

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-18 Thread W. eWatson

On 11/17/2011 9:25 PM, Benjamin Kaplan wrote:

On Thu, Nov 17, 2011 at 11:21 PM, W. eWatsonwolftra...@invalid.com  wrote:


On 11/17/2011 7:59 PM, Dave Angel wrote:


On 11/17/2011 03:31 PM, W. eWatson wrote:


On 11/17/2011 9:39 AM, John Gordon wrote:
SNIP


Can you add IDLE manually to the associated applications list?


Tried that by sending it directly to idle.pyw, but then trying to get
there through the Edit with menu caused a invalid Win32 app.


You've been told repeatedly that building an association to idle.pyw is
useless. It must be to something Windows understands, such as .exe, or
.bat (or several other extensions, as I said in an earlier message) So
why waste our time telling us yet again that it doesn't work?




Because some  people think that's a solution, and ask. It's not. It leads to an 
error message.



Checking my Python install, there should be an idle.bat file in there
too. Have you tried that?

Yes. I tried running it. Got nowhere.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamically Generate Methods

2011-11-18 Thread Ian Kelly
On Fri, Nov 18, 2011 at 7:51 AM, GZ zyzhu2...@gmail.com wrote:
 Hi,

 I have a class Record and a list key_attrs that specifies the names of
 all attributes that correspond to a primary key.

 I can write a function like this to get the primary key:

 def get_key(instance_of_record):
   return tuple(instance_of_record.__dict__[k] for k in key_attrs)

 However, since key_attrs are determined at the beginning of the
 program while get_key() will be called over and over again, I am
 wondering if there is a way to dynamically generate a get_ley method
 with the key attributes expanded to avoid the list comprehension/
 generator.

(Accidentally sent this to the OP only)

This is exactly what the attrgetter factory function produces.

from operator import attrgetter
get_key = attrgetter(*key_attrs)

But if your attribute names are variable and arbitrary, I strongly
recommend you store them in a dict instead.  Setting them as instance
attributes risks that they might conflict with the regular attributes
and methods on your objects.

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


Python 2.7.2 on Win7 and IDLE (Try it)

2011-11-18 Thread W. eWatson
Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2 
flop the same way under Win 7.


One thing I think no one has offered is whether their installation of 
2.7.2 has the same IDLE oddity that I've described.  That is, if you 
right-click on a py file, do you see a choice for the IDLE editor?

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


Re: Python 2.7.2 on Win7 and IDLE (Try it)

2011-11-18 Thread W. eWatson

On 11/18/2011 10:06 AM, W. eWatson wrote:

Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2
flop the same way under Win 7.

One thing I think no one has offered is whether their installation of
2.7.2 has the same IDLE oddity that I've described. That is, if you
right-click on a py file, do you see a choice for the IDLE editor?


Try it on Win 7.
--
http://mail.python.org/mailman/listinfo/python-list


Resources consumed by parent

2011-11-18 Thread Mihai Badoiu
How do I get the resources consumed by the parent process?

getrusage() in the resource module seems to work only for self or the
children processes.

thanks,

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-18 Thread Stephen Hansen
On 11/17/11 8:34 PM, W. eWatson wrote:
 On 11/17/2011 7:04 PM, alex23 wrote:
 On Nov 18, 2:55 am, W. eWatsonwolftra...@invalid.com  wrote:
 Comments?

 Are you using the vanilla installer or ActiveState's ActivePython? I
 find the latter integrates better with Windows.

 Also, out of curiousity, 32 or 64 bit Windows?
 64-bit and plain old python msi installer.

That'd be it, I expect.

Windows has two parallel registry trees; if you launch a 32-bit program,
it sees one.. if you launch a 64-bit program, it sees the other. What
looks like the exact same keys can be different as a result.

The MSI is probably writing the keys into the 32-bit registry, and
Explorer is now a 64-bit application.

You can add the associations for Edit manually. Though not to
idle.pyw, which you keep -- repeatedly -- saying you try and errors.
Of course it errors. That's a python script, not an executable.

Associate to pythonw.exe, and pass it the path to idle.pyw, and then -n
-e %1 -- which will be replaced with the actual filename. But you were
told that already and seem to have just dismissed it out of hand.

Like: PATH\pythonw.exe PATH\idle.pyw -n -e %1

... where PATH is whatever the location of those files are in your
environment.

Yes, its moderately annoying that you have to do this yourself; maybe
you wouldn't if you installed 64-bit python, but I can't be sure. Maybe
it has nothing to do with 32 or 64-bitness at all and my guess is wrong.
Maybe your profile has gone wonky. But it doesn't matter. You can add
the Edit association yourself. Its a one-time fix.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7.2 on Win7 and IDLE (Try it)

2011-11-18 Thread Steven D'Aprano
On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote:

 Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2
 flop the same way under Win 7.
 
 One thing I think no one has offered is whether their installation of
 2.7.2 has the same IDLE oddity that I've described.  That is, if you
 right-click on a py file, do you see a choice for the IDLE editor?

Terry Reedy has already said that his installation works fine.

I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine.


If you have installed the regular, 32-bit version of Python on a 64-bit 
version of Windows, chances are good that there will be registry problems 
stopping things from working correctly. See Stephen Hansen's post.



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


Re: Python 2.7.2 on Win7 and IDLE (Try it)

2011-11-18 Thread W. eWatson

On 11/18/2011 3:44 PM, Steven D'Aprano wrote:

On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote:


Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2
flop the same way under Win 7.

One thing I think no one has offered is whether their installation of
2.7.2 has the same IDLE oddity that I've described.  That is, if you
right-click on a py file, do you see a choice for the IDLE editor?


Terry Reedy has already said that his installation works fine.

I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine.


If you have installed the regular, 32-bit version of Python on a 64-bit
version of Windows, chances are good that there will be registry problems
stopping things from working correctly. See Stephen Hansen's post.




Somehow 3.3.2 doesn't look like 2.7.2.

Ah, I installed a 32-bit.  Missed his post. So what should I do? Try 
3.3.2 64-bit? I'm game. By the time you read this, I will either have 
done it or gotten into it.

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


Re: Python 2.7.2 on Win7 and IDLE (Try it)

2011-11-18 Thread W. eWatson

On 11/18/2011 4:31 PM, W. eWatson wrote:

On 11/18/2011 3:44 PM, Steven D'Aprano wrote:

On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote:


Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2
flop the same way under Win 7.

One thing I think no one has offered is whether their installation of
2.7.2 has the same IDLE oddity that I've described. That is, if you
right-click on a py file, do you see a choice for the IDLE editor?


Terry Reedy has already said that his installation works fine.

I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works fine.


If you have installed the regular, 32-bit version of Python on a 64-bit
version of Windows, chances are good that there will be registry problems
stopping things from working correctly. See Stephen Hansen's post.




Somehow 3.3.2 doesn't look like 2.7.2.

Ah, I installed a 32-bit. Missed his post. So what should I do? Try
3.3.2 64-bit? I'm game. By the time you read this, I will either have
done it or gotten into it.


3.3.2? I do not see that in his single message I found. I see a 3.2.2 
release on http://www.python.org/download/releases/3.2.2/. Google 
shows me nothing for 3.3.2.


I see:
* Windows x86 MSI Installer (3.2.2) (sig) and Visual Studio debug 
information files (sig)
* Windows X86-64 MSI Installer (3.2.2) [1] (sig) and Visual Studio 
debug information files (sig)


Visual Studio  I hope I don't need VS!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7.2 on Win7 and IDLE (Try it)

2011-11-18 Thread MRAB

On 19/11/2011 00:50, W. eWatson wrote:

On 11/18/2011 4:31 PM, W. eWatson wrote:

On 11/18/2011 3:44 PM, Steven D'Aprano wrote:

On Fri, 18 Nov 2011 10:06:47 -0800, W. eWatson wrote:


Undoubtedly some of you have seen my post Both Python 2.5.2 and 2.7.2
flop the same way under Win 7.

One thing I think no one has offered is whether their installation of
2.7.2 has the same IDLE oddity that I've described. That is, if you
right-click on a py file, do you see a choice for the IDLE editor?


Terry Reedy has already said that his installation works fine.

I installed 3.3.2 on a new Win 7 machine and Edit with IDLE works
fine.


If you have installed the regular, 32-bit version of Python on a 64-bit
version of Windows, chances are good that there will be registry
problems
stopping things from working correctly. See Stephen Hansen's post.




Somehow 3.3.2 doesn't look like 2.7.2.

Ah, I installed a 32-bit. Missed his post. So what should I do? Try
3.3.2 64-bit? I'm game. By the time you read this, I will either have
done it or gotten into it.


3.3.2? I do not see that in his single message I found. I see a 3.2.2
release on http://www.python.org/download/releases/3.2.2/. Google
shows me nothing for 3.3.2.

I see:
* Windows x86 MSI Installer (3.2.2) (sig) and Visual Studio debug
information files (sig)
* Windows X86-64 MSI Installer (3.2.2) [1] (sig) and Visual Studio debug
information files (sig)

Visual Studio I hope I don't need VS!


If you look more closely you'll see that there are 5 links on each line:

Windows X86-64 MSI Installer (3.2.2)
[1]
(sig)
Visual Studio debug information files
(sig)

Unless you intending to work on the sources, you need just the first
one:

Windows X86-64 MSI Installer (3.2.2)

for a 64-bit build of Python 3.2.2.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why sock.bind is always report 10048 error when in a script with multiprocessing

2011-11-18 Thread Junfeng Hu
On Nov 18, 10:55 am, MRAB pyt...@mrabarnett.plus.com wrote:
 On 18/11/2011 15:48, Junfeng Hu wrote:





  Thanks
  Yes, I had tried this before, so you could find that I comment the line
  sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
  Here is the results.
  D:\Python testmythread2.py
  Traceback (most recent call last):
     File string, line 1, inmodule
     File C:\Python27\lib\multiprocessing\forking.py, line 347, in main
       self = load(from_parent)
     File C:\Python27\lib\pickle.py, line 1378, in load
       return Unpickler(file).load()
     File C:\Python27\lib\pickle.py, line 858, in load
       dispatch[key](self)
     File C:\Python27\lib\pickle.py, line 1133, in load_reduce
       value = func(*args)
     File C:\Python27\lib\multiprocessing\reduction.py, line 167, in 
  rebuild_sock
  et
       _sock = fromfd(fd, family, type_, proto)
     File C:\Python27\lib\multiprocessing\reduction.py, line 156, in fromfd
       s = socket.fromfd(fd, family, type_, proto)
  AttributeError: 'module' object has no attribute 'fromfd'

 The documentation for socket.fromfd says:

      Availability: Unix.

 You're using Microsoft Windows.- Hide quoted text -

 - Show quoted text -

Yes, but my question is , how to make such script work in windows.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Data Plotting Library Dislin 10.2

2011-11-18 Thread sturlamolden
On 18 Nov, 22:16, Tony the Tiger t...@tiger.invalid wrote:

 Ya, but apparently no source unless you dig deep into your pockets.
 Really, why would we need this when we already have gnuplot?
 Just wondering...

Dislin is a very nice plotting library for scientific data,
particularly for scientists and engineers using Fortran (which,
incidentally, is quite a few).

For Python, we have Matplotlib as well (at least for 2D plots).


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


Re: Python 2.7.2 on Win7 and IDLE (Try it)

2011-11-18 Thread Steven D'Aprano
On Fri, 18 Nov 2011 16:31:03 -0800, W. eWatson wrote:

 Somehow 3.3.2 doesn't look like 2.7.2.

Oops, so you're right. Sorry for the noise.

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


Re: Python 2.7.2 on Win7 and IDLE (Try it)

2011-11-18 Thread W. eWatson

...


3.3.2? I do not see that in his single message I found. I see a 3.2.2
release on http://www.python.org/download/releases/3.2.2/. Google
shows me nothing for 3.3.2.

I see:
* Windows x86 MSI Installer (3.2.2) (sig) and Visual Studio debug
information files (sig)
* Windows X86-64 MSI Installer (3.2.2) [1] (sig) and Visual Studio debug
information files (sig)

Visual Studio I hope I don't need VS!


If you look more closely you'll see that there are 5 links on each line:

Windows X86-64 MSI Installer (3.2.2)
[1]
(sig)
Visual Studio debug information files
(sig)

Unless you intending to work on the sources, you need just the first
one:

Windows X86-64 MSI Installer (3.2.2)

for a 64-bit build of Python 3.2.2.


An oddity occurs here. Yes, x86-64 is the right installer, maybe. While 
noting your msg, my PC got very slow, and I ended up going to a related 
site for the downloads of 3.2.2 while trying for the one above. 
http://www.python.org/download/.


It shows:
Also look at the detailed Python 3.2.2 page:

* Python 3.2.2 Windows x86 MSI Installer (Windows binary -- does 
not include source)
* Python 3.2.2 Windows X86-64 MSI Installer (Windows AMD64 / Intel 
64 / X86-64 binary [1] -- does not include source)


The first of the two choices does not say x-bit anything. The second 
looks off course for my HP 64-bit PC.


I'm going to just use Windows X86-64 MSI Installer (3.2.2).

Wait a minute Windows X86-64 MSI Installer (3.2.2). Windows X86-64 MSI 
Installer (3.2.2) shows it's associated with Visual Studio.  Why would I 
want that? Ah, I get it The single first line has Windows X86-64 MSI 
Installer (3.2.2) and Visual Studio.  That's a really weird way to 
arrange them. OK, now off to Windows X86-64 MSI Installer (3.2.2)


I'll be back shortly after I've made the install.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.7.2 on Win7 and IDLE (Try it)

2011-11-18 Thread W. eWatson

On 11/18/2011 9:03 PM, W. eWatson wrote:

...


3.3.2? I do not see that in his single message I found. I see a 3.2.2
release on http://www.python.org/download/releases/3.2.2/. Google
shows me nothing for 3.3.2.

I see:
* Windows x86 MSI Installer (3.2.2) (sig) and Visual Studio debug
information files (sig)
* Windows X86-64 MSI Installer (3.2.2) [1] (sig) and Visual Studio debug
information files (sig)

Visual Studio I hope I don't need VS!


If you look more closely you'll see that there are 5 links on each line:

Windows X86-64 MSI Installer (3.2.2)
[1]
(sig)
Visual Studio debug information files
(sig)

Unless you intending to work on the sources, you need just the first
one:

Windows X86-64 MSI Installer (3.2.2)

for a 64-bit build of Python 3.2.2.


An oddity occurs here. Yes, x86-64 is the right installer, maybe. While
noting your msg, my PC got very slow, and I ended up going to a related
site for the downloads of 3.2.2 while trying for the one above.
http://www.python.org/download/.

It shows:
Also look at the detailed Python 3.2.2 page:

* Python 3.2.2 Windows x86 MSI Installer (Windows binary -- does not
include source)
* Python 3.2.2 Windows X86-64 MSI Installer (Windows AMD64 / Intel 64 /
X86-64 binary [1] -- does not include source)

The first of the two choices does not say x-bit anything. The second
looks off course for my HP 64-bit PC.

I'm going to just use Windows X86-64 MSI Installer (3.2.2).

Wait a minute Windows X86-64 MSI Installer (3.2.2). Windows X86-64 MSI
Installer (3.2.2) shows it's associated with Visual Studio. Why would I
want that? Ah, I get it The single first line has Windows X86-64 MSI
Installer (3.2.2) and Visual Studio. That's a really weird way to
arrange them. OK, now off to Windows X86-64 MSI Installer (3.2.2)

I'll be back shortly after I've made the install.


I surrender. IDLE does not appear as a choice when I right-click on a py 
file.


IDLE is on the All Programs list, and if I click on it, something more 
or less seems to happen, but it does not reveal anything. There is a 
comparability choice there that asks what OS did it last run on. 
Unfortunately the choices were VISTA (service packs) and Win7. I 
selected Win7 but it didn't help. Off to bed soon.

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


[issue13386] Document documentation conventions for optional args

2011-11-18 Thread Ezio Melotti

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

 From Ezio's original post: '''
 If a function has optional arguments but it doesn't accept keyword 
 arguments, the func([arg1]) notation is used instead. ... The 
 notation func([arg=default]) should never be used, and func([arg]) 
 should be used only when keyword args are not accepted.
 '''

 In the following, I give objections to this PO (position only) rule and  
 suggest an alternative ND (no default) rule: use 'name=default' when
 there is a default and '[name]' when there is not'.

Maybe we should try to keep it simple and just document the signature of the 
function.
Everything that can not be described in the signature can be explained by words.

I tried to write down all the combinations of optional/non optional, 
with/without default, works/doesn't work with keywords to see how to represent 
them, but it started being a bit messy.  The problematic combinations (for 
example a function that accepts an optional arguments with no default but that 
doesn't work with keywords) seem quite rare, and for them we could just write 
down what's special about them.

There are two more cases that could be solved with a specific notation though:
1) optional arg, with default, doesn't work with keywords (e.g. range, 
startswith):
   func(arg1)
   func(arg1, arg2)
   *arg2* defaults to default.
2) optional arg, with no default, that works only with keywords:
   func(arg1, *, arg2)

The keyword-only *, and the multiple signatures tricks can also be used for 
other similar cases.

func(arg1, **kwargs) can be used for functions that accept kwargs without 
expecting any specific value; if the values are known and have defaults they 
could be included in the signature (even if the default is like foo = 
kwargs.get('foo', default)).

This should cover most of the cases, it only uses valid Python syntax and 
avoids potentially confusing [].

--

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



[issue13349] Uninformal error message in index() and remove() functions

2011-11-18 Thread Ezio Melotti

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

 I found safe_repr() from Lib/unittest/util.py.

The functions in Lib/unittest/util.py shouldn't be used outside unittest.

 We would require a similar function, just implemented in C.
 What is a good place to define such C helpers that could be used everywhere?

You could start by adding it in the file where you need it.  If it starts 
becoming useful elsewhere too, it can then be moved somewhere else.  I would 
expect such function to be private, so we are free to move it whenever we need 
it.

--

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



[issue13349] Uninformal error message in index() and remove() functions

2011-11-18 Thread Petri Lehtinen

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

Ezio Melotti wrote:
 You could start by adding it in the file where you need it. If it
 starts becoming useful elsewhere too, it can then be moved somewhere
 else. I would expect such function to be private, so we are free to
 move it whenever we need it.

Well, msg147109 already lists 6 files that would use this function.
Some of them are under Objects, some are under Modules/.

--

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



[issue13423] Ranges cannot be meaningfully compared for equality or hashed

2011-11-18 Thread Chase Albert

New submission from Chase Albert thaoe...@gmail.com:

My expectation was that range(2,5) == range(2,5), and that they should hash the 
same. This is not the case.

--
messages: 147838
nosy: rob.anyone
priority: normal
severity: normal
status: open
title: Ranges cannot be meaningfully compared for equality or hashed
type: behavior
versions: Python 3.2

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



[issue13423] Ranges cannot be meaningfully compared for equality or hashed

2011-11-18 Thread Florent Xicluna

Florent Xicluna florent.xicl...@gmail.com added the comment:

this was implemented with ticket #13201.
It will be available in version 3.3.

--
nosy: +flox
resolution:  - out of date
stage:  - committed/rejected
status: open - closed
superseder:  - Implement comparison operators for range objects
type: behavior - feature request

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



[issue13424] Add examples for open’s new opener argument

2011-11-18 Thread Éric Araujo

New submission from Éric Araujo mer...@netwok.org:

The new opener argument to open and TextIOWrapper closed two bugs on this 
tracker: using O_CLOEXEC and replacing the unofficial 'c' mode (O_CREATE).  I 
think it’d be nice to have these as examples (maybe not in the docs of 
TextIOWrapper which are already huge, but for example in the os docs after the 
O_* constants).

--
assignee: docs@python
components: Documentation
messages: 147840
nosy: docs@python, eric.araujo
priority: normal
severity: normal
status: open
title: Add examples for open’s new opener argument
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13424
___
___
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-11-18 Thread Éric Araujo

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

See #13424 for a doc request about this.

--
nosy: +eric.araujo

___
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



[issue13424] Add examples for open’s new opener argument

2011-11-18 Thread Éric Araujo

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

s/TextIOWrapper/FileIO/

--

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



[issue12797] io.FileIO and io.open should support openat

2011-11-18 Thread Éric Araujo

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

See #13424 for a doc request about this.

--

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



[issue12780] Clean up tests for pyc/pyo in __file__

2011-11-18 Thread Éric Araujo

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

 Seems reasonable to me.  When did/does unicodedata ever have a __file__ 
 attribute?
No idea.  Maybe it has to do with static vs. dynamic linking?  Or alternate VMs?

--

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



[issue2979] use_builtin_types in xmlrpc.server

2011-11-18 Thread Éric Araujo

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

Looks good.

--

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



[issue13358] HTMLParser incorrectly handles cdata elements.

2011-11-18 Thread Ezio Melotti

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

Attached patch should solve the issue.

--
assignee:  - ezio.melotti
keywords: +patch
stage: test needed - commit review
versions: +Python 3.2, Python 3.3
Added file: http://bugs.python.org/file23721/issue13358.diff

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



[issue13294] http.server: HEAD request should not return a body

2011-11-18 Thread Éric Araujo

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

Hi Michele, long time no see :)

 Well, actually SimpleHTTPRequesthandler extends BaseHTTPHandler with basic 
 do_GET and
 do_HEAD methods.
 Unittests for http.server shows that this behavior is intended, since: [snip] 
Not sure what this test shows (maybe because I need coffee :)

 Anyway, I would propose a trivial patch to make http.server a little more 
 elegant.
The first change may do more that you want it to: rstrip without argument will 
remove all whitespace, but there the code wants to remove only CRLF or LF.  
Anyway, changes for the sake of elegance or cleanliness are not done for the 
sake of it, but usually as a part of a greater refactoring or fix.  We prefer 
to minimize chances of compatibility breakage by avoiding gratuitous changes.

--

___
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



[issue4147] xml.dom.minidom toprettyxml: omit whitespace for text-only elements

2011-11-18 Thread Ezio Melotti

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

I did some tests, creating an element ('elem') that contains two adjacent text 
nodes ('text').  With my latest patch the prettyprint is:
?xml version=1.0 ?
elem
text
text
/elem

Here both the text nodes are printed on a newline and they are indented.

With your patch it should be:
?xml version=1.0 ?
elemtexttext/elem

I'm not sure there's any reason to prefer the second option though.

--

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



[issue13425] http.client.HTTPMessage.getallmatchingheaders() always returns []

2011-11-18 Thread Stanisław Jankowski

New submission from Stanisław Jankowski stach.jankow...@gmail.com:

http.client.HTTPMessage.getallmatchingheaders() always returns []

Python 3.2.2:
Calling the code below does not give the expected result.

sjankowski@sjankowski:~$ python3
Python 3.2.2rc1 (default, Aug 14 2011, 18:43:44) 
[GCC 4.6.1] on linux2
Type help, copyright, credits or license for more information.
 from urllib.request import urlopen
 fp = urlopen('http://www.python.org/')
 fp.headers.getallmatchingheaders('Content-Type')
[]

At Python 2.7.2 returns the result.

sjankowski@sjankowski:~$ python
Python 2.7.2+ (default, Aug 16 2011, 09:23:59) 
[GCC 4.6.1] on linux2
Type help, copyright, credits or license for more information.
 from urllib import urlopen
 fp = urlopen('http://www.python.org/')
 fp.headers.getallmatchingheaders('Content-Type')
['Content-Type: text/html\r\n']

--
components: Library (Lib)
messages: 147849
nosy: stachjankowski
priority: normal
severity: normal
status: open
title: http.client.HTTPMessage.getallmatchingheaders() always returns []
type: behavior
versions: Python 3.2

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



[issue13425] http.client.HTTPMessage.getallmatchingheaders() always returns []

2011-11-18 Thread Ezio Melotti

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

The problem seems to be in Lib/http/client.py:227.
The code adds a ':' that is not found in the list of headers returned by 
self.keys().

--
nosy: +ezio.melotti

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



[issue13425] http.client.HTTPMessage.getallmatchingheaders() always returns []

2011-11-18 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
nosy: +petri.lehtinen

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



[issue13426] The Python Standard Library 11. Data Persistence

2011-11-18 Thread Nebelhom

New submission from Nebelhom nebel...@googlemail.com:

--
Python v3.3a0 documentation  The Python Standard Library  11. Data
Persistence

Section 11.1 pickle module

#1
11.1.3. Module Interface

exception pickle.UnpicklingError

   Error raised when there a problem unpickling an object, such as a data 
corruption or a security violation.
   It inherits PickleError.

TYPO: Error raised when there IS a problem unpickling an object

--
#2
11.1.3. Module Interface

persistent_load(pid)

   Raise an UnpickingError by default.

TYPO: Should be UnpicklingError as wrtten earlier in the section


#3
11.1.4 What can be pickled and unpickled

Note that functions (built-in and user-defined) are pickled by fully
qualified name reference, not by value.
This means that only the function name is pickled, along with the name of 
module the function is defined in.

TYPO: along with the name of THE module the function is defined in.


#4
11.1.5.1. Persistence of External Objects

In Windows XP SP3, example does not work out of the box as sqlite3 is not 
included when compiling python3.3a following the Getting Set Up directions in 
the Developer's Guide

Is this an issue?

Code works in Ubuntu 10.04 lucid.

When run from Terminal, it gives the following output:

Pickled records:
[MemoRecord(key=1, task='give food to fish'),
 MemoRecord(key=2, task='prepare group meeting'),
 MemoRecord(key=3, task='fight with a zebra')]
Unpickled records:
[MemoRecord(key=1, task='learn italian'),
 MemoRecord(key=2, task='prepare group meeting'),
 MemoRecord(key=3, task='fight with a zebra')]


 Should that not be given afterwards as a reference to the user, so that
(s)he knows, that the code is right?


#5
11.1.6 Restricting Globals

Thus it is possible to either forbid completely globals

NOTE: should be either completely forbid globals



--
assignee: docs@python
components: Documentation
messages: 147851
nosy: Nebelhom, docs@python
priority: normal
severity: normal
status: open
title: The Python Standard Library  11. Data Persistence
versions: Python 3.3

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



[issue13425] http.client.HTTPMessage.getallmatchingheaders() always returns []

2011-11-18 Thread Ezio Melotti

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

Actually the headers are already parsed, so the code should use self.items() 
instead of self.keys(), check if the key (without ':') matches, and append the 
key-value pair to the list.
Having a list of key-value pairs seems more useful than having a bare string, 
but this would be incompatible with 2.7.
This function also doesn't seem to be tested and documented, and it's used only 
once in the stdlib.

--
keywords: +easy
stage:  - test needed
versions: +Python 3.3

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



[issue13349] Uninformal error message in index() and remove() functions

2011-11-18 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

Please don't stress too much about providing an indication that the repr has 
been truncated - it's an error message, not part of the normal program output. 
Besides, the lack of a closing ')', ']', '}' or '' will usually indicate 
something is amiss in long reprs.

More useful would be to raise a separate feature request about the lack of 
width and precision handling for string formatting in PyUnicode_FromFormatV - 
the common format code handling means it *accepts* the width and precision 
information for string codes, but then proceeds to completely ignore it. It 
should be using them to pad short strings (width) and truncate long ones 
(precision), just like printf() (only in terms of code points rather than 
bytes, since those codes work with Unicode text).

--

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



[issue13427] string comparison with ==

2011-11-18 Thread Alan Beccati

New submission from Alan Beccati alan.becc...@gmail.com:

Hello,
did I discover a python string comparison bug or is this behaviour expected and 
I am doing something wrong?

This is the code I run:
for line in lines[4:]:
currColl=line.split(:)[1].strip()
print ',currColl,',==,',collName,'
if currColl == collName :
return True
else:
print not equal

where currColl is a method parameter and lines is built from subprocess Popen 
like:
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, 
stderr=subprocess.STDOUT)
lines=[]
for line in p.stdout.readlines():
lines.append(line)

The output of the abovementioned code is:
' utm ' == ' utm10 '
not equal
' utm1000 ' == ' utm10 '
not equal
' utm100 ' == ' utm10 '
not equal
' utm10 ' == ' utm10 '
not equal
' utm1 ' == ' utm10 '
not equal

as you can see the fourth comparison should return True while it gives a not 
equal as the others.

Python info:
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) 
[GCC 4.5.2] on linux2

--
messages: 147854
nosy: Alan.Beccati
priority: normal
severity: normal
status: open
title: string comparison with ==
type: behavior
versions: Python 2.7

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



[issue13427] string comparison with ==

2011-11-18 Thread Florent Xicluna

Florent Xicluna florent.xicl...@gmail.com added the comment:

collName is probably not what you expect.
You can print repr(collName), repr(currColl) to verify this.

It is not a bug on Python side.

--
nosy: +flox
resolution:  - works for me
stage:  - committed/rejected
status: open - pending

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



[issue13426] The Python Standard Library 11. Data Persistence

2011-11-18 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset ce34e9223450 by Ezio Melotti in branch '2.7':
#13426: fix typo in pickle doc.
http://hg.python.org/cpython/rev/ce34e9223450

New changeset 1f31061afdaf by Ezio Melotti in branch '3.2':
#13426: fix typos in pickle doc.
http://hg.python.org/cpython/rev/1f31061afdaf

New changeset 7992f3247447 by Ezio Melotti in branch 'default':
#13426: merge with 3.2.
http://hg.python.org/cpython/rev/7992f3247447

--
nosy: +python-dev

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



[issue13426] The Python Standard Library 11. Data Persistence

2011-11-18 Thread Ezio Melotti

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

This is fixed now, thanks for the report!
Regarding #4, sqlite3 is included in the official installer provided for 
Windows, so that shouldn't be a problem.
Regarding the output, I don't think is necessary to add it.
The example is fairly complex, so people that need it will probably have to try 
it and experiment a bit anyway, rather than just reading 100 lines of code and 
trying to understand how they work without actually trying it.

--
assignee: docs@python - ezio.melotti
nosy: +ezio.melotti
resolution:  - fixed
stage:  - committed/rejected
status: open - closed
versions: +Python 2.7, Python 3.2

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



[issue13428] PyUnicode_FromFormatV: support width and precision for string codes, e.g %S and %R

2011-11-18 Thread Petri Lehtinen

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

Currently, the width and precision information for string codes are accepted 
but ignored. They should be used to pad short strings (width) and truncate long 
ones (precision), just like printf() (only in terms of code points rather than 
bytes, since those codes work with Unicode text).

--
components: Interpreter Core
messages: 147858
nosy: petri.lehtinen
priority: normal
severity: normal
status: open
title: PyUnicode_FromFormatV: support width and precision for string codes, e.g 
%S and %R
type: feature request
versions: Python 3.3

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



[issue13349] Uninformal error message in index() and remove() functions

2011-11-18 Thread Petri Lehtinen

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

Nick Coghlan wrote:
 Please don't stress too much about providing an indication that the
 repr has been truncated - it's an error message, not part of the
 normal program output. Besides, the lack of a closing ')', ']', '}'
 or '' will usually indicate something is amiss in long reprs.

Ok. This makes things easier.

 More useful would be to raise a separate feature request about the
 lack of width and precision handling for string formatting in
 PyUnicode_FromFormatV - the common format code handling means it
 *accepts* the width and precision information for string codes, but
 then proceeds to completely ignore it. It should be using them to
 pad short strings (width) and truncate long ones (precision), just
 like printf() (only in terms of code points rather than bytes, since
 those codes work with Unicode text).

Created #13428.

--

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



[issue13428] PyUnicode_FromFormatV: support width and precision for string codes, e.g %S and %R

2011-11-18 Thread STINNER Victor

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

Duplicate of #7330.

--
nosy: +haypo
resolution:  - duplicate
status: open - closed

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



[issue7330] PyUnicode_FromFormat: implement width and precision for %s, %S, %R, %V, %U, %A

2011-11-18 Thread STINNER Victor

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

Issue #13428 has been marked as a duplicate of this issue.

--
nosy: +petri.lehtinen

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



[issue13427] string comparison with ==

2011-11-18 Thread Florent Xicluna

Changes by Florent Xicluna florent.xicl...@gmail.com:


--
status: pending - closed

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



[issue13426] Typos in pickle docs

2011-11-18 Thread Éric Araujo

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


--
nosy: +eric.araujo
title: The Python Standard Library  11. Data Persistence - Typos in pickle 
docs

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



[issue13426] The Python Standard Library 11. Data Persistence

2011-11-18 Thread Nebelhom

Nebelhom nebel...@googlemail.com added the comment:

Hi Ezio,

Regarding the output, I don't think is necessary to add it.

I left it in because of a discussion in core-mentorship, where they
mentioned that it would be beneficial to have it in. I pasted the exchange
below if you are interested.

Thanks for looking at it,

Johannes

-
Pasted content:

Message: 2
Date: Fri, 18 Nov 2011 04:15:03 +0200
From: Eli Bendersky eli...@gmail.com
To: Python Core Development Mentorship core-mentors...@python.org
Subject: Re: [Core-mentorship] What classes as an issue in
   documentation?
Message-ID:
   CAF-Rda-U5Jya999K=fw6xe8vgrspj1phq0etcmz277x2jdt...@mail.gmail.com
Content-Type: text/plain; charset=windows-1252

trying
 to gauge what is relevant and what is just a little overly picky.

 I applied the standard, I use when proofreading scientific texts of fellow
 researchers (which raises the bar into infinity as you may always
encounter
 someone who is willing to split hairs over a comma in the wrong position
 just to be right). I would be grateful, if you could just quickly scan
over
 the list and say in each case (I numbered them) if it is relevant or not.

 thanks a bundle.

 Johannes

 P.S. Also, one issue for all issues in one section (like Nick Coghlan
 suggested)

 --
 Python v3.3a0 documentation ? The Python Standard Library ? 11. Data
 Persistence ?

 Section 11.1 pickle module

 #1
 11.1.3. Module Interface

 exception pickle.UnpicklingError

 ??? Error raised when there a problem unpickling an object, such as a data
 corruption or a security violation.
 ??? It inherits PickleError.

 TYPO: Error raised when there IS a problem unpickling an object

 --
 #2
 11.1.3. Module Interface

 persistent_load(pid)

 ??? Raise an UnpickingError by default.

 TYPO: Should be UnpicklingError as wrtten earlier in the section

 --
--
 #3
 11.1.4 What can be pickled and unpickled

 Note that functions (built-in and user-defined) are pickled by ?fully
 qualified? name reference, not by value.
 This means that only the function name is pickled, along with the name of
 module the function is defined in.

 TYPO: along with the name of THE module the function is defined in.

 
 #4
 11.1.5.1. Persistence of External Objects

 In Windows XP SP3, example does not work out of the box as sqlite3 is not
 included when compiling python3.3a
 following the Getting Set Up directions in the Developer's Guide

 Is this an issue?

 Code works in Ubuntu 10.04 lucid.

 When run from Terminal, it gives the following output:

 Pickled records:
 [MemoRecord(key=1, task='give food to fish'),
 ?MemoRecord(key=2, task='prepare group meeting'),
 ?MemoRecord(key=3, task='fight with a zebra')]
 Unpickled records:
 [MemoRecord(key=1, task='learn italian'),
 ?MemoRecord(key=2, task='prepare group meeting'),
 ?MemoRecord(key=3, task='fight with a zebra')]


 ?Should that not be given afterwards as a reference to the user, so that
 (s)he knows, that the code is right?

 
 #5
 11.1.6 Restricting Globals

 Thus it is possible to either forbid completely globals

 NOTE: should be either completely forbid globals


Johannes,

These look perfectly valid to me. Even the smallest typos mentioned
here are worth fixing. The next step is opening an issue in the
tracker (http://bugs.python.org/) and submitting a patch.

Eli

--

Message: 3
Date: Fri, 18 Nov 2011 13:17:11 +1000
From: Nick Coghlan ncogh...@gmail.com
To: Python Core Development Mentorship core-mentors...@python.org
Subject: Re: [Core-mentorship] What classes as an issue in
   documentation?
Message-ID:
   CADiSq7cH_inw_3MUM8huro4GFT=ut7xof04de-csb+bnjkr...@mail.gmail.com
Content-Type: text/plain; charset=ISO-8859-1

On Fri, Nov 18, 2011 at 12:15 PM, Eli Bendersky eli...@gmail.com wrote:
 Johannes,

 These look perfectly valid to me. Even the smallest typos mentioned
 here are worth fixing. The next step is opening an issue in the
 tracker (http://bugs.python.org/) and submitting a patch.

Although I'll note that even if you're not yet ready to make the patch
yourself, a detailed report like this one makes it very easy for
someone *else* to produce a patch, so the tracker issue is the most
important next step.

Lots of things have to happen for a change to get into the source
tree, and the reason we have tools like the tracker around is so that
the work can be coordinated amongst multiple people.

Even as core devs, we'll still often post changes we design, code and
commit ourselves as tracker issues for a while, just so we have a
venue to coordinate reviews and gather feedback.

Cheers,
Nick.

--
title: Typos in pickle docs - The Python Standard Library  11. Data 
Persistence

___
Python tracker rep...@bugs.python.org

[issue6570] Tutorial clarity: section 4.7.2, parameters and arguments

2011-11-18 Thread Ezio Melotti

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

Here is a new patch.

--
Added file: http://bugs.python.org/file23722/issue6570-2.diff

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



[issue13125] test_all_project_files() expected failure

2011-11-18 Thread Éric Araujo

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


--
nosy: +eric.araujo

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



[issue10772] Several actions for argparse arguments missing from docs

2011-11-18 Thread Éric Araujo

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

Looks good to me.

--

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



[issue10772] Several actions for argparse arguments missing from docs

2011-11-18 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
stage: patch review - commit review

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



[issue4508] distutils compiler not handling spaces in path to output/src files

2011-11-18 Thread Éric Araujo

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

 Ok, I found a similar problem with MMTK.
I don’t know what that is.

 I am currently altering my distutils package to add a function called 
 nt_quote_dir
 that adds quotes to paths with spaces and then applies it to each path if the 
 platform
 is win32.
You shouldn’t have to do that; there’s already a similar function in 
distutils.spawn.

 When I'm done I will submit a diff after confirming that it works.
What is needed is a diff for distutils 2.7 or 3.2 adding a test with a file 
containing a space.  I can’t do anything with diffs for other projects.

--
versions: +Python 3.3 -Python 3.1

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



[issue13294] http.server: HEAD request should not return a body

2011-11-18 Thread Michele Orrù

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

These tests shows how SimpleHTTPRequestHandler behaves: if the class
contains a do_FOO method, it is called, otherwise error501 is raised.
That's what Karl said with «Or to modify the library code that for any
resources not yet defined.».
Since SimpleHTTPRequestHandler.do_HEAD exists, and this is reflected
in the correspondent unittest, I belive that this is not a bug.

Patch attached. No problem if it's not committed now. I hope that
someone in the noisy list will make a little cleanup one day :)


 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue13294
 ___


--
Added file: http://bugs.python.org/file23723/issue13294.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13294
___diff -r a00bb30cf775 Lib/http/server.py
--- a/Lib/http/server.pyTue Nov 15 16:12:49 2011 +0100
+++ b/Lib/http/server.pyWed Nov 16 11:15:45 2011 +0100
@@ -271,14 +271,11 @@
 self.request_version = version = self.default_request_version
 self.close_connection = 1
 requestline = str(self.raw_requestline, 'iso-8859-1')
-if requestline[-2:] == '\r\n':
-requestline = requestline[:-2]
-elif requestline[-1:] == '\n':
-requestline = requestline[:-1]
+requestline = requestline.rstrip('\r\n')
 self.requestline = requestline
 words = requestline.split()
 if len(words) == 3:
-[command, path, version] = words
+command, path, version = words
 if version[:5] != 'HTTP/':
 self.send_error(400, Bad request version (%r) % version)
 return False
@@ -304,7 +301,7 @@
   Invalid HTTP Version (%s) % base_version_number)
 return False
 elif len(words) == 2:
-[command, path] = words
+command, path = words
 self.close_connection = 1
 if command != 'GET':
 self.send_error(400,

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



[issue13427] string comparison with ==

2011-11-18 Thread Alan

Alan alan.becc...@gmail.com added the comment:

Using repr highlights the issue which lies in the behaviour of str.strip() 
which does not strip away null spaces as I would have expected:

' 'utm10\x00' ' == ' 'utm10' '
not equal

Changing the code to:
currColl=line.split(:)[1].strip().strip(\0)

works but I think strip() should already do that by default, shouldn't it?

--

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



[issue13420] newer() function in dep_util.py discard changes in the same second

2011-11-18 Thread Éric Araujo

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

Hi David.  Thanks for reporting the issue.  I have to warn you that there is a 
high bar for distutils changes; due to the mass of code out there that relies 
on undocumented internal behavior or works around old bugs, a feature freeze is 
in effect and we try to be very careful with the changes we make to fix bugs.  
Some things clearly qualify as bugs and can be fixed, some things are clearly 
new features and are redirected to the distutils2 project, some bugs can’t be 
fixed because everyone and every tool is used to the buggy behavior.  Here we 
are in a gray area between bug and feature; one can argue that the behavior is 
not what is expected (bug), but one can reply that the documentation just 
doesn’t say that filesystems with millisecond precision are supported (so it 
would be a new feature).

 For example, I've a file that is modified with an installation prefix.
Modified by what when?

 CDBS runs the build step and after the install step. In build step, the 
 prefix is
 '/usr/local' because the prefix argument isn't supported, immediately the 
 install step
 runs with prefix='/usr', so the file that contains a variable with project 
 path
 modified with the prefix is not copied by distutils, it runs in a different 
 millisec
 but in the same second.
I don’t understand when the file is changed.  (BTW, I read some Debian mailing 
lists and I had the impression that CDBS was deprecated.)

--
nosy: +jsjgruber

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



[issue13427] string comparison with ==

2011-11-18 Thread Ezio Melotti

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

Nope, str.strip only strips whitespace, and \x00 is not considered whitespace:
 '\x00'.isspace()
False

--
nosy: +ezio.melotti
resolution: works for me - invalid

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



[issue13294] http.server: HEAD request should not return a body

2011-11-18 Thread Michele Orrù

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

As Ezio just pointed out, strip('\r\n') is still behaves differently from the 
previous code. Sorry for that.

--

___
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



[issue13420] newer() function in dep_util.py discard changes in the same second

2011-11-18 Thread David Amian

David Amian dam...@emergya.com added the comment:

sorry, I didn't explain well.
I've a project, in the setup.py file, I've a function called update_prefix, 
that updates the 'path_project' variable with prefix arguments from setup.py
If you runs setup.py with --prefix=/usr, then the file in 
'projectname/projectnameconfig.py' is modified changing the 'path_project' 
variable from @PREFIX@+share/projectname to '/usr/share/projectname'.
If you runs setup.py without prefix arguments, the prefix is '/usr/local'.

Debuild which is the tool used to build debian package, in this case using 
CDBS, gives this output:
it first runs:
...
python setup.py build \
--build-base=/tmp/buildd/pdal2-0.3.1/./build
running build
running build_py
creating /tmp/buildd/pdal2-0.3.1/build
creating /tmp/buildd/pdal2-0.3.1/build/lib.linux-i686-2.7
creating /tmp/buildd/pdal2-0.3.1/build/lib.linux-i686-2.7/pdal
copying pdal/utils.py - /tmp/buildd/pdal2-0.3.1/./build/lib.linux-i686-2.7/pdal
copying pdal/pdalconfig.py - 
/tmp/buildd/pdal2-0.3.1/./build/lib.linux-i686-2.7/pdal
...
then it runs:
...
cd .  \
python setup.py install \
--root=/tmp/buildd/pdal2-0.3.1/debian/pdal2/ \
--install-purelib=/usr/lib/python2.7/site-packages/ \
--prefix=/usr --no-compile -O0 --install-layout=deb 
running install
running build
running build_py
running build_scripts

It doesn't copy pdal/pdalconfig.py becouse the file in 
/tmp/buildd/pdal2-0.3.1/./build/lib.linux-i686-2.7/pdal have the same st_mtime 
in seconds than pdal/pdalconfig.py, but if you see de st_mtime, both are 
different in millisec and the file is different.

 File: «pdal/pdalconfig.py»
Modify: 2011-11-16 11:55:52.665727826 +0100

File: «/tmp/buildd/pdal2-0.3.1/./build/lib.linux-i686-2.7/pdal/pdalconfig.py»
Modify: 2011-11-16 11:55:52.0 +0100

but if you print the st_mtime of both files within newer() function you can 
check the file's timestamp are the same when they are really not:
ST_MTIME-source-target-1321440952-1321440952

That is cause of the issue, that I explain in the early comment, I fixed it 
rounding to two decimals instead of rounding to integer.

--

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



[issue13426] Typos in pickle docs

2011-11-18 Thread Éric Araujo

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

 Regarding the output, I don't think is necessary to add it.
 I left it in because of a discussion in core-mentorship, where they
 mentioned that it would be beneficial to have it in.

Well, people can have diverging opinions.  Terry’s was that “having the output, 
perhaps in a separate box, will also help to analyze the code to understand 
it”, but Ezio judged that “the example is fairly complex, so people that need 
it will probably have to try it and experiment a bit anyway”.  I think I agree 
with Ezio.

--
nosy: +terry.reedy
title: The Python Standard Library  11. Data Persistence - Typos in pickle 
docs

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



[issue13424] Add examples for open’s new opener argument

2011-11-18 Thread Ross Lagerwall

Changes by Ross Lagerwall rosslagerw...@gmail.com:


--
nosy: +rosslagerwall

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



[issue12779] Update packaging documentation

2011-11-18 Thread Éric Araujo

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

I worked on this a bit more and the current boring diff has more than 1000 
deleted lines and more than 1000 added lines.  After thinking about it, maybe I 
should not make a mega-patch with markup/boring changes first but rather fix 
markup as part of more consistent wording and reorganization changes.  The 
series of changesets could look like this:

- Update and improve Doc/install (the end-user guide, a few files)
- Update and improve the commands reference in Doc/packaging
- Improve introduction material in Doc/packaging
- Fix X in Doc/library/packaging.foo
- Add missing doc for packaging.spam in Doc/library
- etc.

I think that will make more sense to review.

--

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



[issue13420] newer() function in dep_util.py discard changes in the same second

2011-11-18 Thread Éric Araujo

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

 I've a project, in the setup.py file, I've a function called update_prefix, 
 that updates the
 'path_project' variable with prefix arguments from setup.py
 If you runs setup.py with --prefix=/usr, then the file in 
 'projectname/projectnameconfig.py' is
 modified changing the 'path_project' variable from 
 @PREFIX@+share/projectname to
 '/usr/share/projectname'. If you runs setup.py without prefix arguments, the 
 prefix is '/usr/local'.

Did you write a custom 'install' class or are you for example looking at 
sys.argv to decide whether to run your function?  If it’s not implemented as a 
distutils command, it’s not surprising that it does not integrate well.

 [...]
 That is cause of the issue, that I explain in the early comment, I fixed it 
 rounding to two decimals
 instead of rounding to integer.

Okay.  Can you make sure that this is the source of the problem, for example by 
adding time.sleep(1) between build and install?

--

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



[issue4442] document immutable type subclassing via __new__

2011-11-18 Thread Éric Araujo

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


--
nosy: +eric.araujo

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



[issue4395] Document auto __ne__ generation; provide a use case for non-trivial __ne__

2011-11-18 Thread Éric Araujo

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


--
nosy: +eric.araujo

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



[issue13322] buffered read() and write() does not raise BlockingIOError

2011-11-18 Thread sbt

sbt shibt...@gmail.com added the comment:

 Thanks again. Just a nit: the tests should be in MiscIOTest, since 
 they don't directly instantiate the individual classes. Also, perhaps 
 it would be nice to check that the exception's errno attribute is 
 EAGAIN.


Done.

--
Added file: http://bugs.python.org/file23724/write_blockingioerror.patch

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



[issue13388] document hg commit hooks in the devguide

2011-11-18 Thread Éric Araujo

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

 The commit details (including its changeset, branch and commit message)

In Mercurial terminology, a changeset *is* a commit (or if you really want to 
make a distinction, a commit is the action that creates a changeset).  I think 
you meant “diff”.  Moreover, only the first line of the commit message is 
added, which is IMO worth mentioning.  Finally, I think we should recommend the 
“#12345” style: For one thing, it makes our hgweb application create links.

--

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



[issue13343] Lambda keyword-only argument not updating co_freevars

2011-11-18 Thread Éric Araujo

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

 It's made my day. I get to boast at school now!
You could do more of that if you got a patch committed!  See 
http://docs.python.org/devguide and 
http://mail.python.org/mailman/listinfo/core-mentorship for more info if you’re 
interested.

--
nosy: +eric.araujo

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



[issue13292] missing versionadded for bytearray

2011-11-18 Thread Éric Araujo

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

Thanks for cleaning up the reports.  I’m not a numbers person :)

--

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



[issue4147] xml.dom.minidom toprettyxml: omit whitespace for text-only elements

2011-11-18 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 7262f8f276ff by Ezio Melotti in branch '2.7':
#4147: minidom's toprettyxml no longer adds whitespace around a text node when 
it is the only child of an element.  Initial patch by Dan Kenigsberg.
http://hg.python.org/cpython/rev/7262f8f276ff

New changeset 5401daa96a21 by Ezio Melotti in branch '3.2':
#4147: minidom's toprettyxml no longer adds whitespace around a text node when 
it is the only child of an element.  Initial patch by Dan Kenigsberg.
http://hg.python.org/cpython/rev/5401daa96a21

New changeset cb6614e3438b by Ezio Melotti in branch 'default':
#4147: merge with 3.2.
http://hg.python.org/cpython/rev/cb6614e3438b

--

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



  1   2   >