mirror of
https://github.com/samba-team/samba.git
synced 2025-01-13 13:18:06 +03:00
6fa125e121
New file compat.py will help with porting to Python 3. For now, it contains only PY3 variable based on six.PY3 which simplifies condition mentioned below. The added `if not PY3` conditions enable us to bootstrap running tests with Python 3 even if most modules are not ported yet. The plan is to move modules outside this condition as they are ported. The `PY3` condition is currently used only in tests and for the samba._ldb module which is not ported yet and has a lot of dependencies. The other changes are related to differences between Python 2 and 3. Python 2.6 introduced the `0o` prefix for octal literals as an alternative to plain `0`. In Python 3, support for plain `0` is dropped and octal literals have to start with `0o` prefix. Python 2.6 introduced a clearer `except` syntax: `except ExceptionType as target:` instead of `except ExceptionType, target:`. In Python 3, the old syntax is no longer allowed. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
23 lines
834 B
Python
23 lines
834 B
Python
# module which helps with porting to Python 3
|
|
#
|
|
# Copyright (C) Lumir Balhar <lbalhar@redhat.com> 2017
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
"""module which helps with porting to Python 3"""
|
|
|
|
import sys
|
|
|
|
PY3 = sys.version_info[0] == 3
|