[issue1168] complex arithmetic: strange results with "imag"

2007-09-16 Thread Nusret BALCI

New submission from Nusret BALCI:

"imag" returns incorrect results if invoked on a literal number.
Looks like a bug.

>>> 1-2j
(1-2j)
>>> 1-2j.real
1.0
>>> 1-2j.imag
-1.0
>>> 1-4j.imag
-3.0
>>> (1-4j).imag
-4.0
>>>

--
messages: 55940
nosy: newman
severity: normal
status: open
title: complex arithmetic: strange results with "imag"
type: behavior
versions: Python 2.5, 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



[issue1168] complex arithmetic: strange results with "imag"

2007-09-16 Thread Gabriel Genellina

Gabriel Genellina added the comment:

Note that there are no complex literals in Python, only imaginary 
literals. 1-4j is an expression, not a literal.
So 1-4j.imag means 1-(4j.imag) = 1-4 = -3
See http://docs.python.org/ref/numbers.html#l2h-16

(I'd close this as not a bug)

--
nosy: +gagenellina

__
Tracker <[EMAIL PROTECTED]>

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



[issue1168] complex arithmetic: strange results with "imag"

2007-09-16 Thread Georg Brandl

Georg Brandl added the comment:

Exactly.

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



[issue1134] Parsing a simple script eats all of your memory

2007-09-16 Thread Alexey Suda-Chen

Alexey Suda-Chen added the comment:

Oops, i see there are two bugs. Previously i have fixed multiline
strings only.

I think it will be:

Index: tokenizer.c
===
--- tokenizer.c (revision 58161)
+++ tokenizer.c (working copy)
@@ -395,6 +395,7 @@
goto error;
buflen = size;
}
+
memcpy(s, buf, buflen);
s[buflen] = '\0';
if (buflen == 0) /* EOF */
@@ -402,6 +403,12 @@
if (allocated) {
Py_DECREF(bufobj);
}
+
+  if ( bufobj == tok->decoding_buffer ){
+Py_XDECREF(tok->decoding_buffer);
+tok->decoding_buffer = 0;
+  }
+
return s;
 
 error:

__
Tracker <[EMAIL PROTECTED]>

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



[issue1167] gdbm/ndbm 1.8.1+ needs libgdbm_compat.so

2007-09-16 Thread Martin v. Löwis

Changes by Martin v. Löwis:


--
keywords: +patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue1146] TextWrap vs words 1-character shorter than the width

2007-09-16 Thread Martin v. Löwis

Changes by Martin v. Löwis:


--
keywords: +patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue1727780] 64/32-bit issue when unpickling random.Random

2007-09-16 Thread Martin v. Löwis

Martin v. Löwis added the comment:

Would anybody of you like to work on a 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



[issue1169] Option -OO doesn't remove docstrings from functions

2007-09-16 Thread Daniele Varrazzo

New submission from Daniele Varrazzo:

The issue was already addressed in Issue1722485.

The fix applied in rev. 55732, 55733 only fixes module and class
docstrings, not function docstrings.

The attached patch fixed the issue for function docstrings too.

--
components: None
files: fix_function_docstring.patch
messages: 55945
nosy: piro
severity: normal
status: open
title: Option -OO doesn't remove docstrings from functions
type: compile error
versions: Python 2.5

__
Tracker <[EMAIL PROTECTED]>

__--- compile.c.bak	2007-09-16 17:23:43.0 +0200
+++ compile.c	2007-09-16 17:26:38.0 +0200
@@ -1336,7 +1336,7 @@
 
 	st = (stmt_ty)asdl_seq_GET(s->v.FunctionDef.body, 0);
 	docstring = compiler_isdocstring(st);
-	if (docstring)
+	if (docstring && Py_OptimizeFlag < 2)
 	first_const = st->v.Expr.value->v.Str.s;
 	if (compiler_add_o(c, c->u->u_consts, first_const) < 0)	 {
 	compiler_exit_scope(c);
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1169] Option -OO doesn't remove docstrings from functions

2007-09-16 Thread Daniele Varrazzo

Daniele Varrazzo added the comment:

The attached file shows the issue: running with -OO no docstring should
be printed.

In rev 58163 the functions docstrings are still printed.

__
Tracker <[EMAIL PROTECTED]>

__"""Module docstring"""

class Test:
"""Class docstring"""
def test(self):
"""Method docstring."""
pass

def fun():
"""Function docstring."""
pass

print 'module', __doc__
print 'class', Test.__doc__
print 'method', Test.test.__doc__
print 'fun', fun.__doc__
___
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-09-16 Thread Eduardo Padoan

Changes by Eduardo Padoan:


--
severity: critical -> minor

__
Tracker <[EMAIL PROTECTED]>

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



[issue1169] Option -OO doesn't remove docstrings from functions

2007-09-16 Thread Martin v. Löwis

Changes by Martin v. Löwis:


--
keywords: +patch

__
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-09-16 Thread Raymond Hettinger

Changes by Raymond Hettinger:


--
assignee:  -> rhettinger
nosy: +rhettinger

__
Tracker <[EMAIL PROTECTED]>

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



[issue1158] %f format for datetime objects

2007-09-16 Thread Skip Montanaro

Changes by Skip Montanaro:


__
Tracker <[EMAIL PROTECTED]>

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



[issue1158] %f format for datetime objects

2007-09-16 Thread Skip Montanaro

Skip Montanaro added the comment:

Here are new patches for 2.6 and 3.0 including changes
to doc and test cases.

__
Tracker <[EMAIL PROTECTED]>

__Index: Lib/test/test_datetime.py
===
--- Lib/test/test_datetime.py	(revision 58174)
+++ Lib/test/test_datetime.py	(working copy)
@@ -1488,9 +1488,9 @@
 
 def test_more_strftime(self):
 # This tests fields beyond those tested by the TestDate.test_strftime.
-t = self.theclass(2004, 12, 31, 6, 22, 33)
-self.assertEqual(t.strftime("%m %d %y %S %M %H %j"),
-"12 31 04 33 22 06 366")
+t = self.theclass(2004, 12, 31, 6, 22, 33, 47)
+self.assertEqual(t.strftime("%m %d %y %f %S %M %H %j"),
+"12 31 04 47 33 22 06 366")
 
 def test_extract(self):
 dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234)
@@ -1763,7 +1763,7 @@
 
 def test_strftime(self):
 t = self.theclass(1, 2, 3, 4)
-self.assertEqual(t.strftime('%H %M %S'), "01 02 03")
+self.assertEqual(t.strftime('%H %M %S %f'), "01 02 03 04")
 # A naive object replaces %z and %Z with empty strings.
 self.assertEqual(t.strftime("'%z' '%Z'"), "'' ''")
 
Index: Modules/datetimemodule.c
===
--- Modules/datetimemodule.c	(revision 58174)
+++ Modules/datetimemodule.c	(working copy)
@@ -1130,10 +1130,24 @@
 	return 0;
 }
 
+static PyObject *
+make_freplacement(PyObject *object)
+{
+	char freplacement[7];
+	if (PyTime_Check(object))
+	sprintf(freplacement, "%06d", TIME_GET_MICROSECOND(object));
+	else if (PyDateTime_Check(object))
+	sprintf(freplacement, "%06d", DATE_GET_MICROSECOND(object));
+	else
+	sprintf(freplacement, "%06d", 0);
+
+	return PyString_FromStringAndSize(freplacement, strlen(freplacement));
+}
+
 /* I sure don't want to reproduce the strftime code from the time module,
  * so this imports the module and calls it.  All the hair is due to
- * giving special meanings to the %z and %Z format codes via a preprocessing
- * step on the format string.
+ * giving special meanings to the %z, %Z and %f format codes via a
+ * preprocessing step on the format string.
  * tzinfoarg is the argument to pass to the object's tzinfo method, if
  * needed.
  */
@@ -1145,6 +1159,7 @@
 
 	PyObject *zreplacement = NULL;	/* py string, replacement for %z */
 	PyObject *Zreplacement = NULL;	/* py string, replacement for %Z */
+	PyObject *freplacement = NULL;	/* py string, replacement for %f */
 
 	char *pin;	/* pointer to next char in input format */
 	char ch;	/* next char in input format */
@@ -1186,11 +1201,11 @@
 		}
 	}
 
-	/* Scan the input format, looking for %z and %Z escapes, building
+	/* Scan the input format, looking for %z/%Z/%f escapes, building
 	 * a new format.  Since computing the replacements for those codes
 	 * is expensive, don't unless they're actually used.
 	 */
-	totalnew = PyString_Size(format) + 1;	/* realistic if no %z/%Z */
+	totalnew = PyString_Size(format) + 1;	/* realistic if no %z/%Z/%f */
 	newfmt = PyString_FromStringAndSize(NULL, totalnew);
 	if (newfmt == NULL) goto Done;
 	pnew = PyString_AsString(newfmt);
@@ -1272,6 +1287,18 @@
 			ptoappend = PyString_AS_STRING(Zreplacement);
 			ntoappend = PyString_GET_SIZE(Zreplacement);
 		}
+		else if (ch == 'f') {
+			/* format microseconds */
+			if (freplacement == NULL) {
+freplacement = make_freplacement(object);
+if (freplacement == NULL)
+	goto Done;
+			}
+			assert(freplacement != NULL);
+			assert(PyString_Check(freplacement));
+			ptoappend = PyString_AS_STRING(freplacement);
+			ntoappend = PyString_GET_SIZE(freplacement);
+		}
 		else {
 			/* percent followed by neither z nor Z */
 			ptoappend = pin - 2;
@@ -1313,6 +1340,7 @@
 		Py_DECREF(time);
 	}
  Done:
+	Py_XDECREF(freplacement);
 	Py_XDECREF(zreplacement);
 	Py_XDECREF(Zreplacement);
 	Py_XDECREF(newfmt);
Index: Doc/library/datetime.rst
===
--- Doc/library/datetime.rst	(revision 58174)
+++ Doc/library/datetime.rst	(working copy)
@@ -1297,10 +1297,16 @@
 be used, as time objects have no such values.  If they're used anyway, ``1900``
 is substituted for the year, and ``0`` for the month and day.
 
-For :class:`date` objects, the format codes for hours, minutes, and seconds
-should not be used, as :class:`date` objects have no such values.  If they're
-used anyway, ``0`` is substituted for them.
+For :class:`date` objects, the format codes for hours, minutes, seconds, and
+fractions of sections should not be used, as :class:`date` objects have no
+such values.  If they're used anyway, ``0`` is substituted for them.
 
+:class:`time` and :class:`datetime` objects support a ``%f`` format code
+which expands to the

[issue1158] %f format for datetime objects

2007-09-16 Thread Skip Montanaro

Changes by Skip Montanaro:


__
Tracker <[EMAIL PROTECTED]>

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



[issue1164] tp_print slots don't release the GIL

2007-09-16 Thread Guido van Rossum

Guido van Rossum added the comment:

looks good to me :)

--
assignee:  -> brett.cannon

__
Tracker <[EMAIL PROTECTED]>

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



[issue1164] tp_print slots don't release the GIL

2007-09-16 Thread Brett Cannon

Brett Cannon added the comment:

Applied in r58176.  And I am glad this is not an issue in Py3K.  =)

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



[issue1597011] Reading with bz2.BZ2File() returns one garbage character

2007-09-16 Thread Sean Reifschneider

Sean Reifschneider added the comment:

I have committed this into trunk and the 2.5 maintenance branch.  It
passes all tests and the resulting build passes the submitter-provided test.

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



[issue1020] pydoc doesn't work on pyexpat

2007-09-16 Thread Sean Reifschneider

Changes by Sean Reifschneider:


--
priority:  -> low

__
Tracker <[EMAIL PROTECTED]>

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



[issue1021] logging.basicConfig does not allow to set NOTSET level

2007-09-16 Thread Sean Reifschneider

Changes by Sean Reifschneider:


--
assignee:  -> vsajip
nosy: +vsajip
priority:  -> normal

__
Tracker <[EMAIL PROTECTED]>

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



[issue1025] tracebacks from list comps (probably other comps) don't show full stack

2007-09-16 Thread Sean Reifschneider

Changes by Sean Reifschneider:


--
priority:  -> normal

__
Tracker <[EMAIL PROTECTED]>

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



[issue1042] test_glob fails with UnicodeDecodeError

2007-09-16 Thread Sean Reifschneider

Changes by Sean Reifschneider:


--
priority:  -> high

__
Tracker <[EMAIL PROTECTED]>

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



[issue1053] bogus attributes reported in asyncore doc

2007-09-16 Thread Sean Reifschneider

Changes by Sean Reifschneider:


--
priority:  -> normal

__
Tracker <[EMAIL PROTECTED]>

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



[issue1053] bogus attributes reported in asyncore doc

2007-09-16 Thread Sean Reifschneider

Changes by Sean Reifschneider:


--
assignee:  -> fdrake
nosy: +fdrake

__
Tracker <[EMAIL PROTECTED]>

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



[issue1060] zipfile cannot handle files larger than 2GB (inside archive)

2007-09-16 Thread Sean Reifschneider

Changes by Sean Reifschneider:


--
priority:  -> normal

__
Tracker <[EMAIL PROTECTED]>

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



[issue1003] zipfile password fails validation

2007-09-16 Thread Sean Reifschneider

Changes by Sean Reifschneider:


--
priority:  -> normal

__
Tracker <[EMAIL PROTECTED]>

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



[issue1067] test_smtplib failures (caused by asyncore)

2007-09-16 Thread Sean Reifschneider

Changes by Sean Reifschneider:


--
priority:  -> high

__
Tracker <[EMAIL PROTECTED]>

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



[issue1079] decode_header does not follow RFC 2047

2007-09-16 Thread Sean Reifschneider

Sean Reifschneider added the comment:

Can you provide an example of an address that triggers this?  Preferably
in a code sample that can be used to reproduce it?  Uber-ideally, a
patch to the email module test suite would be great.

--
nosy: +jafo
priority:  -> normal

__
Tracker <[EMAIL PROTECTED]>

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



[issue1597011] Reading with bz2.BZ2File() returns one garbage character

2007-09-16 Thread Sean Reifschneider

Changes by Sean Reifschneider:


--
resolution:  -> fixed

_
Tracker <[EMAIL PROTECTED]>

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



[issue1081] file.seek allows float arguments

2007-09-16 Thread Sean Reifschneider

Changes by Sean Reifschneider:


--
assignee:  -> loewis
nosy: +loewis
priority:  -> normal

__
Tracker <[EMAIL PROTECTED]>

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