Tar file extraction fails on AIX

Tar file extractall() method is failing on AIX with following error. The same is not seen on other platforms like linux and freebsd. Any help as what to look for.

lib/python3.10/tarfile.py", line 2196, in makedir
OSError: [Errno 0] Error: ‘./.’

Not that I know the first thing about AIX, but is that not a path error?

By Narender via Discussions on Python.org at 16May2022 23:47:

Tar file extractall() method is failing on AIX with following error.
The same is not seen on other platforms like linux and freebsd. Any
help as what to look for.

lib/python3.10/tarfile.py", line 2196, in makedir
OSError: [Errno 0] Error: ‘./.’

You’re testing with the same specific file?

The makedir function isn’t at line 2196 in my 3.10 python install (not
AIX), but makedir looks like this here:

def makedir(self, tarinfo, targetpath):
    """Make a directory called targetpath.
    """
    try:
        # Use a safe mode for the directory, the real mode is set
        # later in _extract_member().
        os.mkdir(targetpath, 0o700)
    except FileExistsError:
        pass

That’s a pretty weird path to try to make intentionally, but a simply
implemented tar extract might easily do it, and the code above handles
it. './.' is the current directory and already exists, so it should
raise FileExistsError. But errno==0 is pretty weird - I don’t expect
errno to be zero for a real error.

What happens at the Python 3.10 prompt with this:

import os
os.mkdir('.')
os.mkdir('./.')

Also, is there an errno 0 defined?

import errno
print(repr(sorted(errno.errorcode.keys())))

Cheers,
Cameron Simpson cs@cskk.id.au

Thank you for looking into this.

Python3.10.4 is cross compiled for AIX.

tar file has following content.

-bash-4.2# tar -tvf sample.tar
drwxr-xr-x 400 401 0 Apr 08 20:44:35 2022 ./
-rw-r–r-- 400 401 5063662 Apr 01 21:03:24 2022 ./sample.txt
-bash-4.2#

Here are the errno’s output:

errnos:[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 49, 52, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 93, 109, 112, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]

By Narender via Discussions on Python.org at 17May2022 16:41:

Python3.10.4 is cross compiled for AIX.

Ok. My local 3.10 is 3.10.0.

Can you shown the makedir source code in your version? There should be
a tarfile.py module in your Python install’s library tree. For
comparison, here (on a Mac) it is at
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/tarfile.py.
Yours may be in /opt or /usr/local somewhere.

tar file has following content.

-bash-4.2# tar -tvf sample.tar
drwxr-xr-x 400 401 0 Apr 08 20:44:35 2022 ./
-rw-r–r-- 400 401 5063662 Apr 01 21:03:24 2022 ./sample.txt

That’s a good test.

Here are the errno’s output:

errnos:[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 49, 52, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 93, 109, 112, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]

Thanks. As you see, no error code 0.

Can you run the other tests I asked for using os.mkdir, because on the
face of it the only way for thing to fail is for os.mkdir to have a
surprising behaviour?

Thanks,
Cameron Simpson cs@cskk.id.au

I have the same on my machine.

def makedir(self, tarinfo, targetpath):
“”“Make a directory called targetpath.
“””
try:
# Use a safe mode for the directory, the real mode is set
# later in _extract_member().
os.mkdir(targetpath, 0o700)
except FileExistsError:
pass

Python 3.10.4 (main, May 10 2022, 12:56:49) [GCC 9.3.0] on aix
Type “help”, “copyright”, “credits” or “license” for more information.

import os
os.mkdir(’.’)
Traceback (most recent call last):
File “”, line 1, in
FileExistsError: [Errno 17] File exists: ‘.’

os.mkdir(’./.’)
Traceback (most recent call last):
File “”, line 1, in
FileExistsError: [Errno 17] File exists: ‘./.’

Looks like there is no issue running the program independently. I am actually freezing the application using freeze.py and the frozen application is the one throwing this error. Did not realize this until now.

Python 3.10.4 (main, May 10 2022, 12:56:49) [GCC 9.3.0] on aix
Type “help”, “copyright”, “credits” or “license” for more information.

import tarfile
taropener = tarfile.open(’/tmp/sample.tar’)
import os
os.chdir(’/tmp/sampletest’)
taropener.extractall()
os.listdir(’/tmp/sampletest’)
[‘sample.txt’]

exit()
-bash-4.2#

By Narender via Discussions on Python.org at 17May2022 23:33:

I have the same on my machine.

Good. Expected, since this is very stable code, but good to confirm.

Python 3.10.4 (main, May 10 2022, 12:56:49) [GCC 9.3.0] on aix
Type “help”, “copyright”, “credits” or “license” for more information.

import os
os.mkdir(’.’)
Traceback (most recent call last):
File “”, line 1, in
FileExistsError: [Errno 17] File exists: ‘.’

os.mkdir(’./.’)
Traceback (most recent call last):
File “”, line 1, in
FileExistsError: [Errno 17] File exists: ‘./.’

Looks like there is no issue running the program independently. I am actually freezing the application using freeze.py and the frozen application is the one throwing this error. Did not realize this until now.

That’s interesting.

Where’s freeze.py come from?

Is there strace or truss on your AIX box? You might trace the system
calls the untar is using. However, an OSError with .errno==0
suggests something has hand rolled an OSError and not initialised the
.errno attribute. Whereas os.mkdir should be making one from the
C-level errno variable after a failed C-level mkdir call.

Cheers,
Cameron Simpson cs@cskk.id.au