[issue1686386] Python SEGFAULT on tuple.__repr__ and str()

2007-09-13 Thread Thomas Herve

Thomas Herve added the comment:

I think it could be solved both the same way: if tuple repr is wrong,
there are probably some other repr code that is wrong too, so fixing
PyObject_Repr is safer.

_
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-13 Thread Eric V. Smith

Eric V. Smith added the comment:

It's a nit, but there are a few other comments that should be changed to
mention %f in addition to %z/%Z.

 * giving special meanings to the %z and %Z format codes via a preprocessing

/* Scan the input format, looking for %z and %Z escapes, building

/* percent followed by neither z nor Z */

--
nosy: +eric.smith

__
Tracker <[EMAIL PROTECTED]>

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



[issue1159] os.getenv() not updated after external module uses C putenv()

2007-09-13 Thread Robert Ancell

New submission from Robert Ancell:

The Python os.getenv() function accesses an Python dictionary which is
mirroring the process environment. This dictionary is populated when the
interpreter starts and updated when os.environ.__setitem__() or
os.putenv() are called. However if the python program imports an
extension module that uses the system putenv() then the changes cannot
be accessed using the Python standard library.

This has been a problem for us as we have created Python bindings to an
existing C based library that modifies the environment dynamically (not
the best design decision...). The workaround we are using is to create
our own wrapper to the system (Solaris/Linux) getenv().

A potential solution could be to make environ a class where
os.environ.__setitem__() calls putenv(), os.environ.__getitem__() calls
getenv() and os.environ.keys()/items()/iter*() uses **environ (or other
appropriate system call). This does however have undefined issues on how
the environment behaves on various systems (memory leaks etc).

--
components: Library (Lib)
messages: 55881
nosy: robert.ancell
severity: normal
status: open
title: os.getenv() not updated after external module uses C putenv()
type: behavior
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



[issue1145] Allow str.join to join non-string types (as per PEP 3100)

2007-09-13 Thread Thomas Lee

Thomas Lee added the comment:

Sure - I'll get onto that. Should have another patch up later tonight.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1159] os.getenv() not updated after external module uses C putenv()

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

Martin v. Löwis added the comment:

I can't see a bug here. If you want the current C library value of the
environment variable, just use os.getenv, not os.environ.

--
nosy: +loewis

__
Tracker <[EMAIL PROTECTED]>

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



[issue1159] os.getenv() not updated after external module uses C putenv()

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

Martin v. Löwis added the comment:

Ignore my comment - I see now that you are talking about os.getenv.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1160] Medium size regexp crashes python

2007-09-13 Thread Guido Ostkamp

New submission from 
Guido Ostkamp
:

Hello,

a medium size regular expression crashes Python 2.5.1 as follows:

Traceback (most recent call last):
  File "./regtest.py", line 14, in 
m = rematch(pats)
  File "./regtest.py", line 12, in rematch
return re.compile(pat).match
  File "/export/home/ostkamp/local/lib/python2.5/re.py", line 180, in
compile
return _compile(pattern, flags)
  File "/export/home/ostkamp/local/lib/python2.5/re.py", line 231, in
_compile
p = sre_compile.compile(pattern, flags)
  File "/export/home/ostkamp/local/lib/python2.5/sre_compile.py", line
530, in compile
groupindex, indexgroup
OverflowError: regular expression code size limit exceeded


This is apparently caused by some code in Modules/_sre.c and
Modules/sre.h as follows:

self->code[i] = (SRE_CODE) value;
if ((unsigned long) self->code[i] != value) {
PyErr_SetString(PyExc_OverflowError,
"regular expression code size limit exceeded");
break;
}

An 'unsigned int' value is unnecessarily squeezed into an 'unsigned
short' field defined in sre.h:

#ifdef Py_UNICODE_WIDE
#define SRE_CODE Py_UCS4
#else
#define SRE_CODE unsigned short
#endif

On all systems I'm working on (SuSE Linux SLES 9, Solaris 8 etc.) the
else case of the ifdef applies which chooses 'unsigned short'.

I don't understand the relationship between 'unicode' and what is
apparently the size of the regular expression stack here.

Some experiments have shown that changing the 'unsigned short' to
'unsigned long' and rebuilding Python fixes the problem.

Here is a test program to reproduce the error:

#!/usr/bin/env python
import re, random, sys
def randhexstring():
return "".join(["%04x" % random.randint(0, 0x) for x in range(20)])
pats = [randhexstring() for x in range(1000)]
def rematch(pats):
pat = '(?:%s)' % '|'.join(pats)
return re.compile(pat).match
m = rematch(pats)
count = 0
for s in pats * 100:
if m(s):
count += 1
print count



Regards

Guido

--
components: Regular Expressions
messages: 55885
nosy: ostkamp
severity: normal
status: open
title: Medium size regexp crashes python
type: crash
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



[issue1722225] Build on QNX

2007-09-13 Thread Vladimir Konjkov

Vladimir Konjkov added the comment:

look this
http://www.mail-archive.com/python-bugs-list%40python.org/msg07749.html
it's for python-2.3.5 under qnx4.25.

about pyport.h under qnx4.25:
I include "unix.h" instead of definition of function 
openpty()+forkpty() in pyport.h, openpty()+forkpty() naturaly defined 
in "unix.h" but configure doesn't knows.

--
nosy: +Konjkov

_
Tracker <[EMAIL PROTECTED]>

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



[issue1145] Allow str.join to join non-string types (as per PEP 3100)

2007-09-13 Thread Thomas Lee

Thomas Lee added the comment:

Updated patch:

* unneeded PyUnicode_FromObject call removed (I thought this was
necessary, but the original author appears to be using it for an INCREF)

* documentation now fits into 80 chars

* return values from PyObject_Unicode and PyObject_FromObject checked

* bytes() objects found in the sequence will raise a TypeError

* removed redundant assertion and added the bytes case to test_unicode

__
Tracker <[EMAIL PROTECTED]>

__Index: Objects/unicodeobject.c
===
--- Objects/unicodeobject.c	(revision 58102)
+++ Objects/unicodeobject.c	(working copy)
@@ -5412,14 +5412,20 @@
 
 	item = PySequence_Fast_GET_ITEM(fseq, i);
 	/* Convert item to Unicode. */
-	if (! PyUnicode_Check(item) && ! PyString_Check(item)) {
-	PyErr_Format(PyExc_TypeError,
-			 "sequence item %zd: expected string or Unicode,"
-			 " %.80s found",
-			 i, Py_Type(item)->tp_name);
-	goto onError;
+	if (!PyString_Check(item) && !PyUnicode_Check(item))
+	{
+		if (PyBytes_Check(item))
+		{
+			PyErr_Format(PyExc_TypeError,
+"sequence item %d: join() will not operate on "
+"bytes objects", i);
+			goto onError;
+		}
+		item = PyObject_Unicode(item);
 	}
-	item = PyUnicode_FromObject(item);
+	else
+		item = PyUnicode_FromObject(item);
+
 	if (item == NULL)
 	goto onError;
 	/* We own a reference to item from here on. */
Index: Doc/library/stdtypes.rst
===
--- Doc/library/stdtypes.rst	(revision 58102)
+++ Doc/library/stdtypes.rst	(working copy)
@@ -786,8 +786,11 @@
 
 .. method:: str.join(seq)
 
-   Return a string which is the concatenation of the strings in the sequence *seq*.
-   The separator between elements is the string providing this method.
+   Return a string which is the concatenation of the values in the sequence
+   *seq*. Non-string values in *seq* will be converted to a string using their
+   respective ``str()`` value. If there are any :class:`bytes` objects in
+   *seq*, a :exc:`TypeError` will be raised. The separator between elements is
+   the string providing this method.
 
 
 .. method:: str.ljust(width[, fillchar])
Index: Lib/test/test_descr.py
===
--- Lib/test/test_descr.py	(revision 58102)
+++ Lib/test/test_descr.py	(working copy)
@@ -3238,10 +3238,6 @@
 except ValueError: pass
 else: raise TestFailed("''.split('') doesn't raise ValueError")
 
-try: ''.join([0])
-except TypeError: pass
-else: raise TestFailed("''.join([0]) doesn't raise TypeError")
-
 try: ''.rindex('5')
 except ValueError: pass
 else: raise TestFailed("''.rindex('5') doesn't raise ValueError")
Index: Lib/test/test_unicode.py
===
--- Lib/test/test_unicode.py	(revision 58102)
+++ Lib/test/test_unicode.py	(working copy)
@@ -178,6 +178,10 @@
 def test_join(self):
 string_tests.MixinStrUnicodeUserStringTest.test_join(self)
 
+class MyWrapper:
+def __init__(self, sval): self.sval = sval
+def __str__(self): return self.sval
+
 # mixed arguments
 self.checkequalnofix('a b c d', ' ', 'join', ['a', 'b', 'c', 'd'])
 self.checkequalnofix('abcd', '', 'join', ('a', 'b', 'c', 'd'))
@@ -186,6 +190,8 @@
 self.checkequalnofix('a b c d', ' ', 'join', ['a', 'b', 'c', 'd'])
 self.checkequalnofix('abcd', '', 'join', ('a', 'b', 'c', 'd'))
 self.checkequalnofix('w x y z', ' ', 'join', string_tests.Sequence('wxyz'))
+self.checkequalnofix('1 2 foo', ' ', 'join', [1, 2, MyWrapper('foo')])
+self.checkraises(TypeError, ' ', 'join', [1, 2, 3, bytes()])
 
 def test_replace(self):
 string_tests.CommonTest.test_replace(self)
Index: Lib/test/string_tests.py
===
--- Lib/test/string_tests.py	(revision 58102)
+++ Lib/test/string_tests.py	(working copy)
@@ -13,6 +13,7 @@
 
 class BadSeq1(Sequence):
 def __init__(self): self.seq = [7, 'hello', 123]
+def __str__(self): return '{0} {1} {2}'.format(*self.seq)
 
 class BadSeq2(Sequence):
 def __init__(self): self.seq = ['a', 'b', 'c']
@@ -987,19 +988,19 @@
 self.checkequal('abc', 'a', 'join', ('abc',))
 self.checkequal('z', 'a', 'join', UserList(['z']))
 self.checkequal('a.b.c', '.', 'join', ['a', 'b', 'c'])
-self.checkraises(TypeError, '.', 'join', ['a', 'b', 3])
+self.checkequal('a.b.3', '.', 'join', ['a', 'b', 3])
 for i in [5, 25, 125]:
 self.checkequal'a' * i) + '-') * i)[:-1], '-', 'join',
  ['a' * i] * i)
 self.checkequal'a' * i) + '-') * i)[:-1], '-', 'join',
  

[issue1161] Mangled chars in offending line of SyntaxError traceback

2007-09-13 Thread Eduardo Padoan

New submission from Eduardo Padoan:

Python 3.0a1 (py3k:58103, Sep 11 2007, 13:52:21) 
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> asd asd
  File "", line 1
P��
^
SyntaxError: invalid syntax

--
components: Interpreter Core
messages: 55888
nosy: eopadoan
severity: normal
status: open
title: Mangled chars in offending line of SyntaxError traceback
type: behavior
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



[issue1161] Garbled chars in offending line of SyntaxError traceback

2007-09-13 Thread Eduardo Padoan

Changes by Eduardo Padoan:


--
title: Mangled chars in offending line of SyntaxError traceback -> Garbled 
chars in offending line of SyntaxError traceback

__
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-13 Thread Skip Montanaro

Skip Montanaro added the comment:

Brett> Are you going to add support to strptime as well?

I looked at strptime for about two seconds then moved on.  I presume you
would know how to add it easily though. ;-)

Brett> As for the 'time' module, I don't think it would be useful as it 
serves
Brett> no purpose since the time tuple can't resolve to that
Brett> resolution. 

Resolution isn't the issue.  You just make sure you add enough zeroes to
make it be microseconds.  The bigger problem is that time.strftime() takes a
tuple of ints which basically represents a struct tm.  That struct has an
int seconds field and no sub-second field.  You'd either have to start
allowing floating point tm_sec fields then either truncating or rounding
(but which?) to get ints when you need to actually generate an actual struct
tm.

Skip

__
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-13 Thread Skip Montanaro

Skip Montanaro added the comment:

Eric> It's a nit, but there are a few other comments that should be
Eric> changed to mention %f in addition to %z/%Z.

Yes, thanks.

Skip

__
Tracker <[EMAIL PROTECTED]>

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



[issue1162] Python doesn't compile on Microsoft Visual Studio 2008 "Orcas" Beta 2

2007-09-13 Thread Swaroop

New submission from Swaroop:

I followed the README build instructions for VS2005. I opened
pcbuild.sln in PCbuild8 directory and tried building, and I get the
following errors:




Warning 1   Command line warning D9035 : option 'Wp64' has been deprecated
and will be removed in a future release cl  make_buildinfo
Warning 2   Command line warning D9035 : option 'Wp64' has been deprecated
and will be removed in a future release cl  make_versioninfo
Warning 3   warning C4005: 'WRITE_RESTRICTED' : macro redefinition
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h   7127
pythoncore
Warning 4   warning C4005: 'WRITE_RESTRICTED' : macro redefinition
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h   7127
pythoncore
Warning 5   warning C4133: 'function' : incompatible types - from
'_typeobject *' to 'PyObject *'
c:\all\code\python-svn\modules\_collectionsmodule.c 1113pythoncore
Warning 6   warning C4005: 'WRITE_RESTRICTED' : macro redefinition
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h   7127
pythoncore
Warning 7   warning C4018: '>' : signed/unsigned mismatch
c:\all\code\python-svn\modules\mmapmodule.c 693 pythoncore
Warning 8   warning C4018: '>' : signed/unsigned mismatch
c:\all\code\python-svn\modules\mmapmodule.c 834 pythoncore
Error   9   fatal error C1083: Cannot open include file: 'db.h': No such
file or directory   c:\all\code\python-svn\modules\_bsddb.c 90  _bsddb
Warning 10  warning LNK4075: ignoring '/EDITANDCONTINUE' due to
'/INCREMENTAL:NO' specification _testcapimodule.obj _testcapi
Warning 11  warning C4005: 'WRITE_RESTRICTED' : macro redefinition
c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h   7127_socket
Error   12  error C2373: 'inet_pton' : redefinition; different type
modifiers   c:\all\code\python-svn\modules\socketmodule.c   300 _socket
Error   13  error C2373: 'inet_ntop' : redefinition; different type
modifiers   c:\all\code\python-svn\modules\socketmodule.c   301 _socket
Error   14  error C2373: 'inet_pton' : redefinition; different type
modifiers   c:\all\code\python-svn\modules\socketmodule.c   5124_socket
Error   15  error C2373: 'inet_ntop' : redefinition; different type
modifiers   c:\all\code\python-svn\modules\socketmodule.c   5139_socket
Warning 16  warning LNK4075: ignoring '/EDITANDCONTINUE' due to
'/INCREMENTAL:NO' specification winsound.objwinsound
Warning 17  warning LNK4075: ignoring '/EDITANDCONTINUE' due to
'/INCREMENTAL:NO' specification unicodedata.obj unicodedata
Error   18  fatal error C1083: Cannot open include file: 'tcl.h': No such
file or directory   c:\all\code\python-svn\modules\_tkinter.c   66  
_tkinter
Error   19  fatal error C1083: Cannot open include file: 'tcl.h': No such
file or directory   c:\all\code\python-svn\modules\tkappinit.c  16  
_tkinter
Warning 20  warning LNK4075: ignoring '/EDITANDCONTINUE' due to
'/INCREMENTAL:NO' specification selectmodule.objselect
Error   21  fatal error C1083: Cannot open include file: 'sqlite3.h': No
such file or directory
c:\all\code\python-svn\modules\_sqlite\connection.h 33  _sqlite3
Error   22  fatal error C1083: Cannot open include file: 'sqlite3.h': No
such file or directory
c:\all\code\python-svn\modules\_sqlite\connection.h 33  _sqlite3
Error   23  fatal error C1083: Cannot open include file: 'sqlite3.h': No
such file or directory
c:\all\code\python-svn\modules\_sqlite\connection.h 33  _sqlite3
Error   24  fatal error C1083: Cannot open include file: 'sqlite3.h': No
such file or directory
c:\all\code\python-svn\modules\_sqlite\connection.h 33  _sqlite3
Error   25  fatal error C1083: Cannot open include file: 'sqlite3.h': No
such file or directory
c:\all\code\python-svn\modules\_sqlite\connection.h 33  _sqlite3
Error   26  fatal error C1083: Cannot open include file: 'sqlite3.h': No
such file or directory
c:\all\code\python-svn\modules\_sqlite\connection.h 33  _sqlite3
Error   27  fatal error C1083: Cannot open include file: 'sqlite3.h': No
such file or directory
c:\all\code\python-svn\modules\_sqlite\connection.h 33  _sqlite3
Warning 28  warning LNK4075: ignoring '/EDITANDCONTINUE' due to
'/INCREMENTAL:NO' specification _msi.obj_msi
Warning 29  warning LNK4075: ignoring '/EDITANDCONTINUE' due to
'/INCREMENTAL:NO' specification _elementtree.obj_elementtree
Warning 30  warning LNK4075: ignoring '/EDITANDCONTINUE' due to
'/INCREMENTAL:NO' specification _ctypes_test.obj_ctypes_test
Error   31  fatal error C1083: Cannot open include file: 'bzlib.h': No such
file or directory   c:\all\code\python-svn\modules\bz2module.c  12  
bz2
Warning 32  warning C4005: 'WRITE_RESTRICTED' : macro redefinition
c:\program files\microsoft sdks

[issue1162] Python doesn't compile on Microsoft Visual Studio 2008 "Orcas" Beta 2

2007-09-13 Thread Swaroop

Changes by Swaroop:


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



[issue1162] Python doesn't compile on Microsoft Visual Studio 2008 "Orcas" Beta 2

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

Martin v. Löwis added the comment:

This problems are surely solvable. However, I don't think they need to
be solved yet. Instead, before we make the next Python release, we
decide what VS version to build it with; if it's Orcas, then the
PCbuild directory will be updated to contain working project files.

Meanwhile, if you want to do something now, feel free to submit a
patch, either to PCbuild or PCbuild8. We will not apply that patch,
but it would be available for anybody who wants to experiment with
beta versions of Microsoft compilers.

Regards,
Martin

--
nosy: +loewis

__
Tracker <[EMAIL PROTECTED]>

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



[issue1159] os.getenv() not updated after external module uses C putenv()

2007-09-13 Thread Raghuram Devarakonda

Changes by Raghuram Devarakonda:


--
nosy: +draghuram

__
Tracker <[EMAIL PROTECTED]>

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



[issue1159] os.getenv() not updated after external module uses C putenv()

2007-09-13 Thread Raghuram Devarakonda

Raghuram Devarakonda added the comment:

On 9/13/07, Robert Ancell <[EMAIL PROTECTED]> wrote:

> The Python os.getenv() function accesses an Python dictionary which is
> mirroring the process environment. This dictionary is populated when the
> interpreter starts and updated when os.environ.__setitem__() or
> os.putenv() are called. However if the python program imports an

As per the document and my simple test (on Linux), os.putenv() does
not update os.environ. I think, it should update it.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1159] os.getenv() not updated after external module uses C putenv()

2007-09-13 Thread Stefan Sonnenberg-Carstens

Stefan Sonnenberg-Carstens added the comment:

> As per the document and my simple test (on Linux), os.putenv() does
> not update os.environ. I think, it should update it.
What would be the benefit ?

--
nosy: +pythonmeister

__
Tracker <[EMAIL PROTECTED]>

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



[issue1159] os.getenv() not updated after external module uses C putenv()

2007-09-13 Thread Raghuram Devarakonda

Raghuram Devarakonda added the comment:

> Stefan Sonnenberg-Carstens added the comment:
>
> > As per the document and my simple test (on Linux), os.putenv() does
> > not update os.environ. I think, it should update it.
> What would be the benefit ?

Symmetrical behaviour. When os.getenv() returns the value from
os.environ, one would expect, os.putenv to store the value there (At
least, I did). On the other hand, it is also ok for both os.getenv and
os.putenv get/set the environment directly instead of going through
os.environ. I am sure there was some reason for the current behaviour
of os.putenv. Perhaps, because putenv is supposedly not available on
all platforms?

Any way, I think the OP was asking to always "get" the value
dynamically when ever os.environ['VAR'] or os.getenv['VAR'] is done. I
don't see any problem with that approach. How ever, if it is
considered backwards incompatible, I guess an optional parameter can
be added to os.getenv.

__
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-13 Thread Brett Cannon

Brett Cannon added the comment:

On 9/13/07, Skip Montanaro <[EMAIL PROTECTED]> wrote:
>
> Skip Montanaro added the comment:
>
> Brett> Are you going to add support to strptime as well?
>
> I looked at strptime for about two seconds then moved on.  I presume you
> would know how to add it easily though. ;-)
>

Adding support is not issue.  It's exposing the microseconds to
datetime.  It would probably require something along the lines of
returning a tuple with microseconds included and have time use a
function that creates another tuple with that info removed and
datetime using the more informational tuple.

But adding the %f support is very straightforward.

> Brett> As for the 'time' module, I don't think it would be useful as it 
> serves
> Brett> no purpose since the time tuple can't resolve to that
> Brett> resolution.
>
> Resolution isn't the issue.  You just make sure you add enough zeroes to
> make it be microseconds.  The bigger problem is that time.strftime() takes a
> tuple of ints which basically represents a struct tm.  That struct has an
> int seconds field and no sub-second field.  You'd either have to start
> allowing floating point tm_sec fields then either truncating or rounding
> (but which?) to get ints when you need to actually generate an actual struct
> tm.

Right.  I am in favour of this being just a datetime thing as we
should get people moved off of time for stuff like this anyway.

-Brett

__
Tracker <[EMAIL PROTECTED]>

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



[issue1159] os.getenv() not updated after external module uses C putenv()

2007-09-13 Thread Stefan Sonnenberg-Carstens

Stefan Sonnenberg-Carstens added the comment:

I'd like to see perl/ruby behaviour:
an dict (os.environ), nothing more (perl %ENV,ruby $ENV).
Get rid of setenv/putenv at all.
3.0a1 has even more:
There is os.environ (a dict), os.[put|get]env() and os.environ.putenv()

__
Tracker <[EMAIL PROTECTED]>

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



[issue1145] Allow str.join to join non-string types (as per PEP 3100)

2007-09-13 Thread Georg Brandl

Georg Brandl added the comment:

Guido van Rossum schrieb:
> Guido van Rossum added the comment:
> 
> There's one additional issue.  If any of the items is a bytes, the call
> should fail.

Should it really, even if the bytes is ascii-encodable?

Georg

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



[issue1163] Patch to make py3k/Lib/test/test_thread.py use unittest

2007-09-13 Thread Jono DiCarlo

New submission from Jono DiCarlo:

In the google spreadsheet for py3k tasks for the sprint last month, one
of the listed tasks was to convert Lib/test/test_thread to use the
unittest module, where it previously was using the old-style testing
(i.e. comparing output of print statements to a text file).  I'm
attatching a patch that makes that change.

This is my first time submitting a patch to Python, so please let me
know if I'm doing anything wrong (or if this patch is redundant).

--
components: Tests
files: jdicarlo_stdlibtests_patch_sep7.diff
messages: 55899
nosy: JonoDiCarlo
severity: minor
status: open
title: Patch to make py3k/Lib/test/test_thread.py use unittest
type: rfe
versions: Python 3.0

__
Tracker <[EMAIL PROTECTED]>

__Index: output/test_thread
===
--- output/test_thread	(revision 58058)
+++ output/test_thread	(working copy)
@@ -1,18 +0,0 @@
-test_thread
-waiting for all tasks to complete
-all tasks done
-
-*** Barrier Test ***
-all tasks done
-
-*** Changing thread stack size ***
-caught expected ValueError setting stack_size(4096)
-successfully set stack_size(262144)
-successfully set stack_size(1048576)
-successfully set stack_size(0)
-trying stack_size = 262144
-waiting for all tasks to complete
-all tasks done
-trying stack_size = 1048576
-waiting for all tasks to complete
-all tasks done
Index: test_thread.py
===
--- test_thread.py	(revision 58058)
+++ test_thread.py	(working copy)
@@ -1,55 +1,99 @@
 # Very rudimentary test of thread module
-
 # Create a bunch of threads, let each do some work, wait until all are done
 
-from test.test_support import verbose
+# Imports
+
+import unittest
 import random
 import thread
 import time
 
-mutex = thread.allocate_lock()
-rmutex = thread.allocate_lock() # for calls to random
-running = 0
-done = thread.allocate_lock()
-done.acquire()
+from test import test_support
+from test.test_support import verbose
 
-numtasks = 10
+# Module-level variables
 
+_mutex = thread.allocate_lock()
+_rmutex = thread.allocate_lock() # for calls to random
+_done = thread.allocate_lock()
+_done.acquire()
+
+_running = 0 # Number of task threads currently running
+_numtasks = 10 # Number of task threads to start up in each test stage
+_next_ident = 0 # Identifier for next task thread to start
+_numtrips = 3 # Number of times that threads try to pass the barrier
+
+# Child thread functions
+
 def task(ident):
-global running
-rmutex.acquire()
-delay = random.random() * numtasks
-rmutex.release()
+# Function that will be executed by child threads.
+# ident is a number that uniquely identifies the thread.
+# Sleeps for a random amount of time before finishing.
+global _running
+_rmutex.acquire()
+delay = random.random() * _numtasks
+_rmutex.release()
 if verbose:
 print('task', ident, 'will run for', round(delay, 1), 'sec')
 time.sleep(delay)
 if verbose:
 print('task', ident, 'done')
-mutex.acquire()
-running = running - 1
-if running == 0:
-done.release()
-mutex.release()
+_mutex.acquire()
+_running = _running - 1
+if _running == 0:
+_done.release()
+_mutex.release()
 
-next_ident = 0
-def newtask():
-global next_ident, running
-mutex.acquire()
-next_ident = next_ident + 1
+
+def new_task():
+# Creates a new child thread which will execute the
+# task() function.
+global _next_ident, _running
+_mutex.acquire()
+_next_ident = _next_ident + 1
 if verbose:
-print('creating task', next_ident)
-thread.start_new_thread(task, (next_ident,))
-running = running + 1
-mutex.release()
+print('creating task', _next_ident)
+thread.start_new_thread(task, (_next_ident,))
+_running = _running + 1
+_mutex.release()
 
-for i in range(numtasks):
-newtask()
 
-print('waiting for all tasks to complete')
-done.acquire()
-print('all tasks done')
+def task_with_barrier(ident, bar):
+# A function to be executed by child threads.
+# ident is a number that uniquely identifies the thread.
+# bar must be a _Barrier object.
+# The thread tries to enter, then leave, this barrier.
+global _running
+for i in range(_numtrips):
+if ident == 0:
+# give it a good chance to enter the next
+# barrier before the others are all out
+# of the current one
+delay = 0.001
+else:
+_rmutex.acquire()
+delay = random.random() * _numtasks
+_rmutex.release()
+if verbose:
+print('task', ident, 'will run for', round(delay, 1), 'sec')
+time.sleep(delay)
+if verbose:
+print('task', ident, 'entering barrier', i)
+bar.en

[issue1163] Patch to make py3k/Lib/test/test_thread.py use unittest

2007-09-13 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



[issue416670] MatchObjects not deepcopy()able

2007-09-13 Thread Brett Cannon

Changes by Brett Cannon:


--
dependencies: +Fix #416670: register SRE types


Tracker <[EMAIL PROTECTED]>


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



[issue416670] MatchObjects not deepcopy()able

2007-09-13 Thread Brett Cannon

Changes by Brett Cannon:


--
dependencies:  -Fix #416670: register SRE types


Tracker <[EMAIL PROTECTED]>


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



[issue487331] time mod's timezone doesn't honor TZ var

2007-09-13 Thread Brett Cannon

Brett Cannon added the comment:

time.tzset() was added in Python 2.3.  Closing as fixed.

--
nosy: +brett.cannon
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



[issue504152] rfc822 long header continuation broken

2007-09-13 Thread Brett Cannon

Changes by Brett Cannon:


--
keywords: +patch


Tracker <[EMAIL PROTECTED]>


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



[issue614555] Rewrite _reduce and _reconstructor in C

2007-09-13 Thread Brett Cannon

Brett Cannon added the comment:

Classifying as an RFE since this is not critical (as shown by it not
happening since early 2003).

--
nosy: +brett.cannon
type:  -> rfe


Tracker <[EMAIL PROTECTED]>


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



[issue1083] Confusing error message when dividing timedelta using /

2007-09-13 Thread Brett Cannon

Changes by Brett Cannon:


--
keywords: +py3k
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



[issue539444] asyncore file wrapper & os.error

2007-09-13 Thread Brett Cannon

Brett Cannon added the comment:

Following Josiah's advice and closing this as this has been sitting here
long enough.

--
nosy: +brett.cannon
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



[issue542314] long file name support broken in windows

2007-09-13 Thread Brett Cannon

Brett Cannon added the comment:

Can someone verify that the length issue has been fixed since Ptyhon 2.5?

--
nosy: +brett.cannon


Tracker <[EMAIL PROTECTED]>


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



[issue1083] Confusing error message when dividing timedelta using /

2007-09-13 Thread Brett Cannon

Brett Cannon added the comment:

If you set nb_true_div on timedelta objects to delta_divide (just like
nb_floor_div) you won't have this problem as the division will just
work.  Otherwise there is no other good way as if the divisor doesn't
work you need to return NotImplemented, which then tries the right-hand
object which fails, and 'object' returns the TypeError.  Best you could
do is a warning or something.  

But it might make sense to only set it on nb_true_div as the division
does not round anything.

--
nosy: +brett.cannon

__
Tracker <[EMAIL PROTECTED]>

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



[issue1159] os.getenv() not updated after external module uses C putenv()

2007-09-13 Thread Robert Ancell

Robert Ancell added the comment:

draghuram, unfortunately while os.putenv() can be fixed to be
symmetrical any putenv call from a C module cannot, for example:

If you make an extension:
#include 
PyObject *putenvC(PyObject *module, PyObject *args)
{
int result;

if (!PyArg_ParseTuple(args, ""))
return 0;

result = putenv("FOO=BAR");

return Py_BuildValue("i", result);
}

The following behaviour will occur:
$ python
>>> import putenv
>>> putenv.putenvC()
>>> assert(os.getenv('FOO') == None)
>>> assert(os.environ.get('FOO') == None)

This is because the os.environ dictionary will never be updated:
>From Lib/os.py:
def getenv(key, default=None):
"""Get an environment variable, return None if it doesn't exist.
The optional second argument can specify an alternate default."""
return environ.get(key, default)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1162] Python doesn't compile on Microsoft Visual Studio 2008 "Orcas" Beta 2

2007-09-13 Thread Swaroop

Swaroop added the comment:

Hi Martin,

I completely agree with you.

I would like to get it working but would need some guidance on the build
system... is there someone whose brains I can pick for this? :)

Also, we can mark this issue as 'not a bug'?

--
type:  -> compile error

__
Tracker <[EMAIL PROTECTED]>

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



[issue1159] os.getenv() not updated after external module uses C putenv()

2007-09-13 Thread Robert Ancell

Robert Ancell added the comment:

I've attached proof-of-concept showing how os.environ would ideally
work. It'll only work in Posix, etc etc.

Reading into it more there are a lot of general issues with environments
and memory allocation which is why I suspect Python doesn't use
putenv... See putenv(3) for details.

Compile with:
gcc -shared -o environmodule.so -g -Wall -I /usr/include/python2.5
environmodule.c

__
Tracker <[EMAIL PROTECTED]>

__#include "Python.h"

#include 

static PyObject *environ_getenv(PyObject *self, PyObject *args)
{
char *name, *result;

if(!PyArg_ParseTuple(args, "s", &name))
return NULL;

result = getenv(name);

if(result == NULL)
Py_RETURN_NONE;
else
return PyString_FromString(result);
}

static PyObject *environ_putenv(PyObject *self, PyObject *args)
{
int result;
char *name, *value, *buffer;

if (!PyArg_ParseTuple(args, "ss", &name, &value))
return NULL;

buffer = malloc(sizeof(char) * (strlen(name) + 1 + strlen(value)));
sprintf(buffer, "%s=%s", name, value);
result = putenv(buffer);

return PyInt_FromLong((long)result);
}


/* Environment iterator */

typedef struct {
PyObject_HEAD
int offset;
} environ_EnvironIterObject;

static PyTypeObject environ_EnvironIterType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"environ.EnvironIter", /*tp_name*/
sizeof(environ_EnvironIterObject)  /*tp_basicsize*/
};

static PyObject *Environ_iternext(PyObject *object)
{
environ_EnvironIterObject *o = (environ_EnvironIterObject *)object;
char *value;
int i;

/* Must count from the start in case the environment has shrunk since the last iteration */
for(i = 0; i < o->offset && environ[i]; i++)
value = environ[i];
o->offset++;

if(value == NULL)
return NULL;
else
return PyString_FromString(value);
}


/* Environment object */

typedef struct {
PyObject_HEAD
} environ_EnvironObject;

static PyTypeObject environ_EnvironType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
"environ.Environ", /*tp_name*/
sizeof(environ_EnvironObject)  /*tp_basicsize*/
};

static PyObject *Environ_getitem(PyObject *self, PyObject *arg)
{
char *result, *name;

name = PyString_AsString(arg);
result = getenv(name);

if(result == NULL)
Py_RETURN_NONE;
else
return PyString_FromString(result); /* FIXME: Should split into a 2-tuple */
}

static int Environ_setitem(PyObject *self, PyObject *key, PyObject *v)
{
int result;
char *name, *value, *buffer;

name = PyString_AsString(key);
value = PyString_AsString(v);

/* FIXME: free() the current value if we set it (i.e. getenv() == malloced_value + len(name) + len('=')) */

/* FIXME: We need to remember this malloc so we can free() it later */
buffer = malloc(sizeof(char) * (strlen(name) + 1 + strlen(value)));
sprintf(buffer, "%s=%s", name, value);
result = putenv(buffer);

return 0;
}

static PyMethodDef Environ_methods[] = {
{NULL}
};

static Py_ssize_t Environ_length(PyObject *mp)
{
int count;
for(count = 0; environ[count] != NULL; count++);
return count;
}

static PyMappingMethods environ_as_mapping = {
	(lenfunc)Environ_length, /*mp_length*/
	(binaryfunc)Environ_getitem, /*mp_subscript*/
	(objobjargproc)Environ_setitem, /*mp_ass_subscript*/
};

static PyObject *Environ_iter(PyObject *object)
{
/* NOTE: If the environment is changed during iteration it will be safe but unpredictable */
return environ_EnvironIterType.tp_alloc(&environ_EnvironIterType, 0);
}


/* Module initialisation */

static PyMethodDef environ_methods[] = {
{"getenv", environ_getenv, METH_VARARGS, ""},
{"putenv", environ_putenv, METH_VARARGS, ""},
{NULL}
};

PyMODINIT_FUNC initenviron(void)
{
PyObject *m, *environ;

environ_EnvironType.tp_flags = Py_TPFLAGS_DEFAULT;
environ_EnvironType.tp_doc = "Environment object";
environ_EnvironType.tp_new = PyType_GenericNew;
environ_EnvironType.tp_iter = Environ_iter;
environ_EnvironType.tp_methods = Environ_methods;
if(PyType_Ready(&environ_EnvironType) < 0)
return;

environ_EnvironIterType.tp_flags = Py_TPFLAGS_DEFAULT;
environ_EnvironIterType.tp_doc = "Environment iterator";
environ_EnvironIterType.tp_new = PyType_GenericNew;
environ_EnvironIterType.tp_iternext = Environ_iternext;
environ_EnvironIterType.tp_as_mapping = &environ_as_mapping;
if(PyType_Ready(&environ_EnvironIterType) < 0)
return;

m = Py_InitModule3("environ",
   environ_methods,
   "Module to test potential os.environ replacement");

environ

[issue1162] Python doesn't compile on Microsoft Visual Studio 2008 "Orcas" Beta 2

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

Martin v. Löwis added the comment:

Ok, I'm closing this as "won't fix" now. If you want to look for help,
ask on comp.lang.python. If you want some of the core developers to
resolve this, be patient - in about a year, it should be resolved. If
you ever come up with a patch, please submit this as a new report.

--
resolution:  -> wont fix
type: compile error -> rfe

__
Tracker <[EMAIL PROTECTED]>

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



[issue1162] Python doesn't compile on Microsoft Visual Studio 2008 "Orcas" Beta 2

2007-09-13 Thread Georg Brandl

Changes by Georg Brandl:


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