diff --git a/boltons/funcutils.py b/boltons/funcutils.py index d11593a8..3cd2b1ba 100644 --- a/boltons/funcutils.py +++ b/boltons/funcutils.py @@ -932,7 +932,7 @@ def remove_arg(self, arg_name): try: self.kwonlyargs.remove(arg_name) except (AttributeError, ValueError): - # py2, or py3 and missing from both + # missing from both exc = MissingArgument('arg %r not found in %s argument list:' ' %r' % (arg_name, self.name, args)) exc.arg_name = arg_name diff --git a/boltons/iterutils.py b/boltons/iterutils.py index 98f43092..fb3d3660 100644 --- a/boltons/iterutils.py +++ b/boltons/iterutils.py @@ -1398,10 +1398,7 @@ def reseed(self): self.salt = '-'.join([str(self.pid), socket.gethostname() or '', str(time.time()), - codecs.encode(os.urandom(6), - 'hex_codec').decode('ascii')]) - # that codecs trick is the best/only way to get a bytes to - # hexbytes in py2/3 + os.urandom(6).hex()]) return def __iter__(self): diff --git a/boltons/statsutils.py b/boltons/statsutils.py index a2d726c0..36a82230 100644 --- a/boltons/statsutils.py +++ b/boltons/statsutils.py @@ -128,6 +128,7 @@ import bisect from math import floor, ceil +from collections import Counter class _StatsProperty: @@ -595,12 +596,7 @@ def get_histogram_counts(self, bins=None, **kw): bins = sorted(set(bins)) idxs = [bisect.bisect(bins, d) - 1 for d in self.data] - count_map = {} # would have used Counter, but py26 support - for idx in idxs: - try: - count_map[idx] += 1 - except KeyError: - count_map[idx] = 1 + count_map = Counter(idxs) bin_counts = [(b, count_map.get(i, 0)) for i, b in enumerate(bins)] diff --git a/docs/timeutils.rst b/docs/timeutils.rst index 090c28c1..1eb8e419 100644 --- a/docs/timeutils.rst +++ b/docs/timeutils.rst @@ -28,11 +28,18 @@ working with them: .. _UTC: https://en.wikipedia.org/wiki/Coordinated_Universal_Time +.. note:: + + These days, Python has a `built-in UTC`_, and the UTC tzinfo here, + while equivalent, is just for backwards compat. + .. autoattribute:: boltons.timeutils.UTC .. autodata:: boltons.timeutils.LocalTZ .. autoclass:: boltons.timeutils.ConstantTZInfo +.. _built-in UTC: https://docs.python.org/3/library/datetime.html#datetime.timezone.utc + US timezones ------------ diff --git a/tests/test_fileutils.py b/tests/test_fileutils.py index b7c6d61e..6d61c138 100644 --- a/tests/test_fileutils.py +++ b/tests/test_fileutils.py @@ -14,6 +14,6 @@ def test_fileperms(): assert repr(up) == "FilePerms(user='rwx', group='rwx', other='')" assert up.user == 'rwx' - assert oct(int(up)).endswith('770') # 0770 on py2 and 0o770 on py3 + assert oct(int(up)) == '0o770' assert int(FilePerms()) == 0