]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Fix an invalid string to bytes comparison in Python 3 498/head
authorRoy Williams <rwilliams@lyft.com>
Sat, 27 May 2017 00:04:27 +0000 (17:04 -0700)
committerRoy Williams <rwilliams@lyft.com>
Sat, 27 May 2017 01:21:38 +0000 (18:21 -0700)
In Python 3 this branch would never evaluate to `True` due to comparing a string to bytes.

This was flagged by running some unit tests with the `-bb` flag, so I've added
`-bb` to run with the babel unit tests in Python3.5

Here's some docs on the `-bb` flag:
https://docs.python.org/3.5/library/warnings.html#default-warning-filters
https://docs.python.org/3/howto/pyporting.html#use-continuous-integration-to-stay-compatible

.travis.yml
Makefile
babel/localtime/_unix.py

index 08ac545dfd02919f888d26dbb94e209c2e9fe7a0..1f690426bf24b40911b8040d0320b0ebee2455ce 100644 (file)
@@ -33,6 +33,8 @@ matrix:
       python: 3.4
     - os: linux
       python: 3.5
+      env:
+      - PYTHON_TEST_FLAGS=-bb
 
 install:
   - bash .ci/deps.${TRAVIS_OS_NAME}.sh
index 74b9a673d1d3f8525022cfd5fff82c782a09be4d..eafaeb48d00ba243a4536324fbd7ad21f4655e2a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
 test: import-cldr
-       @PYTHONWARNINGS=default python -m pytest
+       @PYTHONWARNINGS=default python ${PYTHON_TEST_FLAGS} -m pytest
 
 test-cov: import-cldr
-       @PYTHONWARNINGS=default python -m pytest --cov=babel
+       @PYTHONWARNINGS=default python ${PYTHON_TEST_FLAGS} -m pytest --cov=babel
 
 test-env:
        @virtualenv test-env
index e0b54fb28633c0a956c6fc4e69a4795851d43289..8a8b4e9677c947bf3bdfa8f09ba222b8954a7817 100644 (file)
@@ -87,7 +87,7 @@ def _get_localzone(_root='/'):
 
             # Issue #3 in tzlocal was that /etc/timezone was a zoneinfo file.
             # That's a misconfiguration, but we need to handle it gracefully:
-            if data[:5] != 'TZif2':
+            if data[:5] != b'TZif2':
                 etctz = data.strip().decode()
                 # Get rid of host definitions and comments:
                 if ' ' in etctz: