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():
...
@@ -348,7 +348,7 @@ def get_cython_cache_dir():
@
contextmanager
@
contextmanager
def
captured_fd
(
stream
=
2
):
def
captured_fd
(
stream
=
2
,
encoding
=
None
):
pipe_in
=
t
=
None
pipe_in
=
t
=
None
orig_stream
=
os
.
dup
(
stream
)
# keep copy of original stream
orig_stream
=
os
.
dup
(
stream
)
# keep copy of original stream
try
:
try
:
...
@@ -369,11 +369,17 @@ def captured_fd(stream=2):
...
@@ -369,11 +369,17 @@ def captured_fd(stream=2):
finally
:
finally
:
os
.
close
(
pipe_in
)
os
.
close
(
pipe_in
)
def
get_output
():
output
=
b''
.
join
(
data
)
if
encoding
:
output
=
output
.
decode
(
encoding
)
return
output
from
threading
import
Thread
from
threading
import
Thread
t
=
Thread
(
target
=
copy
)
t
=
Thread
(
target
=
copy
)
t
.
daemon
=
True
# just in case
t
.
daemon
=
True
# just in case
t
.
start
()
t
.
start
()
yield
data
yield
get_output
finally
:
finally
:
os
.
dup2
(
orig_stream
,
stream
)
# restore original stream
os
.
dup2
(
orig_stream
,
stream
)
# restore original stream
if
t
is
not
None
:
if
t
is
not
None
:
...
...
runtests.py
View file @
f54826aa
...
@@ -868,20 +868,25 @@ class CythonCompileTestCase(unittest.TestCase):
...
@@ -868,20 +868,25 @@ class CythonCompileTestCase(unittest.TestCase):
so_path = None
so_path = None
if not self.cython_only:
if not self.cython_only:
from Cython.Utils import captured_fd
from Cython.Utils import captured_fd
c_compiler
_stderr = None
get
_stderr = None
try:
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)
so_path = self.run_distutils(test_directory, module, workdir, incdir)
except Exception:
except Exception:
if expected_errors == '_FAIL_C_COMPILE':
if expected_errors == '_FAIL_C_COMPILE'
and get_stderr and get_stderr()
:
assert c_compiler_stderr
pass
else:
else:
raise
raise
else:
else:
c_compiler_stderr =
''.join(c_compiler_stderr).strip
()
c_compiler_stderr =
get_stderr
()
if c_compiler_stderr:
if c_compiler_stderr:
print("
\
n
===
C
/
C
++
compiler
output
:
===
")
print("
\
n
===
C
/
C
++
compiler
error
output
:
===
")
print(c_compiler_stderr)
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':
if expected_errors == '_FAIL_C_COMPILE':
# must raise this outside the try block
# must raise this outside the try block
raise RuntimeError('should have failed C compile')
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