Skip to content

Commit

Permalink
global: reflect upgrade of zstd to 1.5.4
Browse files Browse the repository at this point in the history
An error message change resulted in a changed test. Pretty minor.

Rust complained about new fields on `ZSTD_frameHeader`. So we added
them.

Static APIs are now prefixed by new variants of `ZSTDLIB_API`. So
we strip those as well to make cffi parsing happy on non-Windows.

Closes #190.
  • Loading branch information
indygreg committed Feb 20, 2023
1 parent acfd93d commit de93ee0
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 23 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ num_cpus = "1.15.0"
rayon = "1.6.1"

[dependencies.zstd-safe]
version = "=6.0.3+zstd.1.5.2"
version = "6.0.4+zstd.1.5.4"
features = ["experimental", "legacy", "zstdmt"]

[dependencies.zstd-sys]
version = "=2.0.6+zstd.1.5.2"
version = "2.0.7+zstd.1.5.4"
features = ["experimental", "legacy", "zstdmt"]

[dependencies.pyo3]
Expand Down
2 changes: 1 addition & 1 deletion c-ext/backend_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void zstd_module_init(PyObject *m) {
PyObject *features = NULL;
PyObject *feature = NULL;
unsigned zstd_ver_no = ZSTD_versionNumber();
unsigned our_hardcoded_version = 10502;
unsigned our_hardcoded_version = 10504;
if (ZSTD_VERSION_NUMBER != our_hardcoded_version ||
zstd_ver_no != our_hardcoded_version) {
PyErr_Format(
Expand Down
2 changes: 1 addition & 1 deletion c-ext/python-zstandard.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define ZDICT_STATIC_LINKING_ONLY

#ifdef ZSTD_SINGLE_FILE
#include <zstdlib.c>
#include <zstd.c>

/* We use private APIs from pool.h. We can't rely on availability
of this header or symbols when linking against the system libzstd.
Expand Down
2 changes: 1 addition & 1 deletion docs/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ be specified via the ``ZSTD_EXTRA_COMPILER_ARGS`` environment variable. e.g.
``python-zstandard`` can be sensitive about what version of ``libzstd`` it links
against. For best results, point this package at the exact same version of
``libzstd`` that it bundles. See the bundled ``zstd/zstd.h`` or
``zstd/zstdlib.c`` for which version that is.
``zstd/zstd.c`` for which version that is.

When linking against an external ``libzstd``, not all package features may be
available. Notably, the ``multi_compress_to_buffer()`` and
Expand Down
5 changes: 5 additions & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ Other Actions Not Blocking Release
0.20.0 (not yet released)
=========================

Changes
-------

* Bundled zstd library upgraded from 1.5.2 to 1.5.4.

0.19.0 (released 2022-10-29)
============================

Expand Down
14 changes: 10 additions & 4 deletions make_cffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
HERE = os.path.abspath(os.path.dirname(__file__))

SOURCES = [
"zstd/zstdlib.c",
"zstd/zstd.c",
]

# Headers whose preprocessed output will be fed into cdef().
Expand Down Expand Up @@ -101,9 +101,15 @@ def preprocess(path):
l = b"#define INT_MAX 2147483647\n"

# ZSTDLIB_API may not be defined if we dropped zstd.h. It isn't
# important so just filter it out.
if l.startswith(b"ZSTDLIB_API"):
l = l[len(b"ZSTDLIB_API ") :]
# important so just filter it out. Ditto for ZSTDLIB_STATIC_API and
# ZDICTLIB_STATIC_API.
for prefix in (
b"ZSTDLIB_API",
b"ZSTDLIB_STATIC_API",
b"ZDICTLIB_STATIC_API",
):
if l.startswith(prefix):
l = l[len(prefix) :]

lines.append(l)

Expand Down
2 changes: 2 additions & 0 deletions rust-ext/src/decompressor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ impl ZstdDecompressor {
headerSize: 0,
dictID: 0,
checksumFlag: 0,
_reserved1: 0,
_reserved2: 0,
};
let zresult = unsafe {
zstd_sys::ZSTD_getFrameHeader(
Expand Down
2 changes: 2 additions & 0 deletions rust-ext/src/frame_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ fn get_frame_parameters(py: Python, buffer: PyBuffer<u8>) -> PyResult<Py<FramePa
headerSize: 0,
dictID: 0,
checksumFlag: 0,
_reserved1: 0,
_reserved2: 0,
};
let zresult = unsafe {
zstd_sys::ZSTD_getFrameHeader(&mut header, raw_data.as_ptr() as *const _, raw_data.len())
Expand Down
6 changes: 3 additions & 3 deletions setup_zstd.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def get_c_extension(
extra_args.append("-DZSTD_MULTITHREAD")
else:
extra_args.append("-DZSTD_SINGLE_FILE")
extra_args.append("-DZSTDLIB_VISIBILITY=")
extra_args.append("-DZDICTLIB_VISIBILITY=")
extra_args.append("-DZSTDERRORLIB_VISIBILITY=")
extra_args.append("-DZSTDLIB_VISIBLE=")
extra_args.append("-DZDICTLIB_VISIBLE=")
extra_args.append("-DZSTDERRORLIB_VISIBLE=")

if compiler_type == "unix":
extra_args.append("-fvisibility=hidden")
Expand Down
8 changes: 2 additions & 6 deletions tests/test_decompressor_multi_decompress_to_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,12 @@ def test_item_failure(self):

with self.assertRaisesRegex(
zstd.ZstdError,
"error decompressing item 1: ("
"Corrupted block|"
"Destination buffer is too small)",
"error decompressing item 1: (Data corruption detected|Destination buffer is too small)",
):
dctx.multi_decompress_to_buffer(frames)

with self.assertRaisesRegex(
zstd.ZstdError,
"error decompressing item 1: ("
"Corrupted block|"
"Destination buffer is too small)",
"error decompressing item 1: (Data corruption detected|Destination buffer is too small)",
):
dctx.multi_decompress_to_buffer(frames, threads=2)
2 changes: 1 addition & 1 deletion tests/test_module_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class TestModuleAttributes(unittest.TestCase):
def test_version(self):
self.assertEqual(zstd.ZSTD_VERSION, (1, 5, 2))
self.assertEqual(zstd.ZSTD_VERSION, (1, 5, 4))

self.assertEqual(zstd.__version__, "0.20.0.dev0")

Expand Down

0 comments on commit de93ee0

Please sign in to comment.