[issue8659] ABS(x) == 0 can be simplified to x == 0

2010-05-08 Thread Daniel Stutzbach

New submission from Daniel Stutzbach dan...@stutzbachenterprises.com:

I noticed that in longobject.c, there are a few spots that take the absolute 
value of an int before comparing the int to 0.  There's no -0 for C integers, 
so the absolute value isn't necessary.

I traced back through the commit history, and it looks like they're an artifact 
of the original one's-complement longobject.c (which COULD have -0).  
longobject was switched to two's-complement in 1992. ;-)

--
assignee: stutzbach
components: Interpreter Core
files: abs-zero.patch
keywords: patch
messages: 105265
nosy: stutzbach
priority: normal
severity: normal
stage: patch review
status: open
title: ABS(x) == 0 can be simplified to x == 0
type: performance
versions: Python 3.2
Added file: http://bugs.python.org/file17259/abs-zero.patch

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



[issue8659] ABS(x) == 0 can be simplified to x == 0

2010-05-08 Thread Daniel Stutzbach

Changes by Daniel Stutzbach dan...@stutzbachenterprises.com:


--
keywords: +needs review

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



[issue4171] SSL handshake fails after TCP connection in getpeername()

2010-05-08 Thread Dmitry Dvoinikov

Dmitry Dvoinikov dmi...@targeted.org added the comment:

Checked out and built revision 80956 of py3k against OpenSSL 0.9.8n. Here is 
the banner:

Python 3.2a0 (py3k:80956, May  8 2010, 11:31:45) [MSC v.1500 32 bit (Intel)] on 
win32

Now, the breaking script appears not to be breaking any more, even though I 
tried it in a loop, a 1000 attempts to execute were all successful. 

It seems to be fine now, thank you for your help.

--

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



[issue8659] ABS(x) == 0 can be simplified to x == 0

2010-05-08 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Thanks!  Fixed in r80961 (trunk) and r80962 (py3k).

BTW, are there any particular commit messages or news entries that indicate a 
switch to two's complement?  I've looked for these in the past, but not found 
them.

--
nosy: +mark.dickinson
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

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



[issue8659] ABS(x) == 0 can be simplified to x == 0

2010-05-08 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

I found:

- Long integer shift/mask operations now simulate 2's complement
  to give more useful results for negative operands

in Misc/HISTORY, for the Python 0.9.6 release.  That's different, though:  it's 
about Python's semantics, not C's.  It's orthogonal to the question of whether 
the underlying C implementation uses two's complement, ones' complement or 
sign-magnitude.

I can't find any explicit indication of a decision to assume that the hardware 
integers are two's complement anywhere;  as far as I know, no such decision was 
ever taken.

But of course your simplifications are valid regardless of the integer 
representation of the machine.

--

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



[issue7724] setup.py ignores SDK root on OSX

2010-05-08 Thread Ronald Oussoren

Changes by Ronald Oussoren ronaldousso...@mac.com:


--
stage: patch review - committed/rejected

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



[issue8444] openssl version detection doesn't work properly when using OSX SDK

2010-05-08 Thread Ronald Oussoren

Ronald Oussoren ronaldousso...@mac.com added the comment:

Closing because the patch in issue 7724 fixes this problem.

--
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

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



[issue8510] update to autoconf2.65

2010-05-08 Thread Matthias Klose

Matthias Klose d...@debian.org added the comment:

the update to 2.65 on the py3k branch only did show whitespace changes, 
applying these changes to the trunk.

r80964: require autoconf-2.65

--

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Marc-Andre Lemburg

Marc-Andre Lemburg m...@egenix.com added the comment:

Daniel Stutzbach wrote:
 
 New submission from Daniel Stutzbach dan...@stutzbachenterprises.com:
 
 Currently, Python can be built with an internal Unicode representation of 
 UCS2 or UCS4.  To prevent extension modules compiled with the wrong Unicode 
 representation from linking, unicodeobject.h #defines many of the Unicode 
 functions.  For example, PyUnicode_FromString becomes either 
 PyUnicodeUCS2_FromString or PyUnicodeUCS4_FromString.
 
 Consequently, if one installs a binary egg (e.g., with easy_install), there's 
 a good chance one will get an error such as the following when trying to use 
 it:
 
 undefined symbol: PyUnicodeUCS2_FromString
 
 In Python 2, only some extension modules were stung by this problem.  For 
 Python 3, virtually every extension type will need to call a PyUnicode_* 
 function, since __repr__ must return a Unicode object.  It's basically 
 fruitless to upload a binary egg for Python 3 to PyPi, since it will generate 
 link errors for a large fraction of downloaders (I discovered this the hard 
 way).
 
 Right now, nearly all the functions in unicodeobject.h are wrapped.  Several 
 functions are not.  Many of the unwrapped functions also have no 
 documentation, so I'm guessing they are newer functions that were not wrapped 
 when they were added.

That's true. The main point in wrapping the APIs was to make sure that
if an extension module uses Unicode, it will likely use one of the
wrapped APIs and then be protected by the name mangling to prevent
extensions compiled as UCS2 to be loaded into a UCS4 interpreter
and vice-versa.

The main difference between those two build variants is the definition
of Py_UNICODE. Unfortunately, there's no way to have the linker check
that type definition. The wrapping was chosen as alternative protection.

 Most extensions treat PyUnicodeObjects as opaque and do not care if the 
 internal representation is UCS2 or UCS4.  We can improve ABI compatibility by 
 only wrapping functions where the representation matters from the caller's 
 point of view.
 
 For example, PyUnicode_FromUnicode creates a Unicode object from an array of 
 Py_UNICODE objects.  It will interpret the data differently on UCS2 vs UCS4, 
 so the function should be wrapped.

 On the other hand, PyUnicode_FromString creates a Unicode object from a char 
 *.  The caller can treat the returned object as opaque, so the function 
 should not be wrapped.

The point of the wrapping was not to protect the APIs themselves.
It is just meant to be able to use the linker as protection device
when loading a module.

If you can propose a different method of reliably protecting against
mixed Unicode build module loads, that would be great. We could then
get rid off the wrapping altogether.

 The attached patch implements that rule.  It unwraps 64 opaque functions that 
 were previously wrapped, and wraps 11 non-opaque functions that were 
 previously unwrapped.  make test works with both UCS2 and UCS4 builds.

I don't think that removing a few wrapped function is going to help
with the problem.

Extension modules can still use Py_UNICODE internally and make
use of the macros we have for accessing the PyUnicodeObject
internals. You simply don't catch such usage with wrapping
the APIs - as I said above: it's not a perfect solution, but
only a method that works most of the time.

I'd much rather like to see a solution that always works rather
than making mixed Unicode build extension loading easier.

Perhaps we could do something in the module import mechanism
to check for Unicode build compatibility (much like the Python API
version check, but with raising an error instead of just issuing
a warning).

 I previously brought this issue up on python-ideas, see:
 http://mail.python.org/pipermail/python-ideas/2009-November/006543.html
 
 Here's a summary of that discussion:
 
 Zooko Wilcox-O'Hearn pointed out that my proposal is complimentary to his 
 proposal to standardize on UCS4, to reduce the risk of extension modules 
 built with a mismatched encoding.
 
 Stefan Behnel pointed out that easy_install should allow eggs to specify the 
 encoding they require.  PJE's proposed implementation of that feature 
 (http://bit.ly/1bO62) would allow eggs to specify UCS2, UCS4, or Don't 
 Care.  My proposal greatly increases the number of eggs that could label 
 themselves Don't Care, reducing maintenance work for package maintainers.  
 In other words, they are complimentary fixes.
 
 Guido liked the idea but expressed concern about the possibility of extension 
 modules that link successfully, but later crash because they actually do 
 depend on the UCS2/UCS4 distinction.
 
 With my current patch, there are still two ways for that to happen:
 
 1) The extension uses only opaque functions, but casts the returned PyObject 
 * to PyUnicodeObject * and accesses the str member, or
 
 2) The extension uses only opaque functions, but uses the 

[issue8659] ABS(x) == 0 can be simplified to x == 0

2010-05-08 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Ah, now I understand :)

r2604 introduced a scheme where for a negative PyLongObject x with n digits, 
the value stored in x-ob_size was -1-n.  A little like ones' complement, but 
unrelated to anything to do with the platform integer representation.  So at 
that stage there were two possible internal representations of 0L, which is why 
all the ZABS() stuff was necessary to make sure that those two representations 
of 0L compared equal.

r2751 (in 1992, indeed!) reversed this, using -n instead of -1-n for this case, 
but didn't remove the extra tests for the two different representations of 0L.  
r2751 also changed the semantics of long bitwise operations for negative 
numbers, but that's not relevant to this issue.

Sorry for being slow.

It's impressive that this piece of redundant code has survived this long.

--

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



[issue8084] pep-0370 on osx duplicates existing functionality

2010-05-08 Thread Ronald Oussoren

Ronald Oussoren ronaldousso...@mac.com added the comment:

Committed to the trunk in r80967.

Reducing the priority because this is no longer a release-blocker for the next 
2.7 release.

--
priority: release blocker - normal

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



[issue8084] pep-0370 on osx duplicates existing functionality

2010-05-08 Thread Ronald Oussoren

Ronald Oussoren ronaldousso...@mac.com added the comment:

And committed to 3.2 in r80968

--
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

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




[issue8514] Add fsencode() functions to os module

2010-05-08 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
title: Create fsencode() and fsdecode() functions in os.path - Add fsencode() 
functions to os module

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



[issue8513] subprocess: support bytes program name (POSIX)

2010-05-08 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 I think your partA patch makes sense.

I can fix part A and B in two commits.

 It would benefit from fsencode/fsdecode functions rather 
 than manually doing the 'surrogateescape' thing everywhere.

I choosed to drop the idea of fsdecode() (patch for part A doesn't decode bytes 
anymore, it only encodes str). #8514 has now a short and simple patch. I'm 
waiting for the final decision on #8514 to commit the part A.

 Also, could you add a unittest for os._execvpe to test its behavior?

os._execvpe() is a protected function. issue8513_partA.patch includes a test 
for subprocess. test_subprocess in two twices: with _posixsubprocess (C module) 
and with the pure Python implementation. The pure Python implementation calls 
os._execvpe(), that's why I patched also this function in my patch ;-)

--

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



[issue8510] update to autoconf2.65

2010-05-08 Thread Matthias Klose

Matthias Klose d...@debian.org added the comment:

r80965: Replace AC_HELP_STRING with AS_HELP_STRING
r80966: s/AC_AIX/AC_USE_SYSTEM_EXTENSIONS/
r80969: convert all obsolete AC_TRY_* macros to AC_*_IFELSE
r80970: Avoid autoconf warning: Assume C89 semantics that RETSIGTYPE is always 
void

--

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



[issue8514] Add fsencode() functions to os module

2010-05-08 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Commited: r80971 (py3k), blocked by r80972 (3.1).

--
resolution: accepted - fixed
status: open - closed

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



[issue8490] asyncore test suite

2010-05-08 Thread Giampaolo Rodola'

Giampaolo Rodola' g.rod...@gmail.com added the comment:

I have adjusted the failing tests in r80895 and r80930 which now pass on 
Solaris. 
It seems Solaris has two problems:

 - OOB data (aka handle_expt) doesn't work, but I'm not too worried about this 
as it's very rarely used. In past there have been proposals to remove its 
support, so I'd be for leaving it as it is.

- connect() connects immediately, even before starting the poller.
Now, this may be a problem when writing clients which implement some logic in 
their handle_connect() method.
Since handle_connect() gets called immediately if the user tries to, say, send 
some data over the socket, the dispatcher will immediately be closed as the 
socket is actually still disconnected.

I'd be for starting to commit the patch in attachment which skips such tests on 
SunOS, then if someone could give me SSH access over the Solaris box used for 
buildbots I could try to debug the connect() problem and see if I can fix it.

--
Added file: http://bugs.python.org/file17260/asyncore.patch

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



[issue8657] urlparse.urlunsplit should be smarter about +

2010-05-08 Thread Dan Buch

Dan Buch daniel.b...@gmail.com added the comment:

Is simply adding 'git+' entries comprehensive enough?  I'd have said the same 
thing about the addition of the 'svn+' entries, fwiw :)  Is adding hardcoded 
entries like this the preferred way to extend urlparse?

--
nosy: +meatballhat

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



[issue8084] pep-0370 on osx duplicates existing functionality

2010-05-08 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 And committed to 3.2 in r80968

This commit introduced a regression:

http://www.python.org/dev/buildbot/all/builders/AMD64 Ubuntu wide 
3.x/builds/1055

==
FAIL: test_get_scheme_names (test.test_sysconfig.TestSysConfig)
--
Traceback (most recent call last):
  File 
/home/buildbot/cpython-ucs4-nonascii-€/3.x.pitrou-ubuntu-wide/build/Lib/test/test_sysconfig.py,
 line 239, in test_get_scheme_names
self.assertEquals(get_scheme_names(), wanted)
AssertionError: Tuples differ: ('nt', 'nt_user', 'os2', 'os2_... != ('nt', 
'nt_user', 'os2', 'os2_...

First differing element 4:
osx_framework_user
posix_home

First tuple contains 1 additional elements.
First extra element 7:
posix_user

  ('nt',
   'nt_user',
   'os2',
   'os2_home',
-  'osx_framework_user',
   'posix_home',
   'posix_prefix',
   'posix_user')

--
nosy: +haypo
resolution: fixed - 
status: closed - open

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



[issue8513] subprocess: support bytes program name (POSIX)

2010-05-08 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Update the patch to use os.fsencode().

--
Added file: http://bugs.python.org/file17261/issue8513_partA-fsencode.patch

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



[issue8638] Remove suggestion for name mangling from the tutorial

2010-05-08 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

The section titled Private Variables was updated fairly recently to be more 
in line with the Python philosophy.  In its current form (which I verified to 
be present at e.g. http://docs.python.org/tutorial/classes#private-variables) I 
don't think it needs to be removed or revised (except for further 
clarification, of course.)

If someone disagrees, I would like to see a patch (or a suggestion for new 
wording).

--
nosy: +georg.brandl
status: open - pending

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

I propose a different approach:

1. add a flag to PyModuleDef, indicating whether the module was built in UCS-2 
or UCS-4 mode. Then let the interpreter refuse the load the module, instead of 
having the dynamic linker do so.
2. provide a mode for the header files where Py_UNICODE is not defined. add 
another flag to PyModuleDef indicating whether that mode was used when 
compiling the extension.

Module authors then can make a choice whether or not to refer to the Unicode 
internal representation in their module. If they do, a UCS-2 version won't load 
into a UCS-4 interpreter. If they don't refer to Py_UNICODE at all, the module 
can be used across the two modes.

There is a slight risk that a module may already crash before calling 
PyModule_Create. To prevent that, we need to specify that no Unicode API must 
be used before calling PyModule_Create.

--

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



[issue8660] py3k weakref documentation mentions the long built-in type

2010-05-08 Thread Daniel Urban

New submission from Daniel Urban urban.dani...@gmail.com:

There is a sentence in the weakref module's documentation:
Other built-in types such as tuple and long do not support weak references 
even when subclassed
But there is no long type in py3k.

--
assignee: d...@python
components: Documentation
messages: 105285
nosy: d...@python, durban
priority: normal
severity: normal
status: open
title: py3k weakref documentation mentions the long built-in type
versions: Python 3.1, Python 3.2, Python 3.3

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Marc-Andre Lemburg

Marc-Andre Lemburg m...@egenix.com added the comment:

Martin v. Löwis wrote:
 
 Martin v. Löwis mar...@v.loewis.de added the comment:
 
 I propose a different approach:
 
 1. add a flag to PyModuleDef, indicating whether the module was built in 
 UCS-2 or UCS-4 mode. Then let the interpreter refuse the load the module, 
 instead of having the dynamic linker do so.
 2. provide a mode for the header files where Py_UNICODE is not defined. add 
 another flag to PyModuleDef indicating whether that mode was used when 
 compiling the extension.
 
 Module authors then can make a choice whether or not to refer to the Unicode 
 internal representation in their module. If they do, a UCS-2 version won't 
 load into a UCS-4 interpreter. If they don't refer to Py_UNICODE at all, the 
 module can be used across the two modes.
 
 There is a slight risk that a module may already crash before calling 
 PyModule_Create. To prevent that, we need to specify that no Unicode API must 
 be used before calling PyModule_Create.

+1

We could then get rid off the API renaming altogether.

--

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



[issue7780] unittest: allow an 'import_path' as an alternative to 'top_level_dir' in test discover

2010-05-08 Thread Michael Foord

Michael Foord mich...@voidspace.org.uk added the comment:

Tested in revision 79643. Still needs docs.

--

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



[issue7780] unittest: allow an 'import_path' as an alternative to 'top_level_dir' in test discover

2010-05-08 Thread Michael Foord

Changes by Michael Foord mich...@voidspace.org.uk:


--

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



[issue7780] unittest: allow an 'import_path' as an alternative to 'top_level_dir' in test discover

2010-05-08 Thread Michael Foord

Michael Foord mich...@voidspace.org.uk added the comment:

Test committed revision 80974.

--

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



[issue4171] SSL handshake fails after TCP connection in getpeername()

2010-05-08 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Thank you!

--
status: open - closed

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



[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Looks good to me.

I definitely think this should go into 2.7 as well;  total_seconds has only 
seen the light of day in the beta releases so far, so it's unlikely we'd break 
anyone's code with this change.  (And IMO this is a bugfix, not a feature.)

It might be polite to wait a day or two for the 2.7 backport, though:  2.7 beta 
2 is supposed to be being released today.

--

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



[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

If you want a second (third?) opinion, we could ask Antoine.

--
nosy: +pitrou

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



[issue6715] xz compressor support

2010-05-08 Thread Bernhard Reiter

Changes by Bernhard Reiter ock...@raz.or.at:


--
nosy: +ockham-razor

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



[issue6715] xz compressor support

2010-05-08 Thread Brian Curtin

Changes by Brian Curtin cur...@acm.org:


--
versions:  -Python 2.7

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



[issue4972] let's equip ftplib.FTP with __enter__ and __exit__

2010-05-08 Thread Giampaolo Rodola'

Giampaolo Rodola' g.rod...@gmail.com added the comment:

Is this is still desirable?
If so I can work on a patch for ftplib which provides a finer error handling in 
case of disconnection while sending QUIT and updates tests which should be 
modified to fit in the newer test suite.

--

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



[issue4972] let's equip ftplib.FTP with __enter__ and __exit__

2010-05-08 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' g.rod...@gmail.com:


--

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



[issue4972] let's equip ftplib.FTP with __enter__ and __exit__

2010-05-08 Thread Giampaolo Rodola'

Giampaolo Rodola' g.rod...@gmail.com added the comment:

Is this still desirable?
If so I can work on a patch for ftplib which provides a finer error handling in 
case of disconnection while sending QUIT and updates tests which should be 
modified to fit in the newer test suite.

--

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



[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

[Antoine declines to offer an opinion.]

Committed to py3k in r80979.  I moved the Misc/NEWS entry from the 'Library' 
section to the 'Extension Modules' section.

Leaving open for the 2.7 backport.

--

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



[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
resolution:  - accepted
versions:  -Python 3.2

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Daniel Stutzbach

Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:

On Sat, May 8, 2010 at 5:03 AM, Marc-Andre Lemburg
rep...@bugs.python.org wrote:
 If you can propose a different method of reliably protecting against
 mixed Unicode build module loads, that would be great. We could then
 get rid off the wrapping altogether.

The following code will cause a link error 100% of the time iff
there's a mismatch:

#ifndef Py_UNICODE_WIDE
#define _Py_Unicode_Build_Symbol _Py_UCS2_Build_Symbol
#else
#define _Py_Unicode_Build_Symbol _Py_UCS4_Build_Symbol
#endif
extern int _Py_Unicode_Build_Symbol; /* Defined in unicodeobject.c */
static int *_Py_Unicode_Build_Symbol_Check = _Py_Unicode_Build_Symbol;

In practice, I'd surrounded it with a bunch #ifdefs to disable the
defined but not used warning in gcc and MSVC.

 Please note that UCS2 and UCS4 builds of Python are different in
 more ways than just the underlying Py_UNICODE type. E.g. UCS2 builds
 use surrogates when converting between Unicode and bytes which
 UCS4 don't, sys.maxunicode is different, range checks use different
 bounds, unichr() behaves differently, etc. etc.

That's true, but those differences are visible from pure-Python code
as well aren't they?

--

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



[issue7780] unittest: allow an 'import_path' as an alternative to 'top_level_dir' in test discover

2010-05-08 Thread Michael Foord

Michael Foord mich...@voidspace.org.uk added the comment:

Documented revision 80980.

--
stage:  - committed/rejected
status: open - closed

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Marc-Andre Lemburg

Marc-Andre Lemburg m...@egenix.com added the comment:

Daniel Stutzbach wrote:
 
 Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:
 
 On Sat, May 8, 2010 at 5:03 AM, Marc-Andre Lemburg
 rep...@bugs.python.org wrote:
 If you can propose a different method of reliably protecting against
 mixed Unicode build module loads, that would be great. We could then
 get rid off the wrapping altogether.
 
 The following code will cause a link error 100% of the time iff
 there's a mismatch:
 
 #ifndef Py_UNICODE_WIDE
 #define _Py_Unicode_Build_Symbol _Py_UCS2_Build_Symbol
 #else
 #define _Py_Unicode_Build_Symbol _Py_UCS4_Build_Symbol
 #endif
 extern int _Py_Unicode_Build_Symbol; /* Defined in unicodeobject.c */
 static int *_Py_Unicode_Build_Symbol_Check = _Py_Unicode_Build_Symbol;
 
 In practice, I'd surrounded it with a bunch #ifdefs to disable the
 defined but not used warning in gcc and MSVC.

Are you sure this doesn't get optimized away in practice ?

FWIW: I still like the import logic solution better, since that
will make it possible for the user to see a truly useful
error message rather than just some missing symbol linker
error.

 Please note that UCS2 and UCS4 builds of Python are different in
 more ways than just the underlying Py_UNICODE type. E.g. UCS2 builds
 use surrogates when converting between Unicode and bytes which
 UCS4 don't, sys.maxunicode is different, range checks use different
 bounds, unichr() behaves differently, etc. etc.
 
 That's true, but those differences are visible from pure-Python code
 as well aren't they?

Sure, though, I don't see how this relates to C code relying
on these details, e.g. a C extension will probably use different
conversion code depending on whether UCS2 or UCS4 is compatible
with some external library, etc.

--

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



[issue7724] setup.py ignores SDK root on OSX

2010-05-08 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Ronald, I've reverted the patch since it broke compilation on almost every 
buildbot, and we're close to beta2 release.

--
nosy: +benjamin.peterson
stage: committed/rejected - commit review

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



[issue8660] py3k weakref documentation mentions the long built-in type

2010-05-08 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

Fixed in r80983.

--
nosy: +benjamin.peterson
resolution:  - fixed
status: open - closed

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



[issue8661] FAQ item 2.25 is unclear

2010-05-08 Thread Jean-Paul Calderone

New submission from Jean-Paul Calderone exar...@twistedmatrix.com:

The item How do I prepare a new branch for merging? is unclear about which 
branch needs to be prepared.  It could be the source branch or the destination 
branch.  In #python-dev, I learned that it's probably the destination branch 
being discussed here.  This should be clarified (and it could also be pointed 
out that it is almost always the case that this step has been done by someone 
else already).

--
messages: 105300
nosy: exarkun
priority: normal
severity: normal
status: open
title: FAQ item 2.25 is unclear

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



[issue8514] Add fsencode() functions to os module

2010-05-08 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

Why does this have no tests?

--
nosy: +benjamin.peterson

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Daniel Stutzbach

Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:

On Sat, May 8, 2010 at 10:16 AM, Marc-Andre Lemburg
rep...@bugs.python.org wrote:
 Are you sure this doesn't get optimized away in practice ?

I'm sure it doesn't get optimized away by gcc 4.3, where I tested it. :)

 Sure, though, I don't see how this relates to C code relying
 on these details, e.g. a C extension will probably use different
 conversion code depending on whether UCS2 or UCS4 is compatible
 with some external library, etc.

Can you give an example?

All of the examples I can think of either:
- poke into PyUnicodeObject's internals,
- call a Python function that exposes Py_UNICODE or PyUnicodeObject

I'm explicitly trying to protect those two cases.  It's quite possible
that I'm missing something, but I can't think of any other unsafe way
for a C extension to convert a Python Unicode object to a byte string.

--

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



[issue8661] FAQ item 2.25 is unclear

2010-05-08 Thread Benjamin Peterson

Changes by Benjamin Peterson benja...@python.org:


--
assignee:  - brett.cannon
nosy: +brett.cannon

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



[issue7724] setup.py ignores SDK root on OSX

2010-05-08 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

Just to save you some time investigating, it broke the build because
of missing parentheses in setup.py:

if sys.platform == 'darwin' and dir.startswith('/System') or 
dir.startswith('/usr')

--
nosy: +skrah

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 Are you sure this doesn't get optimized away in practice ?
 
 I'm sure it doesn't get optimized away by gcc 4.3, where I tested it. :)

Did you mean to include the hunk from msg105295 as part of the patch?
If so, wouldn't that defeat the whole point of the patch?

--

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



[issue7723] sqlite only accept buffer() for BLOB objects (input/output)

2010-05-08 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

Documentation can always be updated later.

--
nosy: +benjamin.peterson
priority: release blocker - normal

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



[issue8661] FAQ item 2.25 is unclear

2010-05-08 Thread Senthil Kumaran

Senthil Kumaran orsent...@gmail.com added the comment:

I would also suggest a re-ordering of FAQ entries in this manner:

1st  What tools do I need to merge between branches?
2nd  How do I merge between branches?

And then,
 
How do I prepare a new branch for merging?

With the explanation/clarification.

--
nosy: +orsenthil

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Daniel Stutzbach

Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:

On Sat, May 8, 2010 at 8:07 AM, Martin v. Löwis rep...@bugs.python.org wrote:
 1. add a flag to PyModuleDef, indicating whether the module was built in 
 UCS-2 or UCS-4 mode. Then let the interpreter refuse the load the module, 
 instead of having the dynamic linker do so.
 2. provide a mode for the header files where Py_UNICODE is not defined. add 
 another flag to PyModuleDef indicating whether that mode was used when 
 compiling the extension.

I notice that PyModule_Create currently works like this:

PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*, int apiver);
#define PyModule_Create(module) \
PyModule_Create2(module, PYTHON_API_VERSION)

Instead of modifying PyModuleDef, what if we changed PyModule_Create
to something like the following?

PyAPI_FUNC(PyObject *) PyModule_Create3(struct PyModuleDef*, int apiver);
#define PyModule_Create(module) \
PyModule_Create3(module, PYTHON_API_VERSION, PYTHON_UNICODE_SETTING)

In most cases that will Just Work, without requiring the module writer
to modify their PyModuleDef.

--

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



[issue8084] pep-0370 on osx duplicates existing functionality

2010-05-08 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

Fixed test_sysconfig.py in r80986.

--
resolution:  - fixed
status: open - closed

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Daniel Stutzbach

Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:

On Sat, May 8, 2010 at 11:02 AM, Martin v. Löwis rep...@bugs.python.org wrote:
 Did you mean to include the hunk from msg105295 as part of the patch?
 If so, wouldn't that defeat the whole point of the patch?

My intention is to offer two compilation modes to extension authors:

1) A mode that defines Py_UNICODE, PyUnicodeObject, and various unsafe
functions and macros.
2) A mode that does not define them.

In mode #1, importing the module should fail if the Unicode settings
are mismatched.  I had meant to include the hunk from msg105295 only
in mode #1.

Right now I favor your idea of generating a runtime error when loading
the module, instead of a linker error.  Assuming we go that route, the
hunk from msg105295 will not be used at all.

--

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 In most cases that will Just Work, without requiring the module writer
 to modify their PyModuleDef.

I'd rather modify PyModuleDef_Base, to include a flags field, and
perhaps put the api version into it, as well. That's an ABI change,
unfortunately, but such a flags field may turn out useful, anyway.

--

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Daniel Stutzbach

Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:

On Sat, May 8, 2010 at 11:20 AM, Martin v. Löwis rep...@bugs.python.org wrote:
 I'd rather modify PyModuleDef_Base, to include a flags field, and
 perhaps put the api version into it, as well. That's an ABI change,
 unfortunately, but such a flags field may turn out useful, anyway.

That works for me.  I'll work on a patch (which may end up needing
further revision, but it will at least give us a concrete basis for
further discussion).

--

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Marc-Andre Lemburg

Marc-Andre Lemburg m...@egenix.com added the comment:

Daniel Stutzbach wrote:
 
 Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:
 
 On Sat, May 8, 2010 at 10:16 AM, Marc-Andre Lemburg
 rep...@bugs.python.org wrote:
 Are you sure this doesn't get optimized away in practice ?
 
 I'm sure it doesn't get optimized away by gcc 4.3, where I tested it. :)
 
 Sure, though, I don't see how this relates to C code relying
 on these details, e.g. a C extension will probably use different
 conversion code depending on whether UCS2 or UCS4 is compatible
 with some external library, etc.
 
 Can you give an example?
 
 All of the examples I can think of either:
 - poke into PyUnicodeObject's internals,
 - call a Python function that exposes Py_UNICODE or PyUnicodeObject
 
 I'm explicitly trying to protect those two cases.  It's quite possible
 that I'm missing something, but I can't think of any other unsafe way
 for a C extension to convert a Python Unicode object to a byte string.

One of the more important cases you are missing is the
argument parser in Python:

Py_UNICODE *x;
Py_ssize_t y;
PyArg_ParseTuple(args, u#, x, y);

This uses the native Py_UNICODE type, but doesn't rely on any
Unicode APIs.

Same for the tuple builder:

args = Py_BuildValue((u#), x, y);

--

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



[issue8038] Provide unittest.TestCase.assertNotRegexpMatches

2010-05-08 Thread Michael Foord

Michael Foord mich...@voidspace.org.uk added the comment:

Docstrings committed revision 80990.

--
stage: unit test needed - committed/rejected
status: open - closed

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



[issue8636] enumerate() test cases do not cover optional start argument

2010-05-08 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

Fixed in r80991. Thanks for the patch.

--
nosy: +benjamin.peterson
resolution:  - fixed
status: open - closed

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Daniel Stutzbach

Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:

On Sat, May 8, 2010 at 11:35 AM, Marc-Andre Lemburg
rep...@bugs.python.org wrote:
 One of the more important cases you are missing is the
 argument parser in Python:

Thanks.  I've had my head buried in c-api/unicode.html and unicodeobject.h.

 Py_UNICODE *x;
 Py_ssize_t y;
 PyArg_ParseTuple(args, u#, x, y);

My plan is to not define Py_UNICODE in Unicode-agnostic mode, to
prevent that from compiling.

--

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



[issue8627] Unchecked PyErr_WarnPy3k return value in Objects/typeobject.c

2010-05-08 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

I also have my doubts about the other 'goto error' lines in PyType_Ready, but I 
haven't figured out how to trigger those gotos in normal code.

Trying to figure out how to clean up properly on error in PyType_Ready is 
making my head hurt.

As a quick fix, we could simply do a PyErr_Clear() if the PyErr_WarnPy3k 
returns -1;  this clearly isn't right, but at least it gets rid of the XXX 
undetected error.

--

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



[issue8662] bytes join cannot join bytes

2010-05-08 Thread Timothy Pederick

New submission from Timothy Pederick peder...@gmail.com:

This code behaves as expected:
 ' '.join('cat')
'c a t'

This code does not:
 b'\x00'.join(b'cat')
Traceback (most recent call last):
  ...
b'\x00'.join(b'cat')
TypeError: sequence item 0: expected bytes, int found

Instead, you have to do something like this:
 b'\x00'.join(bytes((i,)) for i in b'cat')
b'c\x00a\x00t'

The cause is that indexing a bytes object gives an int, not a bytes. I know, 
it's as designed, PEP 3137, etc. But in this specific instance, it causes 
Python to behave inconsistently (bytes vs. str) and unintuitively (to me, 
anyway).

(Same problem with bytes or bytearray in either position.)

--
files: joinerror.py
messages: 105317
nosy: perey
priority: normal
severity: normal
status: open
title: bytes join cannot join bytes
type: behavior
versions: Python 3.1
Added file: http://bugs.python.org/file17262/joinerror.py

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



[issue8301] Putting a function in a unittest.TestSuite doesn't work

2010-05-08 Thread Michael Foord

Michael Foord mich...@voidspace.org.uk added the comment:

Committed revision 80997.

--
resolution:  - accepted
stage: needs patch - committed/rejected
status: open - closed

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



[issue8662] bytes join cannot join bytes

2010-05-08 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

It's not a very useful thing to join a single string, though.

--
nosy: +pitrou

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



[issue8663] Failed compile in a non-ASCII path

2010-05-08 Thread Antoine Pitrou

New submission from Antoine Pitrou pit...@free.fr:

Distutils fails logging characters which are not part of the default encoding:

http://www.python.org/dev/buildbot/builders/AMD64%20Ubuntu%20wide%203.x/builds/1062/steps/compile/logs/stdio

[...]
  File 
/home/buildbot/cpython-ucs4-nonascii-\u20ac/3.x.pitrou-ubuntu-wide/build/Lib/distutils/dir_util.py,
 line 67, in mkpath
log.info(creating %s, head)
  File 
/home/buildbot/cpython-ucs4-nonascii-\u20ac/3.x.pitrou-ubuntu-wide/build/Lib/distutils/log.py,
 line 40, in info
self._log(INFO, msg, args)
  File 
/home/buildbot/cpython-ucs4-nonascii-\u20ac/3.x.pitrou-ubuntu-wide/build/Lib/distutils/log.py,
 line 30, in _log
stream.write('%s\n' % msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\u20ac' in position 
81: ordinal not in range(128)
[54439 refs]

--
assignee: tarek
components: Distutils
messages: 105320
nosy: haypo, pitrou, tarek
priority: normal
severity: normal
stage: needs patch
status: open
title: Failed compile in a non-ASCII path
type: compile error
versions: Python 3.1, Python 3.2

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Daniel Stutzbach

Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:

In Unicode-agnostic mode, instead of leaving Py_UNICODE, PyUnicodeObject, and 
many functions undefined, I wonder if it would be sufficient to declare 
Py_UNICODE like this:

struct PY_UNICODE_TYPE;
typedef struct PY_UNICODE_TYPE Py_UNICODE;

That would allow extensions to pass opaque Py_UNICODE pointers around, but not 
allow them to dereference the pointers nor evaluate sizeof(Py_UNICODE).

That would make PyUnicodeObject safe, as well as PyUnicode_Encode* and several 
other functions (anything that doesn't manipulate individual characters, 
basically).

--

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue8513] subprocess: support bytes program name (POSIX)

2010-05-08 Thread Gregory P. Smith

Gregory P. Smith g...@krypto.org added the comment:

Build on the os._execvpe unittest I added in py3k r81001.  Protected functions 
are perfectly fine things to unittest.

--

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



[issue8547] unittest test discovery can fail when package under test is also installed globally

2010-05-08 Thread Michael Foord

Changes by Michael Foord mich...@voidspace.org.uk:


--
resolution:  - accepted
stage: needs patch - committed/rejected
status: open - closed

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



[issue8662] bytes join cannot join bytes

2010-05-08 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

While the bytes-returning-int semantics might be annoying in this case, but as 
you point out, Timothy, it's too late to change this.

--
nosy: +brett.cannon
resolution:  - wont fix
status: open - closed

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



[issue8630] Keepends param in codec readline(s)

2010-05-08 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

I think this can qualify as a bug fix.

--

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



[issue5099] subprocess.Popen.__del__ causes AttributeError (os module == None)

2010-05-08 Thread Gregory P. Smith

Gregory P. Smith g...@krypto.org added the comment:

I think your patch looks good Brett.

--

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



[issue8662] bytes join cannot join bytes

2010-05-08 Thread Timothy Pederick

Timothy Pederick peder...@gmail.com added the comment:

Brett: Well, I was more thinking along the lines of making join() recognise 
when it's been passed a bytes object, rather than changing the semantics of 
indexing bytes. That would be a bit overdramatic!

But if it's wontfix, it's wontfix.

Antoine: Yes, the str example was just for comparison, since the behaviour of 
bytes is generally supposed to be the same as str. (But I'm sure I could think 
of some silly examples where it could be used.) The bytes problem actually came 
up in code I was writing... though I later ripped it out and did it 
differently...

--

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



[issue8654] Improve ABI compatibility between UCS2 and UCS4 builds

2010-05-08 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 In Unicode-agnostic mode, instead of leaving Py_UNICODE,
 PyUnicodeObject, and many functions undefined, I wonder if it would
 be sufficient to declare Py_UNICODE like this:

Sounds good.

--

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



[issue8664] py_compile.compile() should consistently create parent directory of target file

2010-05-08 Thread Arfrever Frehtes Taifersar Arahesis

New submission from Arfrever Frehtes Taifersar Arahesis 
arfrever@gmail.com:

Currently when cfile argument of py_compile.compile() is None, then path to 
target file is automatically calculated and parent directory of target file is 
created. If the same path of target file is explicitly passed as cfile argument 
of py_compile.compile(), then parent directory of target file is not created 
automatically.
This inconsistency in behavior can be easily fixed. Fixing it also allows to 
simplify compileall.compile_file() function, which calls py_compile.compile() 
and currently needs to earlier try to create parent directory of target file.

The following example shows inconsistent behavior:

$ mkdir test
$ touch test/test.py
$ tree test
test
└── test.py

0 directories, 1 file
$ python3.2 -c 'import py_compile; py_compile.compile(test/test.py)'
$ tree test
test
├── __pycache__
│   └── test.cpython-32.pyc
└── test.py

1 directory, 2 files
$ rm -fr test/__pycache__
$ python3.2 -c 'import py_compile; py_compile.compile(test/test.py, 
test/__pycache__/test.cpython-32.pyc)'
Traceback (most recent call last):
  File string, line 1, in module
  File /usr/lib64/python3.2/py_compile.py, line 131, in compile
with open(cfile, 'wb') as fc:
IOError: [Errno 2] No such file or directory: 
'test/__pycache__/test.cpython-32.pyc'
$ mkdir test/__pycache__
$ python3.2 -c 'import py_compile; py_compile.compile(test/test.py, 
test/__pycache__/test.cpython-32.pyc)'
$ tree test
test
├── __pycache__
│   └── test.cpython-32.pyc
└── test.py

1 directory, 2 files

--
components: Library (Lib)
messages: 105328
nosy: Arfrever
priority: normal
severity: normal
status: open
title: py_compile.compile() should consistently create parent directory of 
target file
type: behavior
versions: Python 3.2

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



[issue8664] py_compile.compile() should consistently create parent directory of target file

2010-05-08 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file17263/python-issue8664.patch

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



[issue6507] Enhance dis.dis to autocompile codestrings

2010-05-08 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

disassemble_str should be private with an underscore.

--

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



[issue8664] py_compile.compile() should consistently create parent directory of target file

2010-05-08 Thread Benjamin Peterson

Changes by Benjamin Peterson benja...@python.org:


--
assignee:  - barry
nosy: +barry

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



[issue8084] pep-0370 on osx duplicates existing functionality

2010-05-08 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Ronald, r80967 makes test_site fail on my machine, with the following output:

==
FAIL: test_getsitepackages (__main__.HelperFunctionsTests)
--
Traceback (most recent call last):
  File Lib/test/test_site.py, line 188, in test_getsitepackages
self.assertEqual(len(dirs), 4)
AssertionError: 2 != 4

--
Ran 17 tests in 0.321s

FAILED (failures=1)
Traceback (most recent call last):
  File Lib/test/test_site.py, line 333, in module
test_main()
  File Lib/test/test_site.py, line 330, in test_main
run_unittest(HelperFunctionsTests, ImportSideEffectTests)
  File /Users/dickinsm/python/svn/trunk/Lib/test/test_support.py, line 1038, 
in run_unittest
_run_suite(suite)
  File /Users/dickinsm/python/svn/trunk/Lib/test/test_support.py, line 1021, 
in _run_suite
raise TestFailed(err)
test.test_support.TestFailed: Traceback (most recent call last):
  File Lib/test/test_site.py, line 188, in test_getsitepackages
self.assertEqual(len(dirs), 4)
AssertionError: 2 != 4

Any ideas why?  This is on a non-framework debug build of the trunk.  The 
variable 'dirs' turns out to be:

['Python.framework/lib/python2.7/site-packages', 
'Python.framework/lib/site-python']

What else should be there?

--
nosy: +mark.dickinson
status: closed - open

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



[issue8665] make pycremoval fails

2010-05-08 Thread Antoine Pitrou

New submission from Antoine Pitrou pit...@free.fr:

This is probably because you remove the directory while find is walking it:

$ make pycremoval
find . -name '*.py[co]' -exec rm -f {} ';'
find . -name '__pycache__' -exec rmdir {} ';'
find: `./Lib/http/__pycache__': No such file or directory
find: `./Lib/unittest/test/__pycache__': No such file or directory
find: `./Lib/unittest/__pycache__': No such file or directory
find: `./Lib/email/__pycache__': No such file or directory
find: `./Lib/test/__pycache__': No such file or directory
find: `./Lib/importlib/__pycache__': No such file or directory
find: `./Lib/urllib/__pycache__': No such file or directory
find: `./Lib/__pycache__': No such file or directory
find: `./Lib/encodings/__pycache__': No such file or directory
find: `./Lib/json/__pycache__': No such file or directory
make: [pycremoval] Error 1 (ignored)

--
assignee: barry
components: Build
messages: 105331
nosy: barry, pitrou
priority: normal
severity: normal
stage: needs patch
status: open
title: make pycremoval fails
type: behavior
versions: Python 3.2

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



[issue8664] py_compile.compile() should consistently create parent directory of target file

2010-05-08 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

Looks good. Applied in r81005.

--
nosy: +benjamin.peterson
resolution:  - accepted
status: open - closed

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



[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-08 Thread Tim Chase

New submission from Tim Chase python.l...@tim.thechases.com:

Patch to update ConfigParser.py so that the .get* methods can take an optional 
parameter rather than raising exceptions.  Usage:

  cp = ConfigParser(...)
  # ...
  value = cp.get('MySection', 'MyOption', default='some default')
  i = cp.getint('MySecton', 'MyInt', default=42)
  f = cp.getfloat('MySection', 'MyF', default=3.14)

--
components: Library (Lib)
messages: 105333
nosy: Gumnos
priority: normal
severity: normal
status: open
title: Allow ConfigParser.get*() to take a default value
type: feature request
versions: Python 2.6

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



[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-08 Thread Tim Chase

Tim Chase python.l...@tim.thechases.com added the comment:

For some reason, the diff didn't attach to the previous message.

--

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



[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-08 Thread Tim Chase

Tim Chase python.l...@tim.thechases.com added the comment:

Trying a 3rd time to attach the diff (this time from Safari instead of FF)

--
keywords: +patch
Added file: http://bugs.python.org/file17264/ConfigParser.diff

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



[issue6507] Enhance dis.dis to autocompile codestrings

2010-05-08 Thread Daniel Urban

Daniel Urban urban.dani...@gmail.com added the comment:

Done. Attached new patch as issue6507_2_priv.diff.

--
Added file: http://bugs.python.org/file17265/issue6507_2_priv.diff

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



[issue8084] pep-0370 on osx duplicates existing functionality

2010-05-08 Thread Ronald Oussoren

Ronald Oussoren ronaldousso...@mac.com added the comment:

I'll look into this in the morning.

--

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



[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-08 Thread Brian Curtin

Changes by Brian Curtin cur...@acm.org:


--
stage:  - unit test needed
versions: +Python 3.2 -Python 2.6

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



[issue8642] json.loads description

2010-05-08 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Seems ok to me.

--

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



[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-08 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

I don’t know if this feature request should be discussed on python-ideas first. 
Do you have real use cases for this, is it just a nice-to-have thing?

If it’s accepted, I have some remarks about the patch:
- 2.7 is feature-frozen, so you’ll need to target the py3k branch. (Do we need 
to put a big warning somewhere?) Practically, this means that “ValueError, 
thing” should be “ValueError(thing)”.
- Lone parens or “):” on a line are not pretty.
- Some indentation after a linebreak do not comply with PEP 8 (e.g., do
def function(argument, argument,
 indent after parens column, end):

Thanks for your submission!

--
nosy: +merwok
stage: unit test needed - 

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



[issue8653] urlparse.urlparse/urlsplit doc missing

2010-05-08 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

I think you mean http://docs.python.org/library/urlparse.html#urlparse.urlparse

Dave, perhaps you were looking at an older version? Doc fixes for maintainance 
branches are welcome.

--
nosy: +merwok

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



[issue8663] Failed compile in a non-ASCII path

2010-05-08 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

What is your locale and your locale encoding? distutils use ASCII but I'm not 
sure that your locale encoding is ASCII, because Python fails to start if the 
locale is ASCII and the path contains a non ASCII character.

See also issue #8611: Python3 doesn't support locale different than utf8 and 
an non-ASCII path (POSIX).

--

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



[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Alexander Belopolsky

Alexander Belopolsky belopol...@users.sourceforge.net added the comment:

On Sat, May 8, 2010 at 10:07 AM, Mark Dickinson rep...@bugs.python.org wrote:
..
 I definitely think this should go into 2.7 as well;  total_seconds has only 
 seen the light of day
 in the beta releases so far, so it's unlikely we'd break anyone's code with 
 this change.
  (And IMO this is a bugfix, not a feature.)

Tracker web site seems to be down, so I am trying my luck attaching a
patch to an e-mail reply.  It did work in the past.

The true division by 10**6 could probably be replaced with division by
1e6 in the tests and docs, but I am not sure if the two are always
equivalent.

--
Added file: http://bugs.python.org/file17266/issue8644.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8644
___Index: Misc/NEWS
===
--- Misc/NEWS   (revision 81011)
+++ Misc/NEWS   (working copy)
@@ -70,6 +70,8 @@
   inheritance with the underlying socket object. 
   The cheap inheritance has been deprecated.
 
+- Issue #8644: td.total_seconds() is now equivalent to td / 
timedelta(seconds=1).
+
 - Issue #4265: shutil.copyfile() was leaking file descriptors when disk fills.
   Patch by Tres Seaver.
 
@@ -200,6 +202,8 @@
 Extension Modules
 -
 
+- Issue #8644: Improved accuracy of timedelta.total_seconds().
+
 - Use Clang 2.7's static analyzer to find places to clean up some code.
 
 - Build the ossaudio extension on GNU/kFreeBSD.
Index: Doc/library/datetime.rst
===
--- Doc/library/datetime.rst(revision 81011)
+++ Doc/library/datetime.rst(working copy)
@@ -270,9 +270,13 @@
 
 .. method:: timedelta.total_seconds()
 
-   Return the total number of seconds contained in the duration. Equivalent to
-   ``td.microseconds / 100 + td.seconds + td.days * 24 * 3600``.
+   Return the total number of seconds contained in the duration.
+   Equivalent to ``(td.microseconds + (td.seconds + td.days * 24 *
+   3600) * 10**6) / 10**6`` computed with true division enabled.
 
+   Note that for very large time intervals (greater than 270 years on
+   most platforms) this method will lose microsecond accuracy.
+
.. versionadded:: 2.7
 
 
Index: Lib/test/test_datetime.py
===
--- Lib/test/test_datetime.py   (revision 81011)
+++ Lib/test/test_datetime.py   (working copy)
@@ -2,7 +2,7 @@
 
 See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases
 
-
+from __future__ import division
 import os
 import pickle
 import cPickle
@@ -269,6 +269,13 @@
 for total_seconds in [123456.789012, -123456.789012, 0.123456, 0, 1e6]:
 td = timedelta(seconds=total_seconds)
 self.assertEqual(td.total_seconds(), total_seconds)
+# Issue8644: Test that td.total_seconds() has the same
+# accuracy as td / timedelta(seconds=1).
+for ms in [-1, -2, -123]:
+td = timedelta(microseconds=ms)
+self.assertEqual(td.total_seconds(),
+ ((24*3600*td.days + td.seconds)*10**6
+  + td.microseconds)/10**6)
 
 def test_carries(self):
 t1 = timedelta(days=100,
Index: Modules/datetimemodule.c
===
--- Modules/datetimemodule.c(revision 81011)
+++ Modules/datetimemodule.c(working copy)
@@ -2096,9 +2096,25 @@
 static PyObject *
 delta_total_seconds(PyObject *self)
 {
-   return PyFloat_FromDouble(GET_TD_MICROSECONDS(self) / 100.0 +
- GET_TD_SECONDS(self) +
- GET_TD_DAYS(self) * 24.0 * 3600.0);
+   PyObject *total_seconds;
+   PyObject *total_microseconds;
+   PyObject *one_million;
+
+   total_microseconds = delta_to_microseconds((PyDateTime_Delta *)self);
+   if (total_microseconds == NULL)
+   return NULL;
+
+   one_million = PyLong_FromLong(100L);
+   if (one_million == NULL) {
+   Py_DECREF(total_microseconds);
+   return NULL;
+   }
+
+   total_seconds = PyNumber_TrueDivide(total_microseconds, one_million);
+
+   Py_DECREF(total_microseconds);
+   Py_DECREF(one_million);
+   return total_seconds;
 }
 
 static PyObject *
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8644] timedelta.total_seconds needlessly inaccurate, especially for negative timedeltas

2010-05-08 Thread Alexander Belopolsky

Changes by Alexander Belopolsky belopol...@users.sourceforge.net:


Removed file: http://bugs.python.org/file17266/issue8644.diff

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



[issue8663] Failed compile in a non-ASCII path

2010-05-08 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

As I answered on IRC, this is on a buildbot environment. Compiling from the 
command line works fine, but not from the buildbot environment.

From the command line, the locale is as following:
$ locale
LANG=en_GB.UTF-8
LC_CTYPE=en_GB.UTF-8
LC_NUMERIC=en_GB.UTF-8
LC_TIME=en_GB.UTF-8
LC_COLLATE=en_GB.UTF-8
LC_MONETARY=en_GB.UTF-8
LC_MESSAGES=en_GB.UTF-8
LC_PAPER=en_GB.UTF-8
LC_NAME=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
LC_TELEPHONE=en_GB.UTF-8
LC_MEASUREMENT=en_GB.UTF-8
LC_IDENTIFICATION=en_GB.UTF-8
LC_ALL=

But I guess this information is not useful.

--

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



[issue8663] Failed compile in a non-ASCII path

2010-05-08 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Ok, this might be more interesting:

$ cat | ./python -i
Python 3.2a0 (py3k:81010, May  8 2010, 23:25:47) 
[GCC 4.3.2] on linux2
Type help, copyright, credits or license for more information.
 import locale
 locale.getpreferredencoding()
'UTF-8'
 import sys
 sys.stdin 
_io.TextIOWrapper name='stdin' encoding='ascii'
 sys.getdefaultencoding()
'utf-8'

As you see, stdin uses ascii...

--

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



[issue8666] Allow ConfigParser.get*() to take a default value

2010-05-08 Thread Dan Buch

Changes by Dan Buch daniel.b...@gmail.com:


--
nosy: +meatballhat

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



[issue8663] Failed compile in a non-ASCII path

2010-05-08 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Anyway, regardless of the actual stdout encoding, distutils should be able to 
log messages without crashing, IMO.

--

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



[issue8663] Failed compile in a non-ASCII path

2010-05-08 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Conditions to reproduce the bug: don't use make -j N (unset MAKEFLAGS), stdout 
and stderr should be be TTY = use make 21|cat.

--

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



[issue8663] Failed compile in a non-ASCII path

2010-05-08 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Another long-standing encoding bug was fixed: It was impossible to use e.g. an 
author name with non-ASCII characters. The fix makes distutils use UTF-8. Of 
course, it’s more complicated to choose an encoding for terminal I/O.

--
nosy: +merwok

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



[issue7245] better Ctrl-C support in pdb (program can be resumed) (issue216067)

2010-05-08 Thread Gregory P. Smith

Gregory P. Smith g...@krypto.org added the comment:

Committed to trunk in r81012.  though as this missed 2.7beta2 its possible that 
will be rejected and this becomes a 3.x only feature.

I'm porting to py3k now.

--
versions: +Python 3.2

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



[issue8663] Failed compile in a non-ASCII path

2010-05-08 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

(I wrote before I saw Victor’s reply) Does it work with PYTHONIOENDODING set to 
UTF-8?

--

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



  1   2   >