Skip to content

was able to test on Linux successfully (7z v23+). fixed extracting of encrypted archives.#5

Open
cielavenir wants to merge 19 commits into
harvimt:masterfrom
cielavenir:ciel
Open

was able to test on Linux successfully (7z v23+). fixed extracting of encrypted archives.#5
cielavenir wants to merge 19 commits into
harvimt:masterfrom
cielavenir:ciel

Conversation

@cielavenir
Copy link
Copy Markdown

@cielavenir cielavenir commented Dec 19, 2019

Debian GNU/Linux 13
7z.so Version 25.01


On macOS/Linux, v23 is required. Windows works with both v22 and v23.

@pombredanne
Copy link
Copy Markdown

@harvimt ping?

@cielavenir
Copy link
Copy Markdown
Author

just for my info: 7zip 23+ is incompatible with CDEF_IUnknown patch.

@harvimt
Copy link
Copy Markdown
Owner

harvimt commented Apr 15, 2025

I thought I had already commented this, but to other's who are seeing this in searches or whatever, the reason this isn't merged is the way it's written it drops support for Windows... this was originally intended as a Windows-only project. I'm not opposed to adding Linux support, but the same code needs to work on Linux and Windows.

Also I'm not really working on this project anymore, but people do seem to find it useful as an example if nothing else.

@cielavenir
Copy link
Copy Markdown
Author

Thank you for the comment~

After my company moves to Debian 13, 7z.so will become v24 and I will be able to remove CDEF_IUnknown patch and Windows can work with the same code

@cielavenir
Copy link
Copy Markdown
Author

will start annotation

Comment thread lib7zip/__init__.py
suffixes = '', '7z.so', 'p7zip/7z.so'
prefixes = ['/lib', '/usr/lib']
suffixes = '7z.so', '7zip/7z.so'
prefixes = ['/lib', '/usr/lib', '/usr/local/lib', '/usr/libexec', '/home/linuxbrew/.linuxbrew/lib', '/opt/local/lib', '/sw/lib']
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 7zip v23+ is required, so p7zip should be removed
  • adding path is encouraged to support multiple installation

Comment thread lib7zip/__init__.py Outdated
if pvar.vt == wintypes.VT_BSTR and pvar.bstrVal != ffi.NULL:
C.free(pvar.bstrVal)
if pvar.vt == wintypes.VARTYPE.VT_BSTR and pvar.bstrVal != ffi.NULL:
C.free( ffi.cast('char*',pvar.bstrVal)-4 )
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception ignored from callback for ffi.gc <cdata 'void *' 0x41a4a7d0>:
Traceback (most recent call last):
  File "/devel/pylib7zip/lib7zip/winhelpers.py", line 78, in dealloc_propvariant
    free_propvariant(pvar)
  File "/devel/pylib7zip/lib7zip/__init__.py", line 68, in free_propvariant
    if pvar.vt == wintypes.VT_BSTR and pvar.bstrVal != ffi.NULL:
AttributeError: module 'lib7zip.wintypes' has no attribute 'VT_BSTR'

Comment thread lib7zip/__init__.py
log.debug('initializing')
formats = get_format_info()
max_sig_size = max(len(f.start_signature) for f in formats.values())
max_sig_size = max(len(f.start_signature or '') for f in formats.values())
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeError: object of type 'NoneType' has no len()

some formats have start_signature None

Comment thread lib7zip/py7ziptypes.py
kExtract = 0
kTest = 1
kSkip = 2 No newline at end of file
kSkip = 2
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeError: %d format: a real number is required, not AskMode

Comment thread lib7zip/archive.py
def close(self):
log.debug('Archive.close()')
if self.archive or self.archive.vtable or self.archive.vtable.Close == ffi.NULL:
if self.archive is None or self.archive.vtable is None or self.archive.vtable.Close == ffi.NULL:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2026-04-30 11:06:19,174 lib7zip [DEBUG] [archive.py:104 close] Archive.close()
Exception ignored in: <function Archive.__del__ at 0x7fb50e0e6700>
Traceback (most recent call last):
  File "/devel/pylib7zip/lib7zip/archive.py", line 101, in __del__
  File "/devel/pylib7zip/lib7zip/archive.py", line 105, in close
AttributeError: 'NoneType' object has no attribute 'vtable'

Comment thread lib7zip/__init__.py
)
for i in range(num_formats[0])
}
return retdict
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with

'zip': Format(classid=UUID('23170f69-40c1-278a-1000-000110010000'), extensions=('zip', 'z01', 'zipx', 'jar', 'xpi', 'odt', 'ods', 'docx', 'xlsx', 'epub', 'ipa', 'apk', 'appx'), index=59, start_signature=b'PK\x03\x04')

without

'zip': Format(classid=UUID('23170f69-40c1-278a-1000-000110010000'), extensions=('zip', 'z01', 'zipx', 'jar', 'xpi', 'odt', 'ods', 'docx', 'xlsx', 'epub', 'ipa', 'apk', 'appx'), index=59, start_signature=None)

Comment thread lib7zip/archive.py

log.debug('starting extract of %s!', self.path)
RNOK(self.archive.archive.vtable.Extract(self.archive.archive, ffi.NULL, 0xFFFFFFFF, 0, callback_inst))
RNOK(self.archive.archive.vtable.Extract(self.archive.archive, indices, 1, 0, callback_inst))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to avoid lib7zip::GetStream @ extract_callback.py:163 - DEBUG - index not found log

Comment thread lib7zip/winhelpers.py
elif vt == VARTYPE.VT_FILETIME:
timestamp = int(pvar.filetime.dwLowDateTime)
timestamp += int(pvar.filetime.dwLowDateTime) << 32
timestamp += int(pvar.filetime.dwHighDateTime) << 32
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obvious, was unfortunate that dwLowDateTime was used instead of dwHighDateTime

@cielavenir
Copy link
Copy Markdown
Author

@harvimt diff annotation (each error message) completed. also now password is supported~~

@cielavenir cielavenir changed the title was able to test on Linux successfully was able to test on Linux successfully (7z v23+) Apr 30, 2026
@cielavenir cielavenir changed the title was able to test on Linux successfully (7z v23+) was able to test on Linux successfully (7z v23+). fixed extracting of encrypted archives. May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants