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
Patchbot and Python 3 doctest failures #28622
Comments
comment:1
The failures:
and
and
|
comment:3
A quicker way to get the failures: >>> from sage_patchbot.patchbot import Tee
>>> with Tee('/path/to/logfile', time=True, timeout=40):
... os.system('/path/to/SAGE_ROOT/sage -tp 3 --long src/sage/repl/attach.py src/sage/numerical/backends/generic_backend.pyx src/sage/libs/singular/function.pyx') |
This comment has been minimized.
This comment has been minimized.
comment:5
Could the problem be the inheritability (or not) of the file descriptors in diff --git a/sage_patchbot/patchbot.py b/sage_patchbot/patchbot.py
index b411c7c..2994db1 100755
--- a/sage_patchbot/patchbot.py
+++ b/sage_patchbot/patchbot.py
@@ -142,8 +142,8 @@ class Tee(object):
self._saved = os.dup(sys.stdout.fileno()), os.dup(sys.stderr.fileno())
self.tee = subprocess.Popen(["tee", self.filepath],
stdin=subprocess.PIPE)
- os.dup2(self.tee.stdin.fileno(), sys.stdout.fileno())
- os.dup2(self.tee.stdin.fileno(), sys.stderr.fileno())
+ # os.dup2(self.tee.stdin.fileno(), sys.stdout.fileno())
+ # os.dup2(self.tee.stdin.fileno(), sys.stderr.fileno())
if self.time:
print(now_str())
self.start_time = time.time() Of course also the log file doesn't get written. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:8
Could there be some connection to the use of Python's diff --git a/src/sage/repl/attach.py b/src/sage/repl/attach.py
index c350ec33af..e1c98e32ad 100644
--- a/src/sage/repl/attach.py
+++ b/src/sage/repl/attach.py
@@ -36,7 +36,7 @@ character-by-character::
sage: try:
....: attach(src)
....: except Exception:
- ....: traceback.print_exc()
+ ....: raise
Traceback (most recent call last):
...
exec(preparse_file(f.read()) + "\n", globals)
@@ -48,7 +48,7 @@ character-by-character::
sage: try:
....: attach(src)
....: except Exception:
- ....: traceback.print_exc()
+ ....: raise
Traceback (most recent call last):
...
exec(code, globals) |
comment:9
The following change to diff --git a/src/sage/repl/attach.py b/src/sage/repl/attach.py
index c350ec33af..bdfaad4f7f 100644
--- a/src/sage/repl/attach.py
+++ b/src/sage/repl/attach.py
@@ -20,12 +20,8 @@ Check that no file clutter is produced::
['foobar.sage']
sage: detach(src)
-In debug mode backtraces contain code snippets. We need to manually
-print the traceback because the python doctest module has special
-support for exceptions and does not match them
-character-by-character::
+Check printing of code snippets in debug mode::
- sage: import traceback
sage: with open(src, 'w') as f:
....: _ = f.write('# first line\n')
....: _ = f.write('# second line\n')
@@ -33,10 +29,7 @@ character-by-character::
....: _ = f.write('# fourth line\n')
sage: load_attach_mode(attach_debug=False)
- sage: try:
- ....: attach(src)
- ....: except Exception:
- ....: traceback.print_exc()
+ sage: attach(src)
Traceback (most recent call last):
...
exec(preparse_file(f.read()) + "\n", globals)
@@ -45,10 +38,7 @@ character-by-character::
sage: detach(src)
sage: load_attach_mode(attach_debug=True)
- sage: try:
- ....: attach(src)
- ....: except Exception:
- ....: traceback.print_exc()
+ sage: attach(src)
Traceback (most recent call last):
...
exec(code, globals) The problem is that it would allow some doctests to pass that should fail. From the file: sage: with open(src, 'w') as f:
....: _ = f.write('# first line\n')
....: _ = f.write('# second line\n')
....: _ = f.write('raise ValueError("third") # this should appear in the source snippet\n')
....: _ = f.write('# fourth line\n') Then this passes, as it should: sage: load_attach_mode(attach_debug=True)
sage: attach(src)
Traceback (most recent call last):
...
exec(code, globals)
File ".../foobar.sage....py", line ..., in <module>
raise ValueError("third") # this should appear in the source snippet
ValueError: third But this also passes: note that the second to last line is different: sage: load_attach_mode(attach_debug=True)
sage: attach(src)
Traceback (most recent call last):
...
exec(code, globals)
File ".../foobar.sage....py", line ..., in <module>
raise ValueError("third") # this is gibberish
ValueError: third I guess this is what is meant by "We need to manually print the traceback because ..." |
comment:10
Nice to see that you are making progress. Sorry that I cannot help. |
This comment has been minimized.
This comment has been minimized.
comment:12
FWIW, I systematically get these doctest failures outside the patchbot framework, namely on a Ubuntu 18.04 computer when doing |
comment:13
Couldn't some of them be yet another cases of "flush missing", as the previous py3 problems that were fixed ? In the repl_attach case, the correct answer seems to appear in the next doctest. |
comment:14
Interesting question. If I add some |
Branch: u/jhpalmieri/flushing |
Commit: |
comment:16
Okay, here is an attempt at a fix. It fixes the particular problem in the ticket description, at least for me on OS X. Eric, does it help with your situation? Should I mark it as "needs review", or should some explanatory comments be added? Or is it even the correct approach? New commits:
|
comment:17
This looks good enough for me, even if this is maybe more fixing symptoms than illness. I will launch my atlas patchbot on the branch. |
comment:18
This seems to work with python2 and to fix the python3 issues also on Ubuntu patchbot. I am extremely tempted to give a positive review. |
comment:19
Replying to @jhpalmieri:
I am just running |
comment:20
Replying to @egourgoulhon:
Here is the report from my Ubuntu 18.04 computer:
In other words, all the doctests discussed here are passed! The only failure is that discussed in #28334. So +1 for the positive review. |
comment:21
ok, so let us first turn to "needs review" |
comment:22
John, do you agree that this could be set to positive ? |
comment:23
It’s okay with me. |
Author: John Palmieri |
comment:24
Good. I am setting to positive. |
Reviewer: Frédéric Chapoton, Eric Gourgoulhon |
comment:25
Shouldn't we add reference to this ticket to the added lines of code to avoid inadvertent removal ? |
Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:
|
comment:27
Replying to @dcoudert:
Done. I'm setting back to positive review, also. |
Changed branch from u/jhpalmieri/flushing to |
Changed reviewer from Frédéric Chapoton, Eric Gourgoulhon to Frédéric Chapoton, Eric Gourgoulhon |
Changed commit from |
With a Python 3 patchbot and a Ubuntu 18.04 computer running
make ptestlong
, there are doctest failures in three files:This can be replicated by hand. cd to SAGE_ROOT for a Sage built with Python 3, run Python, and do
Note that in a fresh Python session, the following does not lead to errors:
Component: python3
Author: John Palmieri
Branch:
56e1642
Reviewer: Frédéric Chapoton, Eric Gourgoulhon
Issue created by migration from https://trac.sagemath.org/ticket/28622
The text was updated successfully, but these errors were encountered: