[issue6550] asyncore incorrect failure when connection is refused and using async_chat channel

2009-07-31 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


--
nosy: +giampaolo.rodola

___
Python tracker 

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



[issue6611] HTMLParser cannot deal with mixture of arbitrary data and character reference

2009-07-31 Thread Liu DongMiao

New submission from Liu DongMiao :

HTMLParser (Python 2.6.2) Cannot deal with mixture of arbitrary data and
character reference. 

In line 365-373, replaceEntities(s) returns unichr(charref) in unicode,
which cannot be a mixture with arbitrary data in str.

A fix way: replace unichr(c) with unichr(c).encode('utf-8').

--
components: Library (Lib)
files: chinese.py
messages: 91128
nosy: liudongm...@gmail.com
severity: normal
status: open
title: HTMLParser cannot deal with mixture of arbitrary data and character 
reference
type: compile error
versions: Python 2.6
Added file: http://bugs.python.org/file14613/chinese.py

___
Python tracker 

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



[issue6612] 'import site' fails when called from an unlinked directory

2009-07-31 Thread W. Trevor King

New submission from W. Trevor King :

I don't imagine this comes up very often, but:

$ mkdir /tmp/a; cd /tmp/a; rmdir /tmp/a; python -c 'import site';
rmdir: removing directory, /tmp/a
'import site' failed; use -v for traceback
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/wking/lib/python/site.py", line 73, in 
__boot()
  File "/home/wking/lib/python/site.py", line 33, in __boot
imp.load_module('site',stream,path,descr)
  File "/usr/lib/python2.5/site.py", line 408, in 
main()
  File "/usr/lib/python2.5/site.py", line 392, in main
paths_in_sys = removeduppaths()
  File "/usr/lib/python2.5/site.py", line 96, in removeduppaths
dir, dircase = makepath(dir)
  File "/usr/lib/python2.5/site.py", line 72, in makepath
dir = os.path.abspath(os.path.join(*paths))
  File "/usr/lib/python2.5/posixpath.py", line 403, in abspath
path = join(os.getcwd(), path)
OSError: [Errno 2] No such file or directory

--
messages: 91129
nosy: labrat
severity: normal
status: open
title: 'import site' fails when called from an unlinked directory
versions: Python 2.5

___
Python tracker 

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



[issue5093] 2to3 with a pipe on non-ASCII script

2009-07-31 Thread Matthew Barnett

Matthew Barnett  added the comment:

I'd like to suggest that it the output could/should be encoded in UTF-8.

--
nosy: +mrabarnett

___
Python tracker 

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



[issue6613] ctypes.PyThreadState_SetAsyncExc does not work on linux 64bit machines

2009-07-31 Thread Tiago Coutinho

New submission from Tiago Coutinho :

Hello,

It seems that the ctypes.PyThreadState_SetAsyncExc is not working in
Linux 64bits machines

I have tried the code in attachment in python 2.5 and 2.6 in both 32bits
and 64bits machines with the following return:

  | linux 32bits | linux 64bits |
--|--|--|
py2.5 | 1 (OK)   | 0 (ERR)  |
py2.6 | 1 (OK)   | 0 (ERR)  |

I have also tried to make a python extension in C++ exporting a function
to python that simply calls the C++ PyThreadState_SetAsyncExc and this
works fine.

--
assignee: theller
components: ctypes
files: t16.py
messages: 91131
nosy: coutinhotiago, theller
severity: normal
status: open
title: ctypes.PyThreadState_SetAsyncExc does not work on linux 64bit machines
type: behavior
versions: Python 2.5, Python 2.6
Added file: http://bugs.python.org/file14614/t16.py

___
Python tracker 

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



[issue6613] ctypes.PyThreadState_SetAsyncExc does not work on linux 64bit machines

2009-07-31 Thread Thomas Heller

Thomas Heller  added the comment:

I have no time to figure out what the attached script is supposed to do.
 Please provide a standalone test-script and describe exactly how it
should be used to reproduce the bug.

However, I guess the problem is that the signature of
PyThreadState_SetAsyncEx is this:
  int PyThreadState_SetAsyncExc( long id, PyObject *exc)

To call this function correctly on a 64-bit system you have to set
argtypes because 'long' isn't the same as 'int' any longer.  Without
argtypes, ctypes passes a Python integer as 'int' argument.

--

___
Python tracker 

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



[issue6595] Make Decimal constructor accept all unicode decimal digits in input.

2009-07-31 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

I like the str(int(...))  approach because it guarantees handling that
is consistent with other types.

--

___
Python tracker 

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



[issue6614] heapq.nsmallest and nlargest should be smarter/more usable/more consistent

2009-07-31 Thread Joshua Bronson

New submission from Joshua Bronson :

>From http://docs.python.org/library/heapq.html:
> The latter two functions (nlargest and nsmallest) perform best for
> smaller values of n. For larger values, it is more efficient to use
> the sorted() function. Also, when n==1, it is more efficient to use
> the builtin min() and max() functions.

A quick usability win for the heapq module: Be more specific than "smaller" and 
"larger", e.g. "when n is O(...(len(iterable)))".

>From http://groups.google.com/group/comp.lang.python/msg/9556f56ae25ecf3b:
> I find it interesting that the heapq functions tell you in the
> documentation that they aren't suitable for use where n==1 or where
> n is near the total size of the sequence whereas random.sample()
> chooses what it thinks is the best algorithm based on the input. At
> the very least I would have thought the heapq functions could check
> for n==1 and call min/max when it is.

+1. It looks like the pure Python implementation of nsmallest is actually 
already 
choosing either an insort algorithm or a minheap algorithm based on whether n * 
10 <= 
len(iterable), but the C implementation of nsmallest unconditionally uses a 
minheap 
algorithm. Neither the pure Python nor the C implementation of nlargest chooses 
its 
algorithm conditionally. For the sake of consistency and usability, all 
implementations of nsmallest and nlargest should choose the most efficient 
algorithm 
from among min/max, insort, and minheap, and the docs should be updated to 
describe 
this behavior.

Also, in looking through the heapq.py that came with my Python 2.6.2 
distribution, I 
noticed that line 196 seems to have no reason to be there:
_heappushpop = heappushpop  
This is the only occurrence of "_heappushpop" in the file.

I made a patch for heapq.py, but since I'm not a CPython hacker, I thought it 
might 
be better to leave the changes up to someone who could do both the pure Python 
and 
the C implementations in tandem. I'd be happy to contribute documentation when 
the 
time comes if that would help.

--
messages: 91134
nosy: jab
severity: normal
status: open
title: heapq.nsmallest and nlargest should be smarter/more usable/more 
consistent
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1

___
Python tracker 

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



[issue6614] heapq.nsmallest and nlargest should be smarter/more usable/more consistent

2009-07-31 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

FWIW, 2.7 and 3.1 already have automatic selection of sort()/min()/max()
alternatives.  They use pure python to dispatch to the underlying C
functions:

http://svn.python.org/view/python/branches/release31-maint/Lib/heapq.py?revision=73579&view=markup

--
assignee:  -> rhettinger
nosy: +rhettinger
resolution:  -> out of date
status: open -> closed
type: behavior -> performance
versions: +Python 3.2 -Python 2.5, Python 2.6, Python 3.0, Python 3.1

___
Python tracker 

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



[issue5093] 2to3 with a pipe on non-ASCII script

2009-07-31 Thread James Abbatiello

James Abbatiello  added the comment:

In what case(s) do you propose the output to be encoded in UTF-8?  If
output is to a terminal and that terminal is set to Latin-1 or cp437 or
whatever then outputting UTF-8 in that case will only show garbage
characters to the user.

If output is to a file then using the encoding of the input file makes
the most sense to me.  Assume you have a simple program encoded in
Latin-1 that prints out a string with some non-ASCII characters.  The
patch is printed in UTF-8 encoding and redirected to a file.  The patch
program has no idea what encodings are used and it will just compare the
bytes in the original to the bytes in the patch file.  These won't match
since the encodings are different and he patch will fail.

If the output is to a pipe then I'm not sure what the right thing is. 
It may be intended for display on the screen with something like `less`
or it may not.  I don't think there's a good solution for this.

So following the above logic the patch attached here does the following:
1) If output is to a terminal (sys.stdout.encoding is set) then use that
encoding for output
2) Otherwise if an encoding was determined for the input file, use that
encoding for output
3) If all else fails, use 'ascii' encoding.  If the input contained
non-ASCII characters and no encoding has been determined for the input
then this will cause an exception to be raised.  I think this can only
happen when reading the input file from stdin.  Perhaps that case needs
to be looked at for how to detect the encoding of stdin.

--

___
Python tracker 

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



[issue6614] heapq.nsmallest and nlargest should be smarter/more usable/more consistent

2009-07-31 Thread Joshua Bronson

Joshua Bronson  added the comment:

Oh, that's great!

(I also noticed that the previously inutile line "_heappushpop = heappushpop" 
is now doing something in the heapq.py you linked to, nice.)

It looks like the docs haven't been updated yet though. For instance, 
http://docs.python.org/3.1/library/heapq.html still says "The latter two 
functions perform best for smaller values of n. For larger values, it is more 
efficient to use the sorted() function. Also, when n==1, it is more efficient 
to use the builtin min() and max() functions."

Also, I notice the pure Python implementation of nsmallest still does that 
check to see if n * 10 <= len(iterable), and if so uses an insort-based 
algorithm. It looks like this is still undocumented, inconsistent with the C 
implementation, and asymmetrical to the implementations of nlargest. If this 
branch is remaining there on purpose, I'd love see its existence mentioned and 
its theoretical basis explained in the docs, along with any similar branches 
implemented elsewhere in the code, if they should be.

--

___
Python tracker 

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



[issue6614] heapq.nsmallest and nlargest should be smarter/more usable/more consistent

2009-07-31 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

I prefer the docs the way they are.  They help the reader understand the
relationship between min, max, nsmallest, nlargest, and sorted.

I'm not sure where you got the n * 10 <= len(iterable) switch-over
point.  That is arbitrary.  The correct switchover point depends on the
cost of the comparison function, whether the length of the input is
known, whether the input data is partially ordered, memory constraints,
whether a key function is used, and on other factors.   

FWIW, I also wrote the logic for random.sample().  The switchover logic
was straight-forward because performance depended on factors that were
fully known (length of input, sample size, memory utilization, and
average number of probes for each strategy).

--

___
Python tracker 

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



[issue6614] heapq.nsmallest and nlargest should be smarter/more usable/more consistent

2009-07-31 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

One other thought:  When memory is tight, the programmer needs to be
able to select the heap algorithm in favor of sorted() even for
relatively large values of n.  I do not want an automatic switchover
point that takes away a programmer's choice between speed and space
efficiency.

--

___
Python tracker 

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



[issue5093] 2to3 with a pipe on non-ASCII script

2009-07-31 Thread Matthew Barnett

Matthew Barnett  added the comment:

I was thinking that if you're converting a Python 2.x script to Python
3.x using 2to3 then also encoding the new script in UTF-8 might be a
good idea.

--

___
Python tracker 

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



[issue3493] No Backslash (\) in IDLE 1.2.2

2009-07-31 Thread François HOUNDONOUGBO

François HOUNDONOUGBO  added the comment:

Same probleme here with Idle 2.6.2, with a french keyboard.
I finally thought that it was due to a default binding recorded as 
 or :, something like that, which is 
identical to the binding of Backslash character on my keyboard.
So I modified the binding "expand word" (can't remember why this one), 
recorded it under a new key set and applied it. After that, the 
backslash combination worked perfectly!!

But ... the bug now is that if I come back to the default OSX key set, 
it still works ...

(Another detail is that with the Logitech keyboard configuration (usb PC 
keyboard), it works at first try...)

Maybe this workaround will save your afternoon ...

--
nosy: +funnyfrancois

___
Python tracker 

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



[issue6614] heapq.nsmallest and nlargest should be smarter/more usable/more consistent

2009-07-31 Thread Joshua Bronson

Joshua Bronson  added the comment:

> I prefer the docs the way they are.  They help the reader understand
> the relationship between min, max, nsmallest, nlargest, and sorted.

Except that it's no longer true that "when n==1, it is more efficient to use 
the 
builtin min() and max() functions." Shouldn't this be updated to say "when 
n==1, 
it is equivalent to using the builtin min() and max() functions"?

> I'm not sure where you got the n * 10 <= len(iterable) switch-over
> point.

It's right in the file you linked to. Search for "n * 10" in 
http://svn.python.org/view/python/branches/release31-maint/Lib/heapq.py?
revision=73579&view=markup.

> That is arbitrary.  The correct switchover point depends on the
> cost of the comparison function, whether the length of the input is
> known, whether the input data is partially ordered, memory constraints,
> whether a key function is used, and on other factors.   

So should that be removed, then?

> FWIW, I also wrote the logic for random.sample().  The switchover logic
> was straight-forward because performance depended on factors that were
> fully known (length of input, sample size, memory utilization, and
> average number of probes for each strategy).
> One other thought:  When memory is tight, the programmer needs to be
> able to select the heap algorithm in favor of sorted() even for
> relatively large values of n.  I do not want an automatic switchover
> point that takes away a programmer's choice between speed and space
> efficiency.

Agreed, and thanks for the additional info.

--

___
Python tracker 

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



[issue6606] csv.Sniffer.sniff on data with doublequotes doesn't set up the dialect properly

2009-07-31 Thread Thomas W. Barr

Thomas W. Barr  added the comment:

Patch uploaded to rietveld: http://codereview.appspot.com/96202/show

--

___
Python tracker 

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



[issue4606] Passing 'None' if argtype is set to POINTER(...) doesn't always result in NULL

2009-07-31 Thread Thomas Heller

Thomas Heller  added the comment:

Andrew McNabb schrieb:
> I just looked at ConvParam in a little more detail, and it seems that
> the problem is caused because setting pa->value.i to 0 only works for
> the lower-order bits.  Apparently the higher order bits in pa->value are
> non-zero when ConvParam is called.  Would it be possible to zero-out
> pa->value at the top of ConvParam (i.e., putting "bzero(&(pa->value),
> sizeof(pa->value)" or something at the top of ConvParam)?  Am I missing
> something about what's in pa before ConvParam is called?

Zeroing out higher order bits wouldn't help because the parameter would
still be passed as int instead as pointer; see the ffi_type field.

However, after thinking the whole issue over for some time I'm now
convinced that this patch is the right approach; even if .from_param()
returns 'None' instead of '0' the former should be accepted as well
because it better represents a NULL pointer anyway.

So I will apply the patch to trunk and 2.6, and forward port to the
python3 branches.  After further testing.

--
resolution:  -> accepted
versions: +Python 2.7, Python 3.0, 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



[issue4606] Passing 'None' if argtype is set to POINTER(...) doesn't always result in NULL

2009-07-31 Thread Thomas Heller

Thomas Heller  added the comment:

Python 3.0 is dead ;-).

--
versions:  -Python 3.0

___
Python tracker 

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



[issue6614] heapq.nsmallest and nlargest should be smarter/more usable/more consistent

2009-07-31 Thread Joshua Bronson

Joshua Bronson  added the comment:

One more thing:

> I prefer the docs the way they are.  They help the reader understand
> the relationship between min, max, nsmallest, nlargest, and sorted.

The docs still use the unspecific language "for smaller values of n" and 
"for larger values". I think careful readers would appreciate an addition 
along the lines of what you wrote earlier -- the optimal switchover point 
depends on the cost of the comparison function, the ordering of the input 
data, etc.

--

___
Python tracker 

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



[issue6614] heapq.nsmallest and nlargest should be smarter/more usable/more consistent

2009-07-31 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

> Except that it's no longer true that "when n==1, it is
> more efficient to use the builtin min() and max() functions."

There's still the dispatch overhead.
If someone needs a n==1 case, they
*should* use min/max for both speed
and clarity.

Also, it is important the the docs
communicate the relationship between
min/max, nlargest/nsmallest, and sorted.


> It's right in the file you linked to. Search for "n * 10" in ...

That is in the pure python version of nsmallest() and that
code is not used (it is overriden by the C version).  The
actual C implementation works differently -- it uses an
underlying maxheap so it can use a cleaner algorithm that
doesn't need switchover tricks.

If you feel like "kicking the ball around", please continue the
discussion on comp.lang.python -- I think we're done here.

--

___
Python tracker 

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



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

2009-07-31 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
title: Documentation Clarity -> Tutorial clarity: section 4.7.2, parameters and 
arguments

___
Python tracker 

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



[issue6574] List the __future__ features in a table

2009-07-31 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

For Python3, the table should start empty as of 3.0/3.1

--
nosy: +tjreedy

___
Python tracker 

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



[issue6239] c_char_p return value returns string, not bytes

2009-07-31 Thread Thomas Heller

Thomas Heller  added the comment:

Here's a patch.

--
keywords: +patch
Added file: http://bugs.python.org/file14615/c_char_p.patch

___
Python tracker 

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



[issue6580] No deprecation warning for list comprehension leak conflict

2009-07-31 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

2.5 is closed to fixes other than security fixes.
So this needs to be checked with the latest 2.6.

The implementation of new features does not always exactly follow the
PEP. So if there is also no warning in 2.6, the question remains whether
accident or intention. Perhaps it was decided that the warning was too
difficult or that it would make too much noise because some people were
doing this intentionally and would not want the warning, whereas few
people accidentally do the sort of thing your example does.

If this is true, as I sort of suspect, the PEP should be revised not to
mislead.

--
nosy: +tjreedy

___
Python tracker 

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



[issue6584] gzip module has no custom exception

2009-07-31 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Unless something in the docs claims that there is/should be such a
thing, this is a feature request, not a bug ('behavior') report, and
only applicable to future x.y versions.

--
nosy: +tjreedy
type: behavior -> feature request
versions: +Python 2.7 -Python 2.6, Python 3.1

___
Python tracker 

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



[issue6614] heapq.nsmallest and nlargest should be smarter/more usable/more consistent

2009-07-31 Thread Joshua Bronson

Joshua Bronson  added the comment:

> That is in the pure python version of nsmallest() and that
> code is not used (it is overriden by the C version).

So just because it isn't used by CPython it should remain in there even 
though as you said yourself it's completely without basis? What about non 
CPython? I'm not trying to "kick the ball around" here, we're both on the 
same team just trying to make Python better.

--

___
Python tracker 

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



[issue1115] Minor Change For Better cross compile

2009-07-31 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
assignee: loewis -> gregory.p.smith
nosy: +gregory.p.smith
priority: low -> normal

___
Python tracker 

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



[issue3718] environment variable MACHDEP and python build system

2009-07-31 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
assignee:  -> gregory.p.smith
nosy: +gregory.p.smith
priority:  -> normal

___
Python tracker 

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



[issue1006238] cross compile patch

2009-07-31 Thread Gregory P. Smith

Changes by Gregory P. Smith :


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

___
Python tracker 

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



[issue1597850] Cross compiling patches for MINGW

2009-07-31 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
nosy: +gregory.p.smith

___
Python tracker 

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



[issue5404] Cross-compiling Python

2009-07-31 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
nosy: +gregory.p.smith

___
Python tracker 

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



[issue6614] heapq.nsmallest and nlargest should be smarter/more usable/more consistent

2009-07-31 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

There is a basis for the pure python version to switch to bisect.

There is not a basis for having the final wrapped C function switch to
using sorted().  That is a programmer decision.

The pure python version is there to show how it could be done using a
minheap and it is a bit of hack to get it to work at all.  The C version
uses a maxheap and does not need logic for switching to bisect.  It is
clean and fast.

I'm sorry, but I've lost interest in continuing this discussion.

--

___
Python tracker 

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



[issue5505] sys.stdin.read() doesn't return after first EOF on Windows

2009-07-31 Thread Martin

Martin  added the comment:

Looks like python needs eof() or something for file objects, just like
any other languages.

Since read() is using the system call, that's the right behavior: read()
blocks until EOF, and returns whatever was buffered. EOF character is
consumed, but since it's a stdin, it is never closed. The next read()
will again wait for normal input.

The 2nd EOF mark without anything in-between will return an empty string.

--
nosy: +famart

___
Python tracker 

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



[issue6550] asyncore incorrect failure when connection is refused and using async_chat channel

2009-07-31 Thread Nir Soffer

Nir Soffer  added the comment:

I tested asyncore_fix_refused-3.patch on Mac OS X 10.5 - all asyncore 
and asynchat tests pass.

There is one minor issue - _exception calls the non existing 
handle_close_event instead of handle_close.

However, looking again at the code I think that it is ugly and wrong - 
handle_expt_event should handle the low level expt event called from 
select, allowing third party dispatcher to override the behavior as 
needed.

Another issue - lately, a new event was added - handle_connect_event - 
this is wrong! there is no such low level event. handle_connect is a 
high level event, implied by first read or write on the connecting 
socket. This event will break 3rd party dispatcher that does not 
implement it, and is not documented.

--

___
Python tracker 

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



[issue5737] add Solaris errnos

2009-07-31 Thread Christopher Dolan

Christopher Dolan  added the comment:

This is a patch against the latest subversion revision that adds the
addition errno names, numbers, and messages available in Solaris.

--
keywords: +patch
nosy: +cdolan
Added file: http://bugs.python.org/file14616/issue5737.diff

___
Python tracker 

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



[issue6608] asctime causing python to crash

2009-07-31 Thread James Abbatiello

James Abbatiello  added the comment:

Since there's no good way to disable the assertion (see issue4804),
checking the validity of the argument beforehand looks like an option. 
The checking that's currently being done in the strftime()
implementation looks useful but it is not enough.  The checking in the
MS implementation of asctime() is very strict and validates the entire
date, not just one field at a time.  So there's no way to print out
non-existant dates like (2009, 2, 31, 0, 0, 0, 0, 0, 0) -> 'Mon Feb 31
00:00:00 2009'.  

I don't know if anybody is relying on that kind of behavior.  If not
then the function could be limited to accept only valid dates. 
Alternatively we could just not call down to asctime() but instead
provide our own implementation using sprintf/strftime.

--
nosy: +abbeyj

___
Python tracker 

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



[issue6611] HTMLParser cannot deal with mixture of arbitrary data and character reference

2009-07-31 Thread bones7456

bones7456  added the comment:

another fix way:
and these three lines to the head of file:

import sys
reload(sys)
sys.setdefaultencoding('utf8')

--
nosy: +bones7456

___
Python tracker 

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