Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_undecodable_filename() in Lib/test/test_httpservers.py broken on APFS #75561

Closed
howarthjw mannequin opened this issue Sep 7, 2017 · 9 comments
Closed

test_undecodable_filename() in Lib/test/test_httpservers.py broken on APFS #75561

howarthjw mannequin opened this issue Sep 7, 2017 · 9 comments
Labels
3.7 (EOL) end of life OS-mac tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@howarthjw
Copy link
Mannequin

howarthjw mannequin commented Sep 7, 2017

BPO 31380
Nosy @ronaldoussoren, @vstinner, @ned-deily, @serhiy-storchaka, @mattbillenstein
PRs
  • bpo-31380: Skip test_httpservers test_undecodable_file on macOS. #4720
  • [3.6] bpo-31380: Skip test_httpservers test_undecodable_file on macOS. (GH-4720) #4721
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-12-05.05:09:03.923>
    created_at = <Date 2017-09-07.09:58:29.587>
    labels = ['OS-mac', 'type-bug', 'tests', '3.7']
    title = 'test_undecodable_filename() in Lib/test/test_httpservers.py broken on APFS'
    updated_at = <Date 2017-12-05.05:09:03.921>
    user = 'https://bugs.python.org/howarthjw'

    bugs.python.org fields:

    activity = <Date 2017-12-05.05:09:03.921>
    actor = 'ned.deily'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-12-05.05:09:03.923>
    closer = 'ned.deily'
    components = ['macOS', 'Tests']
    creation = <Date 2017-09-07.09:58:29.587>
    creator = 'howarthjw'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31380
    keywords = ['patch']
    message_count = 9.0
    messages = ['301580', '306006', '307106', '307109', '307114', '307116', '307641', '307643', '307644']
    nosy_count = 6.0
    nosy_names = ['ronaldoussoren', 'vstinner', 'ned.deily', 'serhiy.storchaka', 'mattbillenstein', 'howarthjw']
    pr_nums = ['4720', '4721']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue31380'
    versions = ['Python 3.6', 'Python 3.7']

    @howarthjw
    Copy link
    Mannequin Author

    howarthjw mannequin commented Sep 7, 2017

    The Python 3.x test suite produces a new regression on macOS 10.13 under the new APFS filesystem when executing the test_undecodable_filename() test from Lib/test/test_httpservers.py. The error appears as...

    ======================================================================
    ERROR: test_undecodable_filename
    (test.test_httpservers.SimpleHTTPServerTestCase)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/Users/howarth/Python-3.6.2/Lib/test/support/__init__.py",
    line 601, in wrapper
        return func(*args, **kw)
      File "/Users/howarth/Python-3.6.2/Lib/test/test_httpservers.py",
    line 380, in test_undecodable_filename
        with open(os.path.join(self.tempdir, filename), 'wb') as f:
    OSError: [Errno 92] Illegal byte sequence:
    '/var/folders/7g/1x2rsy3j40n1pydq931hzlkm0000gn/T/tmpomp1r36b/@test_58317_tmp\udce7w\udcf0.txt'

    Ran 59 tests in 3.207s

    See https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html

    """
    APFS accepts only valid UTF-8 encoded filenames for creation, and preserves both case and normalization of the filename on disk in all variants..

    Some differences between how APFS and HFS+ handle filenames include the following:
    ...
    • APFS doesn’t allow files to be created with filenames that contain unassigned codepoints in the Unicode 9.0 standard, whereas HFS+ does.

    @howarthjw howarthjw mannequin added type-crash A hard crash of the interpreter, possibly with a core dump 3.7 (EOL) end of life OS-mac labels Sep 7, 2017
    @mattbillenstein
    Copy link

    Reflected on the High Sierra buildbot now: http://buildbot.python.org/all/#/builders/14/builds/162

    @serhiy-storchaka serhiy-storchaka added tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error and removed type-crash A hard crash of the interpreter, possibly with a core dump labels Nov 10, 2017
    @ned-deily
    Copy link
    Member

    More background: APFS became available in macOS 10.12 although not used by default. But with the current macOS 10.13 (High Sierra), root file systems on certain devices, such as SSDs, are automatically migrated from HFS+ to APFS so are much more likely to be seen starting in 10.13 and, in general, there is no easy way of knowing what type of FS a particular file resides on.

    # TMPDIR on APFS volume
    $ ./bin/python3.7 -m test test_httpservers
    Run tests sequentially
    0:00:00 load avg: 1.43 [1/1] test_httpservers
    test test_httpservers failed -- Traceback (most recent call last):
      File ".../lib/python3.7/test/support/__init__.py", line 598, in wrapper
        return func(*args, **kw)
      File ".../lib/python3.7/test/test_httpservers.py", line 395, in test_undecodable_filename
        with open(os.path.join(self.tempdir, filename), 'wb') as f:
    OSError: [Errno 92] Illegal byte sequence: '/var/folders/sn/0m4rnbyj2z1byjs68sz838300000gn/T/tmpqeg89k76/@test_64005_tmp\udce7w\udcf0.txt'

    test_httpservers failed

    1 test failed:
    test_httpservers

    Total duration: 3 sec
    Tests result: FAILURE
    # TMPDIR redirected to HFS+ volume
    $ TMPDIR=/Volumes/euterpe/a ./bin/python3.7 -m test test_httpservers
    Run tests sequentially
    0:00:00 load avg: 1.28 [1/1] test_httpservers
    1 test OK.

    Total duration: 3 sec
    Tests result: SUCCESS

    @vstinner, as the expert in this area, what do you suggest as the best way to deal with this? In support.__init__.py? Or test_httpservers itself?

    @serhiy-storchaka
    Copy link
    Member

    I suggest to catch an error and skip the test if OSError with the specific errno has been raised.

    @vstinner
    Copy link
    Member

    @vstinner, as the expert in this area, what do you suggest as the best way to deal with this? In support.__init__.py? Or test_httpservers itself?

    It's tricky when a filename is valid or not depending on the path, depending on the filesystem. The tempfile module checks if O_TMPFILE is supported: same issue, it depends on the path, and the user can configure the path. So we check each time if O_TMPFILE works or not.

    @ronaldoussoren
    Copy link
    Contributor

    Another option is to skip this test unconditionally on macOS when using APFS, the test is already skipped on win32 and tests a generic codepath where only testing on Linux should be fine.

    BTW. It is fairly easy to detect if a path is on APFS:

    import subprocess
      
    def is_apfs(path):
        lines = subprocess.check_output(['df', path]).decode('utf-8').splitlines()
        mountpoint = lines[1].split(None, 1)[0]
    
        lines = subprocess.check_output(['mount']).decode('utf-8').splitlines()
        for ln in lines:
            path = ln.split(None, 1)[0]
            if path == mountpoint:
                return '(apfs' in ln
    
        return False
    

    @ned-deily
    Copy link
    Member

    New changeset b3edde8 by Ned Deily in branch 'master':
    bpo-31380: Skip test_httpservers test_undecodable_file on macOS. (bpo-4720)
    b3edde8

    @ned-deily
    Copy link
    Member

    New changeset d9cadc5 by Ned Deily (Miss Islington (bot)) in branch '3.6':
    [3.6] bpo-31380: Skip test_httpservers test_undecodable_file on macOS. (GH-4720) (bpo-4721)
    d9cadc5

    @ned-deily
    Copy link
    Member

    I've chosen to unconditionally skip test_undecodable_filename on macOS; it was already skipped for older macOS systems and I think it would be a mistake to test for a specific error code that could change in later releases. As Ronald points out, testing on Linux should be sufficient. Thanks everyone for your input. Fixed in 3.6.4 and 3.7.0.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life OS-mac tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants