[issue1689617] Intel icc build fails with optimizations -O2

2007-11-10 Thread Michael Forbes

Michael Forbes added the comment:

This appears to have been a bug with the intel compilers.  With the latest 
version 10.1 20070913 everything seems to work.

_
Tracker <[EMAIL PROTECTED]>

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



[issue1689617] Intel icc build fails with optimizations -O2

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

Martin v. Löwis added the comment:

Ok. Closing it as third-party.

--
resolution:  -> invalid
status: open -> closed
versions: +3rd party -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



[issue1417] Weakref not working properly

2007-11-10 Thread MHOOO

New submission from MHOOO:

The following code is not working as expected:
import weakref
class cls1:
def giveTo( self, to ):
to.take( self.bla )
def bla(self ):
pass

class cls2:
def take( self, what ):
self.ref = weakref.ref(what)

c1 = cls1()
c2 = cls2()
c1.giveTo( c2 )
print c1.bla
print c2.ref

It prints out:
>


Why is the weakref pointing to a dead object, when it's still alive?

--
components: Library (Lib)
files: test2.py
messages: 57348
nosy: MHOOO
severity: major
status: open
title: Weakref not working properly
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file8725/test2.py

__
Tracker <[EMAIL PROTECTED]>

__import weakref
class cls1:
	def giveTo( self, to ):
		to.take( self.bla )
	def bla(self ):
		pass
		
class cls2:
	def take( self, what ):
		self.ref = weakref.ref(what)
		
c1 = cls1()
c2 = cls2()
c1.giveTo( c2 )
print c1.bla
print c2.ref___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1415] py3k: pythonw.exe fails because std streams a missing

2007-11-10 Thread Christian Heimes

Christian Heimes added the comment:

Congratulations Amaury and welcome on board! :)

I like to get your opinion on the problem. So far I've figured out that
Windows doesn't create the std streams for Windows WinMain() programs.
As first step towards the solution I like to separate the close check
from the fd. Currently Module/_fileio.c:file_close() sets the fd to a
negative value and open fails immediately with a negative fd. I want to
add a closed flag to the struct and move the fd < 0 check to the read
and write operations.

That's going to fix stdin and stdout for non console based programs on
Windows. For stderr I've to think about a better solution to avoid an
infinite loop (stderr.write() -> exception -> stderr.write() ...). Maybe
I could add some more methods to the dumb writer to make it more file
like and use it?

--
nosy: +amaury.forgeotdarc
title: py3k: pythonw.exe fails to run -> py3k: pythonw.exe fails because std 
streams a missing

__
Tracker <[EMAIL PROTECTED]>

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



[issue1418] Python/hypot.c is never used

2007-11-10 Thread Mark Dickinson

New submission from Mark Dickinson:

With the current ./configure setup, it looks to me as though there are 
no circumstances under which the file Python/hypot.c is compliled.
There's a line

AC_REPLACE_FUNCS(hypot)

in configure.in;  which is supposed (if I understand correctly) to check 
for a system hypot(), and use the replacement file hypot.c if the system 
hypot() isn't found;  but the mechanism for using the replacement file 
seems not to work:  I tried the following:

(1) replace all occurrences of hypot with myhypot in configure.in, 
pyport.h, complexobject.c, mathmodule.c and cmathmodule.c.
(2) move Python/hypot.c to Python/myhypot.c, and rename the function 
contained within from hypot to myhypot
(3) rerun autoconf and autoheader
(4) ./configure && make

The result:  as expected, during configuration I got:

checking for myhypot... no

but building failed with:

ar cr libpython2.6.a Objects/abstract.o Objects/boolobject.o Objects/
bufferobject.o Objects/cellobject.o Objects/classobject.o Objects/
cobject.o Objects/codeobject.o Objects/complexobject.o Objects/
descrobject.o Objects/enumobject.o Objects/exceptions.o Objects/
genobject.o Objects/fileobject.o Objects/floatobject.o Objects/
frameobject.o Objects/funcobject.o Objects/intobject.o Objects/
iterobject.o Objects/listobject.o Objects/longobject.o Objects/
dictobject.o Objects/methodobject.o Objects/moduleobject.o Objects/
object.o Objects/obmalloc.o Objects/rangeobject.o Objects/setobject.o 
Objects/sliceobject.o Objects/stringobject.o Objects/structseq.o 
Objects/tupleobject.o Objects/typeobject.o Objects/weakrefobject.o 
Objects/unicodeobject.o Objects/unicodectype.o
ar cr libpython2.6.a Python/Python-ast.o Python/asdl.o Python/ast.o 
Python/bltinmodule.o Python/ceval.o Python/compile.o Python/codecs.o 
Python/errors.o Python/frozen.o Python/frozenmain.o Python/future.o 
Python/getargs.o Python/getcompiler.o Python/getcopyright.o Python/
getmtime.o Python/getplatform.o Python/getversion.o Python/graminit.o 
Python/import.o Python/importdl.o Python/marshal.o Python/modsupport.o 
Python/mystrtoul.o Python/mysnprintf.o Python/peephole.o Python/
pyarena.o Python/pyfpe.o Python/pystate.o Python/pythonrun.o Python/
structmember.o Python/symtable.o Python/sysmodule.o Python/traceback.o 
Python/getopt.o Python/pystrtod.o Python/dynload_shlib.o Python/
mactoolboxglue.o Python/thread.o
ar cr libpython2.6.a Modules/config.o Modules/getpath.o Modules/main.o 
Modules/gcmodule.o 
ar cr libpython2.6.a Modules/threadmodule.o  Modules/signalmodule.o  
Modules/posixmodule.o  Modules/errnomodule.o  Modules/pwdmodule.o  
Modules/_sre.o  Modules/_codecsmodule.o  Modules/zipimport.o  Modules/
symtablemodule.o  Modules/xxsubtype.o
ranlib libpython2.6.a
gcc -L/opt/local/lib -u _PyMac_Error -o python.exe \
Modules/python.o \
libpython2.6.a -ldl  
/usr/bin/ld: Undefined symbols:
_myhypot

(I'd like to know how to fix this:  I've been working on fixing some of 
the numerical problems in the cmath module, and hoped to imitate the 
hypot setup for the functions log1p, asinh and copysign.)

--
components: Build
messages: 57350
nosy: marketdickinson
severity: minor
status: open
title: Python/hypot.c is never used
versions: Python 2.5, Python 2.6

__
Tracker <[EMAIL PROTECTED]>

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



[issue1405] Garbage collection not working correctly in Python 2.3

2007-11-10 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

Looks like the memory _is_ freed.  As Guido said, "It may be available
for reallocation within Python, just not given back to the operating
system".  I suggest closing this as invalid.

[EMAIL PROTECTED]:~$ python
Python 2.3.5 (#2, Oct 16 2006, 19:19:48)
[GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gc
>>> len ([object for object in gc.get_objects () if isinstance (object,
list)])
25
>>> aList = []
>>> for i in xrange(5E5):
... aList += [[]]
... for j in xrange(10):
... aList[-1].append([]
...
...
KeyboardInterrupt
>>> aList[-1].append([]
KeyboardInterrupt
>>>
[EMAIL PROTECTED]:~/emacs$ python
Python 2.3.5 (#2, Oct 16 2006, 19:19:48)
[GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gc
>>> len ([object for object in gc.get_objects () if isinstance (object,
list)])
25
>>> aList = []
>>> for i in xrange(5E5):
... aList += [[]]
... for j in xrange(10):
... aList[-1].append([])
...
__main__:1: DeprecationWarning: integer argument expected, got float
>>> del aList
>>> len ([object for object in gc.get_objects () if isinstance (object,
list)])
25

__
Tracker <[EMAIL PROTECTED]>

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



[issue1405] Garbage collection not working correctly in Python 2.3

2007-11-10 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

Meh, copied too much.  Disregard first part, second shows it.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1417] Weakref not working properly

2007-11-10 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

Because self.bla is a bound-method object, which is created and then
instantly deleted as unreferenced.  This is not a bug, it is expected.

>>> class X:
...   def foo (self): pass
...
>>> x = X ()
>>> x.foo is x.foo
False

Note how the objects are different.

--
nosy: +_doublep

__
Tracker <[EMAIL PROTECTED]>

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



[issue1416] @prop.setter decorators

2007-11-10 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

Looks great (regardless of how this is implemented).  I always hated this
def get_foo / def set_foo / foo = property (get_foo, set_foo).

--
nosy: +_doublep

__
Tracker <[EMAIL PROTECTED]>

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



[issue1417] Weakref not working properly

2007-11-10 Thread Georg Brandl

Georg Brandl added the comment:

Closing as invalid.

--
nosy: +georg.brandl
resolution:  -> invalid
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



[issue1418] Python/hypot.c is never used

2007-11-10 Thread Georg Brandl

Changes by Georg Brandl:


--
assignee:  -> loewis
nosy: +loewis

__
Tracker <[EMAIL PROTECTED]>

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



[issue1405] Garbage collection not working correctly in Python 2.3

2007-11-10 Thread Guido van Rossum

Changes by Guido van Rossum:


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



[issue1416] @prop.setter decorators

2007-11-10 Thread Guido van Rossum

Guido van Rossum added the comment:

propset2.diff is a new version that improves upon the heuristic for
making the deleter match the setter: when changing setters, if the old
deleter is the same as the old setter, it will replace both the deleter
and setter.

This diff is relative to the 2.6 trunk; it applies to 3.0 too.

Added file: http://bugs.python.org/file8726/propset2.diff

__
Tracker <[EMAIL PROTECTED]>

__Index: Objects/descrobject.c
===
--- Objects/descrobject.c	(revision 58906)
+++ Objects/descrobject.c	(working copy)
@@ -1108,7 +1108,72 @@
 	{0}
 };
 
+PyDoc_STRVAR(getter_doc,
+	 "Descriptor to change the setter on a property.");
 
+PyObject *
+property_getter(PyObject *self, PyObject *getter)
+{
+	Py_XDECREF(((propertyobject *)self)->prop_get);
+	if (getter == Py_None)
+		getter = NULL;
+	Py_XINCREF(getter);
+	((propertyobject *)self)->prop_get = getter;
+	Py_INCREF(self);
+	return self;
+}
+
+PyDoc_STRVAR(setter_doc,
+	 "Descriptor to change the setter on a property.\n"
+	 "This also sets the deleter if it hasn't been set before.");
+
+PyObject *
+property_setter(PyObject *self, PyObject *setter)
+{
+	propertyobject *pself = (propertyobject *)self;
+
+	if (pself->prop_del != NULL && pself->prop_del == pself->prop_set) {
+		Py_DECREF(pself->prop_del);
+		pself->prop_del = NULL;
+	}
+	Py_XDECREF(pself->prop_set);
+	if (setter == Py_None)
+		setter = NULL;
+	Py_XINCREF(setter);
+	pself->prop_set = setter;
+	if (pself->prop_del == NULL && setter != NULL) {
+		Py_INCREF(setter);
+		pself->prop_del = setter;
+	}
+	Py_INCREF(self);
+	return self;
+}
+
+PyDoc_STRVAR(deleter_doc,
+	 "Descriptor to change the deleter on a property.");
+
+PyObject *
+property_deleter(PyObject *self, PyObject *deleter)
+{
+	Py_XDECREF(((propertyobject *)self)->prop_del);
+	if (deleter == Py_None)
+		deleter = NULL;
+	Py_XINCREF(deleter);
+	((propertyobject *)self)->prop_del = deleter;
+	Py_INCREF(self);
+	return self;
+}
+
+
+
+static PyMethodDef property_methods[] = {
+	{"getter", property_getter, METH_O, getter_doc},
+	{"setter", property_setter, METH_O, setter_doc},
+	{"deleter", property_deleter, METH_O, deleter_doc},
+	{0}
+};
+
+
 static void
 property_dealloc(PyObject *self)
 {
@@ -1260,7 +1325,7 @@
 	0,	/* tp_weaklistoffset */
 	0,	/* tp_iter */
 	0,	/* tp_iternext */
-	0,	/* tp_methods */
+	property_methods,			/* tp_methods */
 	property_members,			/* tp_members */
 	0,	/* tp_getset */
 	0,	/* tp_base */
Index: Lib/rfc822.py
===
--- Lib/rfc822.py	(revision 58906)
+++ Lib/rfc822.py	(working copy)
@@ -160,8 +160,7 @@
 if headerseen and line[0] in ' \t':
 # It's a continuation line.
 lst.append(line)
-x = (self.dict[headerseen] + "\n " + line.strip())
-self.dict[headerseen] = x.strip()
+self.dict[headerseen] += line.rstrip()
 continue
 elif self.iscomment(line):
 # It's a comment.  Ignore it.
Index: Lib/test/test_descr.py
===
--- Lib/test/test_descr.py	(revision 58906)
+++ Lib/test/test_descr.py	(working copy)
@@ -2131,6 +2131,70 @@
 p = property(_testcapi.test_with_docstring)
 
 
+def properties_more():
+class C:
+foo = property(doc="hello")
+@foo.getter
+def foo(self):
+return self._foo
+@foo.setter
+def foo(self, value=None):
+if value is None:
+del self._foo
+else:
+self._foo = abs(value)
+c = C()
+assert C.foo.__doc__ == "hello"
+assert not hasattr(c, "foo")
+c.foo = -42
+assert c.foo == 42
+del c.foo
+assert not hasattr(c, "foo")
+
+class D(C):
+@C.foo.deleter
+def foo(self):
+try:
+del self._foo
+except AttributeError:
+pass
+d = D()
+d.foo = 24
+assert d.foo == 24
+del d.foo
+del d.foo
+
+class E:
+@property
+def foo(self):
+return self._foo
+@foo.setter
+def foo (self, value=None):
+raise RuntimeError
+@foo.setter
+def foo(self, value=None):
+if value is None:
+del self._foo
+else:
+self._foo = abs(value)
+e = E()
+e.foo = -42
+assert e.foo == 42
+del e.foo
+
+class F(E):
+@E.foo.deleter
+def foo(self):
+del self._foo
+@foo.setter
+def foo(self, value):
+self._foo = max(0, value)
+f = F()
+f.foo = -10
+assert f.foo == 0
+del f.foo
+
+
 def supers():
 if verbose: print "Testing supe

[issue1418] Python/hypot.c is never used

2007-11-10 Thread Mark Dickinson

Mark Dickinson added the comment:

hypot.patch contains a possible fix, together with a fix for the includes 
in hypot.c itself.  (As it was, compilation of hypot.c would fail due to 
ssize_t being referenced before definition, in pyport.h.)

Added file: http://bugs.python.org/file8727/hypot.patch

__
Tracker <[EMAIL PROTECTED]>

__

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



[issue1416] @prop.setter decorators

2007-11-10 Thread Guido van Rossum

Guido van Rossum added the comment:

propset3.diff removes the hack that makes the deleter equal to the
setter when no separate deleter has been specified.  If you want a
single method to be used as setter and deleter, write this:

@foo.setter
@foo.deleter
def foo(self, value=None): ...

Added file: http://bugs.python.org/file8728/propset3.diff

__
Tracker <[EMAIL PROTECTED]>

__Index: Objects/descrobject.c
===
--- Objects/descrobject.c	(revision 58906)
+++ Objects/descrobject.c	(working copy)
@@ -1108,7 +1108,61 @@
 	{0}
 };
 
+PyDoc_STRVAR(getter_doc,
+	 "Descriptor to change the setter on a property.");
 
+PyObject *
+property_getter(PyObject *self, PyObject *getter)
+{
+	Py_XDECREF(((propertyobject *)self)->prop_get);
+	if (getter == Py_None)
+		getter = NULL;
+	Py_XINCREF(getter);
+	((propertyobject *)self)->prop_get = getter;
+	Py_INCREF(self);
+	return self;
+}
+
+PyDoc_STRVAR(setter_doc,
+	 "Descriptor to change the setter on a property.\n");
+
+PyObject *
+property_setter(PyObject *self, PyObject *setter)
+{
+	Py_XDECREF(((propertyobject *)self)->prop_set);
+	if (setter == Py_None)
+		setter = NULL;
+	Py_XINCREF(setter);
+	((propertyobject *)self)->prop_set = setter;
+	Py_INCREF(self);
+	return self;
+}
+
+PyDoc_STRVAR(deleter_doc,
+	 "Descriptor to change the deleter on a property.");
+
+PyObject *
+property_deleter(PyObject *self, PyObject *deleter)
+{
+	Py_XDECREF(((propertyobject *)self)->prop_del);
+	if (deleter == Py_None)
+		deleter = NULL;
+	Py_XINCREF(deleter);
+	((propertyobject *)self)->prop_del = deleter;
+	Py_INCREF(self);
+	return self;
+}
+
+
+
+static PyMethodDef property_methods[] = {
+	{"getter", property_getter, METH_O, getter_doc},
+	{"setter", property_setter, METH_O, setter_doc},
+	{"deleter", property_deleter, METH_O, deleter_doc},
+	{0}
+};
+
+
 static void
 property_dealloc(PyObject *self)
 {
@@ -1260,7 +1314,7 @@
 	0,	/* tp_weaklistoffset */
 	0,	/* tp_iter */
 	0,	/* tp_iternext */
-	0,	/* tp_methods */
+	property_methods,			/* tp_methods */
 	property_members,			/* tp_members */
 	0,	/* tp_getset */
 	0,	/* tp_base */
Index: Lib/test/test_descr.py
===
--- Lib/test/test_descr.py	(revision 58906)
+++ Lib/test/test_descr.py	(working copy)
@@ -2131,6 +2131,71 @@
 p = property(_testcapi.test_with_docstring)
 
 
+def properties_plus():
+class C:
+foo = property(doc="hello")
+@foo.getter
+def foo(self):
+return self._foo
+@foo.setter
+def foo(self, value):
+self._foo = abs(value)
+@foo.deleter
+def foo(self):
+del self._foo
+c = C()
+assert C.foo.__doc__ == "hello"
+assert not hasattr(c, "foo")
+c.foo = -42
+assert c.foo == 42
+del c.foo
+assert not hasattr(c, "foo")
+
+class D(C):
+@C.foo.deleter
+def foo(self):
+try:
+del self._foo
+except AttributeError:
+pass
+d = D()
+d.foo = 24
+assert d.foo == 24
+del d.foo
+del d.foo
+
+class E:
+@property
+def foo(self):
+return self._foo
+@foo.setter
+def foo (self, value):
+raise RuntimeError
+@foo.setter
+@foo.deleter
+def foo(self, value=None):
+if value is None:
+del self._foo
+else:
+self._foo = abs(value)
+e = E()
+e.foo = -42
+assert e.foo == 42
+del e.foo
+
+class F(E):
+@E.foo.deleter
+def foo(self):
+del self._foo
+@foo.setter
+def foo(self, value):
+self._foo = max(0, value)
+f = F()
+f.foo = -10
+assert f.foo == 0
+del f.foo
+
+
 def supers():
 if verbose: print "Testing super..."
 
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1416] @prop.setter decorators

2007-11-10 Thread Christian Heimes

Christian Heimes added the comment:

Fixed a typo:

+PyDoc_STRVAR(getter_doc,
+"Descriptor to change the setter on a property.");
  ^^^

--
nosy: +tiran
Added file: http://bugs.python.org/file8729/propset4.diff

__
Tracker <[EMAIL PROTECTED]>

__Index: Objects/descrobject.c
===
--- Objects/descrobject.c	(revision 58906)
+++ Objects/descrobject.c	(working copy)
@@ -1108,7 +1108,61 @@
 	{0}
 };
 
+PyDoc_STRVAR(getter_doc,
+	 "Descriptor to change the getter on a property.");
 
+PyObject *
+property_getter(PyObject *self, PyObject *getter)
+{
+	Py_XDECREF(((propertyobject *)self)->prop_get);
+	if (getter == Py_None)
+		getter = NULL;
+	Py_XINCREF(getter);
+	((propertyobject *)self)->prop_get = getter;
+	Py_INCREF(self);
+	return self;
+}
+
+PyDoc_STRVAR(setter_doc,
+	 "Descriptor to change the setter on a property.\n");
+
+PyObject *
+property_setter(PyObject *self, PyObject *setter)
+{
+	Py_XDECREF(((propertyobject *)self)->prop_set);
+	if (setter == Py_None)
+		setter = NULL;
+	Py_XINCREF(setter);
+	((propertyobject *)self)->prop_set = setter;
+	Py_INCREF(self);
+	return self;
+}
+
+PyDoc_STRVAR(deleter_doc,
+	 "Descriptor to change the deleter on a property.");
+
+PyObject *
+property_deleter(PyObject *self, PyObject *deleter)
+{
+	Py_XDECREF(((propertyobject *)self)->prop_del);
+	if (deleter == Py_None)
+		deleter = NULL;
+	Py_XINCREF(deleter);
+	((propertyobject *)self)->prop_del = deleter;
+	Py_INCREF(self);
+	return self;
+}
+
+
+
+static PyMethodDef property_methods[] = {
+	{"getter", property_getter, METH_O, getter_doc},
+	{"setter", property_setter, METH_O, setter_doc},
+	{"deleter", property_deleter, METH_O, deleter_doc},
+	{0}
+};
+
+
 static void
 property_dealloc(PyObject *self)
 {
@@ -1260,7 +1314,7 @@
 	0,	/* tp_weaklistoffset */
 	0,	/* tp_iter */
 	0,	/* tp_iternext */
-	0,	/* tp_methods */
+	property_methods,			/* tp_methods */
 	property_members,			/* tp_members */
 	0,	/* tp_getset */
 	0,	/* tp_base */
Index: Lib/test/test_descr.py
===
--- Lib/test/test_descr.py	(revision 58906)
+++ Lib/test/test_descr.py	(working copy)
@@ -2131,6 +2131,71 @@
 p = property(_testcapi.test_with_docstring)
 
 
+def properties_plus():
+class C:
+foo = property(doc="hello")
+@foo.getter
+def foo(self):
+return self._foo
+@foo.setter
+def foo(self, value):
+self._foo = abs(value)
+@foo.deleter
+def foo(self):
+del self._foo
+c = C()
+assert C.foo.__doc__ == "hello"
+assert not hasattr(c, "foo")
+c.foo = -42
+assert c.foo == 42
+del c.foo
+assert not hasattr(c, "foo")
+
+class D(C):
+@C.foo.deleter
+def foo(self):
+try:
+del self._foo
+except AttributeError:
+pass
+d = D()
+d.foo = 24
+assert d.foo == 24
+del d.foo
+del d.foo
+
+class E:
+@property
+def foo(self):
+return self._foo
+@foo.setter
+def foo (self, value):
+raise RuntimeError
+@foo.setter
+@foo.deleter
+def foo(self, value=None):
+if value is None:
+del self._foo
+else:
+self._foo = abs(value)
+e = E()
+e.foo = -42
+assert e.foo == 42
+del e.foo
+
+class F(E):
+@E.foo.deleter
+def foo(self):
+del self._foo
+@foo.setter
+def foo(self, value):
+self._foo = max(0, value)
+f = F()
+f.foo = -10
+assert f.foo == 0
+del f.foo
+
+
 def supers():
 if verbose: print "Testing super..."
 
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1412] test_subprocess fails on SuSE 10

2007-11-10 Thread Christian Heimes

Christian Heimes added the comment:

Please try this:

$ mkdir -p ~/tmp
$ TMP=~/tmp make test

--
nosy: +tiran

__
Tracker <[EMAIL PROTECTED]>

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



[issue1416] @prop.setter decorators

2007-11-10 Thread Guido van Rossum

Guido van Rossum added the comment:

Checked into trunk as revision 58929.

--
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



[issue1417] Weakref not working properly

2007-11-10 Thread Raymond Hettinger

Raymond Hettinger added the comment:

It's easier to see what is going on if you print the object ids.  The 
id of self.bla is different than the subsequent c1.bla.  The first is 
freed before the second gets created.

--
nosy: +rhettinger

__
Tracker <[EMAIL PROTECTED]>

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



[issue1415] py3k: pythonw.exe fails because std streams a missing

2007-11-10 Thread Christian Heimes

Christian Heimes added the comment:

PATCH:
* remove the analogy fd < 0 -> file is closed from _fileio.FileIO
* added new flag closed to _fileio.FileIO
* renamed closefd to close_fd to distinguish it from closed
* make it impossible to instantiate another stdprinter
* added repr and fileno methods to stdprinter

Guido:
Are you fine with the changes? The patch doesn't fix the problem (yet)
but it's the first step towards a solution.

--
nosy: +gvanrossum
Added file: http://bugs.python.org/file8730/py3k_fileio_closed.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Modules/_fileio.c
===
--- Modules/_fileio.c	(Revision 58929)
+++ Modules/_fileio.c	(Arbeitskopie)
@@ -30,10 +30,11 @@
 typedef struct {
 	PyObject_HEAD
 	int fd;
+	int closed : 1;
 	unsigned readable : 1;
 	unsigned writable : 1;
 	int seekable : 2; /* -1 means unknown */
-	int closefd : 1;
+	int close_fd : 1;
 	PyObject *weakreflist;
 } PyFileIOObject;
 
@@ -46,6 +47,12 @@
 internal_close(PyFileIOObject *self)
 {
 	int save_errno = 0;
+
+	if (self->closed) {
+		return save_errno;
+	}
+	self->closed = 1;
+
 	if (self->fd >= 0) {
 		int fd = self->fd;
 		self->fd = -1;
@@ -60,7 +67,7 @@
 static PyObject *
 fileio_close(PyFileIOObject *self)
 {
-	if (!self->closefd) {
+	if (!self->close_fd) {
 		if (PyErr_WarnEx(PyExc_RuntimeWarning,
  "Trying to close unclosable fd!", 3) < 0) {
 			return NULL;
@@ -86,6 +93,7 @@
 	self = (PyFileIOObject *) type->tp_alloc(type, 0);
 	if (self != NULL) {
 		self->fd = -1;
+		self->closed = 0;
 		self->weakreflist = NULL;
 	}
 
@@ -127,7 +135,7 @@
 fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
 {
 	PyFileIOObject *self = (PyFileIOObject *) oself;
-	static char *kwlist[] = {"file", "mode", "closefd", NULL};
+	static char *kwlist[] = {"file", "mode", "close_fd", NULL};
 	char *name = NULL;
 	char *mode = "r";
 	char *s;
@@ -138,7 +146,7 @@
 	int rwa = 0, plus = 0, append = 0;
 	int flags = 0;
 	int fd = -1;
-	int closefd = 1;
+	int close_fd = 1;
 
 	assert(PyFileIO_Check(oself));
 	if (self->fd >= 0) {
@@ -148,7 +156,7 @@
 	}
 
 	if (PyArg_ParseTupleAndKeywords(args, kwds, "i|si:fileio",
-	kwlist, &fd, &mode, &closefd)) {
+	kwlist, &fd, &mode, &close_fd)) {
 		if (fd < 0) {
 			PyErr_SetString(PyExc_ValueError,
 	"Negative filedescriptor");
@@ -163,7 +171,7 @@
 		/* On NT, so wide API available */
 		PyObject *po;
 		if (PyArg_ParseTupleAndKeywords(args, kwds, "U|si:fileio",
-		kwlist, &po, &mode, &closefd)
+		kwlist, &po, &mode, &close_fd)
 		) {
 			widename = PyUnicode_AS_UNICODE(po);
 		} else {
@@ -178,7 +186,7 @@
 		if (!PyArg_ParseTupleAndKeywords(args, kwds, "et|si:fileio",
 		 kwlist,
 		 Py_FileSystemDefaultEncoding,
-		 &name, &mode, &closefd))
+		 &name, &mode, &close_fd))
 			goto error;
 	}
 	}
@@ -247,13 +255,13 @@
 
 	if (fd >= 0) {
 		self->fd = fd;
-		self->closefd = closefd;
+		self->close_fd = close_fd;
 	}
 	else {
-		self->closefd = 1;
-		if (!closefd) {
+		self->close_fd = 1;
+		if (!close_fd) {
 			PyErr_SetString(PyExc_ValueError,
-"Cannot use closefd=True with file name");
+"Cannot use close_fd=True with file name");
 			goto error;
 		}
 
@@ -292,7 +300,7 @@
 	if (self->weakreflist != NULL)
 		PyObject_ClearWeakRefs((PyObject *) self);
 
-	if (self->fd >= 0 && self->closefd) {
+	if (self->fd >= 0 && self->close_fd) {
 		errno = internal_close(self);
 		if (errno < 0) {
 #ifdef HAVE_STRERROR
@@ -315,12 +323,39 @@
 }
 
 static PyObject *
+err_invalid(void)
+{
+#ifdef EBADF
+	errno = EBADF;
+	PyErr_SetFromErrno(PyExc_IOError);
+	return NULL;
+#else
+	PyErr_SetString(PyExc_IOError, "Bad file descriptor");
+	return NULL;
+#endif
+}
+
+static PyObject *
 err_mode(char *action)
 {
 	PyErr_Format(PyExc_ValueError, "File not open for %s", action);
 	return NULL;
 }
 
+int
+err_check(PyFileIOObject *self)
+{
+	if (self->closed) {
+		err_closed();
+		return 1;
+	}
+	if (self->fd < 0) {
+		err_invalid();
+		return 1;
+	}
+	return 0;
+}
+
 static PyObject *
 fileio_fileno(PyFileIOObject *self)
 {
@@ -332,24 +367,24 @@
 static PyObject *
 fileio_readable(PyFileIOObject *self)
 {
-	if (self->fd < 0)
-		return err_closed();
+	if (err_check(self))
+		return NULL;
 	return PyBool_FromLong((long) self->readable);
 }
 
 static PyObject *
 fileio_writable(PyFileIOObject *self)
 {
-	if (self->fd < 0)
-		return err_closed();
+	if (err_check(self))
+		return NULL;
 	return PyBool_FromLong((long) self->writable);
 }
 
 static PyObject *
 fileio_seekable(PyFileIOObject *self)
 {
-	if (self->fd < 0)
-		return err_closed();
+	if (err_check(self))
+		return NULL;
 	if (self->seekable < 0) {
 		int ret;
 		Py_BEGIN_ALLOW_THREADS
@@ -369,8 +404,8 @@
 	char *ptr;
 	Py_ssize_t n;
 
-	if (self->fd < 0)
-		return err_closed();
+	if (err_check(s

[issue1419] ssl module version 1.10 causes TypeError when accepting connection

2007-11-10 Thread Viktor Ferenczi

New submission from Viktor Ferenczi:

The SSLSocket.accept() method passes arguments to SSLSocket's
constructor in wrong order which causes TypeError later in the
constructor. Proposed patch to ssl.__init__.py:

@@ -257,7 +257,7 @@
 SSL channel, and the address of the remote client."""

 newsock, addr = socket.accept(self)
-return (SSLSocket(newsock, True, self.keyfile, self.certfile,
+return (SSLSocket(newsock, self.keyfile, self.certfile, True,
   self.cert_reqs, self.ssl_version,
   self.ca_certs, self.do_handshake_on_connect),
addr)

--
components: Library (Lib)
messages: 57364
nosy: complex
severity: critical
status: open
title: ssl module version 1.10 causes TypeError when accepting connection
type: crash
versions: Python 2.6

__
Tracker <[EMAIL PROTECTED]>

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



[issue1415] py3k: pythonw.exe fails because std streams a missing

2007-11-10 Thread Christian Heimes

Christian Heimes added the comment:

The new patch fixes the startup problem with pythonw.exe on Windows. I
still wonder if print(sometest) is raising an exception when stdout is
not available.

Added file: http://bugs.python.org/file8731/py3k_fileio_fixes.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Modules/_fileio.c
===
--- Modules/_fileio.c	(revision 58930)
+++ Modules/_fileio.c	(working copy)
@@ -7,6 +7,8 @@
 #include 
 #include  /* For offsetof */
 
+#define INVALID_FD -0xFABC
+
 /*
  * Known likely problems:
  *
@@ -30,10 +32,11 @@
 typedef struct {
 	PyObject_HEAD
 	int fd;
+	int closed : 1;
 	unsigned readable : 1;
 	unsigned writable : 1;
 	int seekable : 2; /* -1 means unknown */
-	int closefd : 1;
+	int close_fd : 1;
 	PyObject *weakreflist;
 } PyFileIOObject;
 
@@ -46,9 +49,15 @@
 internal_close(PyFileIOObject *self)
 {
 	int save_errno = 0;
+
+	if (self->closed) {
+		return save_errno;
+	}
+	self->closed = 1;
+
 	if (self->fd >= 0) {
 		int fd = self->fd;
-		self->fd = -1;
+		self->fd = INVALID_FD;
 		Py_BEGIN_ALLOW_THREADS
 		if (close(fd) < 0)
 			save_errno = errno;
@@ -60,7 +69,7 @@
 static PyObject *
 fileio_close(PyFileIOObject *self)
 {
-	if (!self->closefd) {
+	if (!self->close_fd) {
 		if (PyErr_WarnEx(PyExc_RuntimeWarning,
  "Trying to close unclosable fd!", 3) < 0) {
 			return NULL;
@@ -86,6 +95,7 @@
 	self = (PyFileIOObject *) type->tp_alloc(type, 0);
 	if (self != NULL) {
 		self->fd = -1;
+		self->closed = 0;
 		self->weakreflist = NULL;
 	}
 
@@ -127,7 +137,7 @@
 fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
 {
 	PyFileIOObject *self = (PyFileIOObject *) oself;
-	static char *kwlist[] = {"file", "mode", "closefd", NULL};
+	static char *kwlist[] = {"file", "mode", "close_fd", NULL};
 	char *name = NULL;
 	char *mode = "r";
 	char *s;
@@ -137,8 +147,8 @@
 	int ret = 0;
 	int rwa = 0, plus = 0, append = 0;
 	int flags = 0;
-	int fd = -1;
-	int closefd = 1;
+	int fd = INVALID_FD;
+	int close_fd = 1;
 
 	assert(PyFileIO_Check(oself));
 	if (self->fd >= 0) {
@@ -148,12 +158,12 @@
 	}
 
 	if (PyArg_ParseTupleAndKeywords(args, kwds, "i|si:fileio",
-	kwlist, &fd, &mode, &closefd)) {
-		if (fd < 0) {
+	kwlist, &fd, &mode, &close_fd)) {
+		/*if (fd < 0) {
 			PyErr_SetString(PyExc_ValueError,
 	"Negative filedescriptor");
 			return -1;
-		}
+		}*/
 	}
 	else {
 		PyErr_Clear();
@@ -163,7 +173,7 @@
 		/* On NT, so wide API available */
 		PyObject *po;
 		if (PyArg_ParseTupleAndKeywords(args, kwds, "U|si:fileio",
-		kwlist, &po, &mode, &closefd)
+		kwlist, &po, &mode, &close_fd)
 		) {
 			widename = PyUnicode_AS_UNICODE(po);
 		} else {
@@ -178,7 +188,7 @@
 		if (!PyArg_ParseTupleAndKeywords(args, kwds, "et|si:fileio",
 		 kwlist,
 		 Py_FileSystemDefaultEncoding,
-		 &name, &mode, &closefd))
+		 &name, &mode, &close_fd))
 			goto error;
 	}
 	}
@@ -245,15 +255,15 @@
 		flags |= O_APPEND;
 #endif
 
-	if (fd >= 0) {
+	if (fd != INVALID_FD) {
 		self->fd = fd;
-		self->closefd = closefd;
+		self->close_fd = close_fd;
 	}
 	else {
-		self->closefd = 1;
-		if (!closefd) {
+		self->close_fd = 1;
+		if (!close_fd) {
 			PyErr_SetString(PyExc_ValueError,
-"Cannot use closefd=True with file name");
+"Cannot use close_fd=True with file name");
 			goto error;
 		}
 
@@ -292,7 +302,7 @@
 	if (self->weakreflist != NULL)
 		PyObject_ClearWeakRefs((PyObject *) self);
 
-	if (self->fd >= 0 && self->closefd) {
+	if (self->fd >= 0 && self->close_fd) {
 		errno = internal_close(self);
 		if (errno < 0) {
 #ifdef HAVE_STRERROR
@@ -315,16 +325,44 @@
 }
 
 static PyObject *
+err_invalid(void)
+{
+#ifdef EBADF
+	errno = EBADF;
+	PyErr_SetFromErrno(PyExc_IOError);
+	return NULL;
+#else
+	PyErr_SetString(PyExc_IOError, "Bad file descriptor");
+	return NULL;
+#endif
+}
+
+static PyObject *
 err_mode(char *action)
 {
 	PyErr_Format(PyExc_ValueError, "File not open for %s", action);
 	return NULL;
 }
 
+int
+err_check(PyFileIOObject *self)
+{
+	if (self->closed) {
+		err_closed();
+		return 1;
+	}
+	if (self->fd < 0) {
+		err_invalid();
+		return 1;
+	}
+	return 0;
+}
+
 static PyObject *
 fileio_fileno(PyFileIOObject *self)
 {
-	if (self->fd < 0)
+	/* don't check for valid fd here */
+	if (self->closed)
 		return err_closed();
 	return PyInt_FromLong((long) self->fd);
 }
@@ -332,7 +370,8 @@
 static PyObject *
 fileio_readable(PyFileIOObject *self)
 {
-	if (self->fd < 0)
+	/* don't check for valid fd here */
+	if (self->closed)
 		return err_closed();
 	return PyBool_FromLong((long) self->readable);
 }
@@ -340,7 +379,8 @@
 static PyObject *
 fileio_writable(PyFileIOObject *self)
 {
-	if (self->fd < 0)
+	/* don't check for valid fd here */
+	if (self->closed)
 		return err_closed();
 	return PyBool_FromLong((long) self->writable);
 }