Edgewall Software
Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#13166 closed defect (fixed)

Test failure with Babel 2.7

Reported by: Ryan J Ollos Owned by: Jun Omae
Priority: normal Milestone: 1.0.18
Component: i18n Version:
Severity: normal Keywords: babel
Cc: Branch:
Release Notes:

Made compatible with Babel 2.7.

API Changes:
Internal Changes:

Description (last modified by Ryan J Ollos)

Tests pass with Babel 2.6.0, but fail with Babel 2.7.0. Confirmed failures on 1.0-stable and 1.2-stable.

...
======================================================================
ERROR: test_add_jquery_ui_first_week_day (trac.web.tests.chrome.ChromeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/web/tests/chrome.py", line 374, in test_add_jquery_ui_first_week_day
    self.assertEqual(1, first_week_day(de, de, []))
  File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/web/tests/chrome.py", line 355, in first_week_day
    chrome.add_jquery_ui(req)
  File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/web/chrome.py", line 1409, in add_jquery_ui
    'period_names': get_period_names_jquery_ui(req),
  File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/util/datefmt.py", line 511, in get_period_names_jquery_ui
    for period in ('am', 'pm'))
  File "/Users/rjollos/Documents/Workspace/trac-dev/teo-rjollos.git/trac/util/datefmt.py", line 511, in <genexpr>
    for period in ('am', 'pm'))
  File "/Users/rjollos/.pyenv/versions/trac-2.7.15/lib/python2.7/site-packages/babel/localedata.py", line 218, in __getitem__
    orig = val = self._data[key]
KeyError: 'am'

----------------------------------------------------------------------
Ran 2407 tests in 169.700s

FAILED (errors=1)
make: *** [unit-test] Error 1

Attachments (0)

Change History (6)

comment:1 by Ryan J Ollos, 5 years ago

Description: modified (diff)

comment:2 by Ryan J Ollos, 5 years ago

Description: modified (diff)

comment:3 by Jun Omae, 5 years ago

I investigate whether the locales have am in the day periods.

import babel
from babel.localedata import locale_identifiers
from trac.util.datefmt import get_period_names

locales = sorted(locale_identifiers())
results = {'existent': [], 'missing': []}

print('Babel: %s' % babel.__version__)
for locale in locales:
    names = dict(get_period_names(locale=locale))
    if 'am' in names:
        results['existent'].append(locale)
    else:
        results['missing'].append(locale)
missing = results['missing']
if missing:
    print('No am period: %s' % ' '.join(missing))
else:
    print('All locales have am: %s' % ' '.join(locales))
Babel: 2.6.0
No am period: bm bm_ML ce ce_RU cgg cgg_UG dyo dyo_SN kkj kkj_CM ks ks_IN lg lg_UG lkt lkt_US mfe mfe_MU mzn mzn_IR nd nd_ZW nyn nyn_UG pa_Arab pa_Arab_PK seh seh_MZ uz_Arab uz_Arab_AF vai vai_Latn vai_Latn_LR vai_Vaii vai_Vaii_LR vo vo_001 wae wae_CH

Babel: 2.7.0
No am period: bm bm_ML ce ce_RU cgg cgg_UG de de_AT de_BE de_CH de_DE de_IT de_LI de_LU dyo dyo_SN kkj kkj_CM ks ks_IN lg lg_UG lkt lkt_US mfe mfe_MU mzn mzn_IR nd nd_ZW nyn nyn_UG pa_Arab pa_Arab_PK seh seh_MZ sk sk_SK uz_Arab uz_Arab_AF vai vai_Latn vai_Latn_LR vai_Vaii vai_Vaii_LR vo vo_001 wae wae_CH

de locale in Babel 2.6.0 has am period, but missing am period in Babel 2.7.0.

The am and pm periods have been removed from de locale at https://github.com/unicode-org/cldr/commit/06fed7197377807d993d2a21aa112f9bafaaf57d#diff-ed5d094ffbebef4d7e8476d25ad05bccL2040.

The am and pm periods can be undefined in a locale data, by the investigation.

  • trac/util/datefmt.py

    diff --git a/trac/util/datefmt.py b/trac/util/datefmt.py
    index 97c270e7a..53efa0248 100644
    a b def get_period_names_jquery_ui(req):  
    503503        return {'am': [english_names['am']], 'pm': [english_names['pm']]}
    504504    if babel and locale:
    505505        names = get_period_names(locale=locale)
    506         return dict((period, [names[period], english_names[period]])
     506        return dict((period, [names[period], english_names[period]]
     507                             if period in names else [english_names[period]])
    507508                    for period in ('am', 'pm'))
    508509    else:
    509510        # retrieve names of am/pm from libc

comment:4 by Ryan J Ollos, 5 years ago

Owner: set to Ryan J Ollos
Release Notes: modified (diff)
Status: newassigned

Thanks for the patch. I will push the fix.

comment:5 by Ryan J Ollos, 5 years ago

Resolution: fixed
Status: assignedclosed

Committed to 1.0-stable in r16903, merged in r16904, r16905.

comment:6 by Ryan J Ollos, 5 years ago

Owner: changed from Ryan J Ollos to Jun Omae

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.