Opened 2 years ago

Closed 21 months ago

#27529 closed enhancement (fixed)

py3: tiny fix in env.py

Reported by: chapoton Owned by:
Priority: major Milestone: sage-8.8
Component: python3 Keywords:
Cc: embray, jdemeyer, tscrim, fbissey Merged in:
Authors: Frédéric Chapoton Reviewers: Jeroen Demeyer
Report Upstream: N/A Work issues:
Branch: 8ebcdc6 (Commits) Commit: 8ebcdc67d8abfec50d7891496bd6f069bd76ad99
Dependencies: Stopgaps:

Description


Change History (29)

comment:1 Changed 2 years ago by chapoton

  • Branch set to u/chapoton/27529
  • Cc embray jdemeyer added
  • Commit set to c6ca0b109482c081c79da9cfdb507793148c8fe7
  • Status changed from new to needs_review

New commits:

c6ca0b1py3 tiny fix in env.py

comment:2 Changed 2 years ago by chapoton

  • Cc tscrim fbissey added

green bot, please review

comment:3 Changed 2 years ago by jdemeyer

  • Status changed from needs_review to needs_work

Please use sys.executable instead.

comment:4 Changed 2 years ago by git

  • Commit changed from c6ca0b109482c081c79da9cfdb507793148c8fe7 to 812181f084f197c48be617e83f8f2414b6462c0d

Branch pushed to git repo; I updated commit sha1. New commits:

812181fusing sys.executable instead

comment:5 Changed 2 years ago by chapoton

  • Status changed from needs_work to needs_review

indeed, better. Thx

comment:6 Changed 2 years ago by chapoton

there is another one in src/sage/doctest/control.py, let us fix it too

comment:7 Changed 2 years ago by git

  • Commit changed from 812181f084f197c48be617e83f8f2414b6462c0d to 83aa62d3846a861c07e9b0a6edd4aeb915eedf65

Branch pushed to git repo; I updated commit sha1. New commits:

83aa62danother use of sys.executable

comment:8 Changed 2 years ago by jdemeyer

  • Reviewers set to Jeroen Demeyer

Very good! Positive review if this passes tests on Python 2 and 3.

comment:9 Changed 2 years ago by chapoton

hmm. The change in doctest control breaks one doctest in python3:

sage -t --long src/sage/doctest/control.py
**********************************************************************
File "src/sage/doctest/control.py", line 630, in sage.doctest.control.DocTestController.test_safe_directory
Failed example:
    DC.test_safe_directory(d)
Expected:
    Traceback (most recent call last):
    ...
    RuntimeError: refusing to run doctests...
Got:
    <BLANKLINE>

I am not sure what to do :

  • undo this change ?
  • tag the doctest with # py2 ?

comment:10 Changed 2 years ago by fbissey

That's interesting. It means two things if I am not mistaken.

  • python3 does allow you to run stuff from unsafe directories just like python2
  • the doctest and possibly the functionality never worked with python3. That bit must have always called python2.

comment:11 Changed 2 years ago by jdemeyer

  1. doctest is not tested by python3-known-passing.txt, so that doctest failure doesn't have to prevent merging this ticket. The fix makes sense, despite that it breaks a doctest.
  1. I posted about this failure on https://groups.google.com/d/msg/sage-devel/_pH7bjQmw5A/IJz_zlMxAwAJ but that thread didn't come to a conclusion.

comment:12 Changed 2 years ago by chapoton

I would prefer not to have any new py3-failing file.

comment:13 Changed 23 months ago by chapoton

  • Status changed from needs_review to positive_review

ok, let it be. Jeroen, I am setting to positive in your name.

comment:14 Changed 23 months ago by jdemeyer

I'm also not too happy with this situation, but at least this edited test reflects better the reality that it's failing on Python 3. Note that this specific test has always been somewhat controversial.

comment:15 Changed 23 months ago by embray

  • Status changed from positive_review to needs_work

Please squash your commits, and maybe reference this ticket # in the commit message.

comment:16 Changed 23 months ago by embray

See #26457 which discusses the possibility of removing this test altogether, or #25358 (which would conflict with this) for an alternative middle-ground.

I would rather we go ahead and do one of these than make fixes to a test that's dubious in the first place.

comment:17 Changed 23 months ago by vbraun

  • Branch changed from u/chapoton/27529 to 83aa62d3846a861c07e9b0a6edd4aeb915eedf65
  • Resolution set to fixed
  • Status changed from needs_work to closed

comment:18 Changed 23 months ago by vbraun

  • Commit 83aa62d3846a861c07e9b0a6edd4aeb915eedf65 deleted
  • Resolution fixed deleted
  • Status changed from closed to new

comment:19 Changed 23 months ago by embray

  • Status changed from new to needs_info

comment:20 Changed 23 months ago by chapoton

  • Status changed from needs_info to needs_review

comment:21 Changed 23 months ago by chapoton

  • Branch changed from 83aa62d3846a861c07e9b0a6edd4aeb915eedf65 to u/chapoton/27529
  • Commit set to e928ec7891d2c8d9134dd238c1859dd26f20d67d

New commits:

e928ec7trac #27529 py3 tiny fix in env.py (using sys.executable)

comment:22 follow-up: Changed 21 months ago by jhpalmieri

Why don't we split this (already tiny fix) into pieces? The change in env.py should be safe, right? The more controversial doctest can be dealt with elsewhere.

comment:23 in reply to: ↑ 22 Changed 21 months ago by fbissey

Replying to jhpalmieri:

Why don't we split this (already tiny fix) into pieces? The change in env.py should be safe, right? The more controversial doctest can be dealt with elsewhere.

Works for me.

comment:24 Changed 21 months ago by jhpalmieri

And just to make sure I understand correctly: there are two issues with the tests

    Check that Sage refuses to run doctests from a directory whose
    permissions are too loose.  We create a world-writable directory
    inside a safe temporary directory to test this::

        sage: d = os.path.join(tmp_dir(), "test")
        sage: os.mkdir(d)
        sage: os.chmod(d, 0o777)
        sage: (out, err, ret) = test_executable(["sage", "-t", "nonexisting.py"], cwd=d)
        sage: print(err)
        ...
        RuntimeError: refusing to run doctests...
        sage: (out, err, ret) = test_executable(["sage", "-tp", "1", "nonexisting.py"], cwd=d)
        sage: print(err)
        ...
        RuntimeError: refusing to run doctests...

right? First, they don't work at all with Python 3 because of subprocess.call(['python', ..., and second, they don't work with an unpatched Python. We can fix the second of these by tagging the doctests # build. We could fix the first in a less than ideal way by tagging the doctests # py2.

comment:25 Changed 21 months ago by fbissey

They would "work" if python was python3 which can kind of happen in sage-on-distro. But yes they are the kind of tests the # build tag is suitable for. More so than # py2.

comment:26 Changed 21 months ago by git

  • Commit changed from e928ec7891d2c8d9134dd238c1859dd26f20d67d to 8ebcdc67d8abfec50d7891496bd6f069bd76ad99

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

8ebcdc6trac #27529 py3 tiny fix in env.py (using sys.executable)

comment:27 Changed 21 months ago by chapoton

Here is a branch with only the changes in env.py. Positive ?

comment:28 Changed 21 months ago by jhpalmieri

  • Status changed from needs_review to positive_review

I think so. Jeroen already reviewed positively before, and I can confirm that the change fixes the py3 problem with env.py.

comment:29 Changed 21 months ago by vbraun

  • Branch changed from u/chapoton/27529 to 8ebcdc67d8abfec50d7891496bd6f069bd76ad99
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.