Issue 26937: the chown() method of the tarfile.TarFile class fails on Android - Python tracker

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: xdegaye Nosy List: Alex.Willmer, lars.gustaebel, python-dev, xdegaye
Priority: normal Keywords: patch

Created on 2016-05-03 15:14 by xdegaye, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pwd_grp.patch xdegaye, 2016-05-14 11:16 review
pwd_grp_2.patch xdegaye, 2016-10-30 19:32 review
Pull Requests
URL Status Linked Edit
PR 552 closed dstufft, 2017-03-31 16:36
Messages (4)
msg264738 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016-05-03 15:14
test_tarfile fails on an android emulator running an x86 system image at API level 21.


======================================================================                      [0/9481]
FAIL: test_extract_with_numeric_owner (test.test_tarfile.NumericOwnerTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/sdcard/org.bitbucket.pyona/lib/python3.6/unittest/mock.py", line 1175, in patched
    return func(*args, **keywargs)
  File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_tarfile.py", line 2483, in test_extract_
with_numeric_owner
    any_order=True)
  File "/sdcard/org.bitbucket.pyona/lib/python3.6/unittest/mock.py", line 856, in assert_has_calls
    ) from cause
AssertionError: (call('/data/local/tmp/test_python_2938/@test_2938_tmp-tardir/numeric-owner-testfile
', 99, 98), call('/data/local/tmp/test_python_2938/@test_2938_tmp-tardir/dir/numeric-owner-testfile'
, 88, 87)) not all found in call list

======================================================================
FAIL: test_extractall_with_numeric_owner (test.test_tarfile.NumericOwnerTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/sdcard/org.bitbucket.pyona/lib/python3.6/unittest/mock.py", line 1175, in patched
    return func(*args, **keywargs)
  File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_tarfile.py", line 2503, in test_extracta
ll_with_numeric_owner
    any_order=True)
  File "/sdcard/org.bitbucket.pyona/lib/python3.6/unittest/mock.py", line 856, in assert_has_calls
    ) from cause
AssertionError: (call('/data/local/tmp/test_python_2938/@test_2938_tmp-tardir/numeric-owner-testfile
', 99, 98), call('/data/local/tmp/test_python_2938/@test_2938_tmp-tardir/dir', 77, 76), call('/data/
local/tmp/test_python_2938/@test_2938_tmp-tardir/dir/numeric-owner-testfile', 88, 87)) not all found
 in call list

----------------------------------------------------------------------
Ran 426 tests in 5.549s

FAILED (failures=2, skipped=80)
test test_tarfile failed
1 test failed:
    test_tarfile
Total duration: 0:00:06
msg265520 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016-05-14 11:16
On the android-21-x86 emulator:

>>> import grp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen failed: cannot locate symbol "setgrent" referenced by "grp.cpython-36m-i386-linux-gnu.so"...

The attached patch fixes the tarfile module to handle the case where the pwd module can be imported and the grp module cannot. With this fix test_tarfile runs without any failure.
msg279744 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016-10-30 19:32
The chown() method of the tarfile.TarFile class does not attempt to do a chown when pwd is None, even when numeric_owner is True, and although an attempt is made to fall back to tarinfo.gid when getgrnam() fails, or to tarinfo.uid when getgrnam() fails, nothing is done if only one of the grp or pwd modules fails on import.

This new patch is similar to the previous one and is more explicit.
msg282770 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-12-09 08:36
New changeset e4e7bc640865 by Xavier de Gaye in branch '3.6':
Issue #26937: The chown() method of the tarfile.TarFile class does not fail now
https://hg.python.org/cpython/rev/e4e7bc640865

New changeset da510d1aa683 by Xavier de Gaye in branch 'default':
Issue #26937: Merge 3.6.
https://hg.python.org/cpython/rev/da510d1aa683