[issue1234] semaphore errors on AIX 5.2

2007-11-07 Thread Sébastien Sablé

Sébastien Sablé added the comment:

The bug is still present in Python 2.5.1. The same patch applies.
The patch is rather trivival, could someone please integrate it in trunk?
Thanks in advance

__
Tracker <[EMAIL PROTECTED]>

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



[issue1390] toxml generates output that is not well formed

2007-11-07 Thread Martin v. Löwis

Martin v. Löwis added the comment:

The standard procedure for an incompatible change would be to add such a
parameter to 2.6, and then change the default behavior in 2.7 (or rather
3.1). Of course, people will not notice the change in 2.6, and then be
surprised as much about the default change in 2.7, assuming this problem
arises in some application (and this issue is proof that the problem
does arise in real life - unless drtomc brought up an artificial problem).

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Guido van Rossum

Guido van Rossum added the comment:

On 11/7/07, Christian Heimes <[EMAIL PROTECTED]> wrote:
>
> Christian Heimes added the comment:
>
> By the way what happened to the SoC project related to Python's new IO
> subsystem? IIRC somebody was working on a C optimization of the io lib.
>
> __
> Tracker <[EMAIL PROTECTED]>
> 
> __

I think it was Alexandre Vassalotti. Is that right, Alexandre? Or am I
mixing you up? (If you ca, please respond to the bug.)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1400] Py3k's print() flushing problem

2007-11-07 Thread Wojciech Walczak

New submission from Wojciech Walczak:

py3k's print() is not flushing when the string's length is 1 byte long 
and 'end' parameter is set to ''. Example:
>>> print('x',end='') # it should print 'x' but it does nothing
>>> print('') # we have to call second print() to get buffers flushed
x
>>>

The same thing happens when the string is empty and end's length is 1:
>>> print('',end='x') # it should print 'x' but it does nothing
>>> print('') # we have to call second print() to get buffers flushed
x
>>>

When there is more characters than one, print() is flushing allright 
(despite of lack of a newline in the interpreter):
>>> print('x',end='y')
xy>>> print('xx',end='')
xx>>> print('',end='yy')
yy>>>
   
The same thing happens in scripts. Try this one as script:
-
import time

print('xx',end='')
time.sleep(3)
print('x',end='')
time.sleep(3)
-

First print() will flush immediately even though there is no newline
and flush is not called, while second print() will flush after second
sleep (because python is flushing buffers at the end of the script).
The conclusion is that print() is not flushing immediately when
string is 1 byte long, but when it is longer - then print() is
flushing even when there is no newline or flush was not called by the 
programmer.

I guess print() should act in the same way for every string > 0 bytes 
long instead of for every string > 1 byte long.

Any ideas where is the bug?

You can find Python-3000's mail list discussion about that bug here: 
http://mail.python.org/pipermail/python-3000/2007-November/011191.html


Wojtek Walczak

--
components: Build
messages: 57215
nosy: wojtekwalczak
severity: normal
status: open
title: Py3k's print() flushing problem
type: behavior
versions: Python 3.0

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Raghuram Devarakonda

Raghuram Devarakonda added the comment:

Hi Amaury and Christian,

io3.diff does replacenl() in adjust_chunk() (trying Amaury's
suggestion). Can you see if it fixes test_mailbox failures?

Added file: http://bugs.python.org/file8708/io3.diff

__
Tracker <[EMAIL PROTECTED]>

__Index: Lib/io.py
===
--- Lib/io.py	(revision 58902)
+++ Lib/io.py	(working copy)
@@ -1075,7 +1075,8 @@
 self._pending = ""
 self._snapshot = None
 self._seekable = self._telling = self.buffer.seekable()
-
+self._nl_straddle = False
+
 @property
 def encoding(self):
 return self._encoding
@@ -1136,16 +1137,35 @@
 decoder = self._decoder = make_decoder()  # XXX: errors
 return decoder
 
+def _adjust_chunk(self, readahead, pending):
+if self._readtranslate:
+if self._nl_straddle and pending and pending[0] == "\n":
+pending = pending[1:]
+# should not adjust readahead as otherwise, it can become nul and
+# terminate read loop in self.read() incorrectly.
+# readahead = readahead[1:]
+self._nl_straddle = False
+if pending and pending[-1] == "\r":
+self._nl_straddle = True
+else:
+self._nl_straddle = False
+
+pending = self._replacenl(pending)
+
+return readahead, pending
+
 def _read_chunk(self):
 if self._decoder is None:
 raise ValueError("no decoder")
 if not self._telling:
 readahead = self.buffer.read1(self._CHUNK_SIZE)
 pending = self._decoder.decode(readahead, not readahead)
-return readahead, pending
+return self._adjust_chunk(readahead, pending)
+
 decoder_buffer, decoder_state = self._decoder.getstate()
 readahead = self.buffer.read1(self._CHUNK_SIZE)
 pending = self._decoder.decode(readahead, not readahead)
+readahead, pending = self._adjust_chunk(readahead, pending)
 self._snapshot = (decoder_state, decoder_buffer + readahead, pending)
 return readahead, pending
 
@@ -1244,6 +1264,10 @@
 res = self._pending
 if n < 0:
 res += decoder.decode(self.buffer.read(), True)
+if self._readtranslate:
+if self._nl_straddle and res and res[0] == "\n":
+res = res[1:]
+self._nl_straddle = False
 self._pending = ""
 self._snapshot = None
 return self._replacenl(res)
@@ -1253,8 +1277,9 @@
 res += pending
 if not readahead:
 break
+# res = self._replacenl(res)
 self._pending = res[n:]
-return self._replacenl(res[:n])
+return res[:n]
 
 def __next__(self):
 self._telling = False
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Christian Heimes

Changes by Christian Heimes:


--
nosy: +alexandre.vassalotti

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Christian Heimes

Changes by Christian Heimes:


__
Tracker <[EMAIL PROTECTED]>

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



[issue1399] XML codec

2007-11-07 Thread Guido van Rossum

Guido van Rossum added the comment:

I think it's good to add this; I don't have time to review though.

--
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Guido van Rossum

Guido van Rossum added the comment:

Somebody needs to reverse-engineer the invariants applying to the
various instance variables and add comments explaining them, and
showing how they are maintained by each call.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

> The new patch fixes test_netrc for me but test_csv and test_mailbox are
> still broken.

For test_mailbox at least, I think I have a clue: the _pending member
now contains translated newlines.
But in tell(), we use its length and compare it with the length of a
previous "pending" value stored in self._snapshot...

Can we try to somehow move the replacenl() call inside the _get_chunk
function?
Not sure it will work. This gets more and more obscure...

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Guido van Rossum

Guido van Rossum added the comment:

This looks promising, but my head hurts when I try to understand the
code that's already there and think about whether your patch will always
do the right thing...  I'll look more later.

Regarding "universal newlines without translation:" that means that \r\n
and \r are recognized as line endings (as is \n) and that readline()
will return whatever line end it sees.  Compare this to setting
newline="\n"; then \r is not treated as a line ending at all (and if the
input is a\rb\n, the next readline call would return that entire string).

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Christian Heimes

Christian Heimes added the comment:

The new patch fixes test_netrc for me but test_csv and test_mailbox are
still broken.

--
components: +Library (Lib), Windows
keywords: +py3k

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Raghuram Devarakonda

Raghuram Devarakonda added the comment:

I am attaching another  patch (io2.diff). Please review. I am not sure
whether _adjust_chunk() should also adjust "readahead".

BTW, PEP 3116 says:

"If universal newlines without translation are requested on input (i.e.
newline=''), if a system read operation returns a buffer ending in '\r',
another system read operation is done to determine whether it is
followed by '\n' or not. In universal newlines mode with translation,
the second system read operation may be postponed until the next read
request, and if the following system read operation returns a buffer
starting with '\n', that character is simply discarded."

I suppose this issue is mainly talking about the latter (newline is
None). I don't understand what is meant by "enabling universal new line
mode without translation". Isn't the purpose of enabling universal new
line mode is to translate line endings? I may be missing something
basic, of course.

Added file: http://bugs.python.org/file8706/io2.diff

__
Tracker <[EMAIL PROTECTED]>

__Index: Lib/io.py
===
--- Lib/io.py	(revision 58902)
+++ Lib/io.py	(working copy)
@@ -1075,7 +1075,8 @@
 self._pending = ""
 self._snapshot = None
 self._seekable = self._telling = self.buffer.seekable()
-
+self._nl_straddle = False
+
 @property
 def encoding(self):
 return self._encoding
@@ -1136,16 +1137,31 @@
 decoder = self._decoder = make_decoder()  # XXX: errors
 return decoder
 
+def _adjust_chunk(self, readahead, pending):
+if self._readtranslate:
+if self._nl_straddle and pending and pending[0] == "\n":
+pending = pending[1:]
+# readahead = readahead[1:]
+self._nl_straddle = False
+if pending and pending[-1] == "\r":
+self._nl_straddle = True
+else:
+self._nl_straddle = False
+
+return readahead, pending
+
 def _read_chunk(self):
 if self._decoder is None:
 raise ValueError("no decoder")
 if not self._telling:
 readahead = self.buffer.read1(self._CHUNK_SIZE)
 pending = self._decoder.decode(readahead, not readahead)
-return readahead, pending
+return self._adjust_chunk(readahead, pending)
+
 decoder_buffer, decoder_state = self._decoder.getstate()
 readahead = self.buffer.read1(self._CHUNK_SIZE)
 pending = self._decoder.decode(readahead, not readahead)
+readahead, pending = self._adjust_chunk(readahead, pending)
 self._snapshot = (decoder_state, decoder_buffer + readahead, pending)
 return readahead, pending
 
@@ -1244,6 +1260,10 @@
 res = self._pending
 if n < 0:
 res += decoder.decode(self.buffer.read(), True)
+if self._readtranslate:
+if self._nl_straddle and res and res[0] == "\n":
+res = res[1:]
+self._nl_straddle = False
 self._pending = ""
 self._snapshot = None
 return self._replacenl(res)
@@ -1253,8 +1273,9 @@
 res += pending
 if not readahead:
 break
+res = self._replacenl(res)
 self._pending = res[n:]
-return self._replacenl(res[:n])
+return res[:n]
 
 def __next__(self):
 self._telling = False
Index: Lib/test/test_io.py
===
--- Lib/test/test_io.py	(revision 58902)
+++ Lib/test/test_io.py	(working copy)
@@ -485,6 +485,10 @@
 
 class TextIOWrapperTest(unittest.TestCase):
 
+def setUp(self):
+self.testdata = b"AAA\r\nBBB\rCCC\r\nDDD\nEEE\r\n"
+self.normalized = b"AAA\nBBB\nCCC\nDDD\nEEE\n".decode("ASCII")
+
 def tearDown(self):
 test_support.unlink(test_support.TESTFN)
 
@@ -741,7 +745,59 @@
 print("Reading using readline(): %6.3f seconds" % (t3-t2))
 print("Using readline()+tell():  %6.3f seconds" % (t4-t3))
 
+def test_issue1395_1(self):
+txt = io.TextIOWrapper(io.BytesIO(self.testdata), encoding="ASCII")
 
+# read one char at a time
+reads = ""
+while True:
+c = txt.read(1)
+if not c:
+break
+reads += c
+self.assertEquals(reads, self.normalized)
+
+def test_issue1395_2(self):
+txt = io.TextIOWrapper(io.BytesIO(self.testdata), encoding="ASCII")
+txt._CHUNK_SIZE = 4
+
+reads = ""
+while True:
+c = txt.read(4)
+if not c:
+break
+reads += c
+self.assertEquals(reads, self.normalized)
+
+def test_iss

[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Christian Heimes

Christian Heimes added the comment:

Good work!

The tests for mailbox, netrc and csv are passing with your test. I'm
going to run the entire suite now.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1366] popen spawned process may not write to stdout under windows

2007-11-07 Thread Gabriel Genellina

Gabriel Genellina added the comment:

(I think the title you meant was 
"popen spawned process may not 
write to stderr under windows")

The child is dying with IOError: 
[Errno 22] Invalid argument
at the sys.stderr.flush() call.

Neither the docs for os.popen nor 
the Linux man page for popen(3) 
say that stderr is redirected, so 
one would expect the handle to be 
inherited; the IOError looks like 
a bug.
Try using os.popen4 or 
popen2.popen4 or -the recommended 
choice- the subprocess module. 
Using the latter, this is the 
modified parent.py:

"""
import subprocess
cmd = 'python child.py'
p = subprocess.Popen(cmd, 
stdout=subprocess.PIPE)
for line in p.stdout:
  print ">>>", line,
print p.wait()
"""

and this is the output, as 
expected:

"""
2:stderr
>>> 1:stdout
>>> 3:stdout
0
"""

Note the 2:stderr line lacking the 
>>>, because it was printed 
directly by the child process onto 
the stderr handle inherited from 
its parent.

--
nosy: +gagenellina

__
Tracker <[EMAIL PROTECTED]>

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



[issue1343] XMLGenerator: nice elements

2007-11-07 Thread Gabriel Genellina

Gabriel Genellina added the comment:

Some (ugly) parsers insist on  when the element is not declared to 
be empty, so this should be optional (the 
default being generate )

--
nosy: +gagenellina

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Christian Heimes

Christian Heimes added the comment:

I take it back. I accidentally run the unit tests on the trunk instead
of the py3k branch. mailbox and csv are still breaking with your test,
netrc is doing fine.

Added file: http://bugs.python.org/file8709/py3k_windows.log.gz

__
Tracker <[EMAIL PROTECTED]>

__

py3k_windows.log.gz
Description: GNU Zip compressed data
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1291] test_resource fails on recent linux systems (

2007-11-07 Thread Nick Coghlan

Nick Coghlan added the comment:

I just hit this as well when rerunning the 2.5 tests before checking
something else in. The test itself appears to be fine, but the call to
f.close() outside the try/except block attempting to flush the file to
disk and raising an IOError.

Didn't something like this get fixed recently? Did the new IO module in
py3k have a similar problem?

(assigning to Neal to make a call on the importance for 2.5.2)

--
assignee:  -> nnorwitz
components: +Interpreter Core -Extension Modules
nosy: +ncoghlan, nnorwitz
priority:  -> high
resolution:  -> accepted

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Christian Heimes

Christian Heimes added the comment:

By the way what happened to the SoC project related to Python's new IO
subsystem? IIRC somebody was working on a C optimization of the io lib.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1291] test_resource fails on recent linux systems (

2007-11-07 Thread Guido van Rossum

Guido van Rossum added the comment:

It's fine to fix this in 2.5.2, as it is just a test.  (IMO you can just
copy the 2.6 test_resource.py into 2.5.2, assuming that works.)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1293] Trailing slash in sys.path cause import failure

2007-11-07 Thread Guido van Rossum

Changes by Guido van Rossum:


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

__
Tracker <[EMAIL PROTECTED]>

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



[issue1293] Trailing slash in sys.path cause import failure

2007-11-07 Thread Christian Heimes

Christian Heimes added the comment:

I've checked in a fix in r58903 (py3k branch).

__
Tracker <[EMAIL PROTECTED]>

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



[issue1293] Trailing slash in sys.path cause import failure

2007-11-07 Thread Guido van Rossum

Guido van Rossum added the comment:

Works for me!

On Nov 7, 2007 6:08 AM, Christian Heimes <[EMAIL PROTECTED]> wrote:
>
> Christian Heimes added the comment:
>
> Brett Cannon wrote:
> > Modules/getpath.c:joinpath() I think does what you want in C.
>
> I don't see how it is going to help us.
>
> I've a final offer before I declare the bug as SEP (someone else's problem):
>
> pseudo code
>
> #ifdef MS_WINDOWS
> rv = stat(...)
> if (rv == error)
> check for *one* trailign / or \ and remove it
> rv = stat(...)
> if (rv == error)
> give up
> #endif
>
> It should fix the case when somebody adds a directory with a trailing /
> or \ on Windows. More complex cases are still broken but that's really
> not my concern. ;)
>
> Christian
>
>
> __
> Tracker <[EMAIL PROTECTED]>
> 
> __
>

__
Tracker <[EMAIL PROTECTED]>

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



[issue1398] Can't pickle partial functions

2007-11-07 Thread Daniel

New submission from Daniel:

Creating a function using functools.partial results in a function which
cannot be pickled.

Attached is a small testcase.

--
components: Library (Lib)
files: partial_bug.py
messages: 57200
nosy: danhs
severity: normal
status: open
title: Can't pickle partial functions
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file8705/partial_bug.py

__
Tracker <[EMAIL PROTECTED]>

__from functools import partial
import pickle


def f(a, b):
print a, b

partial_f = partial(f, b = 'hello')


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



[issue1705170] contextmanager eats StopIteration

2007-11-07 Thread Nick Coghlan

Nick Coghlan added the comment:

Done in rev 58901

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

_
Tracker <[EMAIL PROTECTED]>

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



[issue1399] XML codec

2007-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

Nice codec !

The only nit I have is the name: "xml" isn't intuitive enough. I had to
read the code to figure out what the codec actually does. 

"xml" used a encoding usually refers to having Unicode text converted to
ASCII with XML entity escapes for all non-ASCII characters.

How about "xml-auto-detect" or something along those lines ?!

--
nosy: +lemburg

__
Tracker <[EMAIL PROTECTED]>

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



[issue1291] test_resource fails on recent linux systems (

2007-11-07 Thread Nick Coghlan

Nick Coghlan added the comment:

I just compared the 2.5 test_resource with the trunk test_resource - the
latter has been modified to remove the file size limitation before it
attempts to close the file, eliminating the test failure without
changing the underlying behaviour of f.close.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1704621] interpreter crash when multiplying large lists

2007-11-07 Thread Guido van Rossum

Guido van Rossum added the comment:

Shouldn't this be fixed before 2.5.2 goes out?

--
assignee:  -> nnorwitz
nosy: +gvanrossum
priority: normal -> high

_
Tracker <[EMAIL PROTECTED]>

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



[issue1293] Trailing slash in sys.path cause import failure

2007-11-07 Thread Christian Heimes

Christian Heimes added the comment:

Brett Cannon wrote:
> Modules/getpath.c:joinpath() I think does what you want in C.

I don't see how it is going to help us.

I've a final offer before I declare the bug as SEP (someone else's problem):

pseudo code

#ifdef MS_WINDOWS
rv = stat(...)
if (rv == error)
check for *one* trailign / or \ and remove it
rv = stat(...)
if (rv == error)
give up
#endif

It should fix the case when somebody adds a directory with a trailing /
or \ on Windows. More complex cases are still broken but that's really
not my concern. ;)

Christian

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Raghuram Devarakonda

Raghuram Devarakonda added the comment:

> The new patch fixes test_netrc for me but test_csv and test_mailbox are
> still broken.

Unfortunately, I am not able to build python on windows so I can not
test there. Can you post the exact errors? You can send me private
email as well if you think the test output would clutter this issue.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1399] XML codec

2007-11-07 Thread Walter Dörwald

Walter Dörwald added the comment:

"xml-auto-detect" sounds OK to me, it even makes sense for the encoder,
because it normally detects the encoding to use for writing from the XML
declaration.

We could put "xml-auto-detect" into the alias mapping and keep xml as
the module name.

But I noticed I have to rewrap a lot of lines, before I check it in.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1401] urllib 302 POST

2007-11-07 Thread Andres Riancho

New submission from Andres Riancho:

There is an error in urllib2 when doing a POST request to a URI that
responds with a 302 redirection. The problem is in urllib2.py:536, where
the HTTPRedirectHandler creates the new Request based on the original one:

newurl = newurl.replace(' ', '%20')
return Request(newurl,
   headers=req.headers,
   origin_req_host=req.get_origin_req_host(),
   unverifiable=True)


The issue is that when it creates the new request, it uses the old
headers (which contain a content-length header, remember that we
originally sent a POST!) but doesn't use the same post-data from the
original request (in fact it doesn't use any post-data). So, when the
new request is sent, urllib2 sends something like:

START Request=
GET http://f00/1.php HTTP/1.1
Content-length: 63
Accept-encoding: identity
Accept: */*
User-agent: w3af.sourceforge.net
Host: f00
Content-type: application/x-www-form-urlencoded


 END REQUEST ===

The server waits some time for the post-data that is advertised in
"Content-length: 63" but it never arrives, so the connection is closed
and urllib2 timeouts.

There are two different solutions to this issue, implementing one is
enough to solve it:
1) when creating the new request, remove the content length header
2) when creating the new request, add the post-data of the old request

I think that the solution 1) is the most RFC-compliant solution. I coded
a small patch for urllib2.py of python2.5 that solves this issue, the
patch simply adds a line that removes the cl header:

newurl = newurl.replace(' ', '%20')
req.headers.pop('content-length')
return Request(newurl,
   headers=req.headers,
   origin_req_host=req.get_origin_req_host(),
   unverifiable=True)

--
components: None
messages: 57223
nosy: andresriancho
severity: minor
status: open
title: urllib 302 POST
type: behavior
versions: Python 2.5

__
Tracker <[EMAIL PROTECTED]>

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



[issue1401] urllib2 302 POST

2007-11-07 Thread Andres Riancho

Changes by Andres Riancho:


--
title: urllib 302 POST -> urllib2 302 POST

__
Tracker <[EMAIL PROTECTED]>

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



[issue1399] XML codec

2007-11-07 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

Leaving the module name as "xml" would remove that name from the
namespace of possible encodings.

"xml" as encoding name is problematic, as many people regard writing
data in XML as "encoding the data in XML".

I'd simply not use it at all, not even for a codec that converts between
 Unicode and ASCII+XML entities.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1399] XML codec

2007-11-07 Thread Guido van Rossum

Changes by Guido van Rossum:


--
nosy:  -gvanrossum

__
Tracker <[EMAIL PROTECTED]>

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



[issue1402] Interpreter cleanup: order of _PyGILState_Fini and PyInterpreterState_Clear

2007-11-07 Thread Ronald Oussoren

New submission from Ronald Oussoren:

Py_Finalize cleans up the thread state by first calling _PyGILState_Fini 
and then calling PyInterpreterState_Clear. The latter can cause user 
code to run, which could use the GILState API and this then causes a 
crash.

The attached file 'threads.py' causes a crash on OSX leopard because of 
this issue. The script causes an exception to be set that has an 
attribute that uses the GILState API in its dealloc slot.

--
components: Interpreter Core
files: threads.py
messages: 57225
nosy: ronaldoussoren
priority: normal
severity: normal
status: open
title: Interpreter cleanup: order of _PyGILState_Fini and 
PyInterpreterState_Clear
type: crash
versions: Python 2.5
Added file: http://bugs.python.org/file8710/threads.py

__
Tracker <[EMAIL PROTECTED]>

__from Foundation import *
import threading


class MyObject (NSObject):
def myMethod_(self, dummy):
print dummy
raise RuntimeError("hello")

obj = MyObject.new()


class MyThread(threading.Thread):

def run(self):
while True:
pool = NSAutoreleasePool.alloc().init()

print "Doit!"
obj.performSelectorOnMainThread_withObject_waitUntilDone_(
'myMethod:', [], True)
print "Result is in"


del pool


t = MyThread()
t.setDaemon(1)
t.start()

loop = NSRunLoop.currentRunLoop()
try:
loop.run()
except:
print "Exception!"

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



[issue1742669] "%d" format handling for long values

2007-11-07 Thread Gabriel Genellina

Gabriel Genellina added the comment:

Yes, I can reformulate it. In fact my original version was quite 
different, but the resulting diff was hard to understand so I rewrote 
it trying to keep as much as the original code as possible.
I'll submit a new patch next weekend.

_
Tracker <[EMAIL PROTECTED]>

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



[issue1401] urllib2 302 POST

2007-11-07 Thread Facundo Batista

Facundo Batista added the comment:

I don't understand why after receiving a redirection, and going to a new
URL, you say to NOT send the POST data. Shouldn't the HTTP request be
exactly like the original one, but to another URL destination?

But you said that #2 solution was more RFC compliant... Could you please
quote the RFC part that describes this behaviour?

--
nosy: +facundobatista

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

> io3.diff does replacenl() in adjust_chunk() (trying Amaury's
> suggestion). Can you see if it fixes test_mailbox failures?

Unfortunately, it does not. And some tests now fail in test_io
(correcting testTelling seems a good start point, since we just changed
the tell() behaviour)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Guido van Rossum

Guido van Rossum added the comment:

Cool. How hard do you think it would be to extend your work on
StringIO into a translation of TextIOWrapper into C?

On Nov 7, 2007 3:55 PM, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote:
> On 11/7/07, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> > On 11/7/07, Christian Heimes <[EMAIL PROTECTED]> wrote:
> > >
> > > Christian Heimes added the comment:
> > >
> > > By the way what happened to the SoC project related to Python's new IO
> > > subsystem? IIRC somebody was working on a C optimization of the io lib.
> > >
> >
> > I think it was Alexandre Vassalotti. Is that right, Alexandre? Or am I
> > mixing you up? (If you ca, please respond to the bug.)
>
> I think so. My GSoC project was to merge the interface of
> cPickle/pickle and cStringIO/StringIO. I am still working on it,
> albeit slowly (my school homework is killing all my free time, right
> now). My work on StringIO and BytesIO is basically done; I just need
> to add newline translation and encoding support before it can be
> merged into the trunk. The cPickle/pickle merge is mostly done (i.e.,
> all the current tests passes); I am right now in the bug-hunting
> phase.
>

__
Tracker <[EMAIL PROTECTED]>

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



[issue1401] urllib2 302 POST

2007-11-07 Thread Senthil

Senthil added the comment:

I agree with facundobatista here.
1) I am not sure, if what you mention that doing POST in the 302
redirect url does not carry forward the POST data. Some examples would
help to verify that and if this is case, IMO its a bug in urllib2.
2) You mention solution 1 as RFC compliant? Does RFC mention about
changes to request headers for a redirection? Please quote the relevant
section
also I find in RFC2616 under 302 Found that:
  Note: RFC 1945 and RFC 2068 specify that the client is not
allowedto change the method on the redirected request. However, most   
   existing user agent implementations treat 302 as if it were a 303   
   response, performing a GET on the Location field-value regardless   
   of the original request method.
But could not find any references for behaviour with respect to POST on
redirection.

--
nosy: +orsenthil

__
Tracker <[EMAIL PROTECTED]>

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



[issue1165] Should itertools.count work for arbitrary integers?

2007-11-07 Thread Raymond Hettinger

Changes by Raymond Hettinger:


--
resolution:  -> fixed
status: open -> closed
versions: +Python 2.6 -Python 3.0

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

On 11/7/07, Guido van Rossum <[EMAIL PROTECTED]> wrote:
> On 11/7/07, Christian Heimes <[EMAIL PROTECTED]> wrote:
> >
> > Christian Heimes added the comment:
> >
> > By the way what happened to the SoC project related to Python's new IO
> > subsystem? IIRC somebody was working on a C optimization of the io lib.
> >
>
> I think it was Alexandre Vassalotti. Is that right, Alexandre? Or am I
> mixing you up? (If you ca, please respond to the bug.)

I think so. My GSoC project was to merge the interface of
cPickle/pickle and cStringIO/StringIO. I am still working on it,
albeit slowly (my school homework is killing all my free time, right
now). My work on StringIO and BytesIO is basically done; I just need
to add newline translation and encoding support before it can be
merged into the trunk. The cPickle/pickle merge is mostly done (i.e.,
all the current tests passes); I am right now in the bug-hunting
phase.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-07 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

On 11/7/07, Guido van Rossum wrote:
> Cool. How hard do you think it would be to extend your work on
> StringIO into a translation of TextIOWrapper into C?

Well, StringIO and TextIOWrapper are quite different. The only part
that I could reuse, from StringIO, would be the newline translation
facilities. I think that a perfect translation to C of the current
Python implementation of TextIOWrapper will be burdensome (due to
things like function annotations) but not too hard to do.

Nevertheless, that would be neat project for me. I could start to work
it by mid-December, along with the other performance enhancements I
have in mind.

__
Tracker <[EMAIL PROTECTED]>

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