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
Gwenaël Samain
cython
Commits
718a4e27
Commit
718a4e27
authored
Aug 21, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Py3 test fixes
parent
d2f151ed
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
tests/run/cdivision_CEP_516.pyx
tests/run/cdivision_CEP_516.pyx
+16
-14
No files found.
tests/run/cdivision_CEP_516.pyx
View file @
718a4e27
...
...
@@ -32,7 +32,7 @@ True
>>> all([div_int_py(a,b) == a // b for a in range(-10, 10) for b in range(-10, 10) if b != 0])
True
>>> def simple_warn(msg, *args): print
msg
>>> def simple_warn(msg, *args): print
(msg)
>>> import warnings
>>> warnings.showwarning = simple_warn
...
...
@@ -52,23 +52,25 @@ division with oppositely signed operands, C and Python semantics differ
>>> mod_div_zero_int(25, 10, 2)
verbose_call(5)
2
>>>
mod_div_zero_int(25, 10, 0
)
>>>
print(mod_div_zero_int(25, 10, 0)
)
verbose_call(5)
'integer division or modulo by zero'
>>>
mod_div_zero_int(25, 0, 0
)
'integer division or modulo by zero'
integer division or modulo by zero
>>>
print(mod_div_zero_int(25, 0, 0)
)
integer division or modulo by zero
>>> mod_div_zero_float(25, 10, 2)
2.5
>>>
mod_div_zero_float(25, 10, 0
)
'float division'
>>>
mod_div_zero_float(25, 0, 0
)
'float divmod()'
>>>
print(mod_div_zero_float(25, 10, 0)
)
float division
>>>
print(mod_div_zero_float(25, 0, 0)
)
float divmod()
>>> import sys
>>> py_div_long(-5, -1)
5
>>> py_div_long(-sys.maxint-1, -1)
>>> import sys
>>> maxint = getattr(sys, ((sys.version_info[0] >= 3) and 'maxsize' or 'maxint'))
>>> py_div_long(-maxint-1, -1)
Traceback (most recent call last):
...
OverflowError: value too large to perform division
...
...
@@ -136,7 +138,7 @@ def complex_expression(int a, int b, int c, int d):
return
(
a
//
verbose_call
(
b
))
%
(
verbose_call
(
c
)
//
d
)
cdef
int
verbose_call
(
int
x
):
print
"verbose_call(%s)"
%
x
print
u
"verbose_call(%s)"
%
x
return
x
...
...
@@ -147,14 +149,14 @@ def mod_div_zero_int(int a, int b, int c):
try
:
return
verbose_call
(
a
%
b
)
/
c
except
ZeroDivisionError
,
ex
:
return
str
(
ex
)
return
unicode
(
ex
)
@
cython
.
cdivision
(
False
)
def
mod_div_zero_float
(
float
a
,
float
b
,
float
c
):
try
:
return
(
a
%
b
)
/
c
except
ZeroDivisionError
,
ex
:
return
str
(
ex
)
return
unicode
(
ex
)
@
cython
.
cdivision
(
False
)
def
py_div_long
(
long
a
,
long
b
):
...
...
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