[issue1611] doctest.testmod gets noisy if called more than once per SystemExit

2007-12-13 Thread Pat LaVarre

New submission from Pat LaVarre:

SUMMARY:

Calling doctest.testmod more than once before SystemExit spews stderr 
messages such as "*** DocTestRunner.merge: '__main__' in both testers; 
summing outcomes"

STEPS TO REPRODUCE:

$ cat tttestmod.py 
import doctest
doctest.testmod() # 1
doctest.testmod() # 2
doctest.testmod() # 3
$ 

ACTUAL RESULTS:

$ python ./tttestmod.py 
*** DocTestRunner.merge: '__main__' in both testers; summing outcomes.
*** DocTestRunner.merge: '__main__' in both testers; summing outcomes.
$ 

EXPECTED RESULTS:

$ python ./tttestmod.py 
$ 

WORKAROUND:

Filter stdout.write calls from doctest.py to squelch the noise.

REGRESSION/ ISOLATION:

$ python --version
Python 2.5.1
$

Also mentioned 2006-10 in comp.lang.python at DocTestRunner.merge 
verbose,
i.e., http://groups.google.com/group/comp.lang.python/search?
group=comp.lang.python&q=DocTestRunner.merge+verbose

Not yet found in Bugs.python.org at DocTestRunner.

NOTES:

We can reasonably expect newbies to doctest random things
that need to be doctested more than once.

We can't reasonably expect newbies to know to how to filter doctest 
stdout,
for example as below.

#!/usr/bin/env python

r""" ttestmod.py

Filter Doctest stdout a la http://wiki.python.org/moin/doctest
to call doctest.testmod more than once per SystemExit
without producing noise.

>>> import random
>>> import sys
>>>
>>> die = random.randint(1, 6)
>>> print >>sys.stderr, die
>>>
>>> die == 6
True
>>>

"""

import sys

class DocTestOutput:

def __init__(self, out = sys.stdout):

self.out = out
self.write = self.writeOut
self.quietly = False

def writeOut(self, bytes):

head = "*** DocTestRunner.merge: '__main__"
tail = "' in both testers; summing outcomes."

if bytes.startswith(head):
if bytes.endswith(tail):
self.quietly = True

if not self.quietly:
self.out.write(bytes)

if 0 <= bytes.find('\n'):
self.quietly = False

if __name__ == '__main__':

import doctest

sys.stdout = DocTestOutput()

doctest.testmod()
doctest.testmod()

--
components: Library (Lib)
messages: 58533
nosy: [EMAIL PROTECTED]
severity: normal
status: open
title: doctest.testmod gets noisy if called more than once per SystemExit
type: behavior
versions: Python 2.5

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1611>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1082] platform system may be Windows or Microsoft since Vista

2007-09-18 Thread Pat LaVarre

Pat LaVarre added the comment:

Thanks for the cultural education of 2.5.1 isn't supposed to work, I 
didn't know that.

Also I'm glad to hear this is fixed for 2.5.2 already.

Sorry I'm too new & ignorant to understand why you believe this is 
fixed. I don't see that we already have a way to say things like:

if not platform.system('Linux'):

Do we have a way to say things like that?

My first Googles, tried here now at Mac OS X, give me useless 
suggestions like:

>>> platform.platform(aliased=True)
'Darwin-9.0.0b5-i386-32bit'
>>> platform.system_alias(platform.system(), platform.release(), 
platform.version())
('Darwin', '9.0.0b5', 'Darwin Kernel Version 9.0.0b5: Fri Aug 17 
17:24:24 PDT 2007; root:xnu-1182~1/RELEASE_I386')
>>> 

Practically speaking, I was getting by ok with:

if platform.system() != 'Windows':

Until that broke in Vista plus 2.5.1.

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1082>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1082] platform system may be Windows or Microsoft since Vista

2007-09-18 Thread Pat LaVarre

Pat LaVarre added the comment:

--- USAGE:

I agree we should let people in future write:

if not platform.system('Windows'):

rather than:

if not (platform.system() in ('Microsoft', 'Windows')):

now that our people can no longer rely on Python in Vista correctly 
understanding the plain human intent of such code fragments as:

if platform.system() != 'Windows':

--- DRAFT SPEC:

platform.system(name = None) returns the system name if name is None, 
else returns the system name if name is a well-known alias of the 
system name, else returns None.

The string 'Mac OS X' is a well-known alias for the system 'Darwin'.

The string 'Windows' is a well-known alias for the system 'Microsoft' 
in 2.5.1 Python on Vista.

The system name is itself a well-known alias of the system name. For 
example, 'Darwin' is a well-known alias of the 'Darwin' system that is 
sold as the kernel of 'Mac OS X'.

Etc.

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1082>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1082] platform system may be Windows or Microsoft since Vista

2007-09-18 Thread Pat LaVarre

Pat LaVarre added the comment:

Works for me.

I tried python-trunk-vistaplatform-v2.patch in one sample of 2006-11 
RTM Vista plus 2.5.1 Python plus this patch. I quote:

>>> import platform
>>> platform.uname()
('Windows', '[redacted]', 'Vista', '6.0.6000', '', '')
>>> platform.system()
'Windows'
>>> platform.version()
'6.0.6000'
>>>

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1082>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1082] platform system may be Windows or Microsoft since Vista

2007-09-17 Thread Pat LaVarre

Pat LaVarre added the comment:

I recommend we reject this first draft of the python-trunk-
vistaplatform.patch.

I reason as follows ...

ACTUAL RESULTS OF 2.5.1 PLUS PATCH IN VISTA WINDOWS:

>>> import platform
>>> ...
>>> platform.uname()
('Microsoft', '[redacted]', 'Windows', '6.0.6000', '', '')
>>> platform.system()
'Windows'
>>> platform.release()
'Windows'
>>>

EXPECTED RESULTS OF 2.5.1 PLUS PATCH IN VISTA WINDOWS:

>>> import platform
>>> ...
>>> platform.uname()
('Windows', '[redacted]', 'Vista', '6.0.6000', '', '')
>>> platform.system()
'Windows'
>>> platform.release()
'Vista'
>>>

ACTUAL RESULTS OF 2.5 IN SP2 XP WINDOWS:

>>> import platform
>>> ...
>>> platform.uname()
('Windows', '[redacted]', 'XP', '5.1.2600', '', '')
>>> platform.system()
'Windows'
>>> platform.release()
'XP'
>>>

DISCUSSION:

Four thoughts:

1.

I think we meant to write { unameInfo[2] == 'Windows' } where we wrote 
{ unameInfo == 'Windows' } in this patch.

2.

To run the patch I created a copy of platform.py in the same folder and 
applied the patch by hand. I redacted the host names by hand and elided 
the { platform = ... } source line I wrote to let me run the patch in 
place of the original.

3.

I think we should substitute a different kind of patch, a patch to 
correct the platform.uname rather than a patch to redefine 
platform.system and platform.version.

I'd like us to hold to such cross-platform invariants as:

( platform.system() == platform.uname()[0] )

( platform.system() == platform.uname()[2] )

Out on the web I see that we have documented these invariants. I quote:

""" 14.12.1 Cross Platform 
 
uname()

... Returns a tuple of strings (system, node, release, version, 
machine, processor) identifying the underlying platform. 

""" 2007-09-17 fetch of http://docs.python.org/lib/node442.html
""" near http://docs.python.org/lib/module-platform.html

4.

I don't think we can totally fix this trouble in code: we have 
distributed 2.5.1 to Vista too massively already now.

Specifically, I think we should also fix the doc to admit the hereafter 
frequent need for people using Python to write code such as:

if not (platform.system() in ('Microsoft', 'Windows')):

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1082>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1082] platform system may be Windows or Microsoft since Vista

2007-09-01 Thread Pat LaVarre

New submission from Pat LaVarre:

SUMMARY:

'Microsoft' is the platform.system() of Vista Windows, whereas 'Windows' 
was the platform.system() of XP Windows, whoops.

STEPS TO REPRODUCE & ACTUAL RESULTS:

Run 2.5.1 Python in a Vista and see:

>>> import platform
>>> platform.system()
>>>
'Microsoft'
>>> 

EXPECTED RESULTS:

>>> import platform
>>> platform.system()
'Windows'
>>> 

WORKAROUND:

Write new Python source code like:

if platform.system() in ('Windows', 'Microsoft'): 
if not (platform.system() in ('Windows', 'Microsoft')): 

in place of obsolete Python source code like:

if platform.system() == 'Windows': # Microsoft 
if platform.system() != 'Windows': # Microsoft 

REGRESSION/ ISOLATION:

Seen by me in an Enterprise Vista. Indexed by Google as reported by 
Martin v. Löwis (loewis) circa 2007-05-29 07:11 as:

http://mail.python.org/pipermail/patches/2007-June/022947.html 
... 

Patches item #1726668, was opened at 2007-05-28 03:23 

On Microsoft Vista platform.system() returns 'Microsoft' and 
platform.release() returns 'Windows' 

Under Microsoft Windows XP SP2 platform.system() returns 'Windows' and 
platform.release() returns 'XP'. 

This is problem was caused by a change in the output of the "ver" 
command. In Windows XP SP2 "ver" outputted 'Microsoft Windows XP 
[Version 5.1.2600]'  In Microsoft Vista "ver" outputted 'Microsoft 
Windows [Version 6.0.6000]'. The lack of the 3rd word before version 
causes _syscmd_ver(...) in platform.py to return 'Microsoft' for system 
instead of 'Microsoft Windows'. This causes uname() to return the 
incorrect values. Both system() and release() call uname().

NOTES:

There is no fixing all of this?

Cross-platform scripts actually will misbehave across the large 
population that is 2.5 Python in Vista unless those scripts change to 
implement something like the suggested workaround, that's now an 
accomplished fact.

Question: Is it better to leave this feature as is, so that everyone 
eventually learns to workaround it, or is it better to fix it late now 
in 2007-09, so that many people never have to learn to workaround it?

Question: Why are we screen-scraping the Ver command, instead of calling 
Win kernel32.getVersionEx? And how can any code for screen-scraping the 
Ver command be in doubt about whether the platform.system underneath is 
'Windows'?

--
components: Windows
messages: 55561
nosy: [EMAIL PROTECTED]
severity: major
status: open
title: platform system may be Windows or Microsoft since Vista
type: behavior
versions: Python 2.5

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1082>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com