Skip to content

Commit

Permalink
platform module: Fixes interpreter version recognition
Browse files Browse the repository at this point in the history
the previous, human-oriented approach based on Guido's
unmaterialized thought to continue with a version 4 after 3.9.
  • Loading branch information
funkyfuture committed Aug 9, 2023
1 parent 1818381 commit 34e4202
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Cerberus is a collaboratively funded project, see the `funding page`_.
Version 1.3.5
-------------

Unreleased.
Released on August 9, 2023.

New
~~~
Expand Down
5 changes: 3 additions & 2 deletions cerberus/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

from __future__ import absolute_import

import sys
from collections import defaultdict, namedtuple
from copy import copy, deepcopy
from functools import wraps
from pprint import pformat

from cerberus.platform import PYTHON_VERSION, MutableMapping
from cerberus.platform import MutableMapping
from cerberus.utils import compare_paths_lt, quote_string


Expand Down Expand Up @@ -456,7 +457,7 @@ def _encode(value):
error.info = _encode(error.info)
return f(obj, error)

return wrapped if PYTHON_VERSION < 3 else f
return wrapped if sys.version_info < (3,) else f


class BasicErrorHandler(BaseErrorHandler):
Expand Down
9 changes: 3 additions & 6 deletions cerberus/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@
raise RuntimeError("Cerberus can't be run with Python's optimization level 2.")


PYTHON_VERSION = float(sys.version_info[0]) + float(sys.version_info[1]) / 10


if PYTHON_VERSION < 3:
if sys.version_info < (3,):
_int_types = (int, long) # noqa: F821
_str_type = basestring # noqa: F821
else:
_int_types = (int,)
_str_type = str


if PYTHON_VERSION < 3.3:
if sys.version_info < (3, 3):
from collections import (
Callable,
Container,
Expand All @@ -42,7 +39,7 @@
Sized,
)

if PYTHON_VERSION < 3.8:
if sys.version_info < (3, 8):
import importlib_metadata
else:
import importlib.metadata as importlib_metadata
Expand Down

0 comments on commit 34e4202

Please sign in to comment.