|
26 | 26 | from re import IGNORECASE |
27 | 27 | from string import whitespace as whitespace_string |
28 | 28 |
|
29 | | -__version__ = (2,1,6) |
30 | 29 | __author__ = "Brett Cannon" |
31 | 30 | |
32 | 31 |
|
@@ -287,13 +286,19 @@ def __calc_timezone(self): |
287 | 286 | self.__timezone = self.__pad(time.tzname, 0) |
288 | 287 |
|
289 | 288 | def __calc_lang(self): |
290 | | - # Set self.lang by using locale.getlocale() or |
291 | | - # locale.getdefaultlocale(). |
| 289 | + # Set self.__lang by using locale.getlocale() or |
| 290 | + # locale.getdefaultlocale(). If both turn up empty, set the attribute |
| 291 | + # to ''. This is to stop calls to this method and to make sure |
| 292 | + # strptime() can produce an re object correctly. |
292 | 293 | current_lang = locale.getlocale(locale.LC_TIME)[0] |
293 | 294 | if current_lang: |
294 | 295 | self.__lang = current_lang |
295 | 296 | else: |
296 | | - self.__lang = locale.getdefaultlocale()[0] |
| 297 | + current_lang = locale.getdefaultlocale()[0] |
| 298 | + if current_lang: |
| 299 | + self.__lang = current_lang |
| 300 | + else: |
| 301 | + self.__lang = '' |
297 | 302 |
|
298 | 303 |
|
299 | 304 | class TimeRE(dict): |
@@ -463,7 +468,10 @@ def strptime(data_string, format="%a %b %d %H:%M:%S %Y"): |
463 | 468 | julian = int(found_dict['j']) |
464 | 469 | elif group_key == 'Z': |
465 | 470 | found_zone = found_dict['Z'].lower() |
466 | | - if locale_time.timezone[0].lower() == found_zone: |
| 471 | + if locale_time.timezone[0] == locale_time.timezone[1]: |
| 472 | + pass #Deals with bad locale setup where timezone info is |
| 473 | + # the same; first found on FreeBSD 4.4 -current |
| 474 | + elif locale_time.timezone[0].lower() == found_zone: |
467 | 475 | tz = 0 |
468 | 476 | elif locale_time.timezone[1].lower() == found_zone: |
469 | 477 | tz = 1 |
|
0 commit comments