Skip to content
Permalink
Browse files
Use default age when age is None
In some degenerative cases, calculate_birth_timestamp is called with
age == None. This patch sets a default age to prevent Sugar shell from
crashing.

Fixes #4850
  • Loading branch information
walterbender committed May 12, 2015
1 parent 1e47d05 commit 2a370a7
Showing 1 changed file with 3 additions and 0 deletions.
@@ -35,6 +35,7 @@

_group_labels = None
_SECONDS_PER_YEAR = 365 * 24 * 60 * 60.
_DEFAULT_AGE = 10
_DEFAULT_PROMPT = _('Select grade:')
_DEFAULT_LABELS = [_('Preschool'), _('Kindergarten'), _('1st Grade'),
_('2nd Grade'), _('3rd Grade'), _('4th Grade'),
@@ -43,6 +44,8 @@


def calculate_birth_timestamp(age):
if age is None:
age = _DEFAULT_AGE
age_in_seconds = age * _SECONDS_PER_YEAR
birth_timestamp = int(time.time() - age_in_seconds)
return birth_timestamp

0 comments on commit 2a370a7

Please sign in to comment.