[issue1402] Interpreter cleanup: order of _PyGILState_Fini and PyInterpreterState_Clear

2007-11-27 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

> The _PyGILState_Fini function might cause user code to run as well, 
> it removes the thread-local variable that contains the PyThreadState 
> for threads, and that contains some Python objects that might contain 
> arbitrary values (such as the last exception value). 

No, _PyGILState_Fini does not invoke any python code; it only clears C
variables. The last exception value is deleted during the call to 
PyInterpreterState_Clear() (inside PyThreadState_Clear).

__
Tracker <[EMAIL PROTECTED]>

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



[issue756982] mailbox should use email not rfc822

2007-11-27 Thread synx

synx added the comment:

I dunno if this is helpful, but in the 2.5 module, it parses mailboxes
into rfc822 messages, but then expects them to be email.Message messages
when unparsing them back to a mailbox. mbox2.add(mbox1.popitem()[1])
fails with rfc822 as the default factory. Since the "factory" is the
only thing still using rfc822, it's easy to remove the use of rfc822
from this module entirely, which also eliminates the parsing/unparsing
disconnect.

--
nosy: +synx
Added file: http://bugs.python.org/file8812/mailbox.py.patch


Tracker <[EMAIL PROTECTED]>

--- mailbox.py	2007-11-27 09:39:25.0 +
+++ mailbox.py	2007-11-27 09:39:17.0 +
@@ -18,7 +18,6 @@
 import email
 import email.Message
 import email.Generator
-import rfc822
 import StringIO
 try:
 if sys.platform == 'os2emx':
@@ -33,6 +32,9 @@
 'BabylMessage', 'MMDFMessage', 'UnixMailbox',
 'PortableUnixMailbox', 'MmdfMailbox', 'MHMailbox', 'BabylMailbox' ]
 
+def defaultFactory(fp):
+	return email.Parser.Parser().parse(fp)
+
 class Mailbox:
 """A group of messages in a particular place."""
 
@@ -225,7 +227,7 @@
 
 colon = ':'
 
-def __init__(self, dirname, factory=rfc822.Message, create=True):
+def __init__(self, dirname, factory=defaultFactory, create=True):
 """Initialize a Maildir instance."""
 Mailbox.__init__(self, dirname, factory, create)
 if not os.path.exists(self._path):
@@ -1906,7 +1908,7 @@
 
 class _Mailbox:
 
-def __init__(self, fp, factory=rfc822.Message):
+def __init__(self, fp, factory=defaultFactory):
 self.fp = fp
 self.seekp = 0
 self.factory = factory
@@ -2023,7 +2025,7 @@
 
 class MHMailbox:
 
-def __init__(self, dirname, factory=rfc822.Message):
+def __init__(self, dirname, factory=defaultFactory):
 import re
 pat = re.compile('^[1-9][0-9]*$')
 self.dirname = dirname
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1497] Patch to remove API to create new unbound methods

2007-11-27 Thread Christian Heimes

Christian Heimes added the comment:

Guido van Rossum wrote:
> - Please clean up the comment in classobject.c starting with "Method
> objects are used for one purposes:" -- to begin with, "one purposes" is
> ungrammatical.  Best to remove the (a) bullet and rephrase the whole
> thing more like "Method objects are used for bound instance methods (...)"

Done

> - The error "unbound methods are not supported" sounds a bit strange;
> better rephrase more positive as "self must not be None"

Done. Didn't I say that I'm not good with short, precise error messages? :)

> - There is still a comment left "No, it is an unbound method". Is this
> code still reachable? I though all ways to set im_self to NULL/None are
> blocked?

It's not longer reachable but I left it there to catch problems. It's
gone now.

> 
> - Is bug 1202533 still worth testing for in test_descr.py?  I don't know
> that using a lambda reproduces the error condition that once existed.

Removed

> - Do we really need im_class for anything any more?  ISTM that the one
> place where it is still used (in method_repr), we could as well use the
> class of im_self.  (And before you think of super() as a
> counter-argument: super() passes the object's class in rather than the
> class where the method is found (though this may be considered a bug).

You are right. im_class can be substituted with __self__.__class__. I've
also removed the class argument from PyMethod_New(). It's not required
anymore.

> - I think that, like func_code -> __code__, the im_xxx attributes should
> be renamed __xxx__.

Done
im_func -> __func__
im_self -> __self__
im_class -> removed

I've left the names in the struct untouched.

> The 'new' module claims to exist solely for backwards compatibility.  If
> that's true, why are we adding to it?  In any case, the
> _BoundCFunction() class is redundant -- you can just use the "method"
> type, which is easily accessed as any bound method's __class__
> attribute.  And is there a use case for an *unbound* C function? If not,
> you could replace boundcfunction() with just a call to the method type.

How could a bind a builtin method to a class so that
instance().builtin() gets self as first argument? In one unit test the
builtin function id() is bound to a class:

class Example:
id = somemagic(id)

Example().id() results in id(Example())

I can't get the same effect with MethodType because it binds only to
instances, not to classes.

Christian

__
Tracker <[EMAIL PROTECTED]>

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



[issue1497] Patch to remove API to create new unbound methods

2007-11-27 Thread Christian Heimes

Christian Heimes added the comment:

I've committed the changes in r59189. The documentation still needs
updates. I had only time to fix some of the docs.

--
resolution:  -> fixed
status: open -> pending

__
Tracker <[EMAIL PROTECTED]>

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



[issue1504] Add 2to3 fixer for (un)bound methods

2007-11-27 Thread Christian Heimes

New submission from Christian Heimes:

Todo:

im_self -> __self__
im_func -> __func__
im_class -> __self__.__class__
instancemethod(func, self, cls) -> instancemethod(func, self)

--
assignee: collinwinter
components: 2to3 (2.x to 3.0 conversion tool)
keywords: py3k
messages: 57870
nosy: collinwinter, tiran
severity: normal
status: open
title: Add 2to3 fixer for (un)bound methods
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



[issue1505] Changes to PyMethod_New breaks ctypes on Windows

2007-11-27 Thread Christian Heimes

New submission from Christian Heimes:

The problem is in _ctypes.c:create_comerror() around line 4620.

--
assignee: theller
components: Extension Modules, Windows
keywords: py3k
messages: 57871
nosy: theller, tiran
priority: high
severity: normal
status: open
title: Changes to PyMethod_New breaks ctypes on Windows
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



[issue1348] httplib closes socket, then tries to read from it

2007-11-27 Thread vila

vila added the comment:

Well I was confused.

In fact, I have a working http/1.1 client which indeed works around that
close.

HTTPConnection.close() must be called once the response has been
processed or the next request can't be handled since
HTTPConnection.__state is not  _CS_IDLE.

That may be a different problem than the one Bill is after though.

I work around it by saving the sock attribute before the call in a class
inherited from HTTPConnection:

 # Preserve our preciousss
sock = self.sock
self.sock = None
# Let httplib.HTTPConnection do its housekeeping 
self.close()
# Restore our preciousss
self.sock = sock

So not doing the close() is harmless but doing self.sock = None in 
HTTPConnection.close() still break hopes of persistent connections.

May be that method should be splitted...

__
Tracker <[EMAIL PROTECTED]>

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



[issue1455] VS2008, quick hack for distutils.msvccompiler

2007-11-27 Thread Christian Heimes

Christian Heimes added the comment:

I've created another patch to add VS 2008 support to distutils. The new
patch requires you to copy the msvccompiler.py first:

$ cd Lib/distutils
$ svn copy msvccompiler.py msvc9compiler.py
$ cd ../..
$ patch -p0 < py3k_vs2008_4.patch

Martin, if you are going to build Python 3.0a2 with VS 2008 then this
patch should be applied. I've tested it with VS 2008 and it *may* be
compatible with VS 2005, too.

--
priority: normal -> high
Added file: http://bugs.python.org/file8813/py3k_vs2008_4.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Lib/distutils/command/build_ext.py
===
--- Lib/distutils/command/build_ext.py	(revision 59193)
+++ Lib/distutils/command/build_ext.py	(working copy)
@@ -14,6 +14,10 @@
 from distutils.extension import Extension
 from distutils import log
 
+if os.name == 'nt':
+from distutils.msvccompiler import get_build_version
+MSVC_VERSION = int(get_build_version())
+
 # An extension name is just a dot-separated list of Python NAMEs (ie.
 # the same as a fully-qualified module name).
 extension_name_re = re.compile \
@@ -172,7 +176,12 @@
 # Append the source distribution include and library directories,
 # this allows distutils on windows to work in the source tree
 self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC'))
-self.library_dirs.append(os.path.join(sys.exec_prefix, 'PCBuild'))
+if MSVC_VERSION == 9:
+self.library_dirs.append(os.path.join(sys.exec_prefix, 'PCBuild9'))
+elif MSVC_VERSION == 8:
+self.library_dirs.append(os.path.join(sys.exec_prefix, 'PCBuild8'))
+else:
+self.library_dirs.append(os.path.join(sys.exec_prefix, 'PCBuild'))
 
 # OS/2 (EMX) doesn't support Debug vs Release builds, but has the
 # import libraries in its "Config" subdirectory
Index: Lib/distutils/msvc9compiler.py
===
--- Lib/distutils/msvc9compiler.py	(revision 59193)
+++ Lib/distutils/msvc9compiler.py	(working copy)
@@ -1,145 +1,154 @@
-"""distutils.msvccompiler
+"""distutils.msvc9compiler
 
 Contains MSVCCompiler, an implementation of the abstract CCompiler class
-for the Microsoft Visual Studio.
+for the Microsoft Visual Studio 2008.
+
+The module is compatible with VS 2008. The module may also be compatible
+with VS 2005 but it is untested yet. You can find legacy support for older
+versions of VS in distutils.msvccompiler.
 """
 
 # Written by Perry Stoll
 # hacked by Robin Becker and Thomas Heller to do a better job of
 #   finding DevStudio (through the registry)
+# ported to VS 2008 by Christian Heimes
 
 __revision__ = "$Id$"
 
-import sys, os
-from distutils.errors import \
- DistutilsExecError, DistutilsPlatformError, \
- CompileError, LibError, LinkError
-from distutils.ccompiler import \
- CCompiler, gen_preprocess_options, gen_lib_options
+import os
+import subprocess
+import sys
+from distutils.errors import (DistutilsExecError, DistutilsPlatformError, 
+CompileError, LibError, LinkError)
+from distutils.ccompiler import (CCompiler, gen_preprocess_options,
+gen_lib_options)
 from distutils import log
 
-_can_read_reg = False
-try:
-import _winreg
+import _winreg
 
-_can_read_reg = True
-hkey_mod = _winreg
+RegOpenKeyEx = _winreg.OpenKeyEx
+RegEnumKey = _winreg.EnumKey
+RegEnumValue = _winreg.EnumValue
+RegError = _winreg.error
 
-RegOpenKeyEx = _winreg.OpenKeyEx
-RegEnumKey = _winreg.EnumKey
-RegEnumValue = _winreg.EnumValue
-RegError = _winreg.error
+HKEYS = (_winreg.HKEY_USERS,
+ _winreg.HKEY_CURRENT_USER,
+ _winreg.HKEY_LOCAL_MACHINE,
+ _winreg.HKEY_CLASSES_ROOT)
 
-except ImportError:
-try:
-import win32api
-import win32con
-_can_read_reg = True
-hkey_mod = win32con
+VS_BASE = r"Software\Microsoft\VisualStudio\%0.1f"
+WINSDK_BASE = r"Software\Microsoft\Microsoft SDKs\Windows"
+NET_BASE = r"Software\Microsoft\.NETFramework"
+ARCHS = {'DEFAULT' : 'x86',
+'intel' : 'x86', 'x86' : 'x86',
+'amd64' : 'x64', 'x64' : 'x64',
+'itanium' : 'ia64', 'ia64' : 'ia64',
+}
 
-RegOpenKeyEx = win32api.RegOpenKeyEx
-RegEnumKey = win32api.RegEnumKey
-RegEnumValue = win32api.RegEnumValue
-RegError = win32api.error
-except ImportError:
-log.info("Warning: Can't read registry to find the "
- "necessary compiler setting\n"
- "Make sure that Python modules _winreg, "
- "win32api or win32con are installed.")
-pass
+# The globals VERSION, ARCH, MACROS and VC_ENV are defined later
 
-if _can_read_reg:
-HKEYS = (hkey_mod.HKEY_USERS,
- hkey_mod.HKEY_CURRENT

[issue1746088] long.__str__ is quadratic time

2007-11-27 Thread Raymond Hettinger

Changes by Raymond Hettinger:


--
assignee:  -> rhettinger
nosy: +rhettinger
versions: +Python 2.6 -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



[issue1045] Performance regression in 2.5

2007-11-27 Thread Raymond Hettinger

Changes by Raymond Hettinger:


--
assignee: tim_one -> 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



[issue1504] Add 2to3 fixer for (un)bound methods

2007-11-27 Thread Guido van Rossum

Guido van Rossum added the comment:

Crys, why don't you give it a try yourself? It's quite easy to write
such a simple substitution.

--
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

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



[issue1045] Performance regression in 2.5

2007-11-27 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

The slowdown is due to the new function _PyObject_LengthHint: on my
Win2K machine, 
the command
  python -m timeit "tuple(1 for _ in xrange(3))"
answers:
  10 loops, best of 3: 4.14 usec per loop
By adding a line "return rv;" on the second line of
_PyObject_LengthHint, I get:
  10 loops, best of 3: 2.71 usec per loop

Should we disable this function for some known built-in types?

--
nosy: +amaury.forgeotdarc

__
Tracker <[EMAIL PROTECTED]>

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



[issue1045] Performance regression in 2.5

2007-11-27 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I'll take a look at it next week -- want to think through the various 
cases.  The current setup provides nice speedups when the length_hint 
is available.  Possibly, it may be worthwhile to skip that check when 
the input is a generator.  For the most part, I'm more concerned about 
the inner-loop time than the constant startup time outside the loop.

__
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-27 Thread Guido van Rossum

Guido van Rossum added the comment:

> No, _PyGILState_Fini does not invoke any python code

You're right. It calls PyThread_delete_key().  I thought this would
delete entries from a dictionary (thereby potentially invoking Python
code via Py_DECREF()), but it doesn't -- it just frees some memory.

So I'm okay with swapping the order in 2.6 and 3.0.  I'm still not 100%
comfortable with doing this in 2.5, especially since Ronald found a
work-around for his immediate issue.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1045] Performance regression in 2.5

2007-11-27 Thread Raymond Hettinger

Raymond Hettinger added the comment:

FWIW, the 2.4 to 2.5 timing difference came from renaming __len__ to 
__length_hint__.  This was at Guido's request so that the value of bool
(iter(obj)) would always be True.  The consequence of the change was 
that we lost the fast slot lookup for __len__ and instead have to do a 
dictionary based attribute lookup.

For the most part, I don't care about the overhead as it is constant.  
The inner-loop cost dominates.  If you do care, the choices are to add 
some ugly, hackish specific type checks to bypass the attribute lookup 
in cases like generator objects where we know the type is absent.  A 
more general, cleaner solution is to add a new slot for a length hint.  
Personally, I would rather leave this as is and live with the small 
constant lookup time.  If you concur, please close this report.  If 
not, please submit a patch for adding a new slot (model the code after 
that in PyObject_Size()).

__
Tracker <[EMAIL PROTECTED]>

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



[issue1755179] Deadlocks with fork() and multithreading

2007-11-27 Thread Facundo Batista

Facundo Batista added the comment:

Fixed in the trunk, rev 59195.

_
Tracker <[EMAIL PROTECTED]>

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



[issue1504] Add 2to3 fixer for (un)bound methods

2007-11-27 Thread Christian Heimes

Christian Heimes added the comment:

Added fix_methodattrs with an unit test in r59196. Can you check it please.

By the way how do you know my IRC nick? Are you lurking in #python? :)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1505] Changes to PyMethod_New breaks ctypes on Windows

2007-11-27 Thread Thomas Heller

Thomas Heller added the comment:

Christian Heimes schrieb:
> > New submission from Christian Heimes:
> > 
> > The problem is in _ctypes.c:create_comerror() around line 4620.

The code tries to populate a dict with methods and finally pass them to
   PyErr_NewException("_ctypes.COMError", NULL, dict);

I have no idea what to do.  What do I have to put into the dict?

__
Tracker <[EMAIL PROTECTED]>

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



[issue1348] httplib closes socket, then tries to read from it

2007-11-27 Thread Bill Janssen

Bill Janssen added the comment:

That's because the socket.py code has been adapted (the first word I wrote
there was "perverted" :--) to deal with this case.  That is, the close() has
been rendered meaningless because of the explicit reference counting in
socket.py.  But the right solution is to not close the socket till the
application is done with it; that is, transfer the responsibility for the
socket to the part of the application which is still using it.  I'm not sure
that just fixing this one case will remove the need for the explicit
reference counting in socket.py, but this is the case that I noticed.

On Nov 26, 2007 1:11 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote:

>
> Guido van Rossum added the comment:
>
> Bill, is there a code example that should work but breaks because of
> that close()?  ATM, there doesn't seem to be anything in the tests that
> breaks...
>
> __
> Tracker <[EMAIL PROTECTED]>
> 
> __
>

Added file: http://bugs.python.org/file8814/unnamed

__
Tracker <[EMAIL PROTECTED]>

__That's because the socket.py code has been adapted (the first word I wrote 
there was "perverted" :--) to deal with this case.  That is, the 
close() has been rendered meaningless because of the explicit reference 
counting in 
socket.py.  But the right solution is to not close the socket till the 
application is done with it; that is, transfer the responsibility for the 
socket to the part of the application which is still using it.  I'm 
not sure that just fixing this one case will remove the need for the explicit 
reference counting in 
socket.py, but this is the case that I noticed.On Nov 26, 2007 1:11 PM, Guido van Rossum [EMAIL PROTECTED]> wrote:
Guido van Rossum added the comment:Bill, is there a code example 
that should work but breaks because ofthat close()?  ATM, there 
doesn't seem to be anything in the tests thatbreaks...
__Tracker 
[EMAIL PROTECTED]>http://bugs.python.org/issue1348
>__

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



[issue1504] Add 2to3 fixer for (un)bound methods

2007-11-27 Thread Guido van Rossum

Guido van Rossum added the comment:

It works, though the "__self__.__class__" substitution is technically
wrong -- it creates a single NAME node whose contents is that string,
while in the parse tree it should really be three tokens.  But as it
works, I wouldn't worry about it.

I saw you sign a bug with 'Crys' once and I believe you mentioned it in
your intro to python-dev. :-)

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



[issue1504] Add 2to3 fixer for (un)bound methods

2007-11-27 Thread Christian Heimes

Christian Heimes added the comment:

You are too fast. I haven't written a fixer for new.instancemethod yet.
Do we need one?

--
status: closed -> open

__
Tracker <[EMAIL PROTECTED]>

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



[issue1504] Add 2to3 fixer for (un)bound methods

2007-11-27 Thread Guido van Rossum

Guido van Rossum added the comment:

A fixer for new.instancemethod would be nice, though I doubt that there
will be many uses. We could also go a different way: since new.py has a
comment stating it is deprecated (in 2.5 already), perhaps we should
just kill in in 3.0 and add an explicit 3.0 warning to it in 2.6.  (This
is really part of the library reorg, but we might as well take care of
it now rather than making a temporary change to it.)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1506] func alloca inside ctypes lib needs #include on solaris

2007-11-27 Thread Maarten Thibaut

Changes by Maarten Thibaut:


--
components: Library (Lib)
nosy: mthibaut
severity: normal
status: open
title: func alloca inside ctypes lib needs #include  on solaris
type: compile error
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



[issue1504] Add 2to3 fixer for (un)bound methods

2007-11-27 Thread Christian Heimes

Christian Heimes added the comment:

How should I issue a warning in the new module? Should and can I check
for the -3 warning option or should I warn w/o checks for the -3 option?

from warnings import warn as _warn
_warn("The 'new' module is not supported in 3.x",
DeprecationWarning, 2)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1506] func alloca inside ctypes lib needs #include on solaris

2007-11-27 Thread Maarten Thibaut

New submission from Maarten Thibaut:

On Solaris, alloca() is a #define which is inside . 

Ctypes fails to compile because the #define is missing. Please fix by
adding the following at the front of these 2 files:

#if defined (__SVR4) && defined (__sun)
#   include 
#endif

__
Tracker <[EMAIL PROTECTED]>

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



[issue1506] func alloca inside ctypes lib needs #include on solaris

2007-11-27 Thread Maarten Thibaut

Changes by Maarten Thibaut:


--
components: +Extension Modules -Library (Lib)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1731717] race condition in subprocess module

2007-11-27 Thread Tom Culliton

Tom Culliton added the comment:

Looking at the subprocess.py code it occurred to me that it never checks
if the value of self.pid returned by os.fork is -1, this would mean that
later it runs waitpid with -1 as the first argument, putting it into
promiscuous (wait for any process in the group) mode.  This seems like a
bad idea...

_
Tracker <[EMAIL PROTECTED]>

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



[issue1504] Add 2to3 fixer for (un)bound methods

2007-11-27 Thread Guido van Rossum

Guido van Rossum added the comment:

There's C code like this:

if (Py_Py3kWarningFlag &&
PyErr_Warn(PyExc_DeprecationWarning, 
   "apply() not supported in 3.x") < 0)
return NULL;

I don't know how to check for that flag in Python though -- we should
really export all flags via the sys module...

__
Tracker <[EMAIL PROTECTED]>

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



[issue1506] func alloca inside ctypes lib needs #include on solaris

2007-11-27 Thread Guido van Rossum

Changes by Guido van Rossum:


--
assignee:  -> theller
nosy: +theller

__
Tracker <[EMAIL PROTECTED]>

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



[issue1507] complex constructor loses signs of zeros

2007-11-27 Thread Mark Dickinson

New submission from Mark Dickinson:

In Python2.5 and the current trunk, construction of a complex number from two 
floats 
loses the negative sign of a negative zero in the imaginary part.

>>> complex(-0., 0.).real  # behaves as expected
-0.0
>>> complex(0., -0.).imag  # loses sign of zero
0.0

There are situations where it's important to preserve the sign of zero 
(typically 
when doing calculations involving functions with branch cuts);  there are 
probably 
platforms where this is difficult for one reason or another, but on a platform 
that 
complies with all the usual standards I can't see any reason for Python not to 
preserve the signs of zeros, provided that it's straightforward to do so.

The attached patch changes the complex constructor so that if x and y are 
numeric 
and neither x nor y is complex (or a subclass of complex) then complex(x, y) 
simply 
places x into the real part of the complex number and y into the imaginary 
part.  
For someone who doesn't care about the sign of zeros, this patch will have no 
noticeable effect.  Similarly, on a system that does not have full hardware or 
system support for signed zeros, this patch should be harmless.  Note that the 
patch 
does *not* change the feature that complex(z1, z2) returns z1 + 1j*z2 when z1 
and/or 
z2 is itself complex.

There was some previous discussion of this on python-dev earlier this year.  See

http://mail.python.org/pipermail/python-dev/2007-January/070770.html

--
files: complex_new.patch
messages: 57891
nosy: marketdickinson
severity: normal
status: open
title: complex constructor loses signs of zeros
versions: Python 2.5, Python 2.6
Added file: http://bugs.python.org/file8815/complex_new.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Objects/complexobject.c
===
--- Objects/complexobject.c (revision 59202)
+++ Objects/complexobject.c (working copy)
@@ -897,6 +897,8 @@
PyNumberMethods *nbr, *nbi = NULL;
Py_complex cr, ci;
int own_r = 0;
+   int cr_is_complex = 0;
+   int ci_is_complex = 0;
static PyObject *complexstr;
static char *kwlist[] = {"real", "imag", 0};
 
@@ -977,6 +979,7 @@
   retaining its real & imag parts here, and the return
   value is (properly) of the builtin complex type. */
cr = ((PyComplexObject*)r)->cval;
+   cr_is_complex = 1;
if (own_r) {
Py_DECREF(r);
}
@@ -985,7 +988,6 @@
/* The "real" part really is entirely real, and contributes
   nothing in the imaginary direction.  
   Just treat it as a double. */
-   cr.imag = 0.0;  
tmp = PyNumber_Float(r);
if (own_r) {
/* r was a newly created complex number, rather
@@ -1005,15 +1007,14 @@
}
if (i == NULL) {
ci.real = 0.0;
-   ci.imag = 0.0;
}
-   else if (PyComplex_Check(i))
+   else if (PyComplex_Check(i)) {
ci = ((PyComplexObject*)i)->cval;
-   else {
+   ci_is_complex = 1;
+   } else {
/* The "imag" part really is entirely imaginary, and
   contributes nothing in the real direction.
   Just treat it as a double. */
-   ci.imag = 0.0;
tmp = (*nbi->nb_float)(i);
if (tmp == NULL)
return NULL;
@@ -1021,11 +1022,16 @@
Py_DECREF(tmp);
}
/*  If the input was in canonical form, then the "real" and "imag"
-   parts are real numbers, so that ci.real and cr.imag are zero.
+   parts are real numbers, so that ci.imag and cr.imag are zero.
We need this correction in case they were not real numbers. */
-   cr.real -= ci.imag;
-   cr.imag += ci.real;
-   return complex_subtype_from_c_complex(type, cr);
+
+   if (ci_is_complex) {
+   cr.real -= ci.imag;
+   }
+   if (cr_is_complex) {
+   ci.real += cr.imag;
+   }
+   return complex_subtype_from_doubles(type, cr.real, ci.real);
 }
 
 PyDoc_STRVAR(complex_doc,
Index: Lib/test/test_complex.py
===
--- Lib/test/test_complex.py(revision 59202)
+++ Lib/test/test_complex.py(working copy)
@@ -9,6 +9,7 @@
 )
 
 from random import random
+from math import atan2
 
 # These tests ensure that complex math does the right thing
 
@@ -225,6 +226,18 @@
 self.assertAlmostEqual(complex(real=17+23j, imag=23), 17+46j)
 self.assertAlmostEqual(complex(real=1+2j, imag=3+4j), -3+5j)
 
+# check that the sign of a zero in the real or imaginary part
+# is preserved when c

[issue1731717] race condition in subprocess module

2007-11-27 Thread Tom Culliton

Tom Culliton added the comment:

Good question.  The documentation I was reading was mute on the subject 
so I made a "reasonable" guess.  Does it throw an exception instead?

Guido van Rossum wrote:
> Guido van Rossum added the comment:
>
>   
>> Looking at the subprocess.py code it occurred to me that it never
>> checks if the value of self.pid returned by os.fork is -1
>> 
>
> What makes you think os.fork(0 can return -1? It's not C you know...
>
> _
> 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



[issue1731717] race condition in subprocess module

2007-11-27 Thread Guido van Rossum

Guido van Rossum added the comment:

> Looking at the subprocess.py code it occurred to me that it never
> checks if the value of self.pid returned by os.fork is -1

What makes you think os.fork(0 can return -1? It's not C you know...

_
Tracker <[EMAIL PROTECTED]>

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



[issue1507] complex constructor loses signs of zeros

2007-11-27 Thread Guido van Rossum

Guido van Rossum added the comment:

Committed revision 59203.

Anthony, is this OK to backport to 2.5.2?

--
assignee:  -> anthonybaxter
nosy: +anthonybaxter, gvanrossum
resolution:  -> accepted

__
Tracker <[EMAIL PROTECTED]>

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



[issue1731717] race condition in subprocess module

2007-11-27 Thread Guido van Rossum

Guido van Rossum added the comment:

Yes, like all system calls in the os module.

_
Tracker <[EMAIL PROTECTED]>

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



[issue1508] Removal of stale code in _csv.c / pyexpat.c

2007-11-27 Thread Joseph Armbruster

New submission from Joseph Armbruster:

I found two code blocks that look as if they can be safely removed:


>From _csv.c:

/* begin 2.2 compatibility macros */
#ifndef PyDoc_STRVAR
/* Define macros for inline documentation. */
#define PyDoc_VAR(name) static char name[]
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
#ifdef WITH_DOC_STRINGS
#define PyDoc_STR(str) str
#else
#define PyDoc_STR(str) ""
#endif
#endif /* ifndef PyDoc_STRVAR */


>From pyexpat.c:

#ifndef PyDoc_STRVAR

/*
 * fdrake says:
 * Don't change the PyDoc_STR macro definition to (str), because
 * '''the parentheses cause compile failures
 * ("non-constant static initializer" or something like that)
 * on some platforms (Irix?)'''
 */
#define PyDoc_STR(str) str
#define PyDoc_VAR(name)static char name[]
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
#endif

--
components: Extension Modules
messages: 57895
nosy: JosephArmbruster
severity: minor
status: open
title: Removal of stale code in _csv.c / pyexpat.c
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



[issue1504] Add 2to3 fixer for (un)bound methods

2007-11-27 Thread Christian Heimes

Christian Heimes added the comment:

Guido van Rossum wrote:
> Guido van Rossum added the comment:
> 
> There's C code like this:
> 
>   if (Py_Py3kWarningFlag &&
>   PyErr_Warn(PyExc_DeprecationWarning, 
>  "apply() not supported in 3.x") < 0)
>   return NULL;
> 
> I don't know how to check for that flag in Python though -- we should
> really export all flags via the sys module...

I've exposed the flag in r59204 as sys.py3kwarning. I've also added a
method warnings.warnpy3k().

Christian

__
Tracker <[EMAIL PROTECTED]>

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



[issue1506] func alloca inside ctypes lib needs #include on solaris

2007-11-27 Thread Maarten Thibaut

Maarten Thibaut added the comment:

forgot to mention the files:

Modules/_ctypes/callproc.c
Modules/_ctypes/libffi/src/sparc/ffi.c

__
Tracker <[EMAIL PROTECTED]>

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



[issue1496] add str.maketrans()

2007-11-27 Thread Georg Brandl

Georg Brandl added the comment:

Okay, checked in as r59205.

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



[issue1755179] Deadlocks with fork() and multithreading

2007-11-27 Thread Georg Brandl

Georg Brandl added the comment:

Will it be backported?

--
nosy: +georg.brandl

_
Tracker <[EMAIL PROTECTED]>

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



[issue1509] Documentation lacking for the sqlite3 module.

2007-11-27 Thread Peter Mawhorter

New submission from Peter Mawhorter:

The current documentation for the sqlite3 module on the web fails to 
make any mention of the fetch* functions posessed by the Cursor class 
of that module. It in fact gives no indication of how one should 
extract results from sql queries. The docstrings in the module (viewed 
using the help() function) are woefully incomplete, and are 
inconsistent with the function names:

 |  fetchall(...)
 |  Fetches one row from the resultset.
 |  
 |  fetchmany(...)
 |  Fetches all rows from the resultset.
 |  
 |  fetchone(...)
 |  Fetches several rows from the resultset.
 |  

Both of these things need to be fixed in order for this module to be 
useful for someone who doesn't already know how to use it.

--
components: Extension Modules
messages: 57900
nosy: pmawhorter
severity: minor
status: open
title: Documentation lacking for the sqlite3 module.
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



[issue1510] help for file/open should state which is prefered.

2007-11-27 Thread cfk

New submission from cfk:

bltinmodule.c:

PyDoc_STRVAR(open_doc,
"open(name[, mode[, buffering]]) -> file object\n\
\n\
Open a file using the file() type, returns a file object.");

Help for file() is detailed, which would lead people to use file over
open.  given that file() is removed in py3k, I think that should be
mentioned in the current file() docstring, and swap the help for file/open.

--
components: Documentation
messages: 57901
nosy: carlfk
severity: minor
status: open
title: help for file/open should state which is prefered.
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



[issue1511] csv input converts \r\n to \n but csv output does not when a field has internal line breaks

2007-11-27 Thread Bill Fenner

New submission from Bill Fenner:

When a field has internal line breaks, e.g.,

foo,"bar
baz
biff",boo

that is actually 3 lines, but one csv-file row.  csv.reader() converts 
this to ['foo', 'bar\nbaz\nbiff', 'boo'].  This is a reasonable 
behavior.

Unfortunately, csv.writer() does not use the dialect's lineterminator 
setting for values with such internal linebreaks.  This means that the 
resulting file will have a mix of line-termination styles:

foo,"bar\n
baz\n
biff",boo\r\n

If the reading csv implementation is strict about its line termination, 
these line breaks will not be read properly.

--
messages: 57902
nosy: fenner
severity: normal
status: open
title: csv input converts \r\n to \n but csv output does not when a field has 
internal line breaks
type: behavior
versions: Python 2.4

__
Tracker <[EMAIL PROTECTED]>

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



[issue1511] csv input converts \r\n to \n but csv output does not when a field has internal line breaks

2007-11-27 Thread Bill Fenner

Changes by Bill Fenner:


--
components: +Library (Lib)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1511] csv input converts \r\n to \n but csv output does not when a field has internal line breaks

2007-11-27 Thread Bill Fenner

Bill Fenner added the comment:

I realized that my description was not crystal clear - the file being 
read has \r\n line terminators - in the format that I used later, the 
input file is

foo,"bar\r\n
baz\r\n
biff",boo\r\n

__
Tracker <[EMAIL PROTECTED]>

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



[issue1511] csv input converts \r\n to \n but csv output does not when a field has internal line breaks

2007-11-27 Thread Gregory P. Smith

Gregory P. Smith added the comment:

release25-maint and trunk (2.6) appear to do the correct thing when
testing on my ubuntu gutsy linux x86 box.  test script and file attached.

The problem is reproducable in a release24-maint build compiled 2007-11-05.

--
nosy: +gregory.p.smith
Added file: http://bugs.python.org/file8816/issue1511.py

__
Tracker <[EMAIL PROTECTED]>

__

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



[issue1511] csv input converts \r\n to \n but csv output does not when a field has internal line breaks

2007-11-27 Thread Gregory P. Smith

Gregory P. Smith added the comment:

attaching the test input file.  use od -x or similar to compare the
new.csv output with issue1511.csv to see if the problem happened.

its 2.4.. that may be old enough to be considered dead

Added file: http://bugs.python.org/file8817/issue1511.csv

__
Tracker <[EMAIL PROTECTED]>

__foo,"bar
baz
biff",boo
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com