[issue18521] [cppcheck] Full report

2013-08-03 Thread Julien Nabet

Julien Nabet added the comment:

Thank you for your feedback, you can close this tracker.

--

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



[issue18606] Add statistics module to standard library

2013-08-03 Thread Steven D'Aprano

Steven D'Aprano added the comment:

On 03/08/13 13:02, Alexander Belopolsky wrote:

 Alexander Belopolsky added the comment:

 Is there a reason why there is no review link?  Could it be because the 
 file is uploaded as is rather than as a patch?

I cannot answer that question, sorry.

 In any case, I have a question about this code in sum:

  # Convert running total to a float. See comment below for
  # why we do it this way.
  total = type(total).__float__(total)

 The comment below says:

  # Don't call float() directly, as that converts strings and we
  # don't want that. Also, like all dunder methods, we should call
  # __float__ on the class, not the instance.
  x = type(x).__float__(x)

 but this reason does not apply to total that cannot be a string unless you 
 add instances of a really weird class in which case all bets are off and the 
 dunder method won't help much.

My reasoning was that total may be a string if the start parameter is a string, 
but of course I explicitly check the type of start. So I think you are right.

--

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



[issue18595] zipfile: symlinks etc.

2013-08-03 Thread Ronald Oussoren

Ronald Oussoren added the comment:

My initial plan was to add the patch soon after filing the issue, but that's 
before I noticed that this needs some API design to integrate nicely :-)

My current idea for the api:

* add symlink(path, target) to write a symlink

* add readlink(path) to read a symlink

* read will raise an exception when trying to read a symlink
  (alternative: do symlink resolving, but that's too magical to my taste)
 
* extract and extractall extract the symlink as a symlink
  (but I'm not sure yet what to do on systems that don't support symlinks)

* with the various file types it might be better to also provide
  islink(name), isdir(name) and isfile(name) methods (simular to
  their os.path equivalents)

This will also require some changes to the ZipInfo class.

I'm not sure yet if adding support for device files and other unix attributes 
(UID/GID).

--

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



[issue18606] Add statistics module to standard library

2013-08-03 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Is there a reason why there is no 'review' link?  Could it be because the file 
is uploaded as is rather than as a patch?

I think I can answer this question. The answer is yes. You can have review 
only if you use diff not raw file.

The original poster, Steven D'Aprano, uploaded the raw file instead of diff. To 
upload the new file as a diff, (assuming he is using mercurial) he can do 
something like this:

hg add Lib/statistics.py
hg diff Lib/statistics.py  /tmp/statistics_diff.patch

Then he can upload the statistics_diff.patch.

Of course, this is just my hypothetical guess.

--
nosy: +vajrasky

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



[issue16463] testConnectTimeout of test_timeout TCPTimeoutTestCasefailures fails intermittently

2013-08-03 Thread koobs

Changes by koobs koobs.free...@gmail.com:


--
nosy: +koobs

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



[issue18566] In unittest.TestCase docs for setUp() and tearDown() don't mention AssertionError

2013-08-03 Thread Phil Connell

Changes by Phil Connell pconn...@gmail.com:


--
nosy: +pconnell

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



[issue18594] C accelerator for collections.Counter is slow

2013-08-03 Thread Phil Connell

Changes by Phil Connell pconn...@gmail.com:


--
nosy: +pconnell

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



[issue11798] Test cases not garbage collected after run

2013-08-03 Thread Jean-Paul Calderone

Changes by Jean-Paul Calderone exar...@twistedmatrix.com:


--
nosy:  -exarkun

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



[issue18532] hashlib.HASH objects should officially expose the hash name

2013-08-03 Thread Jason R. Coombs

Jason R. Coombs added the comment:

It's not obvious to me if the authors originally intended to have the 'name' 
attribute as a formal interface, so I've decided the change should probably be 
added to Python 3.4. Here's a diff I've put together: 
http://paste.jaraco.com/tMdQ2

It updates the documentation and adds a test to guarantee the interface. I'm 
unsure about the RST syntax, so I would appreciate a review of the syntax 
there. Also, I haven't run the test yet, but I'll do that at a later date.

--

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



[issue18532] hashlib.HASH objects should officially expose the hash name

2013-08-03 Thread Jason R. Coombs

Changes by Jason R. Coombs jar...@jaraco.com:


--
keywords: +needs review
stage: needs patch - patch review

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



[issue16853] add a Selector to the select module

2013-08-03 Thread Charles-François Natali

Charles-François Natali added the comment:

 Guido van Rossum added the comment:
 Can you try again with the failing assert replaced with this?

   self.assertTrue(0.018 = t2-t0 = 0.028, t2-t0)

 That should be a better way to check that code works.

I'm still getting - less frequent - failures:

==
FAIL: test_run_until_complete_timeout (events_test.SelectEventLoopTests)
--
Traceback (most recent call last):
  File tests/events_test.py, line 194, in test_run_until_complete_timeout
self.assertTrue(0.018 = t2-t0 = 0.028, t2-t0)
AssertionError: False is not true : 0.029771103999337356

--


Looking at strace output:
11:00:47.383145 select(4, [3], [], [], {0, 9765}) = 0 (Timeout) 0.015713

select() takes an extra 5ms (15ms instead of 10ms).

5ms is quite low for a GPOS (the typical quantum is around 4ms for
250Hz timer, and on my machine I have high-resolution timers
configured but probably a crappy hardware).

I'd suggest increasing the timeouts (especially when Tulip gets
merged, it'll likely fail on many buildbots).

--

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



[issue10897] UNIX mmap unnecessarily dup() file descriptor

2013-08-03 Thread Charles-François Natali

Charles-François Natali added the comment:

 This can only be raised (above the hard limit) by a privileged
 process, so I would be out of luck there, as I could not convince
 my sysadmins to raise this further.

We all know that feeling :-)

 Meanwhile, I will just use my own module, so feel free to close
 this if you feel like it :)

OK, I'll close it then, since I don't see any satisfactory solution, and - 
until now - you've been the only user to get bitten.

Cheers.

--
resolution:  - wont fix
stage: patch review - committed/rejected
status: open - closed

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



[issue16463] testConnectTimeout of test_timeout TCPTimeoutTestCasefailures fails intermittently

2013-08-03 Thread Charles-François Natali

Charles-François Natali added the comment:

The problem is that the test passes a DNS address to connect(), which means 
that it has to perform a name resolution first.
And since there's not timeout on gethostbyname()/getaddrinfo() you can end up 
well above the timeout.
The hostnames should be resolved beforehand.

--
nosy: +neologix

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



[issue18629] future division breaks timedelta division by integer

2013-08-03 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 03.08.2013 00:47, Alexander Belopolsky wrote:
 
 Alexander Belopolsky added the comment:
 
 Does a result of one and one half seconds make sense as the result of a 
 floor division operation?
 
 Yes.  Timedeltas behave as integers containing the number of microseconds:
 
 timedelta(microseconds=1) / 2
 datetime.timedelta(0)

I think that's a very obscure interpretation of floor division for
timedeltas :-)

IMO, floor division result should work on seconds, not microseconds.

--

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



[issue18629] future division breaks timedelta division by integer

2013-08-03 Thread Mark Dickinson

Mark Dickinson added the comment:

 I think that's a very obscure interpretation of floor division for
 timedeltas :-)

Agreed.

--
nosy: +mark.dickinson

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



[issue18570] OverflowError in division: wrong message

2013-08-03 Thread Mark Dickinson

Mark Dickinson added the comment:

Exception message fixed in revision dab7d6f33b87

--

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



[issue16463] testConnectTimeout of test_timeout TCPTimeoutTestCasefailures fails intermittently

2013-08-03 Thread Charles-François Natali

Charles-François Natali added the comment:

And here's a patch.

--
keywords: +patch
Added file: http://bugs.python.org/file31137/connect_timeout.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16463
___diff -r 1287d4c9cd39 Lib/test/test_timeout.py
--- a/Lib/test/test_timeout.py  Fri Aug 02 10:22:07 2013 +0200
+++ b/Lib/test/test_timeout.py  Sat Aug 03 13:19:24 2013 +0200
@@ -126,13 +126,23 @@
 self.assertLess(delta, timeout + self.fuzz)
 self.assertGreater(delta, timeout - 1.0)
 
+def resolve_address(self, host, port):
+Resolve an (host, port) to an address.
+
+We must perform name resolution before timeout tests, otherwise it will
+be performed by connect().
+
+with support.transient_internet(host):
+return socket.getaddrinfo(host, port, socket.AF_INET,
+  socket.SOCK_STREAM)[0][4]
+
 
 class TCPTimeoutTestCase(TimeoutTestCase):
 TCP test case for socket.socket() timeout functions
 
 def setUp(self):
 self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-self.addr_remote = ('www.python.org.', 80)
+self.addr_remote = self.resolve_address('www.python.org.', 80)
 
 def tearDown(self):
 self.sock.close()
@@ -142,7 +152,7 @@
 # to a host that silently drops our packets.  We can't simulate this
 # from Python because it's a function of the underlying TCP/IP stack.
 # So, the following Snakebite host has been defined:
-blackhole = ('blackhole.snakebite.net', 5)
+blackhole = self.resolve_address('blackhole.snakebite.net', 5)
 
 # Blackhole has been configured to silently drop any incoming packets.
 # No RSTs (for TCP) or ICMP UNREACH (for UDP/ICMP) will be sent back
@@ -154,7 +164,7 @@
 # to firewalling or general network configuration.  In order to improve
 # our confidence in testing the blackhole, a corresponding 'whitehole'
 # has also been set up using one port higher:
-whitehole = ('whitehole.snakebite.net', 56667)
+whitehole = self.resolve_address('whitehole.snakebite.net', 56667)
 
 # This address has been configured to immediately drop any incoming
 # packets as well, but it does it respectfully with regards to the
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18642] enhancement for operator 'assert'

2013-08-03 Thread Al Korgun

New submission from Al Korgun:

It would be pretty good, if 'assert' could raise specified exception, like that:

 data = None
 assert isinstance(data, basestring), TypeError('data' must be a string)

sAssertionError/sTypeError: 'data' must be a string

--
components: Interpreter Core
messages: 194250
nosy: WitcherGeralt
priority: normal
severity: normal
status: open
title: enhancement for operator 'assert'
type: enhancement
versions: Python 2.7

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



[issue18642] enhancement for operator 'assert'

2013-08-03 Thread Mark Dickinson

Mark Dickinson added the comment:

What's wrong with:

if not isinstance(data, basestring):
raise TypeError(...)

?

In any case, you appear to be wanting to use assert to check user input.  
That's not its intended use;  instead, it's there for making debugging 
assertions.  Bear in mind that when running in optimized mode (with python -O), 
Python won't execute those asserts at all.  (See 
http://docs.python.org/3.4/reference/simple_stmts.html#the-assert-statement for 
more.)

I think this should be rejected.

--
nosy: +mark.dickinson
versions: +Python 3.4 -Python 2.7

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



[issue18643] implement socketpair() on Windows

2013-08-03 Thread Charles-François Natali

New submission from Charles-François Natali:

socketpair() is quite useful, notably for tests.
Currently, it's not defined on Windows.
Since it's rather easy to implement, it would be nice to have it, if not in the 
stdlib, at least in test.support.

--
components: Library (Lib)
messages: 194252
nosy: neologix, sbt
priority: normal
severity: normal
stage: needs patch
status: open
title: implement socketpair() on Windows
type: enhancement

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



[issue18396] test_signal.test_issue9324() fails on buildbot AMD64 Windows7 SP1 3.x

2013-08-03 Thread Nick Coghlan

Nick Coghlan added the comment:

I checked the getsignal docs, and indeed None is the expected return value for 
signal handler exists, but was not installed from Python. That's accurate 
given the way faulthandler works:

On Linux (Python 3.3.0):

$ python3 -c import signal; print(signal.getsignal(signal.SIGSEGV))
0
$ python3 -X faulthandler -c import signal; 
print(signal.getsignal(signal.SIGSEGV))
None

So Jeremy's patch looks correct to me - when faulthandler is enabled, we need 
to skip over the signals that have those handlers attached.

--

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



[issue18635] Enum sets _member_type_ to instantiated values but not the class

2013-08-03 Thread Chris Lambacher

Chris Lambacher added the comment:

My use case is a generic mixin for Enums and a generic mixin for Django ORM 
fields that uses the Enums to generate choices. 

The Enum mixin has to call cls.__class__._get_mixins_(cls.__bases__) to get the 
member_type so that it can call the member_type.__new__ method (currently using 
this for int and str). I'm currently setting _member_type_ on the class if it 
doesn't already exist in the Enum class.

The Django ORM field mixin has a to_python method where it is supposed to take 
input from the db/web and turn it into the python type (in this case an Enum). 
If we get a str from the web and we are going to an int, we need to run int on 
it. The generic way to do this in the mixin is to pass the value to 
_member_type_ as a function.

I think I have all the bugs out of my implementation so I should be able to 
extract it out of my app and make it open source this week.

--

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



[issue18396] test_signal.test_issue9324() fails on buildbot AMD64 Windows7 SP1 3.x

2013-08-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b7834800562f by Nick Coghlan in branch '3.3':
Close #18396: fix spurious test_signal failure on Windows
http://hg.python.org/cpython/rev/b7834800562f

New changeset 6fc71ed6a910 by Nick Coghlan in branch 'default':
Merge #18396 from 3.3
http://hg.python.org/cpython/rev/6fc71ed6a910

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

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



[issue18396] test_signal.test_issue9324() fails on buildbot AMD64 Windows7 SP1 3.x

2013-08-03 Thread Nick Coghlan

Nick Coghlan added the comment:

I added one slight tweak to Jeremy's patch - an assertion to ensure that test 
loop is checking at least some* signals, even when faulthandler is enabled.

--

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



[issue18642] enhancement for operator 'assert'

2013-08-03 Thread Al Korgun

Al Korgun added the comment:

Mark Dickinson, and I just think it might be useful in debug. PYO is another 
story.

--

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



[issue15233] atexit: guarantee order of execution of registered functions?

2013-08-03 Thread Charles-François Natali

Charles-François Natali added the comment:

Unless anyone objects, I'll backport it soonish.

--
stage:  - commit review

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



[issue12015] possible characters in temporary file name is too few

2013-08-03 Thread Charles-François Natali

Changes by Charles-François Natali cf.nat...@gmail.com:


--
keywords: +easy, needs review
stage:  - patch review
type:  - enhancement
versions: +Python 3.4 -Python 3.3

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



[issue18642] enhancement for operator 'assert'

2013-08-03 Thread Mark Dickinson

Mark Dickinson added the comment:

Ah, so I think I don't understand the proposal.  In your original message,  is 
it your intention that the assert raises TypeError, or that it raises 
AssertionError?

Again:  what's the benefit over existing solutions?  Either:

if not isinstance(data, basestring):
raise TypeError(Bad user!  You gave me the wrong type)

or

assert isinstance(data, basestring), data should be a string at this point

?

--

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



[issue18644] Got ResourceWarning: unclosed file when using test function from formatter module

2013-08-03 Thread Vajrasky Kok

New submission from Vajrasky Kok:

This python is compiled with --with-pydebug option.

[sky@localhost cpython]$ cat /tmp/a.txt
manly man likes cute cat.
[sky@localhost cpython]$ ./python
Python 3.4.0a0 (default:e408e821d6c8, Jul 27 2013, 10:49:54) 
[GCC 4.7.2 20121109 (Red Hat 4.7.2-8)] on linux
Type help, copyright, credits or license for more information.
 from formatter import test
 test('/tmp/a.txt')
manly man likes cute cat.
__main__:1: ResourceWarning: unclosed file _io.TextIOWrapper name='/tmp/a.txt' 
mode='r' encoding='UTF-8'
 
[sky@localhost cpython]$ ./python Lib/formatter.py /tmp/a.txt
manly man likes cute cat.
Lib/formatter.py:445: ResourceWarning: unclosed file _io.TextIOWrapper 
name='/tmp/a.txt' mode='r' encoding='UTF-8'
  test()

--
components: Tests
files: formatter_fix_resource_warning.patch
keywords: patch
messages: 194260
nosy: vajrasky
priority: normal
severity: normal
status: open
title: Got ResourceWarning: unclosed file when using test function from 
formatter module
type: resource usage
versions: Python 3.4
Added file: 
http://bugs.python.org/file31138/formatter_fix_resource_warning.patch

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



[issue18644] Got ResourceWarning: unclosed file when using test function from formatter module

2013-08-03 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Sorry, I forgot about stdin. Attached the patch to handle stdin gracefully.

--
Added file: 
http://bugs.python.org/file31139/formatter_fix_resource_warning_v2.patch

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



[issue18644] Got ResourceWarning: unclosed file when using test function from formatter module

2013-08-03 Thread Vajrasky Kok

Vajrasky Kok added the comment:

I guess I should not close stdin just in case people are using test function in 
the script.

Attached the patch to only close the open files not stdin.

--
Added file: 
http://bugs.python.org/file31140/formatter_fix_resource_warning_v3.patch

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



[issue18642] enhancement for operator 'assert'

2013-08-03 Thread R. David Murray

R. David Murray added the comment:

I think it would be confusing for assert to raise anything other than an 
AssertionError, so I also think this should be rejected.

It might be interesting for there to be a way to call unittest's assert methods 
in a debug context (that is, without having to have a test case around), but 
that is a very non-trivial (and probably impractical) thought :)

--
nosy: +r.david.murray

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



[issue18595] zipfile: symlinks etc.

2013-08-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

 * read will raise an exception when trying to read a symlink
  (alternative: do symlink resolving, but that's too magical to my taste)

And perhaps when trying to read a directory entry too.

 * extract and extractall extract the symlink as a symlink
  (but I'm not sure yet what to do on systems that don't support symlinks)

What the tar module do?

 * with the various file types it might be better to also provide
  islink(name), isdir(name) and isfile(name) methods (simular to
  their os.path equivalents)

Or rather as methods of the ZipInfo object. See TarInfo.

--
nosy: +serhiy.storchaka

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



[issue18644] Got ResourceWarning: unclosed file when using test function from formatter module

2013-08-03 Thread Martijn Pieters

Martijn Pieters added the comment:

Why is the `formatter` module still part of Python 3? This was a dependency for 
the `htmllib` module in Python 2 only, and that module was deprecated and 
removed from Python 3.

--
nosy: +mjpieters

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



[issue18264] enum.IntEnum is not compatible with JSON serialisation

2013-08-03 Thread Ethan Furman

Ethan Furman added the comment:

Eli, your method is good.  I thought I had tried something similar but I 
obviously had the wrong PyLong constructor.

I'll get it implemented.

--

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



[issue18624] Add alias for iso-8859-8-i which is the same as iso-8859-8

2013-08-03 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 02.08.2013 16:37, R. David Murray wrote:
 
 I got the impression from what I read that -e included additional control 
 sequences, but perhaps I misunderstood and that only meant that the data 
 stream was expected to *use* additional control sequences but the control 
 codes themselves are part of the base codec?
 
 I'm specifically thinking of this statement from the linked reference:
 
 Because HTML uses the Unicode bidirectionality algorithm, conforming 
 documents encoded using ISO 8859-8 must be labeled as ISO-8859-8-i. 
 Explicit directional control is also possible with HTML, but cannot be 
 expressed with ISO 8859-8, so ISO-8859-8-e should not be used.
 
 The cannot be expressed seems to imply there are differences in the codec.

No, not really. After some more research, I found that the -i and
-e suffixes are defined in RFC 1556:

http://tools.ietf.org/html/rfc1556

At the codec level, these encodings are all the same. The suffixes
define whether or not to interpret some of their control characters
with respect to bidi text when visualizing the text.

--

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



[issue11798] Test cases not garbage collected after run

2013-08-03 Thread R. David Murray

R. David Murray added the comment:

Terry: I would not be in favor of using the normal iter, since iterating a 
collection doesn't normally empty it, and there may be tools that iterate a 
test suite outside of test execution.  Adding a pop_iter method would be a 
backward compatibility issue, since replacement test suites would not have 
that method.  I think the current patch is the best bet for maintaining 
backward compatibility.

--
nosy: +r.david.murray

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



[issue18296] test_os.test_trailers() is failing on AMD64 FreeBSD 9.0 dtrace 3.x

2013-08-03 Thread Charles-François Natali

Charles-François Natali added the comment:

The test shouldn't pass 4096 as nbytes: apparently, recent FreeBSD kernels 
zero-fill.

--
nosy: +neologix

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



[issue17998] internal error in regular expression engine

2013-08-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 86b8b035529b by Serhiy Storchaka in branch '3.3':
Issue #17998: Fix an internal error in regular expression engine.
http://hg.python.org/cpython/rev/86b8b035529b

New changeset 36702442ffe0 by Serhiy Storchaka in branch 'default':
Issue #17998: Fix an internal error in regular expression engine.
http://hg.python.org/cpython/rev/36702442ffe0

New changeset e5e425fd1e4f by Serhiy Storchaka in branch '2.7':
Issue #17998: Fix an internal error in regular expression engine.
http://hg.python.org/cpython/rev/e5e425fd1e4f

--
nosy: +python-dev

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



[issue18629] future division breaks timedelta division by integer

2013-08-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

What is so special about seconds?  Why not days? As in

 timedelta(3) // 2
timedelta(1)


Note that in 3.x we have timedelta over timedelta division that lets you do 
floor division in arbitrary time units.

What is the use case for timedelta // int that rounds down to a second?  I 
suspect in most cases you really want timedelta // timedelta(seconds=int) 
instead.

--

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



[issue18629] future division breaks timedelta division by integer

2013-08-03 Thread Mark Dickinson

Mark Dickinson added the comment:

I'm not sure I see a use-case for timedelta // int at all.  To make sense of 
that, you first need some way to make sense of floor(timedelta), and as you say 
it's not clear what that should mean:  number of seconds?  number of days?  
Either of those would seem more natural than number of microseconds, though.

timedelta // timedelta and timedelta / int on the other hand have an obvious 
meaning.

--

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



[issue18629] future division breaks timedelta division by integer

2013-08-03 Thread Mark Dickinson

Mark Dickinson added the comment:

-1 on changing the behaviour in 2.7, though;  I think it's far too late for 
that.

--

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



[issue18629] future division breaks timedelta division by integer

2013-08-03 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 03.08.2013 18:32, Alexander Belopolsky wrote:
 
 Alexander Belopolsky added the comment:
 
 What is so special about seconds?  Why not days? As in
 
 timedelta(3) // 2
 timedelta(1)
 
 
 Note that in 3.x we have timedelta over timedelta division that lets you do 
 floor division in arbitrary time units.
 
 What is the use case for timedelta // int that rounds down to a second?  I 
 suspect in most cases you really want timedelta // timedelta(seconds=int) 
 instead.

The notion of fraction in time usually applies to seconds, not
days, hours or minutes. Since floor removes fractions, the natural
expectation is to have // int apply to seconds, not microseconds
(which represent fractions of a second).

That said, I don't think having // division on timedeltas is useful
at all. I'd be +1 on removing this support and raise a TypeError
instead.

--

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



[issue17998] internal error in regular expression engine

2013-08-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Sorry for the delay. I have committed a simple patch which fixes this bug. But 
I don't close the issue still because there are other related issues.

--

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



[issue17998] internal error in regular expression engine

2013-08-03 Thread R. David Murray

R. David Murray added the comment:

This appears to have turned the buildbots red.

--
nosy: +r.david.murray

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



[issue18629] future division breaks timedelta division by integer

2013-08-03 Thread Tim Peters

Tim Peters added the comment:

Well, a timedelta is a duration.  timedelta // n is as close as possible to one 
n'th of that duration, but rounding down (if necessary) so that the result is 
representable as a timedelta.  In the same way, if i and j are integers, i // j 
is as close as possible to one j'th of i, but rounding down (if necessary) so 
that the result is representable as an integer.  Like:

 from datetime import timedelta
 timedelta(1) // 7
datetime.timedelta(0, 12342, 857142)
 timedelta(1) - 7 * _
datetime.timedelta(0, 0, 6)


The last line shows the part truncated away:  one seventh of a day is not 
representable as a timedetla. If `timedelta // int` rounded to the closest 
representable timedelta, it would return timedelta(0, 12342, 857143) instead.  
That's a little bigger than a seventh of a day:

 timedelta(0, 12342, 857143) * 7
datetime.timedelta(1, 0, 1)

It has nothing directly to do with days, hours, seconds ... it so happens that 
timedelta has microsecond resolution, so the closest representable 
approximations to one n'th of a timedelta most often have non-zero microsecond 
components.  If timedelta had femtosecond resolution, they'd most often have 
non-zero femtosecond components ;-)

--
nosy: +tim_one

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



[issue18629] future division breaks timedelta division by integer

2013-08-03 Thread Jean-Paul Calderone

Jean-Paul Calderone added the comment:

 I think that's a very obscure interpretation of floor division for
timedeltas :-)

Note - I don't care about this.  I just want `timedelta / int` to do the same 
thing in Python 2.7 with __future__.division as `timedelta / int` does in 
Python 3.

Please don't reject this because of some unrelated discussion about how floor 
division should be implemented for timedelta.

--

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



[issue16067] UAC prompt for installation shows temporary file name

2013-08-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 797b1d13d16e by Martin v. Löwis in branch '3.3':
Issue #16067: Add description into MSI file to replace installer's temporary 
name.
http://hg.python.org/cpython/rev/797b1d13d16e

New changeset 7d661f47f73b by Martin v. Löwis in branch 'default':
Issue #16067: Merge with 3.3
http://hg.python.org/cpython/rev/7d661f47f73b

--
nosy: +python-dev

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



[issue18264] enum.IntEnum is not compatible with JSON serialisation

2013-08-03 Thread Eli Bendersky

Eli Bendersky added the comment:

Yes, AFAIU PyNumber_Long is the equivalent of Python-level int(obj). With other 
constructors of PyLong you are limited by long long (while Python integers may 
be arbitrarily large).

Ethan - If you're still short on time I can pretty up this patch and put it for 
review with some tests. Let me know what you prefer.

--

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



[issue18629] future division breaks timedelta division by integer

2013-08-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

There are two schools of thought here.  One school (MAL and Mark) thinks of 
durations as real number of seconds.  The other school (Tim and I) think of 
durations as integer number of resolution intervals.  This is why I and Tim 
before me resisted adding true division of timedelta by a number and 
multiplication of timedelta by a float.  Mark prevailed on that issue (see 
#1289118.)  His expertise in floating point computing certainly helped 
designing and implementing these operations correctly.  We still have a small 
quirk waiting to be ironed out (see #8860), but overall I am happy with the 
current state.

This said, the datetime module carries a long legacy of being a pure integer 
arithmetics in a funny variable-radix notation.  We can disagree on the utility 
of floor division as it is currently defined, but we cannot remove or change it 
in an incompatible way.

--

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



[issue16741] `int()`, `float()`, etc think python strings are null-terminated

2013-08-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ecc8512b427d by Serhiy Storchaka in branch '3.3':
Issue #16741: Fix an error reporting in int().
http://hg.python.org/cpython/rev/ecc8512b427d

New changeset 4fd48a807812 by Serhiy Storchaka in branch 'default':
Issue #16741: Fix an error reporting in int().
http://hg.python.org/cpython/rev/4fd48a807812

--
nosy: +python-dev

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



[issue18264] enum.IntEnum is not compatible with JSON serialisation

2013-08-03 Thread Ethan Furman

Ethan Furman added the comment:

Thanks for the offer, Eli, but I almost have the tests done.  :)

--

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



[issue16067] UAC prompt for installation shows temporary file name

2013-08-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ee0bdc007a0f by Martin v. Löwis in branch '2.7':
Issue #16067: Add description into MSI file to replace installer's temporary 
name.
http://hg.python.org/cpython/rev/ee0bdc007a0f

--

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



[issue16067] UAC prompt for installation shows temporary file name

2013-08-03 Thread Martin v . Löwis

Martin v. Löwis added the comment:

Thanks for the report. This is now fixed on the active branches.

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

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



[issue17998] internal error in regular expression engine

2013-08-03 Thread Larry Hastings

Larry Hastings added the comment:

This broke the test suite on all the 32-bit Linux buildbots.  Sample output is 
here:

http://buildbot.python.org/all/builders/x86%20Ubuntu%20Shared%203.x/builds/8349/steps/test/logs/stdio

There's no obvious fix, and I want to cut 3.4a1 right about now, so I'm going 
to tag the version in trunk just before this checkin.

--

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



[issue16741] `int()`, `float()`, etc think python strings are null-terminated

2013-08-03 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


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

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



[issue18629] future division breaks timedelta division by integer

2013-08-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

 I just want `timedelta / int` to do the same thing in Python 2.7
 with __future__.division as `timedelta / int` does in Python 3.

It other words you want to backport timedelta / int true division.  I am afraid 
it is 3-4 years too late for this request, but I will let others make a call.  
Count me as -0.

I usually prefer explicit error over an obscure bug.  If we backport true 
division the -Qnew flag will be changing the meaning of timedelta / int very 
slightly: instead of rounding down it will round to nearest.  There are cases 
where this difference is important.  Furthemore, when people compare timedeltas 
in tests they rarely do it with precision tolerance.  If you have a good test 
coverage change from floor to true division may break your tests.

My recommendation is: replace timedelta / int with timedelta // int in your 2.x 
code.

--

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



[issue18642] enhancement for operator 'assert'

2013-08-03 Thread Al Korgun

Al Korgun added the comment:

Mark Dickinson, #1 if dedug (and type check, respectively, as in this example, 
and 'raise') isn't needed we just need pyo
 Python won't execute those asserts at all
that is convenient.

if not isinstance(data, basestring):
raise TypeError(...)

- here we need additionally check debug variable, use wrapper or something.
#2 'assert' is a good breakpoint (sorry, bad english. not sure if this is what 
I wanted to say) on its own. And to orientate on check  'raise' we have to 
mark it somehow.
#3 Well, the code is shorter, obviously.

R. David Murray, yes, maybe confusing, but I can imagine many ways when it is 
very convenient.

--

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



[issue18570] OverflowError in division: wrong message

2013-08-03 Thread Terry J. Reedy

Terry J. Reedy added the comment:

With that fixed, I am inclined to close this.

--

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



[issue18642] enhancement for operator 'assert'

2013-08-03 Thread Al Korgun

Al Korgun added the comment:

Mark Dickinson, sorry, didn't answer the first questiuon.
 In your original message,  is it your intention that the assert raises 
 TypeError, or that it raises AssertionError?

I suggest to add the ability to raise relevant (for specific part of code) 
exception on checking assertion.

--

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



[issue18264] enum.IntEnum is not compatible with JSON serialisation

2013-08-03 Thread Ethan Furman

Ethan Furman added the comment:

Okay, patch attached with C code (thanks, Eli!), more python code, and some new 
tests.

Only the `int` case is handled.

--
Added file: http://bugs.python.org/file31141/issue18264.stoneleaf.01.patch

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



[issue18606] Add statistics module to standard library

2013-08-03 Thread Tshepang Lekhonkhobe

Changes by Tshepang Lekhonkhobe tshep...@gmail.com:


--
nosy: +tshepang

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



[issue18642] enhancement for operator 'assert'

2013-08-03 Thread mrDoctorWho0 .

mrDoctorWho0 . added the comment:

Assert with this feature will make code simplest. Simplification isn't python 
way? Why don't add it in python? It's must be really useful. Sometimes its 
necessary, when need to catch specified exception. Its easier to search errors 
by type, not by error body

--
nosy: +mrDoctorWho0..

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



[issue18606] Add statistics module to standard library

2013-08-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

Here is the use-case that was presented to support adding additional operations 
on timedelta objects:


I'm conducting a series of observation experiments where I
measure the duration of an event.  I then want to do various
statistical analysis such as computing the mean, median,
etc.  Originally, I tried using standard functions such as
lmean from the stats.py package.  However, these sorts of
functions divide by a float at the end, causing them to fail
on timedelta objects.  Thus, I have to either write my own
special functions, or convert the timedelta objects to
integers first (then convert them back afterwards).
  (Daniel Stutzbach, in msg26267 on issue1289118.)

The proposed statistics module does not support this use case:

 mean([timedelta(1)])
Traceback (most recent call last):
  File stdin, line 1, in module
  File /Users/sasha/Work/cpython-ro/Lib/statistics.py, line 387, in mean
total = sum(data)
  File /Users/sasha/Work/cpython-ro/Lib/statistics.py, line 223, in sum
total += x
TypeError: unsupported operand type(s) for +=: 'int' and 'datetime.timedelta'
 sum([timedelta(1)], timedelta(0))
Traceback (most recent call last):
  File stdin, line 1, in module
  File /Users/sasha/Work/cpython-ro/Lib/statistics.py, line 210, in sum
raise TypeError('sum only accepts numbers')
TypeError: sum only accepts numbers

--
nosy: +agthorr

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



[issue18642] enhancement for operator 'assert'

2013-08-03 Thread R. David Murray

R. David Murray added the comment:

If your code is catching an exception generated by an assert statement, your 
code is using assert incorrectly.  There is never any reason, as far as I can 
see, to catch an assert outside of a testing framework, and in a testing 
framework you definitely want to be catching an AssertionError when you are 
trying to catch an assert failing.  Making it some other error would just 
confuse the testing framework.

--

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



[issue18645] Add a configure option for performance guided optimization

2013-08-03 Thread Raymond Hettinger

New submission from Raymond Hettinger:

We can make it easier for users make custom, high-performance builds tailored 
to their actual use cases.

Here's an example of how Firefox does it:

https://developer.mozilla.org/en-US/docs/Building_with_Profile-Guided_Optimization

--
components: Build
messages: 194295
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Add a configure option for performance guided optimization
type: behavior
versions: Python 3.4

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



[issue18646] Improve tutorial entry on 'Lambda Forms'.

2013-08-03 Thread Terry J. Reedy

New submission from Terry J. Reedy:

[0. On mailing lists, 'lambda expression' is used rather than 'lambda form'. 
Docs use both. Consistency across docs is a broader issue than this one. So 
leave title alone for this one.]

1. (first sentence) By popular demand, a few features commonly found in 
functional programming languages like Lisp have been added to Python. (in 
early Python 1!) I think this should just be deleted. See 4. below as a 
replacement.

2.  With the lambda keyword, small anonymous functions can be created.
Change to
Small anonymous functions can be created with the lambda keyword.

3. change Here’s a function that returns to This function returns

3.5 add a sentence about the different between def and lambda (the name 
attribute.

4. Add sentences about the purposes of lambda. Add an example that illustrates 
passing functions. 

 pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
 pairs.sort(key=lambda pair: pair[1])
 pairs
[(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]

--
assignee: docs@python
components: Documentation
files: tut-lambda.diff
keywords: patch
messages: 194296
nosy: docs@python, terry.reedy
priority: normal
severity: normal
stage: patch review
status: open
title: Improve tutorial entry on 'Lambda Forms'.
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file31142/tut-lambda.diff

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



[issue18647] re.error: nothing to repeat

2013-08-03 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Now all doctests failed on 32-bit platforms due to the unlucky coincidence of 
my patch with at least two bugs which were hided before.

SubPattern.getwidth() is wrong, it truncates resulted values to sys.maxsize 
(should be MAXREPEAT). As side effect of my patch (on 32-bit MAXREPEAT == 
sys.maxsize) it now returns correct value in some cases on 32-bit platforms. On 
other hand, the _simple() function in sre_compile.py checks if getwidth() 
returns (0, MAXREPEAT) and raise an error in such case. Perhaps it should 
guards against such patterns as '(x*)*' (but it doesn't guards against 
'(x*y?)*' or '(x*y*)*' and can raise false positive). Now getwidth() returns 
(0, MAXREPEAT) for '(x*y?)*' on 32-bit platforms (this is a correct result) and 
triggers the check. The doctest module uses regular expression pattern 
'(?:.*$\n?)*' which now causes an error.

Definitely SubPattern.getwidth() is wrong and should be fixed. At least one of 
two, the _simple() function or doctest pattern should be fixed too. The 
simplest fix is disable the 'nothing to repeat' check.

--
assignee: serhiy.storchaka
components: Library (Lib), Regular Expressions
messages: 194297
nosy: ezio.melotti, larry, mrabarnett, pitrou, serhiy.storchaka
priority: normal
severity: normal
status: open
title: re.error: nothing to repeat
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4

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



[issue18647] re.error: nothing to repeat

2013-08-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c243896e12be by Serhiy Storchaka in branch '3.3':
Issue #18647: Temporary disable the nothing to repeat check to make buildbots 
happy.
http://hg.python.org/cpython/rev/c243896e12be

New changeset 4faf9b73c3df by Serhiy Storchaka in branch 'default':
Issue #18647: Temporary disable the nothing to repeat check to make buildbots 
happy.
http://hg.python.org/cpython/rev/4faf9b73c3df

--
nosy: +python-dev

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



[issue17998] internal error in regular expression engine

2013-08-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See issue18647.

--

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



[issue18635] Enum sets _member_type_ to instantiated values but not the class

2013-08-03 Thread Ethan Furman

Ethan Furman added the comment:

Well, aside from not having a clue as to what Chris is trying to do, should we 
make _member_type_ public?  The only reason I put it there was to aid 
introspection -- Enum does not use it.

--

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



[issue17119] Integer overflow when passing large string or tuple to Tkinter

2013-08-03 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
assignee:  - serhiy.storchaka

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



[issue18648] FP Howto and the PEP 8 lambda guildline

2013-08-03 Thread Terry J. Reedy

New submission from Terry J. Reedy:

Functional Programming HowTo, near the end, has a section
Small functions and the lambda expression
http://docs.python.org/3/howto/functional.html#small-functions-and-the-lambda-expression

To illustrate, it starts with
  adder = lambda x, y: x+y
  print_assign = lambda name, value: name + '=' + str(value)
which are now proscribed by PEP 8. Always use a def statement instead of an 
assignment statement that binds a lambda expression directly to a name.

The text goes on to give the def equivalents and to discourage lambdas. Which 
alternative is preferable? That’s a style question; my usual course is to avoid 
using lambda. But I think the section should instead start with lambda 
examples that would be acceptable in the stdlib.

--
messages: 194301
nosy: akuchling, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: FP Howto and the PEP 8 lambda guildline
versions: Python 2.7, Python 3.3, Python 3.4

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



[issue17478] Tkinter's split() inconsistent for bytes and unicode strings

2013-08-03 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
resolution:  - duplicate
stage:  - committed/rejected
status: open - closed
superseder:  - Tk.split() doesn't work with nested Unicode strings

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



[issue16741] `int()`, `float()`, etc think python strings are null-terminated

2013-08-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There is a test in test_unicode which expects an UnicodeError for 
int('\ud800'). Now it fails. Should we fix a test or int()?

--
resolution: fixed - 
status: closed - open

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



[issue18629] future division breaks timedelta division by integer

2013-08-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

This issue is effectively a duplicate #1083 (see msg101281.)

--

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



[issue16741] `int()`, `float()`, etc think python strings are null-terminated

2013-08-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

I'd say fix the test.  Raising ValueError is correct in this case.  
UnicodeError was an implementation artifact.

--
nosy: +belopolsky

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



[issue18635] Enum sets _member_type_ to instantiated values but not the class

2013-08-03 Thread Eli Bendersky

Eli Bendersky added the comment:

-1 on making more internals public.

--

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



[issue18649] list2cmdline function in subprocess module handles \ sequence wrong

2013-08-03 Thread Piotr Dobrogost

New submission from Piotr Dobrogost:

According to the docstring of list2cmdline function in subprocess module the 
sequence of a backslash followed by a double quote mark should denote double 
quote mark in the output string. However it's not the case

Python 2.7.4 (default, Apr  6 2013, 19:55:15) [MSC v.1500 64 bit (AMD64)] on 
win32
Type help, copyright, credits or license for more information.
 import subprocess
 print subprocess.list2cmdline(r'\1|2\')
\ \ 1 | 2 \ \

The same behavior is in Python 3.3.1.

See On Windows, how can I protect arguments to shell scripts using Python 2.7 
subprocess?(http://stackoverflow.com/q/4970194/95735) question on Stack 
Overflow.

--
components: Library (Lib)
messages: 194307
nosy: Arve.Knudsen, exarkun, piotr.dobrogost, r.david.murray
priority: normal
severity: normal
status: open
title: list2cmdline function in subprocess module handles \ sequence wrong
versions: Python 2.7, Python 3.3

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



[issue18264] enum.IntEnum is not compatible with JSON serialisation

2013-08-03 Thread Eli Bendersky

Eli Bendersky added the comment:

Posted a Rietveld code review

--

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



[issue8860] Rounding in timedelta constructor is inconsistent with that in timedelta arithmetics

2013-08-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

I cleaned up the patch a little:

1. Removed now unused static round_to_long() function.
2. Removed commented out code.

Mark,

Any reason not to apply this?  Do we need a NEWS entry for something like this?

--
priority: low - normal
stage: test needed - commit review
versions: +Python 3.4 -Python 3.2
Added file: http://bugs.python.org/file31143/issue8860a.patch

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



[issue18650] intermittent test_pydoc failure on 3.4.0a1

2013-08-03 Thread Ned Deily

New submission from Ned Deily:

Testing the 3.4.0a1 OS X 10.6 installer on OS X 10.8, I've now seen test_pydoc 
fail twice when the tests are run in order but then passing when the test is 
automatically rerun.  I've not seen this failure previously.

/usr/local/bin/python3.4 -m test -w -uall,-largefile== CPython 3.4.0a1 
(v3.4.0a1:46535f65e7f3, Aug 3 2013, 14:03:34) [GCC 4.2.1 (Apple Inc. build 
5666) (dot 3)]
==   Darwin-12.5.0-x86_64-i386-32bit little-endian
==   /private/var/folders/42/hjgpmmxd2wbcrzh4r9vsk_6hgr/T/test_python_3742
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, 
dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, 
verbose=0, bytes_warning=0, quiet=0, hash_randomization=1)
[  1/376] test_grammar
...
[250/376] test_pyclbr
[251/376] test_pydoc
test test_pydoc failed -- Traceback (most recent call last):
  File 
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/test/test_pydoc.py,
 line 624, in test_url_requests
self.assertEqual(result, title, text)
AssertionError: 'Pydoc: Error - ' != 'Pydoc: Index of Modules'
- Pydoc: Error -
+ Pydoc: Index of Modules
 : !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN
htmlheadtitlePydoc: Error - /title
meta http-equiv=Content-Type content=text/html; charset=utf-8
link rel=stylesheet type=text/css 
href=pydoc_data/_pydoc.css/headbody bgcolor=#f0f0f8
div style='float:left'
Python 3.4.0a1 [v3.4.0a1:46535f65e7f3, GCC 4.2.1 (Apple Inc. 
build 5666) (dot 3)]brDarwin-12.5.0
/div
div style='float:right'
div style='text-align:center'
  a href=index.htmlModule Index/a
  : a href=topics.htmlTopics/a
  : a href=keywords.htmlKeywords/a
/div
div
form action=get style='display:inline;'
  input type=text name=key size=15
  input type=submit value=Get
/formnbsp;
form action=search style='display:inline;'
  input type=text name=key size=15
  input type=submit value=Search
/form
/div
/div
div style=clear:both;padding-top:.5em;
table width=100% cellspacing=0 cellpadding=2 border=0 summary=heading
tr bgcolor=#7799ee
td valign=bottomnbsp;br
font color=#ff face=helvetica, 
arialnbsp;brbigbigstrongError/strong/big/big/font/td
td align=right valign=bottom
font color=#ff face=helvetica, arialnbsp;/font/td/tr/table
p
table width=100% cellspacing=0 cellpadding=2 border=0 summary=section
tr bgcolor=#bb
td colspan=3 valign=bottomnbsp;br
font color=#ff face=helvetica, 
arialbigstrong/strong/big/font/td/tr

trtd 
bgcolor=#bbttnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;/tt/tdtdnbsp;/td
td width=100%KeyError: 
'/Users/pyi/Library/Python/3.4/lib/python/site-packages/setuptools-0.9.8-py3.4.egg'
/td/tr/table/div
/body/html

[252/376/1] test_pyexpat
...
Re-running failed tests in verbose mode
Re-running test 'test_pydoc' in verbose mode
...
test_url_requests (test.test_pydoc.PydocUrlHandlerTest) ... ok
test_keywords (test.test_pydoc.TestHelper) ... ok

--
Ran 25 tests in 2.253s

OK

--
components: Tests
messages: 194309
nosy: ned.deily
priority: normal
severity: normal
status: open
title: intermittent test_pydoc failure on 3.4.0a1
versions: Python 3.4

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



[issue16741] `int()`, `float()`, etc think python strings are null-terminated

2013-08-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7b023134ad83 by Serhiy Storchaka in branch '3.3':
Issue #16741: Remove testing of implementation artifact.
http://hg.python.org/cpython/rev/7b023134ad83

New changeset 1b4772ab420f by Serhiy Storchaka in branch 'default':
Issue #16741: Remove testing of implementation artifact.
http://hg.python.org/cpython/rev/1b4772ab420f

--

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



[issue3591] elementtree tests do not include bytes handling

2013-08-03 Thread Eli Bendersky

Changes by Eli Bendersky eli...@gmail.com:


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

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



[issue8860] Rounding in timedelta constructor is inconsistent with that in timedelta arithmetics

2013-08-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

With the current patch we still have the following quirks:

 timedelta(seconds=0.6112295) == timedelta(seconds=1)*0.6112295
False
 timedelta(seconds=0.6112295) == timedelta(seconds=round(0.6112295, 6))
False

This is not a reason to hold the patch, though.

--

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



[issue13368] Possible problem in documentation of module subprocess, method send_signal

2013-08-03 Thread Eli Bendersky

Eli Bendersky added the comment:

Brian - gentle ping

--

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



[issue17372] provide pretty printer for xml.etree.ElementTree

2013-08-03 Thread Eli Bendersky

Eli Bendersky added the comment:

I've noticed this is a duplicate of issue #14465. Closing it - let's continue 
the discussion there, when the time comes.

--
resolution:  - duplicate
stage: needs patch - committed/rejected
status: open - closed
superseder:  - xml.etree.ElementTree: add feature to prettify XML output

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



[issue14465] xml.etree.ElementTree: add feature to prettify XML output

2013-08-03 Thread Eli Bendersky

Eli Bendersky added the comment:

A patch exists in the duplicate #17372

--

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



[issue18647] re.error: nothing to repeat

2013-08-03 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/issue18647
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18647] re.error: nothing to repeat

2013-08-03 Thread Tim Peters

Changes by Tim Peters tim.pet...@gmail.com:


--
nosy: +tim_one

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



[issue7990] xml.etree.cElementTree lacks full dir() on Element

2013-08-03 Thread Eli Bendersky

Eli Bendersky added the comment:

Could you please refresh the patch for Python 3.3 and 3.4 (_elementtree went 
through many changes in 3.3)?

--

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



[issue17011] ElementPath ignores different namespace mappings for the same path expression

2013-08-03 Thread Eli Bendersky

Eli Bendersky added the comment:

Fixed. Thanks!

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

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



[issue17011] ElementPath ignores different namespace mappings for the same path expression

2013-08-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 854ded9135c2 by Eli Bendersky in branch '3.3':
Issue #17011: Fix caching of xpath path when namespaces are present.
http://hg.python.org/cpython/rev/854ded9135c2

New changeset ce0be0d03c0a by Eli Bendersky in branch 'default':
Merge fix for Issue #17011 from 3.3
http://hg.python.org/cpython/rev/ce0be0d03c0a

--
nosy: +python-dev

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



[issue17359] Mention __main__.py explicitly in command line docs

2013-08-03 Thread Eli Bendersky

Changes by Eli Bendersky eli...@gmail.com:


--
nosy:  -eli.bendersky

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



[issue18268] ElementTree.fromstring non-deterministically gives unicode text data

2013-08-03 Thread Eli Bendersky

Eli Bendersky added the comment:

I'm not sure what the issue here is, exactly. Python 2.7 is known for implicit 
conversions between ascii and unicode, and this appears to be an artifact of 
your data. Note that Python 2.7 only gets fixes for serious bugs at this point.

Can you reproduce this problem with Python 3.3? More generally, can you provide 
a small reproducer? Without this I don't think this is a constructive report, 
and will close the issue in a few days.

--

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



[issue17963] Deprecate the frame hack for implicitly getting module details

2013-08-03 Thread Eli Bendersky

Eli Bendersky added the comment:

I'm (somewhat) back looking at this. Should the first step be 
sys.get_calling_module_name()? I can provide a patch. Re its name, perhaps the 
long name isn't that bad given that this is a rather obscure API. But 
suggestions for something shorter/better will be welcome.

--

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



[issue18648] FP Howto and the PEP 8 lambda guildline

2013-08-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

I would just change my usual course is to avoid using lambda to PEP 8 
prescribes using def.  Note that PEP 8 itself displays f = lambda x: 2*x as an 
example of what not to do.  I see no problem with the current examples.

--
nosy: +belopolsky

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



[issue18606] Add statistics module to standard library

2013-08-03 Thread Steven D'Aprano

Steven D'Aprano added the comment:

On 04/08/13 05:31, Alexander Belopolsky wrote:

 Alexander Belopolsky added the comment:

 Here is the use-case that was presented to support adding additional 
 operations on timedelta objects:

 
 I'm conducting a series of observation experiments where I
 measure the duration of an event.  I then want to do various
 statistical analysis such as computing the mean, median,
 etc.  Originally, I tried using standard functions such as
 lmean from the stats.py package.  However, these sorts of
 functions divide by a float at the end, causing them to fail
 on timedelta objects.  Thus, I have to either write my own
 special functions, or convert the timedelta objects to
 integers first (then convert them back afterwards).
   (Daniel Stutzbach, in msg26267 on issue1289118.)

 The proposed statistics module does not support this use case:
[...]
 TypeError: sum only accepts numbers

That's a nice use-case, but I'm not sure how to solve it, or whether it needs 
to be.

I'm not going to add support for timedelta objects as a special-case. Once we 
start special-casing types, where will it end?

At first I thought that registering timedelta as a numeric type would help, but 
that is a slightly dubious thing to do since timedelta doesn't support all 
numeric operations:

py datetime.timedelta(1, 1, 1)+2
Traceback (most recent call last):
   File stdin, line 1, in module
TypeError: unsupported operand type(s) for +: 'datetime.timedelta' and 'int'

(What would that mean, anyway? Add two days, two seconds, or two milliseconds?)

Perhaps timedelta objects should be enhanced to be (Integral?) numbers. In the 
meantime, there's a simple way to do this:

py from datetime import timedelta as td
py data = [td(2), td(1), td(3), td(4)]
py m = statistics.mean([x.total_seconds() for x in data])
py m
216000.0
py td(seconds=m)
datetime.timedelta(2, 43200)

And for standard deviation:

py s = statistics.stdev([x.total_seconds() for x in data])
py td(seconds=s)
datetime.timedelta(1, 25141, 920371)

median works without any wrapper:

py statistics.median(data)
datetime.timedelta(2, 43200)

I'm now leaning towards will not fix for supporting timedelta objects. If 
they become proper numbers, then they should just work, and if they don't, 
supporting them just requires a tiny bit of extra code.

However, I will add documentation and tests for them.

--

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



[issue18606] Add statistics module to standard library

2013-08-03 Thread Christian Heimes

Changes by Christian Heimes li...@cheimes.de:


--
nosy: +christian.heimes

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



[issue18264] enum.IntEnum is not compatible with JSON serialisation

2013-08-03 Thread Nick Coghlan

Nick Coghlan added the comment:

It occurs to me that operator.index() (without a preceding type check) is
likely the more ducktyping friendly option here.

--

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



  1   2   >