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_timestamp_overflow of test_importlib fails if PYTHONDONTWRITEBYTECODE is set #70770

Closed
inglesp mannequin opened this issue Mar 17, 2016 · 8 comments
Closed

test_timestamp_overflow of test_importlib fails if PYTHONDONTWRITEBYTECODE is set #70770

inglesp mannequin opened this issue Mar 17, 2016 · 8 comments
Assignees
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@inglesp
Copy link
Mannequin

inglesp mannequin commented Mar 17, 2016

BPO 26583
Nosy @brettcannon, @ned-deily
Files
  • issue26583.patch
  • 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 = 'https://github.com/ned-deily'
    closed_at = <Date 2016-03-17.21:59:29.817>
    created_at = <Date 2016-03-17.17:16:47.842>
    labels = ['type-bug', 'tests']
    title = 'test_timestamp_overflow of test_importlib fails if PYTHONDONTWRITEBYTECODE is set'
    updated_at = <Date 2016-03-17.21:59:29.815>
    user = 'https://bugs.python.org/inglesp'

    bugs.python.org fields:

    activity = <Date 2016-03-17.21:59:29.815>
    actor = 'ned.deily'
    assignee = 'ned.deily'
    closed = True
    closed_date = <Date 2016-03-17.21:59:29.817>
    closer = 'ned.deily'
    components = ['Tests']
    creation = <Date 2016-03-17.17:16:47.842>
    creator = 'inglesp'
    dependencies = []
    files = ['42189']
    hgrepos = []
    issue_num = 26583
    keywords = ['patch']
    message_count = 8.0
    messages = ['261919', '261922', '261927', '261929', '261930', '261931', '261937', '261938']
    nosy_count = 4.0
    nosy_names = ['brett.cannon', 'ned.deily', 'python-dev', 'inglesp']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue26583'
    versions = ['Python 3.5', 'Python 3.6']

    @inglesp
    Copy link
    Mannequin Author

    inglesp mannequin commented Mar 17, 2016

    I get the following test failure against changeset 100576 on OSX 10.9.5:

    $ ./python.exe -m test test_import
    [1/1] test_import
    test test_import failed -- Traceback (most recent call last):
      File "/Users/peteringlesby/src/cpython/Lib/test/test_import/__init__.py", line 301, in test_timestamp_overflow
        os.stat(compiled)
    FileNotFoundError: [Errno 2] No such file or directory: '__pycache__/@test_68937_tmp.cpython-36.pyc'

    1 test failed:
    test_import

    @SilentGhost SilentGhost mannequin added OS-mac tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error labels Mar 17, 2016
    @ned-deily
    Copy link
    Member

    Sorry, I am unable to reproduce this on either 10.9.5 or current 10.11.3 OS X systems. Is there something unusual about the working directory you are running the tests from, like residing on an NFS or other networked file system? Any special ./configure options? Does the test always fail?

    @inglesp
    Copy link
    Mannequin Author

    inglesp mannequin commented Mar 17, 2016

    I can reproduce it reliably.

    I ran ./configure with --with-pydebug.

    I'm not using NFS, and I'm not aware of anything else unusual about my filesystem.

    The fact that a timestamp overflows in the failing test is a red herring -- the following also fails, with os.stat raising FileNotFoundError:

        def test_without_timestamp_overflow(self):
            sys.path.insert(0, os.curdir)
            try:
                source = TESTFN + ".py"
                compiled = importlib.util.cache_from_source(source)
                with open(source, 'w') as f:
                    pass
                __import__(TESTFN)
                os.stat(compiled)
            finally:
                del sys.path[0]
                remove_files(TESTFN)

    I've verified that TESTFN does get imported by writing 'print("hello")' to the source file.

    @inglesp
    Copy link
    Mannequin Author

    inglesp mannequin commented Mar 17, 2016

    The problem is that I have PYTHONDONTWRITEBYTECODE set in my environment.

    Should the setUp and tearDown methods ensure that PYTHONDONTWRITEBYTECODE is cleared and reset?

    @ned-deily
    Copy link
    Member

    Ah, setting PYTHONDONTWRITEBYTECODE explains it. When running the tests via "make test", python is invoked with -E to avoid issues like that. But here's a patch that skips test_timestamp_overflow if bytecode files cannot be written (bpo-20796 documents a similar problem and workaround for test_import).

    @ned-deily ned-deily removed the OS-mac label Mar 17, 2016
    @ned-deily ned-deily changed the title test_timestamp_overflow fails test_timestamp_overflow of test_importlib fails if PYTHONDONTWRITEBYTECODE is set Mar 17, 2016
    @brettcannon
    Copy link
    Member

    LGTM, Ned.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 17, 2016

    New changeset 915f158633f4 by Ned Deily in branch '3.5':
    Issue bpo-26583: Skip test_timestamp_overflow in test_import if bytecode
    https://hg.python.org/cpython/rev/915f158633f4

    New changeset e8cab14d8a47 by Ned Deily in branch 'default':
    Issue bpo-26583: merge from 3.5
    https://hg.python.org/cpython/rev/e8cab14d8a47

    @ned-deily
    Copy link
    Member

    Pushed for release in 3.5.2 and 3.6.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
    tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants