[issue5672] Implement a way to change the python process name

2009-12-06 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

> I've just tested it and it works fine here... Any possibility this
> module can be included in the regular python standard library, in the
> future?

Only in the far future. I don't think the Python standard library should
include a module whose version number is 0.2.

I propose to close this issue as "won't fix", with reference to the
external setproctitle module.

--

___
Python tracker 

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



[issue4111] Add DTrace probes

2009-12-06 Thread Mark Wielaard

Changes by Mark Wielaard :


--
nosy: +mjw

___
Python tracker 

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



[issue7449] A number tests "crash" if python is compiled --without-threads

2009-12-06 Thread Jerry Seutter

Changes by Jerry Seutter :


--
assignee:  -> jseutter
nosy: +jseutter

___
Python tracker 

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



[issue5672] Implement a way to change the python process name

2009-12-06 Thread Marcelo Fernández

Marcelo Fernández  added the comment:

2009/12/6 Daniele Varrazzo :
>
> Just released setproctitle 0.2 where I also call prctl() if available.
> It is actually the string used by killall.

Great!

I've just tested it and it works fine here... Any possibility this
module can be included in the regular python standard library, in the
future?

Thanks!

--

___
Python tracker 

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



[issue5672] Implement a way to change the python process name

2009-12-06 Thread Daniele Varrazzo

Daniele Varrazzo  added the comment:

> It seems that some utilities and programs (killall,
> gnome-system-monitor, and so on) looks for the process name in
> /proc/PID/status, not in /proc/PID/cmdline, so it should be better
> (in Linux), to modify both, /proc/PID/cmdline (changing argv) *and*
> /proc/PID/status (calling prctl()).

> I installed py-setproctitle, and can't kill it with killall once I 
> set the name to "hello", for example. :-(

Just released setproctitle 0.2 where I also call prctl() if available. 
It is actually the string used by killall.

>> For what I observed, clobbering argv changes what shown in
>> ``/proc/PID/cmdline``, whereas prctl changes what can be read in
>> ``/proc/PID/status`` (and ``stat`` too). ``ps`` uses the former, 
but
>> switches to the latter when calling ``ps a`` and ``ps f``. ``top``
>> toggles between the two pressing ``c``.

> Sorry, but here (Ubuntu 9.10) it works the other way around: "ps"
> lists the /proc/PID/status -> name field and "ps a" lists the
> /proc/PID/cmdline. But I got the explanation. :-)

Yup, sorry: it was the other way round :P

--

___
Python tracker 

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



[issue6472] Inconsistent use of "iterator" in ElementTree doc & diff between Py and C modules

2009-12-06 Thread flox

flox  added the comment:

I fixed it differently, using the upstream modules (Thank you Fredrik).
 * ElementTree 1.3a3-20070912
 * cElementTree 1.0.6-20090110

It works.
And it closes issue1143, too.

--
Added file: http://bugs.python.org/file15468/issue6472_upstream.diff

___
Python tracker 

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-06 Thread R. David Murray

R. David Murray  added the comment:

Patch actually attached this time.

--
Added file: http://bugs.python.org/file15467/test_imaplib_issue5949.patch

___
Python tracker 

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-06 Thread R. David Murray

R. David Murray  added the comment:

The traceback I posted was a spurious result of my misunderstanding your
test code.  With -uall it worked fine.  Sorry that I didn't make that clear.

Thanks for doing the work of putting the extended test framework
together.  Without that, this would probably have remained stuck.

I don't think the test_socketserver code is a particularly good example
of unittest code, though, so I refactored what you did into something I
like better.  I may be wrong, so feedback welcome.

Alternative test_imaplib patch attached.

Note that in looking at this I discovered that the test suite as a whole
does not currently handle --without-threads cleanly.  I've opened issue
7449 for this.  Since test_imaplib currently only has one
non-thread-dependent test, I've written my version of the patch so that
the whole test is skipped if threading is not available (this skip will
come with an appropriate message in the test output).

Note also that my code generates a traceback analogous to the one I
posted but only when run under -R.  I'll have to look in to that.

--
assignee:  -> r.david.murray

___
Python tracker 

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



[issue5672] Implement a way to change the python process name

2009-12-06 Thread Marcelo Fernández

Marcelo Fernández  added the comment:

2009/12/6 Daniele Varrazzo :
>> My question is because I think there's a better and supported method
> for
>> Linux, that is, using prctl [1]. I read somewhere that changing argv
>> causes some inconsistencies between programs who read /sys files,
> /proc
>> files... or I don't remember what, but it is, in fact, not the
>> *recommended* way. Prctl is. :-)
>
> This is interesting: do you have any reference?

For example, take a look at the comments here:
http://abock.org/2006/02/09/changing-process-name-in-mono

It seems that some utilities and programs (killall,
gnome-system-monitor, and so on) looks for the process name in
/proc/PID/status, not in /proc/PID/cmdline, so it should be better (in
Linux), to modify both, /proc/PID/cmdline (changing argv) *and*
/proc/PID/status (calling prctl()).

I installed py-setproctitle, and can't kill it with killall once I set
the name to "hello", for example. :-(

[1]+  Detenidopython
marc...@marcelo-laptop:~/src/py-setproctitle$ ps a
  PID TTY  STAT   TIME COMMAND
 1030 tty4 Ss+0:00 /sbin/getty -8 38400 tty4
 1033 tty5 Ss+0:00 /sbin/getty -8 38400 tty5
 1049 tty2 Ss+0:00 /sbin/getty -8 38400 tty2
 1050 tty3 Ss+0:00 /sbin/getty -8 38400 tty3
 1052 tty6 Ss+0:00 /sbin/getty -8 38400 tty6
 1349 tty7 Ss+   17:14 /usr/bin/X :0 -br -verbose -auth
/var/run/gdm/auth-for-gdm-XhETSO/database -nolisten tcp vt7
 2225 tty1 Ss+0:00 /sbin/getty -8 38400 tty1
10344 pts/0Ss+0:00 /bin/bash -l
11923 pts/1Ss 0:00 bash
12068 pts/2Ss+0:00 bash
12485 pts/1T  0:00 hello
12496 pts/1R+ 0:00 ps a
marc...@marcelo-laptop:~/src/py-setproctitle$ killall hello
hello: proceso no encontrado

Another example: The gnome-system-monitor still lists the 'hello'
process (PID 12485) like 'python'. So we should try

> I've tested with the difference between clobbering argv and call
> prctl: two demo programs are in the tools directory of the module
> project [2].
>
> For what I observed, clobbering argv changes what shown in
> ``/proc/PID/cmdline``, whereas prctl changes what can be read in
> ``/proc/PID/status`` (and ``stat`` too). ``ps`` uses the former, but
> switches to the latter when calling ``ps a`` and ``ps f``. ``top``
> toggles between the two pressing ``c``.

Sorry, but here (Ubuntu 9.10) it works the other way around: "ps"
lists the /proc/PID/status -> name field and "ps a" lists the
/proc/PID/cmdline. But I got the explanation. :-)

> I think is probably better to have both strings updated: I'd prefer
> this behavior instead of the title being set in different places on
> different Linux versions.

IMHO, I'd prefer both things: to change the argv array *and* calling
prctl() if possible (Linux >2.6.9). If Linux is lower than 2.6.9,
fallback to change argv only.

Regards
-- 
Marcelo F. Fernández
Buenos Aires, Argentina
Licenciado en Sistemas - CCNA

E-Mail: marcelo.fidel.fernan...@gmail.com
Blog: http://blog.marcelofernandez.info
Twitter: http://twitter.com/fidelfernandez

--

___
Python tracker 

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



[issue5672] Implement a way to change the python process name

2009-12-06 Thread Daniele Varrazzo

Daniele Varrazzo  added the comment:

> I'm taking a look at it, and it seems to use setproctitle() in BSD, 
and 
> writes over the argv array "in most Sys-V like systems"; this 
includes 
> Linux?

Yes: Linux uses what in the source is referred as the 
PS_USE_CLOBBER_ARGV strategy: it writes over the area pointed by argv 
and by environ (after checked they are contiguous and moved away). 
Sounds scary, but I've tested that environ keeps working fine (the 
environ can be modified and forked processes receive the correct 
environment).

> My question is because I think there's a better and supported method 
for 
> Linux, that is, using prctl [1]. I read somewhere that changing argv 
> causes some inconsistencies between programs who read /sys files, 
/proc 
> files... or I don't remember what, but it is, in fact, not the 
> *recommended* way. Prctl is. :-)

This is interesting: do you have any reference?

I've tested with the difference between clobbering argv and call 
prctl: two demo programs are in the tools directory of the module 
project [2].

For what I observed, clobbering argv changes what shown in 
``/proc/PID/cmdline``, whereas prctl changes what can be read in 
``/proc/PID/status`` (and ``stat`` too). ``ps`` uses the former, but 
switches to the latter when calling ``ps a`` and ``ps f``. ``top`` 
toggles between the two pressing ``c``.

I don't know which method is better (well, I happen to prefer the 
extended visualization provided by the cmdline, which natively shows 
more detail than just the process name shown in ``status`` but this is 
probably subjective).

> Could this module be altered to use a prctl call in Linux (>2.6.9)?

I think is probably better to have both strings updated: I'd prefer 
this behavior instead of the title being set in different places on 
different Linux versions.

[2] http://code.google.com/p/py-setproctitle/source/browse/tools/

--

___
Python tracker 

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



[issue7449] A number tests "crash" if python is compiled --without-threads

2009-12-06 Thread R. David Murray

New submission from R. David Murray :

In the past (<= 2.6) regrtest skipped a test if any import failure
happened, which masked various real test failures.  This was fixed, and
tests that should be skipped if certain modules are not available were
changed to use (test_)support.import_module, which causes a skip if that
particular module cannot be imported.

If python is compiled --without-threads, then the following tests
currently 'crash' because they cannot import thread and/or threading:

test_hashlib test_asyncore test_wait3 test_threading test_socket
test_wait4 test_capi test_xmlrpc test_ctypes
test_zipimport_support test_threading_local test_multiprocessing
test_file2k test_smtplib test_threadedtempfile test_threadsignals
test_thread test_queue test_asynchat test_contextlib
test_bz2 test_ftplib test_cmd test_pdb test_io test_doctest
test_sqlite test_logging test_telnetlib test_threaded_import
test_httpservers test_fork1 test_docxmlrpc test_urllib2_localnet
test_poplib test_socketserver

All of these tests should either be changed to use import_module when
importing thread/threading, or changed so that the tests requiring
thread support are skipped if thread support is not available.

Note that test_bsddb3 also fails, but it is not an import error crash.

--
components: Tests
keywords: easy
messages: 96035
nosy: r.david.murray
priority: low
severity: normal
stage: needs patch
status: open
title: A number tests "crash" if python is compiled --without-threads
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2

___
Python tracker 

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



[issue1771] Remove cmp parameter to list.sort() and builtin.sorted()

2009-12-06 Thread Mark Dickinson

Mark Dickinson  added the comment:

Ah.  Thanks for the explanation;  I see your point.  I guess you do just 
have to use a CmpToKey-type wrapper for this sort of comparison.

Though for this *particular* example, it seems to me that you could still use a 
key function

lambda q: (q[0] - p[0])/(q[1]-p[1]),

which would be even more efficient.  This is assuming that your extreme 
point p has minimal second coordinate amongst points being sorted, which 
as I understand it is how the Graham Scan typically starts.  There's the 
minor difficulty of dealing with points with the *same* second coordinate 
as p, where I guess the key value should be some form of +Infinity.  I can 
also see that this might be problematic if you're working with a type 
that's exact for addition and multiplication but not for division (e.g., 
Decimal with unbounded precision).

It would be interesting to see some relative timings for the sort stage of 
the Graham scan (on a million random points, say): key function versus cmp 
function.

--

___
Python tracker 

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



[issue5672] Implement a way to change the python process name

2009-12-06 Thread Marcelo Fernández

Marcelo Fernández  added the comment:

Great, piro!

I'm taking a look at it, and it seems to use setproctitle() in BSD, and 
writes over the argv array "in most Sys-V like systems"; this includes 
Linux?

My question is because I think there's a better and supported method for 
Linux, that is, using prctl [1]. I read somewhere that changing argv 
causes some inconsistencies between programs who read /sys files, /proc 
files... or I don't remember what, but it is, in fact, not the 
*recommended* way. Prctl is. :-)

PR_SET_NAME and PR_GET_NAME parameters in prctl.h:
[1] http://www.kernel.org/doc/man-pages/online/pages/man2/prctl.2.html

Could this module be altered to use a prctl call in Linux (>2.6.9)?

Thanks a lot.

--

___
Python tracker 

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



[issue7448] when piping output between subprocesses some fd is left open blocking forever

2009-12-06 Thread Clovis Fabricio

New submission from Clovis Fabricio :

Suppose I want to simulate the following shell pipe using the subprocess
module:

`grep -v not | cut -c 1-10`

The documentation example here
http://docs.python.org/library/subprocess.html#replacing-shell-pipeline
Implies that I want to run this:

grep_process = Popen(["grep", "-v", "not"], stdin=PIPE, stdout=PIPE)
cut_process = Popen(["cut", "-c", "1-10"], stdin=p1.stdout, stdout=PIPE)
grep_process.stdin.write('Hello World\n')
grep_process.stdin.close()
result = cut_process.stdout.read() # blocks forever here
assert result == "Hello Worl\n"

When grep_prcoess starts, two file descriptors are created, one 
for each end of the pipe. Lets call those `grep-stdin-w` and
`grep-stdout-r`.
When I run cut_process, `grep-stdout-r` gets passed as cut_process sdtin. 
Since `close_fds=False` by default, The effect of that is that
cut_process also 
inherits `grep-stdin-w`. So `grep` can't die even if I explicty run
`grep_process.stdin.close()`
because `grep-stdin-w` stdin is still inside cut_process (`cut` ignores
the extra open fd).

Passing `close_fds=True` to the second Popen call makes the code work
perfectly.
`close_fds=True` should be the default on unix systems, because it
closes files descriptors that have nothing to do with the process, leaving
stdin, stdout and stderr working, which is the intended behaviour of
most code.

--
components: Library (Lib)
messages: 96032
nosy: nosklo
severity: normal
status: open
title: when piping output between subprocesses some fd is left open blocking 
forever
type: behavior
versions: Python 2.7, Python 3.2

___
Python tracker 

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-06 Thread Scott Dial

Scott Dial  added the comment:

Thanks for giving it a try. I believe the issue is that I am raising an
exception in the middle of run_server, which was not a pattern tested in
the other modules I looked at. Thus, the threads for those do not get
reaped correctly.

I have rewrote the test to ensure all of the spawned threads and servers
are shutdown correctly.

--
Added file: http://bugs.python.org/file15466/test_imaplib-r76683-2.patch

___
Python tracker 

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



[issue3871] cross and native build of python for mingw32 with distutils

2009-12-06 Thread Roumen Petrov

Changes by Roumen Petrov :


Added file: http://bugs.python.org/file15465/python-trunk-20091206-MINGW.patch

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



[issue3754] minimal cross-compilation support for configure

2009-12-06 Thread Roumen Petrov

Changes by Roumen Petrov :


Added file: http://bugs.python.org/file15464/python-trunk-20091206-CROSS.patch

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-06 Thread R. David Murray

R. David Murray  added the comment:

Ah, my mistake, I misread the code, sorry.

Yes, if I supply -uall to regrtest the tests run correctly.

--

___
Python tracker 

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-06 Thread R. David Murray

R. David Murray  added the comment:

OK, after adding ThreadedNetworkedTests to the 'tests' list in
test_main, the new tests ran and did hang.  After applying the imaplib
patch, the new tests completed.  However, afterward I got the following
traceback:

Exception in thread Thread-6 (most likely raised during interpreter
shutdown):
Traceback (most recent call last):
  File "/home/rdmurray/python/trunk/Lib/threading.py", line 526, in
__bootstrap_inner
  File "/home/rdmurray/python/trunk/Lib/threading.py", line 479, in run
  File "/home/rdmurray/python/trunk/Lib/SocketServer.py", line 583, in
process_request_thread
  File "/home/rdmurray/python/trunk/Lib/test/test_imaplib.py", line 82,
in handle_error
  File "/home/rdmurray/python/trunk/Lib/SocketServer.py", line 434, in
server_close
  File "/home/rdmurray/python/trunk/Lib/socket.py", line 192, in close
: 'NoneType' object is not callable

--

___
Python tracker 

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-06 Thread Scott Dial

Scott Dial  added the comment:

The test requires regrtest.py be run with network support and the python
instance be built with threads.

$ ./python Lib/test/regrtest.py -u network test_imaplib

Without network support, it just skips those test (which is the same way
test_ssl). That seemed a bit fishy to me, but I was just emulating what
I saw.

--

___
Python tracker 

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-06 Thread R. David Murray

R. David Murray  added the comment:

Ah, your new test isn't being run, that's why test_impalib passes.  Let
me figure out why your test isn't run.

--

___
Python tracker 

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



[issue1771] Remove cmp parameter to list.sort() and builtin.sorted()

2009-12-06 Thread Tom Switzer

Tom Switzer  added the comment:

Mark: I think your example actually helps illustrate my point. My point was
that computing the angle directly is less efficient or not as nice
numerically. For instance, if you are sorting points by angle relative to an
extreme point you could do something like this (a first step in the Graham
Scan) - be prepared for non-Python 3.0 code ;)

from functools import partial
from random import random

def turn(p, q, r):
"""Return -1, 0, or 1 if p,q,r forms a right, straight, or left turn
respectively."""
return cmp((q[0] - p[0])*(r[1] - p[1]) - (r[0] - p[0])*(q[1] - p[1]), 0)

pts = [(random(), random()) for i in xrange(10)]
i = min(xrange(len(pts)), key=lambda i: pts[i])
p = pts.pop(i)
pts.sort(cmp=partial(turn, p))

Here our comparison function requires only 2 multiplications and 5
additions/subtractions. This function is nice especially if you are using
arbitrary precision or rational numbers as it is exact.

On Sun, Dec 6, 2009 at 6:57 AM, Mark Dickinson wrote:

>
> Mark Dickinson  added the comment:
>
> Tom, I think I'm missing your point:  all three of the examples you give
> seem like perfect candidates for a key-based sort rather than a
> comparison-based one.  For the first example, couldn't you do something
> like:
>
> def direction(pt1, pt2):
>"""angle of line segment from point 1 to point 2"""
>return atan2(pt2.y - pt1.y, pt2.x - pt1.x)
>
> my_points.sort(key=lambda pt: direction(reference_pt, pt))
>
> ? How would having a cmp keyword argument make this any easier or
> simpler?
>
>
> Here's the best example I can think of for which key-based sorting is
> problematic:  imagine that the Decimal type doesn't exist, and that you
> have triples (sign, coefficient_string, exponent) representing
> arbitrary-precision base 10 floating-point numbers.  It's fairly tricky
> to come up with a key function that maps these triples to some existing
> ordered type, so that they can be sorted in natural numerical order.
> The problem lies in the way that the sort order for the coefficient
> string and exponent depends on the value of the sign (one way for
> positive numbers, reversed for negative numbers). But it's not a big
> deal to define a wrapper for cases like this.
>
> --
> nosy: +mark.dickinson
>
> ___
> Python tracker 
> 
> ___
>

--
Added file: http://bugs.python.org/file15463/unnamed

___
Python tracker 

___Mark: I think your example actually helps illustrate my point. My point was 
that computing the angle directly is less efficient or not as nice numerically. 
For instance, if you are sorting points by angle relative to an extreme point 
you could do something like this (a first step in the Graham Scan) - be 
prepared for non-Python 3.0 code ;)
from functools import partialfrom random import randomdef 
turn(p, q, r):    """Return -1, 0, or 1 if p,q,r forms a 
right, straight, or left turn respectively."""    return 
cmp((q[0] - p[0])*(r[1] - p[1]) - (r[0] - p[0])*(q[1] - p[1]), 0)
pts = [(random(), random()) for i in xrange(10)]i = 
min(xrange(len(pts)), key=lambda i: pts[i])p = 
pts.pop(i)pts.sort(cmp=partial(turn, p))Here our comparison 
function requires only 2 multiplications and 5 additions/subtractions. This 
function is nice especially if you are using arbitrary precision or rational 
numbers as it is exact.
On Sun, Dec 6, 2009 at 6:57 AM, Mark Dickinson 
rep...@bugs.python.org> 
wrote:

Mark Dickinson dicki...@gmail.com> added the 
comment:

Tom, I think I'm missing your point:  all three of the examples you 
give
seem like perfect candidates for a key-based sort rather than a
comparison-based one.  For the first example, couldn't you do something
like:

def direction(pt1, pt2):
    """angle of line segment from point 1 to point 
2"""
    return atan2(pt2.y - pt1.y, pt2.x - pt1.x)

my_points.sort(key=lambda pt: direction(reference_pt, pt))

? How would having a cmp keyword argument make this any easier or
simpler?


Here's the best example I can think of for which key-based sorting is
problematic:  imagine that the Decimal type doesn't exist, and that you
have triples (sign, coefficient_string, exponent) representing
arbitrary-precision base 10 floating-point numbers.  It's fairly tricky
to come up with a key function that maps these triples to some existing
ordered type, so that they can be sorted in natural numerical order.
The problem lies in the way that the sort order for the coefficient
string and exponent depends on the value of the sign (one way for
positive numbers, reversed for negative numbers). But it's not a big
deal to define a wrapper for cases like this.

--
nosy: +mark.dickinson

___
Pyt

[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-06 Thread R. David Murray

R. David Murray  added the comment:

With just the test patch applied, test_imaplib passes for me on trunk
r76687.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue1771] Remove cmp parameter to list.sort() and builtin.sorted()

2009-12-06 Thread Mark Dickinson

Mark Dickinson  added the comment:

Tom, I think I'm missing your point:  all three of the examples you give 
seem like perfect candidates for a key-based sort rather than a 
comparison-based one.  For the first example, couldn't you do something 
like:

def direction(pt1, pt2):
"""angle of line segment from point 1 to point 2"""
return atan2(pt2.y - pt1.y, pt2.x - pt1.x)

my_points.sort(key=lambda pt: direction(reference_pt, pt))

? How would having a cmp keyword argument make this any easier or 
simpler?


Here's the best example I can think of for which key-based sorting is 
problematic:  imagine that the Decimal type doesn't exist, and that you 
have triples (sign, coefficient_string, exponent) representing 
arbitrary-precision base 10 floating-point numbers.  It's fairly tricky 
to come up with a key function that maps these triples to some existing 
ordered type, so that they can be sorted in natural numerical order.  
The problem lies in the way that the sort order for the coefficient 
string and exponent depends on the value of the sign (one way for 
positive numbers, reversed for negative numbers). But it's not a big 
deal to define a wrapper for cases like this.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue6472] Inconsistent use of "iterator" in ElementTree doc & diff between Py and C modules

2009-12-06 Thread flox

Changes by flox :


Added file: http://bugs.python.org/file15462/issue6472_py3k.diff

___
Python tracker 

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



[issue6472] Inconsistent use of "iterator" in ElementTree doc & diff between Py and C modules

2009-12-06 Thread flox

flox  added the comment:

Proposed patch fixes most of the discrepancies between both implementations.

It restores some features that were lost with Python 3:
 * cElement slicing and extended slicing
 * iterparse, cET.getiterator and cET.findall return an iterator
   (as documented)

Some tests were added to check these issues.

--
keywords: +patch
Added file: http://bugs.python.org/file15461/issue6472.diff

___
Python tracker 

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



[issue1923] meaningful whitespace can be lost in rfc822_escape

2009-12-06 Thread Tarek Ziadé

Tarek Ziadé  added the comment:

I will treat the empty line problem in another issue because I won't
apply it in 2.6/3.1.

This one is fixed in r76684, r76685, r76686, r76687.

Thanks !

--
status: open -> closed
versions: +Python 2.6, Python 2.7, Python 3.1, Python 3.2 -Python 2.5

___
Python tracker 

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



[issue7447] Sum() doc and behavior mismatch

2009-12-06 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: georg.brandl -> rhettinger
nosy: +rhettinger

___
Python tracker 

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