Switch to using explicit new-style division behavior, rather than relying on teh classic behavior.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16745 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor 2011-09-09 21:45:58 +00:00
parent e216c3cb1b
commit 699688dc2c
5 changed files with 11 additions and 11 deletions

View File

@ -165,13 +165,13 @@ def naturaltime(value):
return ungettext(
u'a second ago', u'%(count)s seconds ago', delta.seconds
) % {'count': delta.seconds}
elif delta.seconds / 60 < 60:
count = delta.seconds / 60
elif delta.seconds // 60 < 60:
count = delta.seconds // 60
return ungettext(
u'a minute ago', u'%(count)s minutes ago', count
) % {'count': count}
else:
count = delta.seconds / 60 / 60
count = delta.seconds // 60 // 60
return ungettext(
u'an hour ago', u'%(count)s hours ago', count
) % {'count': count}
@ -187,13 +187,13 @@ def naturaltime(value):
return ungettext(
u'a second from now', u'%(count)s seconds from now', delta.seconds
) % {'count': delta.seconds}
elif delta.seconds / 60 < 60:
count = delta.seconds / 60
elif delta.seconds // 60 < 60:
count = delta.seconds // 60
return ungettext(
u'a minute from now', u'%(count)s minutes from now', count
) % {'count': count}
else:
count = delta.seconds / 60 / 60
count = delta.seconds // 60 // 60
return ungettext(
u'an hour from now', u'%(count)s hours from now', count
) % {'count': count}

View File

@ -18,7 +18,7 @@ def id_number_checksum(gd):
if (s % 10) == 0:
return 0
return (((s / 10) + 1) * 10) - s
return (((s // 10) + 1) * 10) - s
def validate_id_birthday(gd, fix_coordination_number_day=True):
"""

View File

@ -88,7 +88,7 @@ class BaseConverter(object):
while x > 0:
digit = x % len(to_digits)
res = to_digits[digit] + res
x = int(x / len(to_digits))
x = int(x // len(to_digits))
return neg, res
base2 = BaseConverter(BASE2_ALPHABET)

View File

@ -42,7 +42,7 @@ def rfc2822_date(date):
time_str = date.strftime('%s, %%d %s %%Y %%H:%%M:%%S ' % (dow, month))
if date.tzinfo:
offset = date.tzinfo.utcoffset(date)
timezone = (offset.days * 24 * 60) + (offset.seconds / 60)
timezone = (offset.days * 24 * 60) + (offset.seconds // 60)
hour, minute = divmod(timezone, 60)
return time_str + "%+03d%02d" % (hour, minute)
else:
@ -54,7 +54,7 @@ def rfc3339_date(date):
if date.tzinfo:
time_str = date.strftime('%Y-%m-%dT%H:%M:%S')
offset = date.tzinfo.utcoffset(date)
timezone = (offset.days * 24 * 60) + (offset.seconds / 60)
timezone = (offset.days * 24 * 60) + (offset.seconds // 60)
hour, minute = divmod(timezone, 60)
return time_str + "%+03d:%02d" % (hour, minute)
else:

View File

@ -166,7 +166,7 @@ def int_to_base36(i):
# Construct base36 representation
while factor >= 0:
j = 36 ** factor
base36.append(digits[i / j])
base36.append(digits[i // j])
i = i % j
factor -= 1
return ''.join(base36)