[issue19562] Added description for assert statement

2013-12-13 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

I am going to reject this.  Assert failures should never be seen by users and 
for a developer assert 1 = month = 12 is as clear as month must be in 
1..12.

--
nosy: +belopolsky
resolution:  - wont fix
stage:  - committed/rejected
status: open - closed

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



[issue19562] Added description for assert statement

2013-12-13 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

@terry - datetime.py was originally written as a prototype for the C code and 
many seemingly unpythonic constructs therein are motivated by the desire to 
ease the translation to C.

I would not mind simplifying _DI4Y calculation as you suggest, but please check 
how it is done in C.  I would like to keep the two implementation as similar as 
possible.

Please open a separate issue if you would like to have this done.

--

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



[issue19562] Added description for assert statement

2013-12-13 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Thank you for the explanation. If the style comment is not in the file already, 
you might add it whenever you next edit the file for substantive purposes (a 
real bug or feature change). Ditto for _DI4Y.

--

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



[issue19562] Added description for assert statement

2013-11-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Since failed asserts print the failed assert, repeating the assertion in a 
message is useless.
 assert 1 = i
Traceback (most recent call last):
  File pyshell#3, line 1, in module
assert 1 = i
AssertionError

It is already obvious that i must be = 1. So I would reject the patch.

 And isn't this too much defensive programming?

Whether stdlib python code should have asserts is a more interesting question. 
I will ask on pydev.

--
nosy: +terry.reedy

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



[issue19562] Added description for assert statement

2013-11-15 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
versions: +Python 3.4 -Python 2.7, Python 3.3

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



[issue19562] Added description for assert statement

2013-11-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Looking further, the current code has a message object, the month that fails 
the test and your patch removes that in adding the redundant message. I also 
see that your change would make the first assert match the next 2. But I would 
rather change the next two.

Sequences like
_DI4Y   = _days_before_year(5) 
# A 4-year cycle has an extra leap day over what we'd get from pasting
# together 4 single years.
assert _DI4Y == 4 * 365 + 1

are bizarre. The constant should be directly set to 4*365 + 1 and then 
_days_before_year(5) == _DI4Y tested in test_datetime.

--

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



[issue19562] Added description for assert statement

2013-11-12 Thread Srinivas Reddy T

New submission from Srinivas  Reddy T:

Added descriptive message to assert statement in datetime module.
Since _check_date_fields does the job of data integrity, i did not check for 
ValueError, TypeError checks in the function.

However, i am not sure of the adding descriptive messages to the other assert 
statements like, assert seconds == int(seconds). And isn't this too much 
defensive programming?

--
components: Library (Lib)
files: datetime.patch
keywords: patch
messages: 202708
nosy: thatiparthy
priority: normal
severity: normal
status: open
title: Added description for assert statement
versions: Python 2.7, Python 3.3
Added file: http://bugs.python.org/file32588/datetime.patch

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