[issue14028] random.choice hits ValueError: cannot convert float NaN to integer

2012-02-16 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
nosy: +rhettinger

___
Python tracker 

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



[issue14028] random.choice hits ValueError: cannot convert float NaN to integer

2012-02-16 Thread Martin v . Löwis

Changes by Martin v. Löwis :


--
versions:  -Python 2.6, Python 3.1

___
Python tracker 

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



[issue13986] ValueError: cannot convert float NaN to integer

2012-02-16 Thread Gregory P. Smith

Gregory P. Smith  added the comment:

FYI - A "similar" NaN appearing in an unexpected place (the random module in 
this case) bug that I just filed - http://bugs.python.org/issue14028.

I don't actually know if these will be related or not.

--
nosy: +gregory.p.smith

___
Python tracker 

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



[issue2489] Patch for bugs in pty.py

2012-02-16 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 994659efa292 by Gregory P. Smith in branch '3.2':
Issue #2489: Fix bug in _copy loop that could consume 100% cpu on EOF.
http://hg.python.org/cpython/rev/994659efa292

New changeset c7338f62f956 by Gregory P. Smith in branch 'default':
Issue #2489: Fix bug in _copy loop that could consume 100% cpu on EOF.
http://hg.python.org/cpython/rev/c7338f62f956

New changeset f889458c65cc by Gregory P. Smith in branch '2.7':
Issue #2489: Fix bug in _copy loop that could consume 100% cpu on EOF.
http://hg.python.org/cpython/rev/f889458c65cc

--
nosy: +python-dev

___
Python tracker 

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



[issue2489] Patch for bugs in pty.py

2012-02-16 Thread Gregory P. Smith

Gregory P. Smith  added the comment:

I'm keeping this open to address the added behavior for spawn in 3.3.

--
assignee:  -> gregory.p.smith
nosy: +gregory.p.smith
stage: test needed -> 
versions: +Python 3.3 -Python 2.7, Python 3.1, Python 3.2

___
Python tracker 

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



[issue14029] When using setattr identifiers can start with any character

2012-02-16 Thread Lyudmil Nenov

New submission from Lyudmil Nenov :

I am not sure if this is actually a bug. 

Given documentation @ 
http://docs.python.org/release/2.5.2/ref/identifiers.html, the issue is that 
setattr does not appear to check identifier for naming convention.

See a short example below. Running on windows

>>> sys.version_info(major=2, minor=7, micro=1, releaselevel='final', serial=0)
>>> sys.version_info
sys.version_info(major=2, minor=7, micro=1, releaselevel='final', serial=0)
>>> class Example():
pass
>>> example = Example()
>>> example.@foo = 4
SyntaxError: invalid syntax
>>> setattr(example, '@foo', 'bar')
>>> dir(example)
['@foo', '__doc__', '__module__']
>>> example.@foo
SyntaxError: invalid syntax
>>> getattr(example, '@foo')
'bar'

--
messages: 153468
nosy: lnenov
priority: normal
severity: normal
status: open
title: When using setattr identifiers can start with any character
type: behavior

___
Python tracker 

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



[issue14025] unittest.TestCase.assertEqual does not show diff when comparing str with unicode

2012-02-16 Thread Jaap Karssenberg

Jaap Karssenberg  added the comment:

On Thu, Feb 16, 2012 at 12:29 AM, Michael Foord wrote:

> The type check in assertEqual, that delegates to the different comparison
> methods, is strict because we can't know that using the error message
> algorithms is sane for arbitrary subclasses - all we can know is whether an
> equality comparison fails or succeeds.
>

So would you allow me to register a method for type "basestring" and have
assertEqual dispatch to that method when both arguments are of this type ?

That way at least I could customize the behavior in sub classes.

Thanks,

Jaap

--

___
Python tracker 

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



[issue14029] When using setattr identifiers can start with any character

2012-02-16 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

It's not a bug. The specification of identifiers refers only to the places 
where they appear in the language grammar, i.e. what you can put into source 
code. What parameters objects accept in __setattr__ is an entirely different 
question. Some objects may check for well-formedness, some objects may accept 
only a small number of identifiers (e.g. when they use __slots__), some may 
accept non-strings as attribute names.

--
nosy: +loewis
resolution:  -> invalid
status: open -> closed

___
Python tracker 

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



[issue14030] Be more careful about selecting the compiler in distutils

2012-02-16 Thread Dirkjan Ochtman

Changes by Dirkjan Ochtman :


--
versions: +Python 2.7

___
Python tracker 

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



[issue14030] Be more careful about selecting the compiler in distutils

2012-02-16 Thread Dirkjan Ochtman

New submission from Dirkjan Ochtman :

distutils incorrectly handles CFLAGS as 1 argument instead of
space-separated list of arguments. distutils should respect environment
variables, which set compiler, linker etc.

--- Lib/distutils/unixccompiler.py
+++ Lib/distutils/unixccompiler.py
@@ -297,7 +297,7 @@
# this time, there's no way to determine this information from
# the configuration data stored in the Python installation, so
# we use this hack.
-compiler = os.path.basename(sysconfig.get_config_var("CC"))
+compiler = os.path.basename(self.compiler[0])
if sys.platform[:6] == "darwin":
# MacOSX's linker doesn't understand the -R flag at all
return "-L" + dir

Patch was created by Arfrever Frehtes Taifersar Arahesis 
(arfrever@gmail.com). It was originally written for PyPy, but it seems like 
it should actually apply to the stdlib. This patch is for 2.7, I'm hoping it 
could be taken as a bug fix.

--
messages: 153471
nosy: djc
priority: normal
severity: normal
status: open
title: Be more careful about selecting the compiler in distutils

___
Python tracker 

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



[issue14028] random.choice hits ValueError: cannot convert float NaN to integer

2012-02-16 Thread Mark Dickinson

Changes by Mark Dickinson :


--
nosy: +mark.dickinson

___
Python tracker 

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



[issue13986] ValueError: cannot convert float NaN to integer

2012-02-16 Thread Mark Dickinson

Mark Dickinson  added the comment:

My guess would be not related.  My best guess for this issue is that it's 
caused by some mismatch in the struct stat declarations / uses on MIPS / Linux. 
 A Google search for MIPS and stat suggests that there are problems in this 
area.

--

___
Python tracker 

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



[issue14028] random.choice hits ValueError: cannot convert float NaN to integer

2012-02-16 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee:  -> rhettinger

___
Python tracker 

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



[issue14028] random.choice hits ValueError: cannot convert float NaN to integer

2012-02-16 Thread Mark Dickinson

Mark Dickinson  added the comment:

Hmm, this is a little odd.  For 2.7 at least, the error message is coming from 
PyLong_FromDouble in Objects/longobject.c.  I can't immediately see how 
PyLong_FromDouble could be called by the random seeding process.

So it seems more likely that the error is really coming from the int() call in 
the traceback.  But now that implies that the random call is returning NaN, 
which looks unpossible from the code (random_random in Modules/_randommodule.c).


static PyObject *
random_random(RandomObject *self)
{
unsigned long a=genrand_int32(self)>>5, b=genrand_int32(self)>>6;
return PyFloat_FromDouble((a*67108864.0+b)*(1.0/9007199254740992.0));
}


So despite your comments about healthy hardware, my bet's on corrupted memory. 
:-)

--

___
Python tracker 

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



[issue14028] random.choice hits ValueError: cannot convert float NaN to integer

2012-02-16 Thread Mark Dickinson

Mark Dickinson  added the comment:

The bugs.launchpad.net URL shows a call to 'entropy.choice'.  Any idea what 
'entropy' is?  Could it be that they're using their own Random subclass, not 
tied to the Python MT implementation?

--

___
Python tracker 

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



[issue14028] random.choice hits ValueError: cannot convert float NaN to integer

2012-02-16 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

The hypothesis that time.time() is returning NaN doesn't match the provided 
traceback.  If time.time() had returned NaN, the exception would have happened 
earlier, on line 113 in random.py:  long(time.time() * 256)

I'm wondering if the NaN arises in the C code for random():

random_random(RandomObject *self)
{
unsigned long a=genrand_int32(self)>>5, b=genrand_int32(self)>>6;
return PyFloat_FromDouble((a*67108864.0+b)*(1.0/9007199254740992.0));
}

Upstream from that, only integers are used, so this would be the earliest a NaN 
could arise when running the code in choice():  ``return seq[int(self.random() 
* len(seq))]``

--

___
Python tracker 

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



[issue14028] random.choice hits ValueError: cannot convert float NaN to integer

2012-02-16 Thread Mark Dickinson

Mark Dickinson  added the comment:

> I'm wondering if the NaN arises in the C code for random():

I don't think that's possible.  In the second line:

return PyFloat_FromDouble((a*67108864.0+b)*(1.0/9007199254740992.0));

a and b are already C unsigned longs, so no matter what their value, the result 
of the expression is well in range for an IEEE 754 double, and on a normal 
machine there's just no realistic way that this calculation could produce a 
NaN.  PyFloat_FromDouble does no manipulation of the C double, but just stores 
it directly in the PyFloat object.


I think there are two different things going on here.

(1) The Ubuntu error reporter seems to be using something other than the 
standard Random class, so all bets are off there without knowing more about 
what's being used.  Chances seem good that whatever random number generator 
they're using really *is* producing a NaN.

(2) That leaves Greg's report above, where the standard Random class is 
apparently what's being used.  Here I'm baffled---I can't see any realistic 
mechanism that might produce that traceback.

--

___
Python tracker 

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



[issue12627] Implement PEP 394: The "python" Command on Unix-Like Systems

2012-02-16 Thread Nick Coghlan

Changes by Nick Coghlan :


Removed file: http://bugs.python.org/file22738/version33_links.patch

___
Python tracker 

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



[issue12627] Implement PEP 394: The "python" Command on Unix-Like Systems

2012-02-16 Thread Nick Coghlan

Nick Coghlan  added the comment:

I removed the 3.3 patch, since all the previous version did was change symbolic 
links to hard links, and the latest round of discussions favoured retaining the 
symlinks since they're much easier to introspect.

However, it turns out there is still one change needed for 3.3 - updating the 
current python3 hardlink to make it a symlink instead.

--

___
Python tracker 

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



[issue12627] Implement PEP 394: The "python" Command on Unix-Like Systems

2012-02-16 Thread Nick Coghlan

Nick Coghlan  added the comment:

Actually, the Python 3 Makefile.pre.in is currently broken if $(EXE) is ever 
non-empty - in a few places it uses "$(PYTHON)$(VERSION)$(EXE)" and 
"$(PYTHON)3$(EXE)".

Those are wrong, because the definition of $(PYTHON) at the top of the file is 
"python$(EXE)"

Instead, they need to be written as "python$(VERSION)$(EXE)" and "python3$(EXE)"

--

___
Python tracker 

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



[issue12627] Implement PEP 394: The "python" Command on Unix-Like Systems

2012-02-16 Thread Nick Coghlan

Nick Coghlan  added the comment:

New patch that aims to create the appropriate symlinks in "make bininstall". I 
don't currently have a sacrificial VM set up to test it in though.

--
Added file: http://bugs.python.org/file24530/pep394_python27_symlinks.diff

___
Python tracker 

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



[issue12627] Implement PEP 394: The "python" Command on Unix-Like Systems

2012-02-16 Thread Nick Coghlan

Changes by Nick Coghlan :


Removed file: http://bugs.python.org/file22737/version27_links.patch

___
Python tracker 

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



[issue13988] Expose the C implementation of ElementTree by default when importing ElementTree

2012-02-16 Thread Ezio Melotti

Ezio Melotti  added the comment:

I'm still not sure that's the best option.  Without deprecation people will 
keep using cElementTree and we will have to keep it around forever (or at least 
until Python4 and then have a 3to4 to fix the import).
This might be fine, but as a developer I would still like Python to tell me 
"You can just import ElementTree now, there's no need to use cElementTree".  
Maybe the deprecation can be added to 3.4?

P.S. I'm fine with keeping it around for several more versions, but if we 
eventually have to remove it, we would still have to warn the users beforehand. 
 The more we wait, the more users will be still using cElementTree by the time 
we will actually remove it.

--

___
Python tracker 

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



[issue14026] test_cmd_line_script should include more sys.argv checks

2012-02-16 Thread Jason Yeo

Changes by Jason Yeo :


--
nosy: +Jason.Yeo

___
Python tracker 

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



[issue13210] Support Visual Studio 2010

2012-02-16 Thread Jack Jansen

Changes by Jack Jansen :


--
nosy: +jackjansen

___
Python tracker 

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



[issue14031] logging module cannot format str.format log messages

2012-02-16 Thread Guido Kollerie

New submission from Guido Kollerie :

When logging messages with variable data one typically writes:

username = 'Guido'
logging.info('User %s logged in', username)

However Python 3 has support str.format (PEP 3101). If one has adopted 
str.format for formatting strings in Python 3 code one should also be able to 
write the above as:

logging.info('User {} logged in', username)

However this currently is not supported. For backwards compatibility,% style 
logging should remain the default. However when a logger is configured using:

import logging
logging.basicConfig(style='{', format='{levelname}:{message}')

all subsequent calls to logging.debug, logging.info, logging.warning, 
logging.error, logging.critical, logging.exception and logging.log should use 
str.format for formatting.

--
messages: 153481
nosy: gkoller
priority: normal
severity: normal
status: open
title: logging module cannot format str.format log messages
type: enhancement
versions: Python 3.2

___
Python tracker 

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



[issue14031] logging module cannot format str.format log messages

2012-02-16 Thread R. David Murray

R. David Murray  added the comment:

That can't work.  The logging messages may come from libraries written by 
someone else, using % formatting.  The style has to be set at the individual 
logger level.

--
nosy: +r.david.murray, vinay.sajip

___
Python tracker 

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



[issue13892] distutils handling of windows manifest isn't optimal

2012-02-16 Thread Jack Jansen

Jack Jansen  added the comment:

Indeed, my situation is different from the cscript.exe situation because in my 
case Python needs to call back into the hosting application.

Further experiments have shown that this is indeed the problem, and moreover 
that this is a problem that cannot be solved (at least, I am not smart enough 
to solve it:-). The Python extension module that does the callbacks would have 
to live in two different runtime worlds: if it allocates python objects it 
would have to use the VS2008 runtime, if it allocates Ambulant objects it would 
 have to use 2010 runtime.

This makes the whole original topic of this bug report of academic interest 
only. Fell free to close/won't fix.

--

___
Python tracker 

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



[issue14031] logging module cannot format str.format log messages

2012-02-16 Thread Guido Kollerie

Guido Kollerie  added the comment:

I see, could this be made to work if I explicitly request a logger instead?:

logger = logging.getLogger('my_logger', style='{')
logger.info('User {} logged in', username)

Maybe even for the root logger:

root_logger = logging.getLogger(style='{')
root_logger.info('User {} logged in', username)

--

___
Python tracker 

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



[issue14032] test_cmd_line_script prints undefined 'data' variable

2012-02-16 Thread Jason Yeo

New submission from Jason Yeo :

Hi, I'm new around here. I was trying to fix issue 14026 and I found this 
problem. In test_cmd_line_script, the test_issue8202 tries to print an 
undefined data variable when verbose is set to > 1. I have a patch attached to 
print(out) instead of print(data). Please let me know if this is the correct 
thing to do.

--
components: Tests
files: mypatch
messages: 153485
nosy: Jason.Yeo
priority: normal
severity: normal
status: open
title: test_cmd_line_script prints undefined 'data' variable
type: compile error
versions: Python 3.3
Added file: http://bugs.python.org/file24531/mypatch

___
Python tracker 

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



[issue14032] test_cmd_line_script prints undefined 'data' variable

2012-02-16 Thread Jason Yeo

Changes by Jason Yeo :


Added file: http://bugs.python.org/file24532/mypatch

___
Python tracker 

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



[issue14032] test_cmd_line_script prints undefined 'data' variable

2012-02-16 Thread Jason Yeo

Changes by Jason Yeo :


Removed file: http://bugs.python.org/file24532/mypatch

___
Python tracker 

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



[issue14033] distutils problem with setup.py build &setup.py install vs direct setup.py install

2012-02-16 Thread 勇刚 罗

New submission from 勇刚 罗 :

D:\CI\bld\vcs>build-pygit2.bat

D:\CI\bld\vcs\pygit2>call python setup.py build  & call python setup.py install 
 & cd /d D:\CI\bld\vcs
running build
running build_py
running build_ext
building 'pygit2' extension
creating build
creating build\temp.win32-3.2
creating build\temp.win32-3.2\Release
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox 
/MD /W3 /GS- /DNDEBUG -ID:\CI\Tools\vcs\libgit2\include -IC:\Python32\
include -IC:\Python32\PC /Tcpygit2.c /Fobuild\temp.win32-3.2\Release\pygit2.obj
pygit2.c
pygit2.c(476) : warning C4101: 'aux' : unreferenced local variable
pygit2.c(498) : warning C4101: 'err' : unreferenced local variable
pygit2.c(1088) : warning C4101: 'err' : unreferenced local variable
pygit2.c(1185) : warning C4244: 'function' : conversion from 'git_time_t' to 
'long', possible loss of data
pygit2.c(2794) : warning C4244: 'function' : conversion from 'const git_time_t' 
to 'long', possible loss of data
creating build\lib.win32-3.2
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo 
/INCREMENTAL:NO /LIBPATH:D:\CI\Tools\vcs\libgit2\lib /LIBPATH:C:\Pytho
n32\libs /LIBPATH:C:\Python32\PCbuild git2.lib /EXPORT:PyInit_pygit2 
build\temp.win32-3.2\Release\pygit2.obj /OUT:build\lib.win32-3.2\pygit2.pyd 
/IMPL
IB:build\temp.win32-3.2\Release\pygit2.lib 
/MANIFESTFILE:build\temp.win32-3.2\Release\pygit2.pyd.manifest
   Creating library build\temp.win32-3.2\Release\pygit2.lib and object 
build\temp.win32-3.2\Release\pygit2.exp
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe -nologo -manifest 
build\temp.win32-3.2\Release\pygit2.pyd.manifest -outputresource:build\lib.
win32-3.2\pygit2.pyd;2
copying D:\CI\Tools\vcs\libgit2\bin\git2.dll -> pygit2
running install
running build
running build_py
copying pygit2\git2.dll -> build\lib.win32-3.2
running build_ext
running install_lib
copying build\lib.win32-3.2\git2.dll -> C:\Python32\Lib\site-packages
copying build\lib.win32-3.2\pygit2.pyd -> C:\Python32\Lib\site-packages
running install_egg_info
Writing C:\Python32\Lib\site-packages\pygit2-0.16.0-py3.2.egg-info

D:\CI\bld\vcs>

Direct install

D:\CI\bld\vcs>build-pygit2.bat

D:\CI\bld\vcs\pygit2>call python setup.py install  & cd /d D:\CI\bld\vcs
running install
running build
running build_py
running build_ext
building 'pygit2' extension
creating build
creating build\temp.win32-3.2
creating build\temp.win32-3.2\Release
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox 
/MD /W3 /GS- /DNDEBUG -ID:\CI\Tools\vcs\libgit2\include -IC:\Python32\
include -IC:\Python32\PC /Tcpygit2.c /Fobuild\temp.win32-3.2\Release\pygit2.obj
pygit2.c
pygit2.c(476) : warning C4101: 'aux' : unreferenced local variable
pygit2.c(498) : warning C4101: 'err' : unreferenced local variable
pygit2.c(1088) : warning C4101: 'err' : unreferenced local variable
pygit2.c(1185) : warning C4244: 'function' : conversion from 'git_time_t' to 
'long', possible loss of data
pygit2.c(2794) : warning C4244: 'function' : conversion from 'const git_time_t' 
to 'long', possible loss of data
creating build\lib.win32-3.2
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo 
/INCREMENTAL:NO /LIBPATH:D:\CI\Tools\vcs\libgit2\lib /LIBPATH:C:\Pytho
n32\libs /LIBPATH:C:\Python32\PCbuild git2.lib /EXPORT:PyInit_pygit2 
build\temp.win32-3.2\Release\pygit2.obj /OUT:build\lib.win32-3.2\pygit2.pyd 
/IMPL
IB:build\temp.win32-3.2\Release\pygit2.lib 
/MANIFESTFILE:build\temp.win32-3.2\Release\pygit2.pyd.manifest
   Creating library build\temp.win32-3.2\Release\pygit2.lib and object 
build\temp.win32-3.2\Release\pygit2.exp
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe -nologo -manifest 
build\temp.win32-3.2\Release\pygit2.pyd.manifest -outputresource:build\lib.
win32-3.2\pygit2.pyd;2
copying D:\CI\Tools\vcs\libgit2\bin\git2.dll -> pygit2
running install_lib
copying build\lib.win32-3.2\pygit2.pyd -> C:\Python32\Lib\site-packages
running install_egg_info
Writing C:\Python32\Lib\site-packages\pygit2-0.16.0-py3.2.egg-info

D:\CI\bld\vcs>

--
assignee: tarek
components: Distutils
messages: 153486
nosy: eric.araujo, tarek, 勇刚.罗
priority: normal
severity: normal
status: open
title: distutils problem with setup.py build &setup.py install vs direct 
setup.py install
versions: Python 3.2

___
Python tracker 

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



[issue14031] logging module cannot format str.format log messages

2012-02-16 Thread Vinay Sajip

Vinay Sajip  added the comment:

Use instead the approach described in this post:

http://plumberjack.blogspot.com/2010/10/supporting-alternative-formatting.html

--
resolution:  -> out of date
status: open -> closed

___
Python tracker 

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



[issue14028] random.choice hits ValueError: cannot convert float NaN to integer

2012-02-16 Thread Gregory P. Smith

Gregory P. Smith  added the comment:

I think my claim the hardware appears healthy was premature.  I misunderstood 
our initial error report internally on where the code ran and was looking at 
the wrong host.  doh.  my bad.

Several more of these have been found in the last week and they all 
suspiciously ran on the same machine.  One of them had a _different_ failure 
that is an even stronger suggestion of bad hardware:

 File "/.../lib/python2.6/random.py", line 57, in 
   NV_MAGICCONST = 4 * _exp(-0.5)/_sqrt(2.0)
ValueError: math domain error

Sorry for the false alarm.

--
resolution:  -> invalid
status: open -> closed

___
Python tracker 

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



[issue14020] Improve HTMLParser doc

2012-02-16 Thread Ezio Melotti

Ezio Melotti  added the comment:

Do you remember how to do it?

--

___
Python tracker 

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



[issue12655] Expose sched.h functions

2012-02-16 Thread Matt Joiner

Matt Joiner  added the comment:

Please also expose sched_getcpu().

--
nosy: +anacrolix

___
Python tracker 

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



[issue14034] the example in argparse doc is too complex

2012-02-16 Thread Tshepang Lekhonkhobe

New submission from Tshepang Lekhonkhobe :

The argparse example (http://docs.python.org/dev/library/argparse.html#example) 
introduces way too many concepts too early. It's written as if targeted to 
existing users of optparse, instead of newcomers to Python's CLI handling.

Perhaps the example could be more gentle, or if there is insistence on showing 
off, maybe the page could be kept as-is, but with a link to some tutorial (as 
is done with logging: http://docs.python.org/dev/library/logging.html).

--
assignee: docs@python
components: Documentation
messages: 153491
nosy: docs@python, tshepang
priority: normal
severity: normal
status: open
title: the example in argparse doc is too complex
type: enhancement
versions: Python 2.7, Python 3.2, Python 3.3

___
Python tracker 

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



[issue13878] test_sched failures on Windows buildbot

2012-02-16 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 662c60d26183 by Charles-François Natali in branch '3.2':
Issue #13878: Fix random test_sched failures.
http://hg.python.org/cpython/rev/662c60d26183

New changeset e35091b95813 by Charles-François Natali in branch 'default':
Issue #13878: Fix random test_sched failures.
http://hg.python.org/cpython/rev/e35091b95813

--
nosy: +python-dev

___
Python tracker 

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



[issue13961] Have importlib use os.replace()

2012-02-16 Thread Charles-François Natali

Changes by Charles-François Natali :


--
stage: patch review -> commit review

___
Python tracker 

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



[issue14024] logging.Formatter Cache Prevents Exception Format Overriding

2012-02-16 Thread Vinay Sajip

Vinay Sajip  added the comment:

A number of points:

1. exc_text is not just an implementation detail - it's in the docs. Thus, 
removing the cache altogether would be backwards-incompatible.

2. The exc_text value is the only simple way of propagating the exception 
information across the wire, which is a common use case (e.g SocketHandler).

3. This is not a "behavior" issue, as the behaviour is by design and documented.

4. What's wrong with the following approach?

class NoStackTraceFormatter(logging.Formatter):
def formatException(self, exc_info):  # Don't emit the stack trace
return '\n'.join(traceback.format_exception_only(exc_info[0], 
exc_info[1])) # type and value only

def format(self, record):
saved_exc_text = record.exc_text # optional
record.exc_text = None
result = super(NoStackTraceFormatter, self).format(record)
record.exc_text = saved_exc_text # or None, if you want
return result

You can either save and restore the previous exc_text value, or set it to None 
after the parent class operation - this will cause it to be always recomputed 
by the next handler. This way, a handler which needs abbreviated information 
always gets it, but other handlers append the full stack trace.

I'm closing this as I believe my suggestion shows a way of subclassing and 
overriding which works. You can re-open if you think I've missed something.

--
nosy: +vinay.sajip
resolution:  -> invalid
status: open -> closed

___
Python tracker 

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



[issue13609] Add "os.get_terminal_size()" function

2012-02-16 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

I don't think there's much point in the proposed complications.
If you're willing to know the terminal size, you're probably interested in 
displaying something in it (using stdout), so why would you care about stderr 
or stdin?

--

___
Python tracker 

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



[issue13609] Add "os.get_terminal_size()" function

2012-02-16 Thread Zbyszek Szmek

Zbyszek Szmek  added the comment:

Stdout can be connected to a pipe, e.g to less, which in turn might
be connected to a terminal. The program can then display output properly 
scaled for the terminal, assuming that because stdin is
connnected to a terminal, output will eventually reach the same 
terminal. Sometimes this is true, sometimes not.

--

___
Python tracker 

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



[issue13878] test_sched failures on Windows buildbot

2012-02-16 Thread Charles-François Natali

Charles-François Natali  added the comment:

Should be fixed now, thanks.

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

___
Python tracker 

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



[issue13995] sqlite3 Cursor.rowcount documentation for old sqlite bug

2012-02-16 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset 74b2da95c6be by Petri Lehtinen in branch '3.2':
sqlite3: Fix documentation errors concerning Cursor.rowcount
http://hg.python.org/cpython/rev/74b2da95c6be

New changeset a1f17e108a1b by Petri Lehtinen in branch '2.7':
Fix errors in sqlite3's Cursor.rowcount documentation
http://hg.python.org/cpython/rev/a1f17e108a1b

New changeset 08699214f79b by Petri Lehtinen in branch 'default':
Merge branch '3.2'
http://hg.python.org/cpython/rev/08699214f79b

--
nosy: +python-dev
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue13995] sqlite3 Cursor.rowcount documentation for old sqlite bug

2012-02-16 Thread Petri Lehtinen

Petri Lehtinen  added the comment:

Fixed, thanks!

--
nosy: +petri.lehtinen
versions: +Python 2.7, Python 3.2, Python 3.3

___
Python tracker 

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



[issue13641] decoding functions in the base64 module could accept unicode strings

2012-02-16 Thread Catalin Iacob

Catalin Iacob  added the comment:

Attached alternative patch with a different approach: on input, strings are 
encoded as bytes and the rest of the code proceeds as before.

All existing tests for bytes now test for strings as well and there is a new 
test for strings with non ASCII characters.

Berker's patch was more intrusive and forgot to allow strings in _translate, 
leading to failures if altchars or map01 were used.

--
nosy: +catalin.iacob
Added file: http://bugs.python.org/file24533/issue13641-alternative-v1.patch

___
Python tracker 

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



RuntimeError: maximum recursion depth exceeded in cmp

2012-02-16 Thread OwenLJN
Hi
I wrote a python function self_contained(x) that finds all lists in x that
contain themselves.
Here's the body of the function:

def self_contained(x):
L = []
if not isinstance(x, list):
return []
for i in x:
if isinstance(i, list):
if i in i:
L += [i]
return L

L5 =[]
L6 = []
L5.append(L6)
L6.append(L5)

then I compare L5 and L6 in shell:
L5 == L6
and it gives me this error:
RuntimeError: maximum recursion depth exceeded in cmp
I think probably I need to add another parameter to self_contained or to a
helper function to make my function work when I call L5 or L6. So How can I
fix this error??
I put this code: sys.setrecursionlimit(2500) in the begining doens't fix the
error.
And I don't know how to change self_contained to a recursive function can
any1 help me with this?Thanks!


--
View this message in context: 
http://python.6.n6.nabble.com/RuntimeError-maximum-recursion-depth-exceeded-in-cmp-tp4471100p4471100.html
Sent from the Python - python-bugs-list mailing list archive at Nabble.com.
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: RuntimeError: maximum recursion depth exceeded in cmp

2012-02-16 Thread OwenLJN
Let me restate my question:I want to make self_contained(L5) and
self_contained(L6) work, but I get RuntimeError how can I fix this by adding
one more parameter to check if a list inside a list was seen before, and
then stop the loop to prevent the error message from showing again? And I
found that the id of L5 is different with L6 and
"L5 in L6" and "L6 in L5" returns True

--
View this message in context: 
http://python.6.n6.nabble.com/RuntimeError-maximum-recursion-depth-exceeded-in-cmp-tp4471100p4474728.html
Sent from the Python - python-bugs-list mailing list archive at Nabble.com.
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13641] decoding functions in the base64 module could accept unicode strings

2012-02-16 Thread R. David Murray

R. David Murray  added the comment:

Um.  I'm inclined to think that #13637 was a mistake.

Functions that accept bytes and return bytes and also accept string and return 
string seem uncontroversial.  However, accepting bytes or string and returning 
bytes is not an obviously good idea, and IMO at least merits some discussion.  
In fact, I thought it *had* been discussed, specifically in the context of the 
b2a/a2b functions, and been rejected.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue13641] decoding functions in the base64 module could accept unicode strings

2012-02-16 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> However, accepting bytes or string and returning bytes is not an
> obviously good idea, and IMO at least merits some discussion.

Why? "a" in "a2b" means ASCII, and unicode is as valid a container for ASCII 
text as bytes is.

--

___
Python tracker 

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



[issue9631] Python 2.7 installation issue for Linux gcc-4.1.0-3 (Fedora Core 5?)

2012-02-16 Thread miro ilias

miro ilias  added the comment:

Hi, 

with the fresh downloadable version of Python 2.7.2 I got the same error.


/usr/bin/install -c -m 644 ./Lib/curses/wrapper.py 
/home/ilias/bin/python_static/lib/python2.7/curses
/usr/bin/install -c -m 644 ./Lib/pydoc_data/__init__.py 
/home/ilias/bin/python_static/lib/python2.7/pydoc_data
/usr/bin/install -c -m 644 ./Lib/pydoc_data/topics.py 
/home/ilias/bin/python_static/lib/python2.7/pydoc_data
/usr/bin/install -c -m 644 ./Lib/plat-linux3/IN.py 
/home/ilias/bin/python_static/lib/python2.7/plat-linux3
/usr/bin/install -c ./Lib/plat-linux3/regen 
/home/ilias/bin/python_static/lib/python2.7/plat-linux3
/usr/bin/install -c -m 644 ./LICENSE 
/home/ilias/bin/python_static/lib/python2.7/LICENSE.txt
PYTHONPATH=/home/ilias/bin/python_static/lib/python2.7   \
./python -Wi -tt 
/home/ilias/bin/python_static/lib/python2.7/compileall.py \
-d /home/ilias/bin/python_static/lib/python2.7 -f \
-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
/home/ilias/bin/python_static/lib/python2.7
Traceback (most recent call last):
  File "/home/ilias/bin/python_static/lib/python2.7/compileall.py", line 16, in 

import struct
  File "/home/ilias/bin/python_static/lib/python2.7/struct.py", line 1, in 

from _struct import *
ImportError: No module named _struct
make: *** [libinstall] Chyba 1

--
nosy: +miro_ilias

___
Python tracker 

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



[issue14035] behavior of test.support.import_fresh_module

2012-02-16 Thread Florent Xicluna

New submission from Florent Xicluna :

While writing tests xml.etree, I hit a strange behaviour of import_fresh_module.

How to reproduce:

- dummy/__init__.py
- dummy/foo.py
- dummy/bar.py
- test_fresh_import.py


# 'dummy/foo.py'
from dummy.bar import func

# 'dummy/bar.py'
fortytwo = 42
def func():
assert fortytwo == 42

# 'test_fresh_import.py'
(see attachment)


# Output:
~ $ ./python.exe test_fresh_import.py 
OK dummy.foo
OK dummy.bar
OK dummy.bar
OK dummy.foo
Traceback (most recent call last):
  File "test_fresh_import.py", line 24, in 
test_fresh(m)
  File "test_fresh_import.py", line 5, in test_fresh
rv = module.func()
  File "./dummy/bar.py", line 6, in func
assert fortytwo == 42
AssertionError

--
components: Tests
files: test_fresh_import.py
messages: 153503
nosy: eli.bendersky, flox, ncoghlan
priority: normal
severity: normal
status: open
title: behavior of test.support.import_fresh_module
type: behavior
versions: Python 3.3
Added file: http://bugs.python.org/file24534/test_fresh_import.py

___
Python tracker 

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



[issue13641] decoding functions in the base64 module could accept unicode strings

2012-02-16 Thread poq

poq  added the comment:

FWIW, I was surprised by the return type of b64encode when I first used it in 
Python 3. It seems to me that b64encode turns binary data into text and thus 
intuitively should take bytes and return str.

Similarly it seems intuitive to me for b64decode to take str as input and 
return bytes, as it turns text back into binary data.

--
nosy: +poq

___
Python tracker 

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



[issue14035] behavior of test.support.import_fresh_module

2012-02-16 Thread Florent Xicluna

Changes by Florent Xicluna :


--
nosy: +ezio.melotti

___
Python tracker 

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



[issue13641] decoding functions in the base64 module could accept unicode strings

2012-02-16 Thread R. David Murray

R. David Murray  added the comment:

OK, I skimmed the thread I was remembering, and while it was discussing 
str->str and bytes->bytes primarily, the only pronouncement I could find was 
that functions should not accept a *mix* of bytes and string.  So I guess I 
withdraw my objection, although it still makes me a bit uncomfortable.

--

___
Python tracker 

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



[issue7652] Merge C version of decimal into py3k.

2012-02-16 Thread Stefan Krah

Stefan Krah  added the comment:

STINNER Victor  wrote:
> decimal.Decimal.__truediv__() has an optional context argument, whereas 
> _decimal defines PyNumberMethods.

Regarding the special methods: decimal.py uses the optional context arguments
for convenience so that these methods can be re-used in other places.

I wouldn't consider this context argument as part of the API.

> decimal.Decimal.quantize() second argument is optional and its default value
> is None, but if I pass None to _decimal.Decimal.quantize(), I get a TypeError
> because _decimal expects an integer.

About this I'm not sure. I think type errors are a courtesy to the user.
Look what is possible now in decimal.py:

Decimal('9')

But here the argument might well be made for accepting None (and only
None apart from rounding modes). - I hope Mark and Raymond will give
their opinions, too.

--

___
Python tracker 

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



[issue7652] Merge C version of decimal into py3k.

2012-02-16 Thread Stefan Krah

Stefan Krah  added the comment:

I walked into the Roundup trap again:

>>> Decimal(9).quantize(1, "?!?!?")
Decimal('9')

--

___
Python tracker 

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



[issue10513] sqlite3.InterfaceError after commit

2012-02-16 Thread Anders Blomdell

Anders Blomdell  added the comment:

> So my suggestion is to remove in "pysql_connection_commit" the call to :
> pysqlite_do_all_statements(self, ACTION_RESET, 0);
> to bring back the correct old behavior.
That's what I have been running for years, now...

> And also eventually to remove in "pysqlite_connection_rollback" the 
> call to :
> pysqlite_do_all_statements(self, ACTION_RESET, 1);
Have no opinion on this

Would be really nice to not have to fix this in ech new release :-)

--

___
Python tracker 

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



[issue13089] parsetok.c: memory leak

2012-02-16 Thread Stefan Krah

Stefan Krah  added the comment:

Yes, that's basically what I did, but using the latest revision I cannot
reproduce the parsetok leak either.

The atexit leak is an old friend (#11826), so I think we can close
this one for now.

--
resolution:  -> out of date
stage: needs patch -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue2377] Replace __import__ w/ importlib.__import__

2012-02-16 Thread Brett Cannon

Brett Cannon  added the comment:

Just a quick update. I have refactored importlib in the cpython repo to allow 
for implementing bits of importlib.__import__() and importlib._gcd_import() in 
C. This means that the built-in __import__() is now calling importlib 
underneath the covers. Eventually what is in importlib.__import__() and 
_gcd_import() directly will be translated into the equivalent C code. This will 
speed up accessing sys.modules. After that whatever is deemed on the critical 
path and worth rewriting in C can be done function by function. That, though, 
should wait for Python-level profiling and optimization before wasting one's 
time.

--

___
Python tracker 

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



[issue2377] Replace __import__ w/ importlib.__import__

2012-02-16 Thread Brett Cannon

Brett Cannon  added the comment:

Add Nick since the refactoring of importlib.__import__() into functions was his 
idea.

--
nosy: +ncoghlan

___
Python tracker 

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



[issue14036] urlparse insufficient port property validation

2012-02-16 Thread zulla

New submission from zulla :

The "port" component of a URL is not properly be sanitized or validated. This 
may lead to the evasion of netloc/hostname based filters or exceptions.

--
components: Library (Lib)
files: testurllib.py
messages: 153512
nosy: zulla
priority: normal
severity: normal
status: open
title: urlparse insufficient port property validation
type: security
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file24535/testurllib.py

___
Python tracker 

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



[issue14035] behavior of test.support.import_fresh_module

2012-02-16 Thread Florent Xicluna

Florent Xicluna  added the comment:

Trigger the same behavior without import_fresh_module. (test_fresh_import2.py)

If you uncomment line #A or #B, it succeed.
On the other side, if you comment line #C or #D, it succeed too.

The import machinery is a bit complex, indeed ...

--
nosy: +brett.cannon
Added file: http://bugs.python.org/file24536/test_fresh_import2.py

___
Python tracker 

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



[issue14038] Packaging test support code raises exception

2012-02-16 Thread Vinay Sajip

New submission from Vinay Sajip :

test_packaging has started failing in the pythonv branch:

==
ERROR: test_old_record_extensions 
(packaging.tests.test_command_install_dist.InstallTestCase)
--
Traceback (most recent call last):
  File "/usr/local/lib/python3.3/packaging/tests/test_command_install_dist.py", 
line 214, in test_old_record_extensions
support.copy_xxmodule_c(project_dir)
  File "/usr/local/lib/python3.3/packaging/tests/support.py", line 334, in 
copy_xxmodule_c
filename = _get_xxmodule_path()
  File "/usr/local/lib/python3.3/packaging/tests/support.py", line 346, in 
_get_xxmodule_path
if os.path.exists(path):
UnboundLocalError: local variable 'path' referenced before assignment

==
ERROR: test_build_ext (packaging.tests.test_command_build_ext.BuildExtTestCase)
--
Traceback (most recent call last):
  File "/usr/local/lib/python3.3/packaging/tests/test_command_build_ext.py", 
line 30, in test_build_ext
support.copy_xxmodule_c(self.tmp_dir)
  File "/usr/local/lib/python3.3/packaging/tests/support.py", line 334, in 
copy_xxmodule_c
filename = _get_xxmodule_path()
  File "/usr/local/lib/python3.3/packaging/tests/support.py", line 346, in 
_get_xxmodule_path
if os.path.exists(path):
UnboundLocalError: local variable 'path' referenced before assignment

Upon investigation, the code for _get_xxmodule_path is this:

def _get_xxmodule_path():
if sysconfig.is_python_build():
srcdir = sysconfig.get_config_var('projectbase')
path = os.path.join(os.getcwd(), srcdir, 'Modules', 'xxmodule.c')
else:
os.path.join(os.path.dirname(__file__), 'xxmodule.c')
if os.path.exists(path):
return path

It looks as if the else: path should have a "path = " ... with that change, the 
test_packaging failures go away.

--
assignee: tarek
components: Distutils2, Library (Lib)
messages: 153515
nosy: alexis, eric.araujo, tarek, vinay.sajip
priority: normal
severity: normal
status: open
title: Packaging test support code raises exception
type: behavior
versions: Python 3.3

___
Python tracker 

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



[issue14037] Allow grouping of argparse subparser commands in help output

2012-02-16 Thread Nick Coghlan

New submission from Nick Coghlan :

I've just started using the argparse subparser feature, and it's very nice. 
However, I'd love to be able to group the different subparser commands into 
different sections the way I can group ordinary arguments with 
add_argument_group().

Initially I thought just calling "parser.add_subparsers()" multiple times with 
different "title" values would work, but argparse doesn't currently like that - 
it errors out with "cannot have multiple subparser arguments".

I propose that instead of treating this case as an error, argparse should treat 
it as a way for defining subparser groups - there would still only be a single 
subparser argument accepted, but the individual commands would appear grouped 
appropriately in the help output.

--
components: Library (Lib)
messages: 153514
nosy: bethard, ncoghlan
priority: normal
severity: normal
stage: needs patch
status: open
title: Allow grouping of argparse subparser commands in help output
type: enhancement
versions: Python 3.3

___
Python tracker 

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



[issue14039] Add "metavar" argument to add_subparsers() in argparse

2012-02-16 Thread Nick Coghlan

New submission from Nick Coghlan :

Currently, using add_subparsers() means that the entire list of subcommands is 
added to the main usage message. This gets rather unwieldy when there are a lot 
of subcommands.

It would be nice if the add_subparsers() method accepted a "metavar" argument 
that would be substituted into the usage string instead of using the subparser 
list directly.

--
components: Library (Lib)
messages: 153516
nosy: bethard, ncoghlan
priority: normal
severity: normal
stage: needs patch
status: open
title: Add "metavar" argument to add_subparsers() in argparse
type: enhancement
versions: Python 3.3

___
Python tracker 

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



[issue14037] Allow grouping of argparse subparser commands in help output

2012-02-16 Thread Nick Coghlan

Nick Coghlan  added the comment:

I realised that my initial idea doesn't play nicely with my other suggestion of 
allowing a "metavar" argument to add_subparsers() (see #14039).

A better model may be to mimic the add_argument_group() directly by offering an 
add_parser_group() method on the subparser management object.

This would allow ungrouped commands to be presented first, with grouped 
commands following under their own headings.

--

___
Python tracker 

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



[issue14025] unittest.TestCase.assertEqual does not show diff when comparing str with unicode

2012-02-16 Thread Ezio Melotti

Ezio Melotti  added the comment:

If you really want the diff you could use assertMultiLineEqual, but even on 
Python 2 you shouldn't mix str and unicode.  I would rather fix the code to 
return unicode than using assertMultilineEqual to get a diff between str and 
unicode.  Moreover assertMultiLineEqual only works if the str happens to be 
ASCII-only:

>>> class MyTest(TestCase):
...   def test_foo(self):
... self.assertMultiLineEqual('bàr', u'bàz')
... 
>>> unittest.main(exit=False)
E
==
ERROR: test_foo (__main__.MyTest)
--
Traceback (most recent call last):
  File "", line 3, in test_foo
  File "/home/wolf/dev/py/2.7/Lib/unittest/case.py", line 920, in 
assertMultiLineEqual
diff = '\n' + ''.join(difflib.ndiff(firstlines, secondlines))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal 
not in range(128)

--

--

___
Python tracker 

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



[issue14035] behavior of test.support.import_fresh_module

2012-02-16 Thread Florent Xicluna

Florent Xicluna  added the comment:

Keeping reference of fresh modules solves the issue.

--
keywords: +patch
stage:  -> patch review
Added file: http://bugs.python.org/file24537/issue14035_fresh_modules.diff

___
Python tracker 

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



[issue13882] PEP 410: Use decimal.Decimal type for timestamps

2012-02-16 Thread STINNER Victor

STINNER Victor  added the comment:

Patch version 18:
 - Fix a loss of precision in _PyTime_SetDenominator()
 - Add more tests on integer overflow

I also updated the patch adding datetime.datetime support because some people 
are interested by the type, even I don't think that it is interesting to add 
it. datetime.datetime is only usable with time.time(), os.*stat() and 
time.clock_gettime(), whereas it is incompatible with all other functions.

--
Added file: http://bugs.python.org/file24538/time_decimal-18.patch

___
Python tracker 

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



[issue13882] PEP 410: Use decimal.Decimal type for timestamps

2012-02-16 Thread STINNER Victor

Changes by STINNER Victor :


Removed file: http://bugs.python.org/file24505/time_decimal-17.patch

___
Python tracker 

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



[issue13882] PEP 410: Use decimal.Decimal type for timestamps

2012-02-16 Thread STINNER Victor

Changes by STINNER Victor :


Added file: http://bugs.python.org/file24539/timestamp_datetime-2.patch

___
Python tracker 

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



[issue13882] PEP 410: Use decimal.Decimal type for timestamps

2012-02-16 Thread STINNER Victor

Changes by STINNER Victor :


Removed file: http://bugs.python.org/file24414/timestamp_datetime.patch

___
Python tracker 

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



[issue14028] random.choice hits ValueError: cannot convert float NaN to integer

2012-02-16 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Well, at least it was an interesting bug report ;-)

--

___
Python tracker 

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



[issue14036] urlparse insufficient port property validation

2012-02-16 Thread zulla

zulla  added the comment:

The "port" and "netloc" component of a ParsedResult-object is not properly 
sanitized or validated. This may lead to bypass-able hostname-based filters. 
Remote Crash vulnerabilities be be also possible.

--

___
Python tracker 

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



[issue14036] urlparse insufficient port property validation

2012-02-16 Thread R. David Murray

R. David Murray  added the comment:

Did you upload urlparse.py to the issue by accident?

Can you please provide some examples of where you think the current code is 
producing incorrect results?

--
nosy: +r.david.murray

___
Python tracker 

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



[issue14036] urlparse insufficient port property validation

2012-02-16 Thread zulla

zulla  added the comment:

Hi. No, it's a patched version. It won't crash under circumstances like that 
[1] and won't succeed with invalid input:


>>> import urlparse
>>> urlparse.urlparse("http://www.google.com:foo";)
ParseResult(scheme='http', netloc='www.google.com:foo', path='', params='', 
query='', fragment='')
>>> urlparse.urlparse("http://www.google.com:foo";).port
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urlparse.py",
 line 105, in port
port = int(netloc.split(':')[1], 10)
ValueError: invalid literal for int() with base 10: 'foo'
>>>

--

___
Python tracker 

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



[issue14036] urlparse insufficient port property validation

2012-02-16 Thread zulla

zulla  added the comment:

Whops. I forgot an int() :-)

Here's the right patch.

--
Added file: http://bugs.python.org/file24540/testurllib.py

___
Python tracker 

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



[issue14036] urlparse insufficient port property validation

2012-02-16 Thread zulla

Changes by zulla :


Removed file: http://bugs.python.org/file24535/urlparse.py

___
Python tracker 

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



[issue14026] test_cmd_line_script should include more sys.argv checks

2012-02-16 Thread Jason Yeo

Jason Yeo  added the comment:

I would like to work on this but I am not sure how to go about it. It seems 
that the method signature for _check_script has to be changed in include 
another parameter for expected_argv1, expected_argv2, etc. The _check_output 
also has to be changed to include assertIn(printed_argv1, data) for the 
additional parameters. This also means that test_source has to include some 
lines to print the sys.argv[1], sys.argv[2], etc. 

Am I on the right track? Or is there a easier way?

(By the way, when I set verbose to a value > 1, errors are found. I realized 
that a print() statement was printing an undefined variable. I have filed an 
issue and attached a patch to it. The link for the issue is 
http://bugs.python.org/issue14032)

--

___
Python tracker 

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



[issue14036] urlparse insufficient port property validation

2012-02-16 Thread R. David Murray

R. David Murray  added the comment:

It's not a patch if it is the whole file.  A diff would be much more useful, 
since then we could see the changes easily.

This kind of change would require a bit of discussion.  I'm doubtful that it 
would be applied as a bug fix, and we might even want the validation to be 
optional and not the default.  Part of the issue is that urlparse was 
originally based on the older standards, as you can see from the docstring.

You may find others to agree with you, but personally it doesn't look to me 
like this rises to the level of a security issue.

--
nosy: +orsenthil

___
Python tracker 

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



[issue14036] urlparse insufficient port property validation

2012-02-16 Thread zulla

zulla  added the comment:

I understand your point of view, but I disagree.

Various libraries and projects rely on urlparse.urlparse and 
urllib.parse.urlparse.

This bug just blew up in my face. I'm working with Cython and PyQt4.

When a developer relies on ParseResult().netloc being a valid netloc, and .port 
being None [bool(False)] or a integer between 1-65535 really bad things can 
happen in a environment that has 0-tolerance for security issues (like C/C++ 
mixed in python).

I agree that the 

if self.scheme == "http":
return 80
elif self.scheme == "https":
[...]

part of my patch is debetable, but we should _at least_ ensure that IF there is 
a ParseResult().port, the developer can be sure that it is a valid port between 
1-65545.

i apologize for upload the whole file; i attached the diff now.

regards,
dan

--
keywords: +patch
Added file: http://bugs.python.org/file24541/urlparse.diff

___
Python tracker 

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



[issue14035] behavior of test.support.import_fresh_module

2012-02-16 Thread Nick Coghlan

Nick Coghlan  added the comment:

Keeping module references implicitly in import_fresh_module will leak 
references like crazy in the test suite. The onus is on the code referencing 
module contents to ensure that the module globals remain valid.

If we get rid of the explicit clearing of module globals to break reference 
cycles, this problem will also go away, so closing as a dupe of #812369.

--
resolution:  -> duplicate
status: open -> closed
superseder:  -> module shutdown procedure based on GC

___
Python tracker 

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



[issue812369] module shutdown procedure based on GC

2012-02-16 Thread Nick Coghlan

Nick Coghlan  added the comment:

In #14035, Florent pointed out the current behaviour potentially causes 
problems for some uses of import_fresh_modules() in the test suite (with 
globals sometimes being set to None if there's no indepenent reference to the 
module).

GC based module cleanup would avoid that problem automatically.

--
nosy: +ncoghlan

___
Python tracker 

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



[issue14035] behavior of test.support.import_fresh_module

2012-02-16 Thread Eli Bendersky

Eli Bendersky  added the comment:

Florent, I can reproduce the problem by leaving just the last 
import_fresh_module in test_fresh_import.py

And your patch fixes it, although as Nick says it's problematic in terms of ref 
leaks.

What I'm not sure about is why the extra reference is needed. The modules *are* 
kept in sys.modules, after all.

IIUC, this is probably causing the strange failure I was having with 
test_xml_etree_c not being able to use the cET_alias global in some tests.

--
resolution: duplicate -> 
status: closed -> open

___
Python tracker 

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



[issue13598] string.Formatter doesn't support empty curly braces "{}"

2012-02-16 Thread Ramchandra Apte

Ramchandra Apte  added the comment:

@Nick I don't understand why should my patch make Formatter thread-unsafe - the 
auto_field_count and manual variables are local variables just like the 
variables in the other functions in Formatter.

--

___
Python tracker 

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



[issue13598] string.Formatter doesn't support empty curly braces "{}"

2012-02-16 Thread Ramchandra Apte

Ramchandra Apte  added the comment:

I have submitted a new patch, I have moved the increment to the end of if loop.

--
Added file: http://bugs.python.org/file24542/issue13598.diff

___
Python tracker 

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



[issue812369] module shutdown procedure based on GC

2012-02-16 Thread Florent Xicluna

Changes by Florent Xicluna :


--
nosy: +flox

___
Python tracker 

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