From f4afbd0cf06e3585c777a974aa29039efd3c909c Mon Sep 17 00:00:00 2001 From: Jim Pivarski Date: Wed, 29 Jan 2020 07:43:15 -0600 Subject: [PATCH] Fixes #445 by not reusing a variable. --- tests/test_compression.py | 7 ------- uproot/source/compressed.py | 8 ++++---- uproot/tree.py | 7 ++++--- uproot/version.py | 2 +- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/tests/test_compression.py b/tests/test_compression.py index fbf1e928..409e3741 100644 --- a/tests/test_compression.py +++ b/tests/test_compression.py @@ -2,13 +2,6 @@ # BSD 3-Clause License; see https://github.com/scikit-hep/uproot/blob/master/LICENSE -try: - import lzma -except ImportError: - from backports import lzma -import lz4 -import zstandard - import uproot class Test(object): diff --git a/uproot/source/compressed.py b/uproot/source/compressed.py index 3b0450fc..ff51bfaa 100644 --- a/uproot/source/compressed.py +++ b/uproot/source/compressed.py @@ -66,7 +66,7 @@ def decompress(self, source, cursor, compressedbytes, uncompressedbytes=None): try: from backports.lzma import decompress as lzma_decompress except ImportError: - raise ImportError("Install lzma package with:\n pip install backports.lzma\nor\n conda install backports.lzma\n(or just use Python >= 3.3).") + raise ImportError("install lzma package with:\n pip install backports.lzma\nor\n conda install backports.lzma\n(or just use Python >= 3.3).") return lzma_decompress(cursor.bytes(source, compressedbytes)) elif self.algo == uproot.const.kOldCompressionAlgo: @@ -76,7 +76,7 @@ def decompress(self, source, cursor, compressedbytes, uncompressedbytes=None): try: from lz4.block import decompress as lz4_decompress except ImportError: - raise ImportError("Install lz4 package with:\n pip install lz4\nor\n conda install lz4") + raise ImportError("install lz4 package with:\n pip install lz4\nor\n conda install lz4") if uncompressedbytes is None: raise ValueError("lz4 needs to know the uncompressed number of bytes") @@ -86,7 +86,7 @@ def decompress(self, source, cursor, compressedbytes, uncompressedbytes=None): try: import zstandard as zstd except ImportError: - raise ImportError("Install zstd package with:\n pip install zstandard\nor\n conda install zstandard") + raise ImportError("install zstd package with:\n pip install zstandard\nor\n conda install zstandard") dctx = zstd.ZstdDecompressor() return dctx.decompress(cursor.bytes(source, compressedbytes)) @@ -141,7 +141,7 @@ def _prepare(self): try: import xxhash except ImportError: - raise ImportError("Install xxhash package with:\n pip install xxhash\nor\n conda install python-xxhash") + raise ImportError("install xxhash package with:\n pip install xxhash\nor\n conda install python-xxhash") compression = self.compression.copy(uproot.const.kLZ4) compressedbytes -= 8 checksum = cursor.field(self._compressed, self._format_field0) diff --git a/uproot/tree.py b/uproot/tree.py index 01ace4d7..df2fef89 100644 --- a/uproot/tree.py +++ b/uproot/tree.py @@ -1972,20 +1972,21 @@ def lazyarrays(path, treepath, branches=None, namedecode="utf-8", entrysteps=flo lazyfiles = _LazyFiles(paths, treepath, branches, entrysteps, flatten, awkward.__name__, basketcache, keycache, executor, persistvirtual, localsource, xrootdsource, httpsource, options) + brancheslist = None for path in paths: file = uproot.rootio.open(path, localsource=localsource, xrootdsource=xrootdsource, httpsource=httpsource, **options) try: tree = file[treepath] except KeyError: continue - branches = list(tree._normalize_branches(branches, awkward)) + brancheslist = list(tree._normalize_branches(branches, awkward)) break - if branches is None: + if brancheslist is None: raise ValueError("no matching paths contained a tree named {0}".format(repr(treepath))) out = awkward.Table() - for branch, interpretation in branches: + for branch, interpretation in brancheslist: inner = interpretation while isinstance(inner, asjagged): inner = inner.content diff --git a/uproot/version.py b/uproot/version.py index 2e9e8023..124782e9 100644 --- a/uproot/version.py +++ b/uproot/version.py @@ -6,7 +6,7 @@ import re -__version__ = "3.11.1" +__version__ = "3.11.2" version = __version__ version_info = tuple(re.split(r"[-\.]", __version__))