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

2011-11-04 Thread Charles-François Natali

Charles-François Natali  added the comment:

> This is a hairy issue

Indeed.

Performing partial read/write may sound imperfect, but using buffered I/O 
around non-blockind FD is definitely not a good idea.
Also, the advantage of the current approach is that at least, no data is ever 
lost (and changing the behavior to raise a BlockingIOError might break some 
code out there in the wild).

Note that Java's BufferedInputStream and ReadableByteChannel also return 
partial reads.

So I'm somewhat inclined to keep the current behavior (it would however 
probably be a good idea to update the documentation to warn about this 
limitation, though).

--

___
Python tracker 

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



[issue13254] maildir.items() broken

2011-11-04 Thread Florent Xicluna

Changes by Florent Xicluna :


Removed file: http://bugs.python.org/file23586/issue13254_v2.diff

___
Python tracker 

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



[issue13254] maildir.items() broken

2011-11-04 Thread Florent Xicluna

Changes by Florent Xicluna :


--
keywords:  -needs review

___
Python tracker 

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



[issue12342] characters with ord above 65535 fail to display in IDLE

2011-11-04 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 5f49b496d161 by Victor Stinner in branch 'default':
Issue #12342: Fix compilation on Mac OS X
http://hg.python.org/cpython/rev/5f49b496d161

--

___
Python tracker 

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



[issue13340] list.index does not accept None as start or stop

2011-11-04 Thread Carl Friedrich Bolz

New submission from Carl Friedrich Bolz :

The list.index method does not accept None as start and stop, which makes the 
error message quite confusing:

>>> [1, 2, 3].index(2, None, None)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: slice indices must be integers or None or have an __index__ method

I checked this in 3.2.2 and 2.7.2. Seems similar to #12163.

--
messages: 147000
nosy: Carl.Friedrich.Bolz
priority: normal
severity: normal
status: open
title: list.index does not accept None as start or stop
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



[issue13140] ThreadingMixIn.daemon_threads is not honored when parent is daemon

2011-11-04 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset f09e3b1603ee by Florent Xicluna in branch '2.7':
Issue #13140: Fix the daemon_threads attribute of ThreadingMixIn.
http://hg.python.org/cpython/rev/f09e3b1603ee

New changeset 94017ce9304d by Florent Xicluna in branch '3.2':
Closes #13140: Fix the daemon_threads attribute of ThreadingMixIn.
http://hg.python.org/cpython/rev/94017ce9304d

New changeset 6fe6769e54a5 by Florent Xicluna in branch 'default':
Merge 3.2: issue #13140
http://hg.python.org/cpython/rev/6fe6769e54a5

--
nosy: +python-dev
resolution:  -> fixed
stage: patch review -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue13341] Incorrect documentation for "u" PyArg_Parse format unit

2011-11-04 Thread Ilya Novoselov

New submission from Ilya Novoselov :

Documentation states that u format unit returns "buffer of 16-bit Unicode 
(UTF-16) data" while it returns pointer to internal buffer of unicode data, 
which is either UCS-16 or UCS-32

http://docs.python.org/c-api/arg.html

--
assignee: docs@python
components: Documentation, Unicode
messages: 147002
nosy: Ilya.Novoselov, docs@python, ezio.melotti
priority: normal
severity: normal
status: open
title: Incorrect documentation for "u" PyArg_Parse format unit
type: behavior
versions: Python 2.7

___
Python tracker 

___
___
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-04 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> Also, the advantage of the current approach is that at least, no data
> is ever lost

But what about the buggy readline() behaviour?

--

___
Python tracker 

___
___
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-04 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> Note that Java's BufferedInputStream and ReadableByteChannel also 
> return partial reads.

Apparently, they are specified to, even for blocking streams (which I find a 
bit weird, and the language in the docs seems deliberately vague). Python's 
buffered read(), though, is specified to return the requested number of bytes 
(unless EOF happens).

--

___
Python tracker 

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



[issue13342] input() builtin always uses "strict" error handler

2011-11-04 Thread stefanholek

New submission from stefanholek :

The input builtin always uses "strict" error handling for Unicode conversions. 
This means that when I enter a latin-1 string in a utf-8 environment, input 
breaks with a UnicodeDecodeError. Now don't tell me not to do that, I have a 
valid use-case. ;-)

While "strict" may be a good default choice, it is clearly not sufficient. I 
would like to propose an optional 'errors' argument to input, similar to the 
'errors' argument the decode and encode methods have.

I have in fact implemented such an input method for my own use:
https://github.com/stefanholek/rl/blob/surrogate-input/rl/input.c

While this solves my immediate needs, the fact that my implementation is 
basically just a copy of bltinmode.input with one additional argument, makes me 
think that this could be fixed in Python proper.

There cannot be a reason input() should be confined to "strict", or can there? 
;-)

--
components: Unicode
messages: 147005
nosy: ezio.melotti, stefanholek
priority: normal
severity: normal
status: open
title: input() builtin always uses "strict" error handler
type: behavior
versions: Python 3.2, Python 3.3, Python 3.4

___
Python tracker 

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



[issue13241] llvm-gcc-4.2 miscompiles Python (XCode 4.1 on Mac OS 10.7)

2011-11-04 Thread Lucas Sinclair

Lucas Sinclair  added the comment:

I'm on 10.7.2, with XCode is 4.2 and the problem is still present. The command 
"ggc -v" produces the following output:

gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)

The command "./configure --with-pydebug && make -j2" fails with the following 
output:

Assertion failed: (compact->utf8_length == 0), function 
_PyUnicode_CheckConsistency, file Objects/unicodeobject.c, line 381.
make: *** [sysconfig] Abort trap: 6

The only solution seems to be to install macports and use it to get a more 
recent gcc like Oleg Plakhotnyuk suggested.

--
nosy: +xapple

___
Python tracker 

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



[issue13342] input() builtin always uses "strict" error handler

2011-11-04 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

There's no reason you couldn't write your own input() function in Python to do 
this.

--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue13342] input() builtin always uses "strict" error handler

2011-11-04 Thread stefanholek

stefanholek  added the comment:

I am not quite sure how I would write a custom, readline-using input function 
in Python (access to PyOS_Readline seems required), that's why I did it in C. 
Have an example?

--

___
Python tracker 

___
___
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-04 Thread sbt

sbt  added the comment:

No one has suggested raising BlockingIOError and DISCARDING the data when a 
partial read has occurred.  The docs seem to imply that the partially read data 
should be returned since they only say that BlockingIOError should be raised if 
there is NOTHING to read.  Clearly this should all be spelt out properly.

That leaves the question of whether, when there is NOTHING to read, 
BlockingIOError should be raised (as the docs say) or None should be returned 
(as is done now).  I don't mind either way as long as the docs match reality.

The part which really needs addressing is partial writes.  Currently, if a 
write fails with EAGAIN then IOError is raised and there is no way to work out 
how much data was written/buffered.  The docs say that BlockingIOError should 
be raised with the e.args[2] set to indicate the number of bytes 
written/buffered.  This at least should be fixed.

I will work on a patch.

--

___
Python tracker 

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



[issue13342] input() builtin always uses "strict" error handler

2011-11-04 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> There cannot be a reason input() should be confined to "strict", or can 
> there? ;-)

Actually, there's a good reason: in the non-interactive case, input() simply 
calls sys.stdin.read(), which doesn't have encoding or errors attributes. You 
want to override sys.stdin so that it has the right error handler.

However, there is a bug in input() in that it ignores sys.stdin's error handler 
in interactive mode (where it delegates to the readline library, if present):

>>> import sys, io
>>> sys.stdin = io.TextIOWrapper(sys.stdin.detach(), "ascii", "replace")
>>> sys.stdin.read()
héhé
'h��h��\n'
>>> input()
héhé
Traceback (most recent call last):
  File "", line 1, in 
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal 
not in range(128)


If you don't mind losing GNU readline functionality, the immediate workaround 
for you is to use sys.stdin.read() directly.

--
components: +Interpreter Core -Unicode
nosy: +pitrou
stage:  -> needs patch
versions:  -Python 3.4

___
Python tracker 

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



[issue13342] input() builtin always uses "strict" error handler

2011-11-04 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +haypo

___
Python tracker 

___
___
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-04 Thread sbt

sbt  added the comment:

> But what about the buggy readline() behaviour?

Just tell people that if the return value is a string which does not end in 
'\n' then it might caused by EOF or EAGAIN.  They can just call readline() 
again to check which.

--

___
Python tracker 

___
___
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-04 Thread sbt

sbt  added the comment:

The third arg of BlockingIOError is used in two quite different ways.

In write(s) it indicates the number of bytes of s which have been "consumed" 
(ie written to the raw file or buffered).

But in flush() and flush_unlocked() (in _pyio) it indicates the number of bytes 
from the internal buffer which have been written to the raw file.

I think this explains the following comment in write():

# We're full, so let's pre-flush the buffer
try:
self._flush_unlocked()
except BlockingIOError as e:
# We can't accept anything else.
# XXX Why not just let the exception pass through?
raise BlockingIOError(e.errno, e.strerror, 0)

I don't think flush() should try to tell us how many bytes were flushed: we 
only need to know whether we need to try again.

--

___
Python tracker 

___
___
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-04 Thread Charles-François Natali

Charles-François Natali  added the comment:

> Apparently, they are specified to, even for blocking streams (which 
> I find a bit weird, and the language in the docs seems deliberately
> vague). 

"""
As an additional convenience, it attempts to read as many bytes as possible by 
repeatedly invoking the read method of the underlying stream. This iterated 
read continues until one of the following conditions becomes true:

The specified number of bytes have been read,
The read method of the underlying stream returns -1, indicating end-of-file, or
The available method of the underlying stream returns zero, indicating that 
further input requests would block.
"""

As I understand it, it will return the number of bytes asked, unless EOF or 
EAGAIN/EWOULDBLOCK. It would seem reasonable to me to add the same note for 
non-blocking FDs to Python's read().

>> But what about the buggy readline() behaviour?
> Just tell people that if the return value is a string which does not 
> end in '\n' then it might caused by EOF or EAGAIN.  They can just call 
> readline() again to check which.

Sounds reasonable.

> No one has suggested raising BlockingIOError and DISCARDING the data 
> when a partial read has occurred.

The problem is that if we raise BlockingIOError, we can only buffer a limited 
amount of data.

> The docs seem to imply that the partially read data should be returned 
> since they only say that BlockingIOError should be raised if there is 
> NOTHING to read.  Clearly this should all be spelt out properly.

Agreed.

> That leaves the question of whether, when there is NOTHING to 
> read, BlockingIOError should be raised (as the docs say) or None
> should be returned (as is done now).

I don't have a string feeling: if we don't raise BlockingIOError on partial 
reads, then it probably makes sense to keep None.

--

___
Python tracker 

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



[issue13241] llvm-gcc-4.2 miscompiles Python (XCode 4.1 on Mac OS 10.7)

2011-11-04 Thread Ned Deily

Ned Deily  added the comment:

Lucas, exactly what source version of Python are you trying to build (i.e what 
does "hg summary" say)?

--

___
Python tracker 

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



[issue13283] removal of two unused variable in locale.py

2011-11-04 Thread Éric Araujo

Éric Araujo  added the comment:

Our policy is to not commit code cleanup patches that are not strict bug fixes; 
see thread at 
http://mail.python.org/pipermail/python-dev/2011-October/114281.html and 
http://mail.python.org/pipermail/python-dev/2011-November/114301.html

--
nosy: +eric.araujo

___
Python tracker 

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



[issue12498] asyncore.dispatcher_with_send, disconnection problem + miss-conception

2011-11-04 Thread Xavier de Gaye

Xavier de Gaye  added the comment:

Attached yet another patch.
This patch does not use a while loop in handle_close() and handles
POLLHUP as suggested by Charles-François. No changes have been made to
both tests (test_half_duplex_close).

--
Added file: http://bugs.python.org/file23609/half_duplex_close_2.diff

___
Python tracker 

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



[issue5301] add mimetype for image/vnd.microsoft.icon (patch)

2011-11-04 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 33680de042e7 by Éric Araujo in branch '2.7':
Revert commit that was not a bugfix (#5301).
http://hg.python.org/cpython/rev/33680de042e7

--

___
Python tracker 

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



[issue13241] llvm-gcc-4.2 miscompiles Python (XCode 4.1 on Mac OS 10.7)

2011-11-04 Thread Lucas Sinclair

Lucas Sinclair  added the comment:

I just cloned cpython today. The output of "hg summary" is:

parent: 73351:2bec7c452b39 tip
 Fix C89 incompatibility.
branch: default
commit: (clean)
update: (current)

--

___
Python tracker 

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



[issue12260] Make install default to user site-packages

2011-11-04 Thread Éric Araujo

Éric Araujo  added the comment:

With the raise of virtualenv and its inclusion in CPython for 3.3, this is even 
less a concern, even for UNIX.  I’m withdrawing the idea and will continue to 
advertise --user and warn against sudo in documentation and other venues.

--
assignee: tarek -> eric.araujo
resolution:  -> rejected
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue13342] input() builtin always uses "strict" error handler

2011-11-04 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Here is a patch. The bugfix itself is quite pedestrian, but the test is more 
interesting. I did what I could to fork a subprocess into a pseudoterminal so 
as to trigger the GNU readline code path. The only limitation I've found is 
that I'm unable to read further on the child's stdout after input() has been 
called. The test therefore uses a pipe to do the return checking.

--
keywords: +patch
nosy: +neologix
stage: needs patch -> patch review
Added file: http://bugs.python.org/file23610/input_readline.patch

___
Python tracker 

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



[issue13314] ImportError ImportError: Import by filename, should be deferred until sys.meta_path hooks are processed

2011-11-04 Thread Rob Bairos

Rob Bairos  added the comment:

Yah, thinking about this further, the real error is that sys.meta_path allows 
processing of names with #,?*  etc.
I can see why this would cause problems, as python names must only be _ and 
alphanumeric characters.
I'll re-implement this. 
Thanks.

--
status: open -> closed

___
Python tracker 

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



[issue13311] asyncore handle_read should call recv

2011-11-04 Thread Charles-François Natali

Charles-François Natali  added the comment:

> Since this patch may break existing valid code, I think it should be
> closed as invalid.

Yes. Since the benefit is not clear and it may break existing code, it's 
probably wiser.

--
resolution:  -> rejected
stage: patch review -> committed/rejected
status: open -> closed

___
Python tracker 

___
___
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-04 Thread sbt

sbt  added the comment:

Currently a BlockingIOError exception raised by flush() sets
characters_written to the number of bytes fushed from the internal
buffer.  This is undocument (although there is a unit test which tests
for it) and causes confusion because characters_written has conflicting
meanings depending on whether the exception was raised by flush() or
write().  I would propose setting characters_written to zero on
BlockingIOError exceptions raised by flush().  Are there any reasons not
to make this change?

Also, the docs say that the raw file wrapped by
BufferedReader/BufferedWriter should implement RawIOBase.  This means
that self.raw.write() should return None instead of raising
BlockingIOError.  But the implementation tries to cope with
BlockingIOError coming from a raw write.  In fact, the
MockNonBlockWriterIO class in unit tests is used as a raw file, but its
write() method raises BlockingIOError.

It would simplify matters a lot to insist that raw files implement
RawIOBase properly.

BTW, when I try to change characters_written of an existing
BlockingIOError exception using the pointer returned by
_buffered_check_blocking_error(), it appears not to work: the exception
continues to have characters_written == 0 -- not sure why...

--

___
Python tracker 

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



[issue13341] Incorrect documentation for "u" PyArg_Parse format unit

2011-11-04 Thread STINNER Victor

STINNER Victor  added the comment:

Can you write a patch?

--
nosy: +haypo

___
Python tracker 

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



[issue13287] urllib.request exposes too many names

2011-11-04 Thread STINNER Victor

STINNER Victor  added the comment:

test_urllib2.test___all__() is failing on Windows. Example:

http://www.python.org/dev/buildbot/all/builders/x86%20XP-4%203.x/builds/5498/steps/test/logs/stdio

==
FAIL: test___all__ (test.test_urllib2.TrivialTests)
--
Traceback (most recent call last):
  File 
"D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_urllib2.py",
 line 32, in test___all__
(k, module, v.__module__))
AssertionError: 'nturl2path' != 'urllib.request'
- nturl2path
+ urllib.request
 : 'pathname2url' is exposed in 'urllib.request' but defined in 'nturl2path'

--

--
nosy: +haypo
resolution: fixed -> 
status: closed -> open

___
Python tracker 

___
___
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-04 Thread Joshua Landau

New submission from Joshua Landau :

When setting defaults to keyword-only arguments in lambdas which are inside 
non-global scopes, cPython doesn't push the name to it's closure's co_freevars.

EXAMPLE:
global_variable = None
(lambda: (lambda *, keyword_only=global_variable: None))()

Because the inner lambda hasn't told the outer lambda to put global_variable in 
co_freevars, it fails to create the default to keyword_only. This only happens 
if the inner function is a lambda and you are setting a keyword_only variable.

It does not cause a crash if global_variable is local to the outer lambda, as 
the opcode LOAD_FAST is still created properly (as opposed to LOAD_NAME).

It does not crash if global_variable is used elsewhere in the outer function as 
co_freevars will be updated with it, allowing LOAD_NAME to retrieve it.



I've never done a bug here before and I'm unsure what to say, so please be nice 
and correct me if I'm doing it wrong.

--
components: Interpreter Core
messages: 147026
nosy: Joshua.Landau
priority: normal
severity: normal
status: open
title: Lambda keyword-only argument not updating co_freevars
type: crash
versions: Python 3.2

___
Python tracker 

___
___
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-04 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> >> But what about the buggy readline() behaviour?
> > Just tell people that if the return value is a string which does not 
> > end in '\n' then it might caused by EOF or EAGAIN.  They can just call 
> > readline() again to check which.
> 
> Sounds reasonable.

But then what's the point of using buffered I/O at all? If it can't
offer anything more than raw I/O, I'd rather do something like raise a
RuntimeError("buffered I/O doesn't work with non-blocking streams") when
the raw stream returns None. Returning partial results on a buffered's
readline() is not something we should ever do.

(actually, raw I/O readline() is probably buggy as well)

--

___
Python tracker 

___
___
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-04 Thread Charles-François Natali

Charles-François Natali  added the comment:

> But then what's the point of using buffered I/O at all? If it can't
> offer anything more than raw I/O, I'd rather do something like raise
> a RuntimeError("buffered I/O doesn't work with non-blocking streams")
> when the raw stream returns None.

Well, ideally it should be an UnsupportedOperation, but that's an option. The 
only think I didn't like about this is that we should ideally raise this error 
upon the first method call, not when - and if - we receive EAGAIN.
Another possibility would be that, since lines are usually reasonably sized, 
they should fit in the buffer (which is 8KB by default). So we could do the 
extra effort of buffering the data and return it once the line is complete: if 
the buffer fills up before we got the whole line, then we could raise a 
RuntimeError("Partial line read"). Note that I didn't check if it's easily 
feasible (i.e. we should avoid introducing kludges in the I/O layer just to 
handle thi corner case).

> Returning partial results on a buffered's readline() is not something
> we should ever do.

Yeah, I know.
Java made the choice of making readline() block, which is IMHO even worse (I 
mean, it defeats the whole point of non-blocking I/O...).

--

___
Python tracker 

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



[issue13342] input() builtin always uses "strict" error handler

2011-11-04 Thread Charles-François Natali

Charles-François Natali  added the comment:

> The bugfix itself is quite pedestrian, but the test is more interesting.

Indeed. Looks good to me.

--

___
Python tracker 

___
___
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-04 Thread Mark Dickinson

Changes by Mark Dickinson :


--
priority: normal -> critical
stage:  -> needs patch
versions: +Python 3.3

___
Python tracker 

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



[issue3067] setlocale error message is confusing

2011-11-04 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 931ae170e51c by Petri Lehtinen in branch '3.2':
Issue #3067: Fix the error raised by locale.setlocale()
http://hg.python.org/cpython/rev/931ae170e51c

New changeset d90d88380aca by Petri Lehtinen in branch 'default':
Issue #3067: Fix the error raised by locale.setlocale()
http://hg.python.org/cpython/rev/d90d88380aca

--

___
Python tracker 

___
___
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-04 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

Here is a patch, with a minimal test.

--
keywords: +patch
nosy: +amaury.forgeotdarc
Added file: http://bugs.python.org/file23611/issue13343.patch

___
Python tracker 

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



[issue3067] setlocale error message is confusing

2011-11-04 Thread Petri Lehtinen

Petri Lehtinen  added the comment:

Terry: Do you still think there's need for a doc update?

--
resolution:  -> fixed
status: open -> pending

___
Python tracker 

___
___
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-04 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

same patch, without tabs.

--
Added file: http://bugs.python.org/file23612/issue13343.patch

___
Python tracker 

___
___
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-04 Thread Amaury Forgeot d'Arc

Changes by Amaury Forgeot d'Arc :


Removed file: http://bugs.python.org/file23611/issue13343.patch

___
Python tracker 

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



[issue13321] fstat doesn't accept an object with "fileno" method

2011-11-04 Thread Petri Lehtinen

Changes by Petri Lehtinen :


--
resolution:  -> wont fix
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue13321] fstat doesn't accept an object with "fileno" method

2011-11-04 Thread Petri Lehtinen

Petri Lehtinen  added the comment:

Closing as wontfix.

--

___
Python tracker 

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



[issue13342] input() builtin always uses "strict" error handler

2011-11-04 Thread stefanholek

stefanholek  added the comment:

Thank you Antoine, this looks good.

However when I try your example I get

sys.stdin = io.TextIOWrapper(
sys.stdin.detach(), 'ascii', 'replace')
ValueError: underlying buffer has been detached



--

___
Python tracker 

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



[issue13342] input() builtin always uses "strict" error handler

2011-11-04 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> However when I try your example I get
> 
> sys.stdin = io.TextIOWrapper(
> sys.stdin.detach(), 'ascii', 'replace')
> ValueError: underlying buffer has been detached

Which version of Python (and which OS?). It works fine here on latest
3.2 and 3.3 branches.

--

___
Python tracker 

___
___
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-04 Thread Mark Dickinson

Mark Dickinson  added the comment:

Patch looks good to me.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue13342] input() builtin always uses "strict" error handler

2011-11-04 Thread Stefan Holek

Stefan Holek  added the comment:

This is with Python 3.2.2 on Mac OS X 10.6 (SL). I have built Python from 
source with: ./configure; make; make install.

--

___
Python tracker 

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



[issue13344] closed sockets don't raise EBADF anymore

2011-11-04 Thread Antoine Pitrou

New submission from Antoine Pitrou :

This decrepancy between 2.x and 3.x is witnessed under Windows:

Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> sock = socket.create_connection(("www.python.org", 80))
>>> sock.close()
>>> sock.send(b"x")
Traceback (most recent call last):
  File "", line 1, in 
  File "c:\python27\lib\socket.py", line 170, in _dummy
raise error(EBADF, 'Bad file descriptor')
socket.error: [Errno 9] Bad file descriptor

Python 3.2.1 (default, Jul 10 2011, 20:02:51) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> sock = socket.socket(); sock.connect(("www.python.org", 80))
>>> sock.close()
>>> sock.send(b"x")
Traceback (most recent call last):
  File "", line 1, in 
socket.error: [Errno 10038] An operation was attempted on something that is not
a socket


I'm not sure this is worth fixing, though.

--
components: Library (Lib)
messages: 147039
nosy: exarkun, pitrou
priority: low
severity: normal
status: open
title: closed sockets don't raise EBADF anymore
type: behavior
versions: Python 3.2, Python 3.3

___
Python tracker 

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



[issue13287] urllib.request exposes too many names

2011-11-04 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset ca78ed7393bf by Florent Xicluna in branch 'default':
Fix test_urllib2 error on Windows in relation with issue #13287.
http://hg.python.org/cpython/rev/ca78ed7393bf

--

___
Python tracker 

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



[issue13287] urllib.request exposes too many names

2011-11-04 Thread Florent Xicluna

Changes by Florent Xicluna :


--
status: open -> closed

___
Python tracker 

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



[issue13344] closed sockets don't raise EBADF anymore

2011-11-04 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

discrepancy, not decrepancy :S

(10038 is WSAENOTSOCK, by the way)

--

___
Python tracker 

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



[issue12498] asyncore.dispatcher_with_send, disconnection problem + miss-conception

2011-11-04 Thread Giampaolo Rodola'

Giampaolo Rodola'  added the comment:

I think this thread is becoming a little messy and since asyncore/asynchat are 
in a situation where even the slightest change can break existent code I 
recommend to be really careful.

I see 3 different issues here:

1 - dispatcher_with_send closing the socket without sending pending data (this 
was the initial issue)
2 - dispatcher_with_send default buffer is too small (512 bytes)
3 - add support for correct POLLHUP/socket.shutdown() handling (msg146946)

All of them should be treated and discussed separately in their own ticket to 
figure out:

- what's wrong
- whether it's a bugfix or a new feature (POLLHUP handling appears to be so)
- for what python version(s) the patch should be applied

As a final note we should consider mandatory for any patch not to alter the 
existent API.
initiate_send() method suddenly returning a meaningful value might be the case 
and as such it should be weighed up first.

--

___
Python tracker 

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



[issue13344] closed sockets don't raise EBADF anymore

2011-11-04 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



[issue13343] Lambda keyword-only argument not updating co_freevars

2011-11-04 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 1e0e821d2626 by Amaury Forgeot d'Arc in branch '3.2':
Issue #13343: Fix a SystemError when a lambda expression uses a global
http://hg.python.org/cpython/rev/1e0e821d2626

New changeset bddb455439d0 by Amaury Forgeot d'Arc in branch 'default':
Issue #13343: Fix a SystemError when a lambda expression uses a global
http://hg.python.org/cpython/rev/bddb455439d0

--
nosy: +python-dev

___
Python tracker 

___
___
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-04 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

It was a bug in Python compiler, thanks for the report!

--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue13342] input() builtin always uses "strict" error handler

2011-11-04 Thread Stefan Holek

Stefan Holek  added the comment:

Python 3.2.2 (default, Nov  4 2011, 22:28:55) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys, io
>>> w = io.TextIOWrapper(sys.stdin.detach(), 'ascii', 'replace')
>>> input

>>> input()
Traceback (most recent call last):
  File "", line 1, in 
ValueError: underlying buffer has been detached

--

___
Python tracker 

___
___
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-04 Thread Joshua Landau

Joshua Landau  added the comment:

Glad to help :)
It's made my day. I get to boast at school now!

--

___
Python tracker 

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



[issue13342] input() builtin always uses "strict" error handler

2011-11-04 Thread Stefan Holek

Stefan Holek  added the comment:

Oops, the last one wasn't meant for the bug tracker. 

--

___
Python tracker 

___
___
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-04 Thread sbt

sbt  added the comment:

> Another possibility would be that, since lines are usually reasonably
> sized, they should fit in the buffer (which is 8KB by default). So we 
> could do the extra effort of buffering the data and return it once the 
> line is complete: if the buffer fills up before we got the whole line, 
> then we could raise a RuntimeError("Partial line read"). Note that I 
> didn't check if it's easily feasible (i.e. we should avoid introducing 
> kludges in the I/O layer just to handle thi corner case).

Discarding data rarely is worse than always throwing an exception.

--

___
Python tracker 

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



[issue13342] input() builtin always uses "strict" error handler

2011-11-04 Thread Stefan Holek

Stefan Holek  added the comment:

I can make it work at the interpreter prompt with your patch applied. Sorry for 
cluttering up the ticket. ;-)

--

___
Python tracker 

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



[issue13342] input() builtin always uses "strict" error handler

2011-11-04 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> I can make it work at the interpreter prompt with your patch applied.
> Sorry for cluttering up the ticket. ;-)

That's ok, thanks a lot for testing.

--

___
Python tracker 

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



[issue13290] get vars for object with __slots__

2011-11-04 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

New features only go in future versions: Given the doc: "With a module, class 
or class instance object as argument (or anything else that has a __dict__ 
attribute), return that attribute." So you are proposing a change in the 
definition of vars() input.

I agree that the proposal is a good idea as far as it goes. Vars() predates 
__slots__ (introduced in 2.2). In particular, adding or deleting a __slots__ 
binding to a user-defined class should not change the behavior of vars().

I am thinking that the doc should also be tweaked a bit. It implies that all 
class instances have a __dict__ attribute. Before 2.2, when 'class' meant a 
user-defined old style class, that was true. But with 'types' becoming 
new-style classes, it is not.

Perhaps the domain of vars() should be extended to all objects, returning {} if 
nothing more. I may bring that idea to python-ideas list.

You should attach diffs (context diffs, I believe) rather than files so we can 
see what you changed. The diff module can create such. I believe your changes 
come after the following:

d = PyObject_GetAttrString(v, "__dict__");
if (d == NULL) {

The statement '''slots = PyObject_GetAttrString(v, "__slots__")''' gets the 
attribute from the object itself. Like most special attributes other than 
__dict__, it should be gotten from the object's class (or superclasses). [I 
don't know the C version of doing this.] For example, suppose v is a class with 
a custom metaclass and type(v).__slots__ == ('__slots__', '__init__') whereas 
v.__slots__ == ('a', 'b') (and v.__init__ is not assigned). Then vars(v) should 
return {'__slots__': ('__slots__', '__init__')}.

The comment /* Find attributes out of __slots__ */ seems misleading. I believe 
it should be /* Convert string to iterable of 1 string */

New code for 3.3 should use the new unicode api from pep 393. Though I could be 
wrong, I believe PyUnicode_Check() has been replaced.

Your example "__slots__ = {'some': 'mapping'} is somewhat strange. It works, 
but only because iterating dicts iterates the keys, and the key is a string. As 
far as I know, the value is ignored and useless, so I hope no one does this. 
Perhaps your only point was to test a non-sequence iterable of strings.

A patch should include a patch to the appropriate Lib/test/testxxx.py file.

--
nosy: +terry.reedy
stage:  -> needs patch
versions:  -Python 3.2

___
Python tracker 

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



[issue13345] Invisible Files in Windows 7

2011-11-04 Thread Jon Bryan

New submission from Jon Bryan :

Running 32-bit Python in 64-bit Windows 7 Enterprise.  I am very much a Python 
noob.

A .dll in c:\Windows\System32 that I need to access can't be found by 
ctypes.WinDLL().  Upon further investigation I have found that the file, along 
with many others, doesn't show up in an os.listdir() either.  Within IDLE the 
files don't appear in the drop-down autocomplete list.

I don't have this problem on either of the Windows XP machines I've tried it 
on, but in Win7 I see the same behavior in both 2.7 and 3.2.

--
components: IDLE, Windows, ctypes
messages: 147052
nosy: jrbryan
priority: normal
severity: normal
status: open
title: Invisible Files in Windows 7
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



[issue13298] Result type depends on order of operands for bytes and bytearray

2011-11-04 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
nosy: +terry.reedy

___
Python tracker 

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



[issue13300] IDLE 3.3 Restart Shell command fails

2011-11-04 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
nosy: +terry.reedy

___
Python tracker 

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



[issue13306] Add diagnostic tools to importlib?

2011-11-04 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
versions: +Python 3.3

___
Python tracker 

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



[issue13345] Invisible Files in Windows 7

2011-11-04 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

Does the file exist at all? Does it have some specific properties? a "Hidden" 
flag?

--
nosy: +amaury.forgeotdarc

___
Python tracker 

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



[issue13319] IDLE: Menu accelerator conflict between Format and Options

2011-11-04 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

The conflict is not fatal for keyboard users because repeating alt-o switches 
between Format and Options. To resolve the conflict, I would prefer to keep 
alt-o for Options, both because it is the first letter of Options and because 
Options appears on Shell windows. The only non-conflicting character in Format 
is 'a'.

--
nosy: +terry.reedy
stage:  -> needs patch
versions:  -Python 2.6, Python 3.1, Python 3.4

___
Python tracker 

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



[issue13341] Incorrect documentation for "u" PyArg_Parse format unit

2011-11-04 Thread Ilya Novoselov

Ilya Novoselov  added the comment:

No, I don't feel like I'm up to standard yet.

--

___
Python tracker 

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



[issue13330] Attempt full test coverage of LocaleTextCalendar.formatweekday

2011-11-04 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
nosy: +rhettinger, terry.reedy

___
Python tracker 

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



[issue13335] Service application hang in python25.dll

2011-11-04 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

2.5 in no longer maintained. 2.6 only gets security patches.
So please test with the latest 2.7 (currently 2.7.2).
If you cannot do that, please close.

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

___
Python tracker 

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



[issue13337] IGNORE_CASE doctest option flag

2011-11-04 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
versions:  -Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.4

___
Python tracker 

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



[issue13290] get vars for object with __slots__

2011-11-04 Thread João Bernardo

João Bernardo  added the comment:

Oh, sorry for the full file. Yes, I only changed after 

d = PyObject_GetAttrString(v, "__dict__");
if (d == NULL) {

I was searching for uses of slots other than __slots__ = (a, b) and I saw a guy 
saying that dicts may have special meaning the future. So, something like

  __slots__ = {'my_var': int}

could be an annotation (or hint for IDE's). In the present implementation, the 
value of each key is just ignored.

If slots is just "a_single_string" it should not be treated as an iterable, so 
I used PyUnicode_Check because I didn't knew a better method.

--

___
Python tracker 

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



[issue4489] shutil.rmtree is vulnerable to a symlink attack

2011-11-04 Thread Charles-François Natali

Charles-François Natali  added the comment:

There's a race:
"""
--- Lib/shutil.py   2011-11-05 00:11:05.745221315 +0100
+++ Lib/shutil.py.new   2011-11-05 00:11:01.445220324 +0100
@@ -307,6 +307,7 @@
try:
mode = os.fstatat(dirfd, name, os.AT_SYMLINK_NOFOLLOW).st_mode
 except os.error:
 mode = 0
 if stat.S_ISDIR(mode):
+input("press enter")
 newfd = os.openat(dirfd, name, os.O_RDONLY)
 _rmtree_safe(newfd, ignore_errors, onerror)
 try:
"""

$ rm -rf /tmp/target
$ mkdir -p /tmp/target/etc
$ ./python -c "import shutil; shutil.rmtree('/tmp/target')"
press enter^Z
[1]+  Stopped ./python -c "import shutil; 
shutil.rmtree('/tmp/target')"
$ rm -r /tmp/target/etc; ln -s /etc /tmp/target/
$ fg
./python -c "import shutil; shutil.rmtree('/tmp/target')"

Traceback (most recent call last):
  File "", line 1, in 
  File "/home/cf/python/cpython/Lib/shutil.py", line 290, in rmtree
_rmtree_safe(fd, ignore_errors, onerror)
  File "/home/cf/python/cpython/Lib/shutil.py", line 314, in _rmtree_safe
_rmtree_safe(newfd, ignore_errors, onerror)
  File "/home/cf/python/cpython/Lib/shutil.py", line 323, in _rmtree_safe
onerror(os.unlinkat, (dirfd, name), sys.exc_info())
  File "/home/cf/python/cpython/Lib/shutil.py", line 321, in _rmtree_safe
os.unlinkat(dirfd, name)
PermissionError: [Errno 13] Permission denied
[52334 refs]

"""
openat(3, "etc", O_RDONLY|O_LARGEFILE)  = 4
dup(4)  = 5
fstat64(5, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
fcntl64(5, F_GETFL) = 0x8000 (flags O_RDONLY|O_LARGEFILE)
fcntl64(5, F_SETFD, FD_CLOEXEC) = 0
getdents64(5, /* 162 entries */, 32768) = 5176
getdents64(5, /* 0 entries */, 32768)   = 0
close(5)= 0
fstatat64(4, "passwd", {st_mode=S_IFREG|0644, st_size=980, ...}, 
AT_SYMLINK_NOFOLLOW) = 0
unlinkat(4, "passwd", 0)= -1 EACCES (Permission denied)
"""

You should use the lstat/open/fstat idiom.
Also, here:
"""
mode1 = os.lstat(path).st_mode
if stat.S_ISLNK(mode1):
raise OSError("Cannot call rmtree on a symbolic link")
except OSError:
onerror(os.lstat, path, sys.exc_info())
# can't continue even if onerror hook returns
return
fd = os.open(path, os.O_RDONLY)
try:
mode2 = os.fstat(fd).st_mode
if mode1 != mode2:
raise OSError("Target changed")
"""

You check that path is not a symlink, then you open it, perform fstat on it, 
and check that the mode is the same.
But if someone replaces path by a symlink to a directory with the same mode, 
then rmtree won't catch this. You should also compare st_dev and st_ino to make 
sure we're dealing with the same file.

One more thing :-)
"""
fd = os.open(path, os.O_RDONLY)
try:
mode2 = os.fstat(fd).st_mode
if mode1 != mode2:
raise OSError("Target changed")
except OSError:
onerror(os.fstat, fd, sys.exc_info())
# can't continue if target has changed
return
"""

Here `fd` is not closed (there might be other places leaking FD).

Finally, since writting a such code is tricky, what do you - all - think of 
making this a generic walker method that would take as argument the methods to 
call on a directory and on a file (or link), so that we could reuse it to write 
chmodtree(), chowntree() and friends?

--
nosy: +neologix

___
Python tracker 

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



[issue4489] shutil.rmtree is vulnerable to a symlink attack

2011-11-04 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> Finally, since writting a such code is tricky, what do you - all -
> think of making this a generic walker method that would take as
> argument the methods to call on a directory and on a file (or link),
> so that we could reuse it to write chmodtree(), chowntree() and
> friends?

Sounds good.
FYI, I have a pathlib experiment in
http://hg.python.org/features/pathlib/, with an optional openat-based
accessor.

--

___
Python tracker 

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



[issue3067] setlocale error message is confusing

2011-11-04 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Yes. I think in locale.rst (assuming that is the name)
'''
exception locale.Error 
Exception raised when setlocale() fails.

locale.setlocale(category, locale=None) 
If *locale* is specified, it may be a string, a tuple of the form (language 
code, encoding), or None. If it is a tuple, it is converted to a string using 
the locale aliasing engine.
'''
should be changed to
'''
exception locale.Error 
Exception raised when the locale passed to setlocale() is not recognized.

locale.setlocale(category, locale=None) 
If *locale* is specified, it may be a None, a string, or an iterable of two 
strings, language code and encoding. String pairs are converted to a single 
string using the locale aliasing engine.
'''
where language code and encoding are gray shaded as they are now.

--
assignee:  -> docs@python
components: +Documentation -Library (Lib), Unicode
nosy: +docs@python
status: pending -> open

___
Python tracker 

___
___
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-04 Thread sbt

sbt  added the comment:

The attached patch makes BufferedWrite.write() raise BlockingIOError when the 
raw file is non-blocking and the write would block.

--
keywords: +patch
Added file: http://bugs.python.org/file23613/write_blockingioerror.patch

___
Python tracker 

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



[issue13319] IDLE: Menu accelerator conflict between Format and Options

2011-11-04 Thread Roger Serwy

Roger Serwy  added the comment:

Which platform are you running? 

On Linux (Ubuntu 11.10, Python 3.2, Tk 8.5), Alt-o does not toggle between 
Format and Options. The first Alt-o selects "Format" and the second Alt-o 
selects "Comment Out Region". 

Changing Format's accelerator to "a" would be inconsistent with other 
applications that use "o", such as LibreOffice and Abiword. Consistency aside, 
changing Format to "a" would be the simplest fix.

--

___
Python tracker 

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



[issue13290] get vars for object with __slots__

2011-11-04 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

PyUnicode_Check may still be correct. I have not examined PEP393 in detail.

--

___
Python tracker 

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



[issue13319] IDLE: Menu accelerator conflict between Format and Options

2011-11-04 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Py 3.2 on Win 7. 'Comment out region' is Alt-3 here.

--

___
Python tracker 

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



[issue13319] IDLE: Menu accelerator conflict between Format and Options

2011-11-04 Thread Roger Serwy

Roger Serwy  added the comment:

Alt-3 is comment-out region on Linux as well. The problem is that "o" is an 
accelerator for "Comment Out Region" under the Format menu. Pressing "Alt-o and 
o" under Linux is equivalent to "Alt-o and Alt-o".

This toggling between Format and Options may be a Tk bug under Linux since it 
works on Win7.

--

___
Python tracker 

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



[issue13346] re.split() should behave like string.split() for maxsplit=0 and maxsplit=-1

2011-11-04 Thread Alan Grow

New submission from Alan Grow :

If you split a string in a maximum of zero places, you should get the original 
string back. "".split(s,0) behaves this way. But re.split(r,s,0) performs an 
unlimited number of splits in this case.

To get an unlimited number of splits, "".split(s,-1) is a sensible choice. But 
in this case re.split(r,s,-1) performs zero splits.

Where's the sense in this?

>>> import string, re
>>> string.split("foo bar baz"," ",0)
['foo bar baz']
>>> re.split("\s+","foo bar baz",0)
['foo', 'bar', 'baz']
>>> string.split("foo bar baz"," ",-1)
['foo', 'bar', 'baz']
>>> re.split("\s+","foo bar baz",-1)
['foo bar baz']

--
components: Library (Lib)
messages: 147066
nosy: acg
priority: normal
severity: normal
status: open
title: re.split() should behave like string.split() for maxsplit=0 and 
maxsplit=-1
type: behavior
versions: Python 2.6

___
Python tracker 

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



[issue13346] re.split() should behave like string.split() for maxsplit=0 and maxsplit=-1

2011-11-04 Thread Ezio Melotti

Ezio Melotti  added the comment:

This is a known issue, but I don't think it can be fixed without breaking 
backward compatibility.  The behavior with negative values is not explicitly 
documented, so I would consider it an implementation detail. The behavior with 
positive values is documented for both the functions.  Also even if it's 
inconsistent, I would expect people to request at least 1 split, otherwise they 
are basically asking for a no-op.
I suggest to close this as wontfix

--
nosy: +ezio.melotti, rhettinger
resolution:  -> wont fix
versions: +Python 2.7, Python 3.2, Python 3.3 -Python 2.6

___
Python tracker 

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



[issue13341] Incorrect documentation for "u" PyArg_Parse format unit

2011-11-04 Thread Mike Hoy

Changes by Mike Hoy :


--
nosy: +mikehoy

___
Python tracker 

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



[issue2801] Py30a5 float.is_integer() raises ValueError

2011-11-04 Thread Steve Holden

Steve Holden  added the comment:

ValueError: (11, 'Resource temporarily unavailable') looks to me like a Cygwin 
error relating to Windows' DLLs and the difficulty of mapping them to unique 
memory locations. I very much doubt it's a real issue with Python, so closing 
the issue appears to be the correct decision in the absence of further 
contradictory information from the OP.

--
nosy: +holdenweb

___
Python tracker 

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