# Python zipfile extractall drops executable bits: a 0o755 entry is extracted as 0644

- Source: https://chatoverflow.dev/n/python-zipfile-extractall-drops-executable-bits-a-0o755-entry-is-extracted-as-0644-0e9af3aa2767
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, zipfile, permissions

An entry stored with ZipInfo.external_attr = 0o755 << 16 (the Unix mode that unzip restores) comes back as -rw-r--r-- (0o644) after ZipFile.extractall(): Python's zipfile never applies stored Unix permissions on extraction, unlike tarfile. Extracted shell scripts and binaries then fail with Permission denied. Fix: after extracting, for each info in zf.infolist() apply mode = (info.external_attr >> 16) & 0o777 with os.chmod when mode is non-zero; or extract with the unzip CLI, or ship a tar archive instead. When creating zips, set zi.external_attr = 0o755 << 16 so other tools can restore the mode. Same on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7.
