[issue1309567] linecache module returns wrong results

2008-11-16 Thread Rafe Sacks

Rafe Sacks <[EMAIL PROTECTED]> added the comment:

This seems related to http://bugs.python.org/issue1218234 as well. 
This is my first bug report. I hope I do this right.
I posted this to comp.lang.python and was directed here. Here is a
chopped paste of that post:

I am getting an error on line 510 of inspect.py:

504if iscode(object):
505if not hasattr(object, 'co_firstlineno'):
506raise IOError('could not find function definition')
507lnum = object.co_firstlineno - 1
508pat = re.compile(r'^(\s*def\s)|(.*(? 0:
510if pat.match(lines[lnum]): break
511lnum = lnum - 1
512return lines, lnum

I finally figured out that there was a caching problem. The function I
passed was changed, but the code lines (strings) retrieved by
linecache.getlines() (on lines 464 and 466) didn't update with the new
module contents... To get around this, I invoke linecache.clearcache()...

linecache.clearcache()
lines, n = inspect.getsourcelines(fn)


While inspect uses the cached module to get the text, the line number
used to find the block of source lines is retrieved from the passed
object. So, if I pass a function which reports that it starts on line
50, but in the cache it starts on line 40, an error isn't raised but the
lines of code returned are wrong. The error only occurs when the line
number is higher than the number of lines in the cached module.

Cheers,

- Rafe

--
nosy: +RafeSacks

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4252] some missing links in html help index pane

2008-11-16 Thread Hirokazu Yamamoto

Changes by Hirokazu Yamamoto <[EMAIL PROTECTED]>:


Added file: http://bugs.python.org/file12025/resolved.png

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4252] some missing links in html help index pane

2008-11-16 Thread Hirokazu Yamamoto

Hirokazu Yamamoto <[EMAIL PROTECTED]> added the comment:

This describes second bug.

When multiple target was bound to same keyword, only first target could
be browsed.

In index_on_firefox.png, we can see "operator, [1], [2]". This [?] means
multiple targets are linked to same keyword and we can browse each
target in firefox. But from htmlhelp, we can only browse first target.

Attached patch "sphinx_multiple_targets.patch" will enable us to select
each targets in popup dialog. (They all have same title, I think it's
useless though)

Please apply this patch after applied sphinx_inactive_index_item.patch.

--
title: inactive item not shown in html help index pane -> some missing links in 
html help index pane
Added file: http://bugs.python.org/file12024/sphinx_multiple_targets.patch

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4332] asyncore.file_dispatcher does not use dup()'ed fd

2008-11-16 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' <[EMAIL PROTECTED]>:


--
nosy: +giampaolo.rodola

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4332] asyncore.file_dispatcher does not use dup()'ed fd

2008-11-16 Thread Benjamin Peterson

Changes by Benjamin Peterson <[EMAIL PROTECTED]>:


--
assignee:  -> josiahcarlson
nosy: +josiahcarlson

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4334] Mac Build Script is broken for 2.6 release

2008-11-16 Thread Benjamin Peterson

Benjamin Peterson <[EMAIL PROTECTED]> added the comment:

This has been backported and will be fixed in 2.6.1.

--
nosy: +benjamin.peterson
resolution:  -> out of date
status: open -> closed

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4334] Mac Build Script is broken for 2.6 release

2008-11-16 Thread Noah Gift

New submission from Noah Gift <[EMAIL PROTECTED]>:

Just an FYI, the Mac Build script in:

Python-2.6 2/Mac/BuildScript/build-installer.py

contains broken download URLs for SQLite, and cause the build to fail.  
I fixed this myself, but noticed this appears to be fixed in the trunk, 
already.  Having a working build script is a fairly big deal for mac 
users, as they often need to have readline compiled properly with 
Python, which is a pain.  This might be nice to have fixed in the 
production release.

--
components: Build
messages: 75949
nosy: ngift
severity: normal
status: open
title: Mac Build Script is broken for 2.6 release
type: crash
versions: Python 2.6

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4333] Reworked Dialog.py

2008-11-16 Thread Guilherme Polo

New submission from Guilherme Polo <[EMAIL PROTECTED]>:

Hi,

I have changed the lib-tk/Dialog.py so it handles the cases where one
might receive a tuple as a result containing a Tcl_Obj. I've also
modified all the rest of it to make it "cleaner".

It is b/w compatible although I dislike the usage of cnf, but I guess
I'm too late to suggest this change even for py3k :/
A "more complete" description of the changes is in
http://svn.python.org/view?rev=67240&view=rev

--
components: Tkinter
files: Dialog.diff
keywords: patch
messages: 75948
nosy: gpolo
severity: normal
status: open
title: Reworked Dialog.py
versions: Python 2.7
Added file: http://bugs.python.org/file12023/Dialog.diff

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4332] asyncore.file_dispatcher does not use dup()'ed fd

2008-11-16 Thread Christian Becke

New submission from Christian Becke <[EMAIL PROTECTED]>:

asyncore.file_dispatcher stores the file descriptor passed to
asyncore.file_dispatcher.__init__ into the map, not the dup()'ed one
created by asyncore.file_wrapper. Because of this, a "select.error (9,
'Bad file descriptor')" is raised in asyncore.loop() if the fd passed to
asyncore.file_dispatcher.__init__ is closed while the loop is running.
Attached patch fixes the issue.

--
components: Library (Lib)
files: asyncore_file_dispatcher_use_duped_fd.diff
keywords: patch
messages: 75947
nosy: christianbecke
severity: normal
status: open
title: asyncore.file_dispatcher does not use dup()'ed fd
type: behavior
versions: Python 2.6
Added file: 
http://bugs.python.org/file12022/asyncore_file_dispatcher_use_duped_fd.diff

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4331] Can't use _functools.partial() created function as method

2008-11-16 Thread Raymond Hettinger

Raymond Hettinger <[EMAIL PROTECTED]> added the comment:

Reclassifying as a feature request.
A descriptor could be added to partial()
so that it too would have automatic
method binding just like pure python functions.

--
nosy: +rhettinger
type: behavior -> feature request
versions: +Python 2.7, Python 3.0 -Python 2.5, Python 2.6

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4331] Can't use _functools.partial() created function as method

2008-11-16 Thread Calvin Spealman

Calvin Spealman <[EMAIL PROTECTED]> added the comment:

I don't think this is any kind of bug, it is simply a product of only 
function objects being decorated automatically as methods. Your python 
version works because it is, in fact, a function. _functools.partial 
objects are not functions, but simply callable objects.

--
nosy: +ironfroggy

___
Python tracker <[EMAIL PROTECTED]>

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



[issue2260] conditional jump to a POP_TOP optimization

2008-11-16 Thread Raymond Hettinger

Raymond Hettinger <[EMAIL PROTECTED]> added the comment:

Georg, would you please give this a second review.  It passes the whole
test suite for me and triggers often.

--
assignee: rhettinger -> georg.brandl
nosy: +georg.brandl

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3106] speedup some comparisons

2008-11-16 Thread Antoine Pitrou

Antoine Pitrou <[EMAIL PROTECTED]> added the comment:

Hello,

> You may get better timings if you more the types-are-equal test inside
> the types-i-know test.

I get no discernable difference.

> In general, I'm not too keen on adding this kind of dispatch code to
> ceval.c.  It saves the time spent in PyObject_RichCompare() trying to
> figure out where to delegate the work.

Some minimal type testing is necessary if we want to implement the
identity-implies-equality optimization for some types without breaking
the fact that e.g. NaN != NaN. This optimization is important when
dealing with e.g. interned strings. There could be a special flag in the
type structure signaling that the optimization is safe.

I'm attaching a patch which reduces the additional dispatch to a
minimum. The speedup on pybench is smaller, but there is no significant
slowdown for "other" comparisons.

Test minimum run-timeaverage  run-time
 thisother   diffthisother   diff
---
 CompareFloats:   176ms   173ms   +1.9%   180ms   175ms   +3.2%
 CompareFloatsIntegers:   237ms   234ms   +1.0%   251ms   240ms   +4.6%
   CompareIntegers:   266ms   276ms   -3.6%   266ms   278ms   -4.3%
CompareInternedStrings:   160ms   261ms  -38.6%   161ms   261ms  -38.4%
  CompareLongs:   156ms   166ms   -6.1%   156ms   167ms   -7.1%
CompareStrings:   167ms   172ms   -2.9%   170ms   173ms   -1.9%
---
Totals:  1161ms  1281ms   -9.4%  1184ms  1295ms   -8.6%

Added file: http://bugs.python.org/file12021/cmps4.patch

___
Python tracker <[EMAIL PROTECTED]>

___diff -r c8ad1bd796f0 Objects/longobject.c
--- a/Objects/longobject.c  Sun Nov 16 19:33:53 2008 +0100
+++ b/Objects/longobject.c  Sun Nov 16 21:28:08 2008 +0100
@@ -2209,37 +2209,60 @@
 static int
 long_compare(PyLongObject *a, PyLongObject *b)
 {
-   Py_ssize_t sign;
-
-   if (Py_SIZE(a) != Py_SIZE(b)) {
-   if (ABS(Py_SIZE(a)) == 0 && ABS(Py_SIZE(b)) == 0)
-   sign = 0;
-   else
-   sign = Py_SIZE(a) - Py_SIZE(b);
+   Py_ssize_t sa = Py_SIZE(a), sb = Py_SIZE(b), i;
+   if (sa != sb) {
+   return sa > sb ? 1 : -1;
}
-   else {
-   Py_ssize_t i = ABS(Py_SIZE(a));
-   while (--i >= 0 && a->ob_digit[i] == b->ob_digit[i])
-   ;
-   if (i < 0)
-   sign = 0;
-   else {
-   sign = (int)a->ob_digit[i] - (int)b->ob_digit[i];
-   if (Py_SIZE(a) < 0)
-   sign = -sign;
+   i = ABS(sa);
+   while (--i >= 0) {
+   digit ad = a->ob_digit[i], bd = b->ob_digit[i];
+   if (ad != bd) {
+   if (sa < 0)
+   return ad < bd ? 1 : -1;
+   else
+   return ad > bd ? 1 : -1;
}
}
-   return sign < 0 ? -1 : sign > 0 ? 1 : 0;
+   return 0;
 }
+
+#define TEST_COND(cond) \
+   ((cond) ? Py_True : Py_False)
 
 static PyObject *
 long_richcompare(PyObject *self, PyObject *other, int op)
 {
-   PyObject *result;
+   int cmp;
+   PyObject *v;
CHECK_BINOP(self, other);
-   result = Py_CmpToRich(op, long_compare((PyLongObject*)self, 
-  (PyLongObject*)other));
-   return result;
+   cmp = long_compare((PyLongObject*)self,
+  (PyLongObject*)other);
+   /* Convert the return value to a Boolean */
+   switch (op) {
+   case Py_EQ:
+   v = TEST_COND(cmp == 0);
+   break;
+   case Py_NE:
+   v = TEST_COND(cmp != 0);
+   break;
+   case Py_LE:
+   v = TEST_COND(cmp <= 0);
+   break;
+   case Py_GE:
+   v = TEST_COND(cmp >= 0);
+   break;
+   case Py_LT:
+   v = TEST_COND(cmp == -1);
+   break;
+   case Py_GT:
+   v = TEST_COND(cmp == 1);
+   break;
+   default:
+   PyErr_BadArgument();
+   return NULL;
+   }
+   Py_INCREF(v);
+   return v;
 }
 
 static long
diff -r c8ad1bd796f0 Objects/unicodeobject.c
--- a/Objects/unicodeobject.c   Sun Nov 16 19:33:53 2008 +0100
+++ b/Objects/unicodeobject.c   Sun Nov 16 21:28:08 2008 +0100
@@ -6508,81 +6508,62 @@
 return 0;
 }
 
+
+#define TEST_COND(cond) \
+   ((cond) ? Py_True : Py_False)
+
 PyObject *PyUnicode_RichComp

[issue4331] Can't use _functools.partial() created function as method

2008-11-16 Thread scott sadler

scott sadler <[EMAIL PROTECTED]> added the comment:

A short update, I believe that the reason that it was working in one
instance was because of some abstractions by a base class (Django model,
get_absolute_url).

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4330] wsgiref.validate doesn't accept arguments to readline

2008-11-16 Thread Ian Bicking

Ian Bicking <[EMAIL PROTECTED]> added the comment:

cgi started using this argument due to the potential of a DoS attack
without the length limit.  So undoing this in cgi (even as an option)
would be a regression.

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3106] speedup some comparisons

2008-11-16 Thread Raymond Hettinger

Raymond Hettinger <[EMAIL PROTECTED]> added the comment:

You may get better timings if you more the types-are-equal test inside
the types-i-know test.  Instead of:
+   if (Py_TYPE(v) == Py_TYPE(w)) {
+   if (PyLong_CheckExact(v)) {
+   if (v == w)
+   break;
+   return PyLong_RichCompare(v, w, op);
+   }
+   if (PyUnicode_CheckExact(v)) {

Do something like:
+   if (PyLong_CheckExact(v)) {
+   if (Py_TYPE(v) == Py_TYPE(w)) {
+   if (v == w)
+   break;
+   return PyLong_RichCompare(v, w, op);
+   }
+   if (PyUnicode_CheckExact(v)) {
+   if (Py_TYPE(v) == Py_TYPE(w)) {

In general, I'm not too keen on adding this kind of dispatch code to
ceval.c.  It saves the time spent in PyObject_RichCompare() trying to
figure out where to delegate the work.  But it comes at the expense of
weighing down ALL of the other comparisons which haven't gotten a
short-cut specialization.

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4330] wsgiref.validate doesn't accept arguments to readline

2008-11-16 Thread Phillip J. Eby

Phillip J. Eby <[EMAIL PROTECTED]> added the comment:

Then obviously it makes no sense to update wsgiref before the 
spec.  ISTM the correct way to deal with this is update the cgi 
module to include a WSGI-compatible API.

___
Python tracker <[EMAIL PROTECTED]>

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



[issue2260] conditional jump to a POP_TOP optimization

2008-11-16 Thread Raymond Hettinger

Raymond Hettinger <[EMAIL PROTECTED]> added the comment:

Adding a simpler approach.  It's a bit limited because some common cases
have the POP_TOP JUMP_FORWARD 1 pair split across two basic blocks. 
Those cases should not be optimized away on a first pass.

Added file: http://bugs.python.org/file12020/pop_peep.diff

___
Python tracker <[EMAIL PROTECTED]>

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



[issue2260] conditional jump to a POP_TOP optimization

2008-11-16 Thread Raymond Hettinger

Raymond Hettinger <[EMAIL PROTECTED]> added the comment:

Am taking this one back.  May have a simpler approach.

--
assignee:  -> rhettinger

___
Python tracker <[EMAIL PROTECTED]>

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



[issue2260] conditional jump to a POP_TOP optimization

2008-11-16 Thread Antoine Pitrou

Antoine Pitrou <[EMAIL PROTECTED]> added the comment:

> Antoine, the issue with JUMP_IF variants is that they interfere with
> other existing byte code optimizations, resulting in a net loss.

Which other byte code optimizations does it interfere with?

___
Python tracker <[EMAIL PROTECTED]>

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



[issue2260] conditional jump to a POP_TOP optimization

2008-11-16 Thread Raymond Hettinger

Raymond Hettinger <[EMAIL PROTECTED]> added the comment:

This looks fine to me.  Go ahead and uncomment the memcpy() line (I
presume you commented it out in order to demonstrate the basic
transformation without the dead code elimination).  Be sure to add a
testcase.

Antoine, the issue with JUMP_IF variants is that they interfere with
other existing byte code optimizations, resulting in a net loss.

BTW, don't expect much of a real-world speed-up from this patch.  The
JUMP_ABSOLUTE opcode is very fast.

--
assignee: rhettinger -> 
versions: +Python 2.7, Python 3.0

___
Python tracker <[EMAIL PROTECTED]>

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



[issue1694663] Overloading int.__pow__ does not work

2008-11-16 Thread Raymond Hettinger

Raymond Hettinger <[EMAIL PROTECTED]> added the comment:

Georg, do you want to take a look at this patch.  I've neglected it
because I don't see why the argument signature matters (__neg__ and
__pow__ take a different number of arguments than the other magic
numeric methods that work just fine).

--
assignee: rhettinger -> georg.brandl
nosy: +georg.brandl
priority: low -> normal

___
Python tracker <[EMAIL PROTECTED]>

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



[issue1721812] A subclass of set doesn't always have __init__ called.

2008-11-16 Thread Raymond Hettinger

Raymond Hettinger <[EMAIL PROTECTED]> added the comment:

Fixed in r67232.

Don't think this should be backported to the 2.x series as it may break
working code relying on the old behavior.

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

___
Python tracker <[EMAIL PROTECTED]>

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



[issue1721812] A subclass of set doesn't always have __init__ called.

2008-11-16 Thread Raymond Hettinger

Raymond Hettinger <[EMAIL PROTECTED]> added the comment:

Improved solution attached.

Added file: http://bugs.python.org/file12019/set.diff

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4316] Improper use of [] in configure.in leads to useless regexp in configure

2008-11-16 Thread Georg Brandl

Georg Brandl <[EMAIL PROTECTED]> added the comment:

Thanks, applied in r67227.

--
nosy: +georg.brandl
resolution:  -> fixed
status: open -> closed

___
Python tracker <[EMAIL PROTECTED]>

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