Skip to content

Commit

Permalink
Merge pull request #2 from brianhelba/36
Browse files Browse the repository at this point in the history
Add Python 3.6 support
  • Loading branch information
brianhelba authored Feb 24, 2021
2 parents eaabfd0 + 5757931 commit 72f8b40
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9"]
python-version: ["3.6", "3.7", "3.8", "3.9"]
steps:
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Build manylinux wheels
uses: RalfG/[email protected]_x86_64
with:
python-versions: 'cp37-cp37m cp38-cp38 cp39-cp39'
python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39'
# Necessary for setuptools_scm to read the version from Git
system-packages: 'git-lfs'
- name: Install tox
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Extract DEFLATE64 ZIP archives with Python's `zipfile` API.
pip install zipfile-deflate64
```

Python 3.7, 3.8, and 3.9 supported, with [manylinux2014 wheels](https://github.com/pypa/manylinux) published to PyPI.
Python 3.6, 3.7, 3.8, and 3.9 supported, with [manylinux2014 wheels](https://github.com/pypa/manylinux) published to PyPI.

## Usage
Anywhere in a Python codebase:
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
'License :: OSI Approved :: Apache Software License',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python',
'Topic :: System :: Archiving',
'Topic :: System :: Archiving :: Compression',
],
python_requires='>=3.7',
python_requires='>=3.6',
packages=find_packages(),
ext_modules=[
Extension(
Expand Down
14 changes: 14 additions & 0 deletions zipfile_deflate64/deflate64/deflate64module.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ static int zlib_out(void* out_desc, unsigned char* buf, unsigned len) {
// Concatenate buf onto self->output_buffer
Py_ssize_t old_output_size = PyBytes_GET_SIZE(self->output_buffer);

#if PY_VERSION_HEX < 0x3070700 // v3.7.3
// Workaround for bpo-33817, which was first (via backport) fixed in Python 3.7.3
// Before this, size-zero bytes objects could not be resized
if (old_output_size == 0) {
Py_DECREF(self->output_buffer);
// Just create a new buffer with the target size; the following resize will short-circuit
self->output_buffer = PyBytes_FromStringAndSize(NULL, old_output_size + len);
if (self->output_buffer == NULL) {
PyErr_NoMemory();
return -1;
}
}
#endif

int err = _PyBytes_Resize(&self->output_buffer, old_output_size + len);
if (err < 0) {
// MemoryError is set, and output_buffer is deallocated and set to NULL
Expand Down

0 comments on commit 72f8b40

Please sign in to comment.