[issue10073] calendar.isleap() not checking parameter type

2010-10-19 Thread Boštjan Mejak
Boštjan Mejak bostjan.me...@gmail.com added the comment: I have read the Zen of PYthon before. I have also written a typo report. But got rejected. No one listens to my ideas. So why do you have a bug tracker anyway? On Tue, Oct 19, 2010 at 6:46 AM, Éric Araujo rep...@bugs.python.org wrote:

[issue10073] calendar.isleap() not checking parameter type

2010-10-19 Thread Alexander Belopolsky
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: Removed file: http://bugs.python.org/file19283/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073 ___

[issue10073] calendar.isleap() not checking parameter type

2010-10-19 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: On Tue, Oct 19, 2010 at 12:34 PM, Boštjan Mejak rep...@bugs.python.org wrote: I have also written a typo report. But got rejected. No one listens to my ideas. So why do you have a bug tracker anyway? Bug tracker is not

[issue10073] calendar.isleap() not checking parameter type

2010-10-19 Thread Boštjan Mejak
Boštjan Mejak bostjan.me...@gmail.com added the comment: your change to the parentheses changes the semantics. (Georg Brandl) How does adding those parens change semantics? The behaviour of the function isleap() is the same. I have throughtly tested this function and found no semantic errors

[issue10073] calendar.isleap() not checking parameter type

2010-10-19 Thread Boštjan Mejak
Changes by Boštjan Mejak bostjan.me...@gmail.com: Removed file: http://bugs.python.org/file19284/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073 ___

[issue10073] calendar.isleap() not checking parameter type

2010-10-19 Thread Boštjan Mejak
Changes by Boštjan Mejak bostjan.me...@gmail.com: Removed file: http://bugs.python.org/file19275/calendar-isleap.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073 ___

[issue10073] calendar.isleap() not checking parameter type

2010-10-19 Thread Boštjan Mejak
Boštjan Mejak bostjan.me...@gmail.com added the comment: I am applying a patch that only fixes the docstrings to match the return value of calendar.isleap(). The return value of isleap() is not 1 or 0 -- it is True or False. Please apply the patch. Thank you. -- Added file:

[issue10073] calendar.isleap() not checking parameter type

2010-10-19 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: Committed the docstring patch in r85725. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073 ___

[issue10073] calendar.isleap() not checking parameter type

2010-10-19 Thread Boštjan Mejak
Boštjan Mejak bostjan.me...@gmail.com added the comment: Thank you for applying my patch. Glad to help. Please apply it to the trunk and other branches as well. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073

[issue10073] calendar.isleap() not checking parameter type

2010-10-19 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: It will be merged in due time. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073 ___ ___

[issue10073] calendar.isleap() not checking parameter type

2010-10-19 Thread Éric Araujo
Éric Araujo mer...@netwok.org added the comment: How does adding those parens change semantics? It changes boolean evaluation paths. See for example http://docs.python.org/py3k/reference/expressions#boolean-operations . If you have more questions, python-list is an open and friendly mailing

[issue10073] calendar.isleap() not checking parameter type

2010-10-18 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: On Sun, Oct 17, 2010 at 3:54 PM, Boštjan Mejak rep...@bugs.python.org wrote: .. About the  if year == 0  check... Well, read Wikipedia's article   http://en.wikipedia.org/wiki/0_(year)  which clearly states that Year

[issue10073] calendar.isleap() not checking parameter type

2010-10-18 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: The most pedantic implementation of calendar.isleap() would be from datetime import date, timedelta def isleap(year): return date(year, 3, 1) - date(year, 2, 1) == timedelta(29) Since python calendar only supports

[issue10073] calendar.isleap() not checking parameter type

2010-10-18 Thread Georg Brandl
Changes by Georg Brandl ge...@python.org: -- nosy: -georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073 ___ ___ Python-bugs-list

[issue10073] calendar.isleap() not checking parameter type

2010-10-18 Thread Boštjan Mejak
Boštjan Mejak bostjan.me...@gmail.com added the comment: Also, your pedantic version of isleap() is not pedantic at all. return date(year, 3, 1) - date(year, 2, 1) == timedelta(29) does not seem readable at all. Readability counts! return date(year, 3, 1) is not understandable. What are the

[issue10073] calendar.isleap() not checking parameter type

2010-10-18 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: return date(year, 3, 1) is not understandable. What are the arguments 3 and 1 in the date() function for? Boštjan, we appreciate your concern for the programming style of the Python standard library. However, your question shows that you

[issue10073] calendar.isleap() not checking parameter type

2010-10-18 Thread Boštjan Mejak
Boštjan Mejak bostjan.me...@gmail.com added the comment: else: --ndays = (date(year, month + 1, 1) - first).days return first.weekday(), ndays Oh my God! The line with a pointer is so ugly! On Mon, Oct 18, 2010 at 7:59 PM, Alexander Belopolsky rep...@bugs.python.org wrote:

[issue10073] calendar.isleap() not checking parameter type

2010-10-18 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: I don't think anything good will come out of this. Closing as rejected. -- resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org

[issue10073] calendar.isleap() not checking parameter type

2010-10-18 Thread Alexander Belopolsky
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: Removed file: http://bugs.python.org/file19267/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073 ___

[issue10073] calendar.isleap() not checking parameter type

2010-10-18 Thread Alexander Belopolsky
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: Removed file: http://bugs.python.org/file19268/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073 ___

[issue10073] calendar.isleap() not checking parameter type

2010-10-18 Thread Boštjan Mejak
Changes by Boštjan Mejak bostjan.me...@gmail.com: Removed file: http://bugs.python.org/file19255/calendar-isleap.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073 ___

[issue10073] calendar.isleap() not checking parameter type

2010-10-18 Thread Boštjan Mejak
Boštjan Mejak bostjan.me...@gmail.com added the comment: I have uploaded a new patch. It removes the if year == 0 nonsense. Check it out. I hope you like it now. When you were organizing the Standard Library, you didn't fix flaws in the calendar module. What I have in mind is, for example,

[issue10073] calendar.isleap() not checking parameter type

2010-10-18 Thread Philip Jenvey
Changes by Philip Jenvey pjen...@underboss.org: -- nosy: -pjenvey ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073 ___ ___ Python-bugs-list

[issue10073] calendar.isleap() not checking parameter type

2010-10-18 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: Not only is this issue already closed, the patch is also wrong -- your change to the parentheses changes the semantics. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073

[issue10073] calendar.isleap() not checking parameter type

2010-10-18 Thread Éric Araujo
Éric Araujo mer...@netwok.org added the comment: for example, the isleap() function which should be defined as is_leap() Who says that? Not PEP 8: “Function names should be lowercase, with words separated by underscores *as necessary to improve readability*” (emphasis mine). isleap is

[issue10073] calendar.isleap() not checking parameter type

2010-10-17 Thread Boštjan Mejak
Boštjan Mejak bostjan.me...@gmail.com added the comment: Let me fix this function a little bit... def isleap(year): Return True for leap years, False for non-leap years. if year == 0: raise ValueError('year 0 does not exist') return (year % 4 == 0) and (year % 100 != 0) or

[issue10073] calendar.isleap() not checking parameter type

2010-10-16 Thread Retro
Retro vinet...@gmail.com added the comment: Please leave this function as is because it works just fine. calendar.isleap(2011) False The argument for isleap() must not be in quotes. That's all. -- nosy: +Retro ___ Python tracker

[issue10073] calendar.isleap() not checking parameter type

2010-10-16 Thread Retro
Retro vinet...@gmail.com added the comment: I would just add an exception to the isleap() function. def isleap(year): Return 1 for leap years, 0 for non-leap years. try: return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) except TypeError: # somehow inform

[issue10073] calendar.isleap() not checking parameter type

2010-10-15 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: I don't see the point. If you file one such bug per day, you won't be finished in a year -- there's no reason to start adding typechecking in this function. -- nosy: +georg.brandl ___ Python tracker

[issue10073] calendar.isleap() not checking parameter type

2010-10-15 Thread Terry J. Reedy
Terry J. Reedy tjre...@udel.edu added the comment: To me, Alexander's example calendar.isleap(%d) False is a buggy result. So I would reclassify the issue. The rationale for not checking input types is that bad types result in an error, but that does not happen here due to a design

[issue10073] calendar.isleap() not checking parameter type

2010-10-15 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: To me, Alexander's example calendar.isleap(%d) False is a buggy result. So I would reclassify the issue. You'll always find plenty wrong inputs for which a function doesn't raise an exception. That's the downside of duck typing. The

[issue10073] calendar.isleap() not checking parameter type

2010-10-12 Thread AM Helin
New submission from AM Helin shadi...@gmail.com: calendar.isleap() doesn't enforce any types, leading to string formatting errors when a string is passed to it: calendar.isleap(2011) Traceback (most recent call last): File stdin, line 1, in module File

[issue10073] calendar.isleap() not checking parameter type

2010-10-12 Thread AM Helin
Changes by AM Helin shadi...@gmail.com: -- type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073 ___ ___ Python-bugs-list mailing

[issue10073] calendar.isleap() not checking parameter type

2010-10-12 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +belopolsky ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073 ___ ___ Python-bugs-list

[issue10073] calendar.isleap() not checking parameter type

2010-10-12 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: In Python we often don't type check, we just let errors happen. It is true that it would make the problem clearer to do a type check and issue a specific error message, but I don't know if it is worth it. (The error would already have

[issue10073] calendar.isleap() not checking parameter type

2010-10-12 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: I agree with David on this one. In addition to the arguments already stated, the string value of an exception is not part of specification. The exception is still TypeError even if the message may be confusing. I also

[issue10073] calendar.isleap() not checking parameter type

2010-10-12 Thread Éric Araujo
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10073 ___ ___ Python-bugs-list

[issue10073] calendar.isleap() not checking parameter type

2010-10-12 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: I would also like to note the following curiosity: calendar.isleap(%d) False I still don't think there is anything worth fixing here, but we can consider replacing year % 4 == 0 predicate with year 3 == 0 which will

[issue10073] calendar.isleap() not checking parameter type

2010-10-12 Thread Éric Araujo
Éric Araujo mer...@netwok.org added the comment: I’d be in favor of type checking here, but I know I’m in the minority. I’m very much not in favor of making code less readable (“ 3”). -- ___ Python tracker rep...@bugs.python.org

[issue10073] calendar.isleap() not checking parameter type

2010-10-12 Thread shadikka
shadikka shadi...@gmail.com added the comment: To clarify my original point, I'm for making an explicit error message for that, definitely not for any silent failure or automatic string conversion. -- ___ Python tracker rep...@bugs.python.org

[issue10073] calendar.isleap() not checking parameter type

2010-10-12 Thread Philip Jenvey
Philip Jenvey pjen...@underboss.org added the comment: Another option is to wrap the operations in a try/except. When a TypeError is raised have it throw a new TypeError with an improved error message and the original chained to it -- nosy: +pjenvey