Skip to content
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

Backwards compability for Python 2 64bit #104

Merged
merged 2 commits into from
Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions pyswip/easy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@
# SOFTWARE.


import sys

from pyswip.core import *


# For backwards compability with Python 2 64bit
if sys.version_info < (3,):
integer_types = (int, long,)
else:
integer_types = (int,)


class InvalidTypeError(TypeError):
def __init__(self, *args):
type_ = args and args[0] or "Unknown"
Expand Down Expand Up @@ -67,7 +76,7 @@ def fromTerm(cls, term):

if isinstance(term, Term):
term = term.handle
elif not isinstance(term, (c_void_p, int)):
elif not isinstance(term, (c_void_p, integer_types)):
raise ArgumentTypeError((str(Term), str(c_void_p)), str(type(term)))

a = atom_t()
Expand Down Expand Up @@ -266,7 +275,7 @@ def fromTerm(cls, term):

if isinstance(term, Term):
term = term.handle
elif not isinstance(term, (c_void_p, int)):
elif not isinstance(term, (c_void_p, integer_types)):
raise ArgumentTypeError((str(Term), str(int)), str(type(term)))

f = functor_t()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,5 +280,5 @@ def test_sudoku(self):

def example_path(path):
import os.path
return os.path.normpath(os.path.join(os.path.split(os.path.abspath(__file__))[0], "..", "examples", path))
return os.path.normpath(os.path.join(os.path.split(os.path.abspath(__file__))[0], "..", "examples", path)).replace("\\", "\\\\")