Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
f54826aa
Commit
f54826aa
authored
May 02, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix stderr test output printing in Py3
parent
047a1d83
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
Cython/Utils.py
Cython/Utils.py
+8
-2
runtests.py
runtests.py
+12
-7
No files found.
Cython/Utils.py
View file @
f54826aa
...
...
@@ -348,7 +348,7 @@ def get_cython_cache_dir():
@
contextmanager
def
captured_fd
(
stream
=
2
):
def
captured_fd
(
stream
=
2
,
encoding
=
None
):
pipe_in
=
t
=
None
orig_stream
=
os
.
dup
(
stream
)
# keep copy of original stream
try
:
...
...
@@ -369,11 +369,17 @@ def captured_fd(stream=2):
finally
:
os
.
close
(
pipe_in
)
def
get_output
():
output
=
b''
.
join
(
data
)
if
encoding
:
output
=
output
.
decode
(
encoding
)
return
output
from
threading
import
Thread
t
=
Thread
(
target
=
copy
)
t
.
daemon
=
True
# just in case
t
.
start
()
yield
data
yield
get_output
finally
:
os
.
dup2
(
orig_stream
,
stream
)
# restore original stream
if
t
is
not
None
:
...
...
runtests.py
View file @
f54826aa
...
...
@@ -868,20 +868,25 @@ class CythonCompileTestCase(unittest.TestCase):
so_path = None
if not self.cython_only:
from Cython.Utils import captured_fd
c_compiler
_stderr = None
get
_stderr = None
try:
with captured_fd(2) as
c_compiler
_stderr:
with captured_fd(2) as
get
_stderr:
so_path = self.run_distutils(test_directory, module, workdir, incdir)
except Exception:
if expected_errors == '_FAIL_C_COMPILE':
assert c_compiler_stderr
if expected_errors == '_FAIL_C_COMPILE'
and get_stderr and get_stderr()
:
pass
else:
raise
else:
c_compiler_stderr =
''.join(c_compiler_stderr).strip
()
c_compiler_stderr =
get_stderr
()
if c_compiler_stderr:
print("
\
n
===
C
/
C
++
compiler
output
:
===
")
print(c_compiler_stderr)
print("
\
n
===
C
/
C
++
compiler
error
output
:
===
")
sys.stdout.flush()
try:
out = sys.stdout.buffer # Py3
except AttributeError:
out = sys.stdout # Py2
out.write(c_compiler_stderr)
if expected_errors == '_FAIL_C_COMPILE':
# must raise this outside the try block
raise RuntimeError('should have failed C compile')
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment