[issue1365] bytes() constructor

2007-10-31 Thread Christian Heimes

New submission from Christian Heimes:

Hey Guido!

During my testing and local modifications of the PEP 3137 branch I found
a bunch of unit tests that were choking on bytes(1) where bytes is PyString.

The PEP doesn't list bytes() as a valid constructor, only
buffer(). I don't see a reason why bytes() shouldn't accept an int
when b'1' still creates a byte sequence with 3 elements. Here is a patch

--
components: Interpreter Core
messages: 56990
nosy: gvanrossum, tiran
severity: normal
status: open
title: bytes() constructor
type: rfe
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



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

2007-10-31 Thread Patrick Mézard

New submission from Patrick Mézard:

Let child.py be:
"""
import sys

sys.stdout.write('1:stdout\n')
sys.stdout.flush()
sys.stderr.write('2:stderr\n')
sys.stderr.flush()
sys.stdout.write('3:stdout\n')
sys.stdout.flush()
"""

and parent.py:
"""
import os

cmd = 'python child.py'
for l in os.popen(cmd):
print l,
"""

Then running it:
"""
>python parent.py
1:stdout

>python
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on win32
"""

I would have expected at least:
"""
1:stdout
3:stdout
"""
to be output, which actually happens if the stderr is nullified like
"python child.py 2>nul" in parent.py call.

Am I wrong ?

--
components: Windows
messages: 56991
nosy: pmezard
severity: normal
status: open
title: popen spawned process may not write to stdout under windows
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



[issue1367] mkdir+chdir problem in multiple threads

2007-10-31 Thread anonyprog

New submission from anonyprog:

Under certain circumstances, creating a directory using os.mkdir then
immediately changing to it using os.chdir fails with a file not found
exception.

Here is some code to demonstrate that. Using the following program with
a parameter of 1 works fine. But anything greater than that and
exceptions occur in the first os.chdir until only one thread is left to
run completely.

Tested on Python 2.5.1 for Windows and Python 2.3.5 for Linux.

# mkdirtest.py
#
# usage: mkdirtest 

import os, threading, sys

x = int(sys.argv[1])

class MkdirTest(threading.Thread):

def __init__(self, t):
threading.Thread.__init__(self)
self.t = t
print "new thread "+str(t)

def run(self):
for i in range(0,50):
s = str(self.t)+"_"+str(i)
print "mkdir "+s
os.mkdir(s)
os.chdir(s)
os.chdir("..")
print "end thread "+str(t)

for t in range(0,x):
print t
a = MkdirTest(t)
a.start()

--
components: None
messages: 56992
nosy: anonyprog
severity: normal
status: open
title: mkdir+chdir problem in multiple threads
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



[issue1365] bytes() constructor

2007-10-31 Thread Martin v. Löwis

Martin v. Löwis added the comment:

Where is the patch?

--
nosy: +loewis

__
Tracker <[EMAIL PROTECTED]>

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



[issue1365] bytes() constructor

2007-10-31 Thread Christian Heimes

Christian Heimes added the comment:

Here it is.

patch + unit test

Added file: http://bugs.python.org/file8670/py3k_pystring_ssize.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Objects/stringobject.c
===
--- Objects/stringobject.c	(Revision 58729)
+++ Objects/stringobject.c	(Arbeitskopie)
@@ -3113,6 +3113,26 @@
 		return NULL;
 	}
 
+	/* Is it an int? */
+	size = PyNumber_AsSsize_t(x, PyExc_ValueError);
+	if (size == -1 && PyErr_Occurred()) {
+		PyErr_Clear();
+	}
+	else {
+		if (size < 0) {
+			PyErr_SetString(PyExc_ValueError, "negative count");
+			return NULL;
+		}
+		new = PyString_FromStringAndSize(NULL, size);
+		if (new == NULL) {
+			return NULL;
+		}
+		if (size > 0) {
+			memset(((PyStringObject*)new)->ob_sval, 0, size);
+		}
+		return new;
+	}
+
 	/* Use the modern buffer interface */
 	if (PyObject_CheckBuffer(x)) {
 		Py_buffer view;
Index: Lib/test/test_bytes.py
===
--- Lib/test/test_bytes.py	(Revision 58729)
+++ Lib/test/test_bytes.py	(Arbeitskopie)
@@ -50,6 +50,15 @@
 self.assertRaises(ValueError, bytes, [C(-1)])
 self.assertRaises(ValueError, bytes, [C(256)])
 
+def test_from_ssize(self):
+self.assertEqual(bytes(0), b'')
+self.assertEqual(bytes(1), b'\x00')
+self.assertEqual(bytes(5), b'\x00\x00\x00\x00\x00')
+self.assertRaises(ValueError, bytes, -1)
+
+self.assertEqual(bytes('0', 'ascii'), b'0')
+self.assertEqual(bytes(b'0'), b'0')
+
 def test_constructor_type_errors(self):
 self.assertRaises(TypeError, bytes, 0.0)
 class C:
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1651995] sgmllib _convert_ref UnicodeDecodeError exception, new in 2.

2007-10-31 Thread Simon

Changes by Simon:


--
nosy: +bind

_
Tracker <[EMAIL PROTECTED]>

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



[issue1367] mkdir+chdir problem in multiple threads

2007-10-31 Thread Jean-Paul Calderone

Jean-Paul Calderone added the comment:

This isn't a bug in Python.  Working directory, which os.chdir modifies,
is process-global.  One of your threads makes a directory, then gets
suspended while another one makes a different directory and changes into
it, then the first tries to change into its directory and fails.

--
nosy: +exarkun

__
Tracker <[EMAIL PROTECTED]>

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



[issue1367] mkdir+chdir problem in multiple threads

2007-10-31 Thread anonyprog

anonyprog added the comment:

Sorry for filing this as a bug, I am a fool. I should have read the
documentation for each operating systems' mkdir call more carefully.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1365] bytes() constructor

2007-10-31 Thread Guido van Rossum

Guido van Rossum added the comment:

Committed revision 58730.
Thanks!

PS. Christian, please work with Neal or Martin to get developer
privileges...

--
resolution:  -> accepted
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



[issue1516330] Module uuid: functions for retrieving MAC addres

2007-10-31 Thread Mike Klaas

Mike Klaas added the comment:

Is this meant to be inserted into uuid.py?  It seems more like a snippet 
from unrelated code: code coventions do not follow PEP 8; there are no 
tests; code does not run as-is (references non-existent variable '_os'--
why no 'import os'?); etc.

--
nosy: +klaas

_
Tracker <[EMAIL PROTECTED]>

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



[issue1516327] Module uuid: reduce pickle footprint

2007-10-31 Thread Mike Klaas

Mike Klaas added the comment:

Is the footprint of UUID an issue?

Note that changing the pickle format of UUID will require code that can 
unpickle both versions, for compatibility.  I don't really see the need.

Also, no real patch provided.

--
nosy: +klaas

_
Tracker <[EMAIL PROTECTED]>

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



[issue1292] libffi needs an update to support mips64, arm and armeabi on linux

2007-10-31 Thread Thomas Heller

Thomas Heller added the comment:

In the branches_ctypes-branch I hacked setup.py to always use an
installed libffi if one is found.  Then I triggered the trunk buildbots
which failed or crashed before in some c_longdouble tests; the tests
worked ok on them (ppc Debian unstable, and S-390 Debian).

__
Tracker <[EMAIL PROTECTED]>

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



[issue1292] libffi needs an update to support mips64, arm and armeabi on linux

2007-10-31 Thread Thomas Heller

Thomas Heller added the comment:

I meant branches/ctypes_branch, of course.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1705170] contextmanager eats StopIteration

2007-10-31 Thread Mike Klaas

Mike Klaas added the comment:

Verified on 2.5.0.  The problem stems from contextmanager.__exit__:

 def __exit__(self, type, value, traceback):
if type is None:
try:
self.gen.next()
except StopIteration:
return
else:
raise RuntimeError("generator didn't stop")
else:
try:
self.gen.throw(type, value, traceback)
raise RuntimeError("generator didn't stop after throw
()")
except StopIteration, exc:
# Suppress the exception *unless* it's the same 
exception that
# was passed to throw().  This prevents a StopIteration
# raised inside the "with" statement from being 
suppressed
return exc is not value
except:
# only re-raise if it's *not* the exception that was
# passed to throw(), because __exit__() must not raise
# an exception unless __exit__() itself failed.  But 
throw()
# has to raise the exception to signal propagation, so 
this
# fixes the impedance mismatch between the throw() 
protocol
# and the __exit__() protocol.
#
if sys.exc_info()[1] is not value:
raise

Conjecture: internal StopIteration exceptions are always the same 
instance (PyExc_StopIteration) when propagated to python, invalidating 
the return exc is not value
check.

--
nosy: +klaas

_
Tracker <[EMAIL PROTECTED]>

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



[issue1773632] Remove references to _xmlrpclib from xmlrpclib.py

2007-10-31 Thread Mike Klaas

Mike Klaas added the comment:

Patch applies to 2.5 cleanly, test_xmlrpc passes.

--
nosy: +klaas

_
Tracker <[EMAIL PROTECTED]>

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



[issue738948] Logic Variable Thread Synchronization

2007-10-31 Thread Mike Klaas

Mike Klaas added the comment:

PEPs should be proposed on python-list and python-dev.  This is a four-
year-old idea that seems quite profound in the changes proposed.  
Recommend closing.

--
nosy: +klaas


Tracker <[EMAIL PROTECTED]>


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



[issue1292] libffi needs an update to support mips64, arm and armeabi on linux

2007-10-31 Thread Matthias Klose

Matthias Klose added the comment:

oops, did the same for arm* on trunk, but in configure.in

__
Tracker <[EMAIL PROTECTED]>

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



[issue1247] PEP 3137 patch (repr, names, parser)

2007-10-31 Thread Guido van Rossum

Guido van Rossum added the comment:

I've submitted the 'harmless' patch (and much, much more) in r58741.
I'm closing this now, the rest probably has been implemented one way or
another as well.  If you see something I missed, please open a new issue
with a patch for just that issue.

--
resolution:  -> accepted
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