Re: [Python-Dev] Real-world use of Counter
On 6 Nov 2014 06:53, "Alexander Belopolsky" wrote: > > > On Wed, Nov 5, 2014 at 2:47 PM, R. David Murray wrote: >> >> As I said on the issue, there is no reason I can see to add extra code >> just to turn an AttributeError into a TypeError. The AttributeError >> works just fine in letting you know your input type didn't work. > > > +1 > > Unlike ValueError or LookupError, TypeError and AttributeError indicate a logical problem with the code rather than an issue with the user input. >From the programmer perspective, any code that catches and mutates exceptions is a nuisance. Right. Especially in a ducktyping context, AttributeError and TypeError are often functionally equivalent - it usually isn't worthwhile adding code specifically to turn one into the other. The case that doesn't throw an exception at all seems a little strange, but I haven't looked into the details. Regards, Nick. > > ___ > Python-Dev mailing list > Python-Dev@python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com > ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [Python-checkins] cpython (2.7): #22650: test suite: load Unicode test data files from www.pythontest.net
What is pythontest.net? Is it something we control, and if so how do we add things to it for tests? Did I miss an email on python-dev or python-committers about this? On Thu Nov 06 2014 at 8:57:22 AM georg.brandl wrote: > https://hg.python.org/cpython/rev/0af36ea1d010 > changeset: 93417:0af36ea1d010 > branch: 2.7 > parent: 93401:3e8d3c4bc17e > user:Georg Brandl > date:Thu Nov 06 14:37:49 2014 +0100 > summary: > #22650: test suite: load Unicode test data files from www.pythontest.net > > files: > Lib/test/test_codecmaps_cn.py | 8 +++- > Lib/test/test_codecmaps_hk.py | 2 +- > Lib/test/test_codecmaps_jp.py | 12 +--- > Lib/test/test_codecmaps_kr.py | 8 +++- > Lib/test/test_codecmaps_tw.py | 6 ++ > Lib/test/test_normalization.py | 2 +- > 6 files changed, 15 insertions(+), 23 deletions(-) > > > diff --git a/Lib/test/test_codecmaps_cn.py b/Lib/test/test_codecmaps_cn.py > --- a/Lib/test/test_codecmaps_cn.py > +++ b/Lib/test/test_codecmaps_cn.py > @@ -10,19 +10,17 @@ > class TestGB2312Map(test_multibytecodec_support.TestBase_Mapping, > unittest.TestCase): > encoding = 'gb2312' > -mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-CN.TXT' > +mapfileurl = 'http://www.pythontest.net/unicode/EUC-CN.TXT' > > class TestGBKMap(test_multibytecodec_support.TestBase_Mapping, > unittest.TestCase): > encoding = 'gbk' > -mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/VENDORS/' \ > - 'MICSFT/WINDOWS/CP936.TXT' > +mapfileurl = 'http://www.pythontest.net/unicode/CP936.TXT' > > class TestGB18030Map(test_multibytecodec_support.TestBase_Mapping, > unittest.TestCase): > encoding = 'gb18030' > -mapfileurl = 'http://source.icu-project.org/repos/icu/data/' \ > - 'trunk/charset/data/xml/gb-18030-2000.xml' > +mapfileurl = 'http://www.pythontest.net/unicode/gb-18030-2000.xml' > > > def test_main(): > diff --git a/Lib/test/test_codecmaps_hk.py b/Lib/test/test_codecmaps_hk.py > --- a/Lib/test/test_codecmaps_hk.py > +++ b/Lib/test/test_codecmaps_hk.py > @@ -10,7 +10,7 @@ > class TestBig5HKSCSMap(test_multibytecodec_support.TestBase_Mapping, > unittest.TestCase): > encoding = 'big5hkscs' > -mapfileurl = 'http://people.freebsd.org/~ > perky/i18n/BIG5HKSCS-2004.TXT' > +mapfileurl = 'http://www.pythontest.net/unicode/BIG5HKSCS-2004.TXT' > > def test_main(): > test_support.run_unittest(__name__) > diff --git a/Lib/test/test_codecmaps_jp.py b/Lib/test/test_codecmaps_jp.py > --- a/Lib/test/test_codecmaps_jp.py > +++ b/Lib/test/test_codecmaps_jp.py > @@ -10,8 +10,7 @@ > class TestCP932Map(test_multibytecodec_support.TestBase_Mapping, > unittest.TestCase): > encoding = 'cp932' > -mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/' > \ > - 'WINDOWS/CP932.TXT' > +mapfileurl = 'http://www.pythontest.net/unicode/CP932.TXT' > supmaps = [ > ('\x80', u'\u0080'), > ('\xa0', u'\uf8f0'), > @@ -27,15 +26,14 @@ > unittest.TestCase): > encoding = 'euc_jp' > mapfilename = 'EUC-JP.TXT' > -mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JP.TXT' > +mapfileurl = 'http://www.pythontest.net/unicode/EUC-JP.TXT' > > > class TestSJISCOMPATMap(test_multibytecodec_support.TestBase_Mapping, > unittest.TestCase): > encoding = 'shift_jis' > mapfilename = 'SHIFTJIS.TXT' > -mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/OBSOLETE' \ > - '/EASTASIA/JIS/SHIFTJIS.TXT' > +mapfileurl = 'http://www.pythontest.net/unicode/SHIFTJIS.TXT' > pass_enctest = [ > ('\x81_', u'\\'), > ] > @@ -49,14 +47,14 @@ > unittest.TestCase): > encoding = 'euc_jisx0213' > mapfilename = 'EUC-JISX0213.TXT' > -mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JISX0213.TXT' > +mapfileurl = 'http://www.pythontest.net/unicode/EUC-JISX0213.TXT' > > > class TestSJISX0213Map(test_multibytecodec_support.TestBase_Mapping, > unittest.TestCase): > encoding = 'shift_jisx0213' > mapfilename = 'SHIFT_JISX0213.TXT' > -mapfileurl = 'http://people.freebsd.org/~ > perky/i18n/SHIFT_JISX0213.TXT' > +mapfileurl = 'http://www.pythontest.net/unicode/SHIFT_JISX0213.TXT' > > > def test_main(): > diff --git a/Lib/test/test_codecmaps_kr.py b/Lib/test/test_codecmaps_kr.py > --- a/Lib/test/test_codecmaps_kr.py > +++ b/Lib/test/test_codecmaps_kr.py > @@ -10,14 +10,13 @@ > class TestCP949Map(test_multibytecodec_support.TestBase_Mapping, > unittest.TestCase): > encoding = 'cp949' > -mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT' > \ > - '/WINDOWS/CP949.TXT' > +mapfileurl = 'http://www.py
Re: [Python-Dev] [Python-checkins] cpython (2.7): #22650: test suite: load Unicode test data files from www.pythontest.net
On Thu, Nov 6, 2014, at 09:39, Brett Cannon wrote: > What is pythontest.net? Is it something we control, and if so how do we > add > things to it for tests? Did I miss an email on python-dev or > python-committers about this? See https://bugs.python.org/issue22650 > > On Thu Nov 06 2014 at 8:57:22 AM georg.brandl > > wrote: > > > https://hg.python.org/cpython/rev/0af36ea1d010 > > changeset: 93417:0af36ea1d010 > > branch: 2.7 > > parent: 93401:3e8d3c4bc17e > > user:Georg Brandl > > date:Thu Nov 06 14:37:49 2014 +0100 > > summary: > > #22650: test suite: load Unicode test data files from www.pythontest.net > > > > files: > > Lib/test/test_codecmaps_cn.py | 8 +++- > > Lib/test/test_codecmaps_hk.py | 2 +- > > Lib/test/test_codecmaps_jp.py | 12 +--- > > Lib/test/test_codecmaps_kr.py | 8 +++- > > Lib/test/test_codecmaps_tw.py | 6 ++ > > Lib/test/test_normalization.py | 2 +- > > 6 files changed, 15 insertions(+), 23 deletions(-) > > > > > > diff --git a/Lib/test/test_codecmaps_cn.py b/Lib/test/test_codecmaps_cn.py > > --- a/Lib/test/test_codecmaps_cn.py > > +++ b/Lib/test/test_codecmaps_cn.py > > @@ -10,19 +10,17 @@ > > class TestGB2312Map(test_multibytecodec_support.TestBase_Mapping, > > unittest.TestCase): > > encoding = 'gb2312' > > -mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-CN.TXT' > > +mapfileurl = 'http://www.pythontest.net/unicode/EUC-CN.TXT' > > > > class TestGBKMap(test_multibytecodec_support.TestBase_Mapping, > > unittest.TestCase): > > encoding = 'gbk' > > -mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/VENDORS/' \ > > - 'MICSFT/WINDOWS/CP936.TXT' > > +mapfileurl = 'http://www.pythontest.net/unicode/CP936.TXT' > > > > class TestGB18030Map(test_multibytecodec_support.TestBase_Mapping, > > unittest.TestCase): > > encoding = 'gb18030' > > -mapfileurl = 'http://source.icu-project.org/repos/icu/data/' \ > > - 'trunk/charset/data/xml/gb-18030-2000.xml' > > +mapfileurl = 'http://www.pythontest.net/unicode/gb-18030-2000.xml' > > > > > > def test_main(): > > diff --git a/Lib/test/test_codecmaps_hk.py b/Lib/test/test_codecmaps_hk.py > > --- a/Lib/test/test_codecmaps_hk.py > > +++ b/Lib/test/test_codecmaps_hk.py > > @@ -10,7 +10,7 @@ > > class TestBig5HKSCSMap(test_multibytecodec_support.TestBase_Mapping, > > unittest.TestCase): > > encoding = 'big5hkscs' > > -mapfileurl = 'http://people.freebsd.org/~ > > perky/i18n/BIG5HKSCS-2004.TXT' > > +mapfileurl = 'http://www.pythontest.net/unicode/BIG5HKSCS-2004.TXT' > > > > def test_main(): > > test_support.run_unittest(__name__) > > diff --git a/Lib/test/test_codecmaps_jp.py b/Lib/test/test_codecmaps_jp.py > > --- a/Lib/test/test_codecmaps_jp.py > > +++ b/Lib/test/test_codecmaps_jp.py > > @@ -10,8 +10,7 @@ > > class TestCP932Map(test_multibytecodec_support.TestBase_Mapping, > > unittest.TestCase): > > encoding = 'cp932' > > -mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/' > > \ > > - 'WINDOWS/CP932.TXT' > > +mapfileurl = 'http://www.pythontest.net/unicode/CP932.TXT' > > supmaps = [ > > ('\x80', u'\u0080'), > > ('\xa0', u'\uf8f0'), > > @@ -27,15 +26,14 @@ > > unittest.TestCase): > > encoding = 'euc_jp' > > mapfilename = 'EUC-JP.TXT' > > -mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JP.TXT' > > +mapfileurl = 'http://www.pythontest.net/unicode/EUC-JP.TXT' > > > > > > class TestSJISCOMPATMap(test_multibytecodec_support.TestBase_Mapping, > > unittest.TestCase): > > encoding = 'shift_jis' > > mapfilename = 'SHIFTJIS.TXT' > > -mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/OBSOLETE' \ > > - '/EASTASIA/JIS/SHIFTJIS.TXT' > > +mapfileurl = 'http://www.pythontest.net/unicode/SHIFTJIS.TXT' > > pass_enctest = [ > > ('\x81_', u'\\'), > > ] > > @@ -49,14 +47,14 @@ > > unittest.TestCase): > > encoding = 'euc_jisx0213' > > mapfilename = 'EUC-JISX0213.TXT' > > -mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JISX0213.TXT' > > +mapfileurl = 'http://www.pythontest.net/unicode/EUC-JISX0213.TXT' > > > > > > class TestSJISX0213Map(test_multibytecodec_support.TestBase_Mapping, > > unittest.TestCase): > > encoding = 'shift_jisx0213' > > mapfilename = 'SHIFT_JISX0213.TXT' > > -mapfileurl = 'http://people.freebsd.org/~ > > perky/i18n/SHIFT_JISX0213.TXT' > > +mapfileurl = 'http://www.pythontest.net/unicode/SHIFT_JISX0213.TXT' > > > > > > def test_main(): > > diff --git a/Lib/test/test_codecmaps_kr.py b/Lib/test/test_codecmaps_kr.py > > --- a/Lib/test/test_codecmaps_kr.py > > +++ b/Lib/test/
Re: [Python-Dev] [Python-checkins] cpython (2.7): #22650: test suite: load Unicode test data files from www.pythontest.net
On 06.11.2014 15:39, Brett Cannon wrote: > What is pythontest.net? Is it something we control, and if so how do we add > things to it for tests? Did I miss an email on python-dev or > python-committers about this? pythontest.net is a domain owned by the PSF and run by Donald Stufft and Benjamin (I believe). https://bugs.python.org/issue22650 has the details. > On Thu Nov 06 2014 at 8:57:22 AM georg.brandl > wrote: > >> https://hg.python.org/cpython/rev/0af36ea1d010 >> changeset: 93417:0af36ea1d010 >> branch: 2.7 >> parent: 93401:3e8d3c4bc17e >> user:Georg Brandl >> date:Thu Nov 06 14:37:49 2014 +0100 >> summary: >> #22650: test suite: load Unicode test data files from www.pythontest.net -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Nov 06 2014) >>> Python Projects, Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ 2014-10-24: Released eGenix pyOpenSSL 0.13.5 ... http://egenix.com/go63 : Try our mxODBC.Connect Python Database Interface for free ! :: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Real-world use of Counter
On Thu, Nov 6, 2014 at 1:10 AM, Nick Coghlan wrote: > Right. Especially in a ducktyping context, AttributeError and TypeError > are often functionally equivalent - it usually isn't worthwhile adding code > specifically to turn one into the other. > Yeah, these are so often interchangeable that I wish they had a common ancestor. Then again when you are catching these you might as well be catching all exceptions. > The case that doesn't throw an exception at all seems a little strange, > but I haven't looked into the details. > It comes from a simple approach to creating an intersection; paraphrasing, the code does this: def intesection(a, b): result = set() for x in a: if x in b: result.add(x) return result If a is empty this never looks at b. I think it's okay not to raise in this case (though it would also be okay if it *did* raise). -- --Guido van Rossum (python.org/~guido) ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] [Python-checkins] cpython (2.7): #22650: test suite: load Unicode test data files from www.pythontest.net
Ah, cool! Just an FYI, the index.html file is not being served for me. -Brett On Thu Nov 06 2014 at 9:41:59 AM Benjamin Peterson wrote: > > > On Thu, Nov 6, 2014, at 09:39, Brett Cannon wrote: > > What is pythontest.net? Is it something we control, and if so how do we > > add > > things to it for tests? Did I miss an email on python-dev or > > python-committers about this? > > See https://bugs.python.org/issue22650 > > > > > On Thu Nov 06 2014 at 8:57:22 AM georg.brandl > > > > wrote: > > > > > https://hg.python.org/cpython/rev/0af36ea1d010 > > > changeset: 93417:0af36ea1d010 > > > branch: 2.7 > > > parent: 93401:3e8d3c4bc17e > > > user:Georg Brandl > > > date:Thu Nov 06 14:37:49 2014 +0100 > > > summary: > > > #22650: test suite: load Unicode test data files from > www.pythontest.net > > > > > > files: > > > Lib/test/test_codecmaps_cn.py | 8 +++- > > > Lib/test/test_codecmaps_hk.py | 2 +- > > > Lib/test/test_codecmaps_jp.py | 12 +--- > > > Lib/test/test_codecmaps_kr.py | 8 +++- > > > Lib/test/test_codecmaps_tw.py | 6 ++ > > > Lib/test/test_normalization.py | 2 +- > > > 6 files changed, 15 insertions(+), 23 deletions(-) > > > > > > > > > diff --git a/Lib/test/test_codecmaps_cn.py > b/Lib/test/test_codecmaps_cn.py > > > --- a/Lib/test/test_codecmaps_cn.py > > > +++ b/Lib/test/test_codecmaps_cn.py > > > @@ -10,19 +10,17 @@ > > > class TestGB2312Map(test_multibytecodec_support.TestBase_Mapping, > > > unittest.TestCase): > > > encoding = 'gb2312' > > > -mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-CN.TXT' > > > +mapfileurl = 'http://www.pythontest.net/unicode/EUC-CN.TXT' > > > > > > class TestGBKMap(test_multibytecodec_support.TestBase_Mapping, > > > unittest.TestCase): > > > encoding = 'gbk' > > > -mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/VENDORS/' \ > > > - 'MICSFT/WINDOWS/CP936.TXT' > > > +mapfileurl = 'http://www.pythontest.net/unicode/CP936.TXT' > > > > > > class TestGB18030Map(test_multibytecodec_support.TestBase_Mapping, > > > unittest.TestCase): > > > encoding = 'gb18030' > > > -mapfileurl = 'http://source.icu-project.org/repos/icu/data/' \ > > > - 'trunk/charset/data/xml/gb-18030-2000.xml' > > > +mapfileurl = 'http://www.pythontest.net/unicode/gb-18030-2000.xml > ' > > > > > > > > > def test_main(): > > > diff --git a/Lib/test/test_codecmaps_hk.py > b/Lib/test/test_codecmaps_hk.py > > > --- a/Lib/test/test_codecmaps_hk.py > > > +++ b/Lib/test/test_codecmaps_hk.py > > > @@ -10,7 +10,7 @@ > > > class TestBig5HKSCSMap(test_multibytecodec_support.TestBase_Mapping, > > > unittest.TestCase): > > > encoding = 'big5hkscs' > > > -mapfileurl = 'http://people.freebsd.org/~ > > > perky/i18n/BIG5HKSCS-2004.TXT' > > > +mapfileurl = 'http://www.pythontest.net/uni > code/BIG5HKSCS-2004.TXT' > > > > > > def test_main(): > > > test_support.run_unittest(__name__) > > > diff --git a/Lib/test/test_codecmaps_jp.py > b/Lib/test/test_codecmaps_jp.py > > > --- a/Lib/test/test_codecmaps_jp.py > > > +++ b/Lib/test/test_codecmaps_jp.py > > > @@ -10,8 +10,7 @@ > > > class TestCP932Map(test_multibytecodec_support.TestBase_Mapping, > > > unittest.TestCase): > > > encoding = 'cp932' > > > -mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/VENDORS/ > MICSFT/' > > > \ > > > - 'WINDOWS/CP932.TXT' > > > +mapfileurl = 'http://www.pythontest.net/unicode/CP932.TXT' > > > supmaps = [ > > > ('\x80', u'\u0080'), > > > ('\xa0', u'\uf8f0'), > > > @@ -27,15 +26,14 @@ > > > unittest.TestCase): > > > encoding = 'euc_jp' > > > mapfilename = 'EUC-JP.TXT' > > > -mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-JP.TXT' > > > +mapfileurl = 'http://www.pythontest.net/unicode/EUC-JP.TXT' > > > > > > > > > class TestSJISCOMPATMap(test_multibytecodec_support.TestBase_Mapping, > > > unittest.TestCase): > > > encoding = 'shift_jis' > > > mapfilename = 'SHIFTJIS.TXT' > > > -mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/OBSOLETE' \ > > > - '/EASTASIA/JIS/SHIFTJIS.TXT' > > > +mapfileurl = 'http://www.pythontest.net/unicode/SHIFTJIS.TXT' > > > pass_enctest = [ > > > ('\x81_', u'\\'), > > > ] > > > @@ -49,14 +47,14 @@ > > > unittest.TestCase): > > > encoding = 'euc_jisx0213' > > > mapfilename = 'EUC-JISX0213.TXT' > > > -mapfileurl = 'http://people.freebsd.org/~pe > rky/i18n/EUC-JISX0213.TXT' > > > +mapfileurl = 'http://www.pythontest.net/unicode/EUC-JISX0213.TXT' > > > > > > > > > class TestSJISX0213Map(test_multibytecodec_support.TestBase_Mapping, > > > unittest.TestCase): > > > encoding = 'shift
Re: [Python-Dev] [Python-checkins] cpython (2.7): #22650: test suite: load Unicode test data files from www.pythontest.net
On Thu, Nov 6, 2014, at 10:41, Brett Cannon wrote: > Ah, cool! Just an FYI, the index.html file is not being served for me. At the moment it's only served on www. ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com