Code Monkey home page Code Monkey logo

pyswip's People

Contributors

nonducor avatar yuce avatar

pyswip's Issues

Bus error on Ubuntu Lucid

What steps will reproduce the problem?
1. Install Ubuntu's swi prolog
2. Install latest pyswip from Google code site
3. Import prolog module
4. Watch Python interpreter die.

The problem is that Pyswip is passing in an executable name of "./", which the 
SWI code tries to mmap and than scan.  But mmap'ing a directory doesn't work 
well--it tries to scan a bad pointer.

I fixed by modifying Ubuntu's version of SWI (5.8.0) in attach_archive() so 
that it checks both that it can fstat() the file (current code), but also 
verifies that the file is S_ISREG().  With that change, I can now access SWI 
from Python.

Original issue reported on code.google.com by [email protected] on 28 Jun 2010 at 9:36

pyswip doesn't work on cygwin

What steps will reproduce the problem?
1. run sudoku.py

What is the expected output? What do you see instead?
I expected a solved sudoku puzzle, got this instead:
  --
libpl (shared) not found. Possible reasons:
1) SWI-Prolog not installed as a shared library. Install SWI-Prolog (5.6.34
works just fine)
  --

What version of the product are you using? On what operating system?
pyswip version: 0.2.2; os: cygwin on windows vista, libpl.dll is on the PATH

Suggested fix:
in core.py, change the line
  --
if sys.platform[:3] == "win":
  --
to
  --
if sys.platform[:3] == "win" or sys.platform == "cygwin":
  --

Original issue reported on code.google.com by martinlaz on 29 Apr 2009 at 9:59

Patch for a dynamic metho

I attached a patch (against 0.2.2) that implements a "dynamic" method in
the class Prolog.

The patch is very simple, but I tested and it worked.

By the way, great job!

Original issue reported on code.google.com by [email protected] on 12 Apr 2008 at 10:27

Attachments:

sys.exit does not work when importing pyswip

What steps will reproduce the problem?

python -c 'import sys; import pyswip; sys.exit(1)'; echo $?
0
python -c 'import sys; sys.exit(1)'; echo $?
1

What is the expected output? What do you see instead?
See above

What version of the product are you using? On what operating system?
0.2.2

Please provide any additional information below.
N/A

Original issue reported on code.google.com by [email protected] on 21 Dec 2011 at 8:27

Missing unification API's

Variable's have a nice "unify" API, but a number of the PL_unify_* calls they 
want to make were not pulled out of the DLL in core.py.  You should make sure 
they're all available from core.py.


Original issue reported on code.google.com by [email protected] on 30 Jun 2010 at 11:20

Can't find SWI-Prolog library in Homebrew's /usr/local

What steps will reproduce the problem?
1. install SWI-Prolog with brew
2. download & install pyswip with "sudo python setup.py install"
3. try "from pyswip import Prolog"

What is the expected output? What do you see instead?
I expect a successful import. Instead I see this:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pyswip/__init__.py", line 29, in <module>
    from pyswip.prolog import Prolog
  File "pyswip/prolog.py", line 29, in <module>
    from pyswip.core import *
  File "pyswip/core.py", line 356, in <module>
    (_path, SWI_HOME_DIR) = _findSwipl()
  File "pyswip/core.py", line 319, in _findSwipl
    raise ImportError('Could not find the SWI-Prolog library in this '
ImportError: Could not find the SWI-Prolog library in this platform. If you are 
sure it is installed, please open an issue.

What version of the product are you using? On what operating system?
I am certain SWI-Prolog is installed. I'm using OS X 10.8.2, python 2.7.2, 
pyswip 0.2.3, swipl 6.2.3, and Homebrew 0.9.3.

Please provide any additional information below.
SWI-Prolog was install by Homebrew to /usr/local/bin/swipl.
It looks like the library is installed to:
/usr/local/lib/swipl-6.2.3/lib/x86_64-darwin12.2.1/libswipl.a
/usr/local/lib/swipl-6.2.3/lib/x86_64-darwin12.2.1/libswipl.dylib

Linking those files to /usr/local/lib/libswipl.dylib didn't help.

Original issue reported on code.google.com by [email protected] on 1 Jan 2013 at 12:32

Segmentation fault with integers in clauses

I'm getting a "segmentation fault: 11" when using numbers in the clauses.

The following code, without numbers, works fine:

from pyswip import Prolog
p = Prolog()
p.assertz("fact(a)")
p.assertz("fact(b)")
print list(p.query("fact(X)"))

However, if I add:

p.assertz("fact(3)")
print list(p.query("fact(X)"))

I get the segmentation fault.

I'm using pyswip 0.2.3, SWI-prolog 6.2.6, on a Mac OS Lion (Darwin kernel 
11.4.2), 64 bits.

Original issue reported on code.google.com by [email protected] on 25 Feb 2013 at 2:00

Attachments:

foreign functions seem to require only lower case letters for function names

What steps will reproduce the problem?
1. Modify the "Example (Foreign Functions)" example by capitalizing the name of 
the "Hello" function:

from pyswip import Prolog, registerForeign

def Hello(t):
    print "Hello,", t
Hello.arity = 1

registerForeign(Hello)

prolog = Prolog()
prolog.assertz("father(michael,john)")
prolog.assertz("father(michael,gina)")    
list(prolog.query("father(michael,X), Hello(X)"))

What is the expected output? What do you see instead?

expected:
Hello, john
Hello, gina

received:

  list(prolog.query("father(michael,X), Hello(X)"))
  File "C:\Python25\lib\site-packages\pyswip\prolog.py", line 90, in __call__
    raise PrologError("".join(["Caused by: '", query, "'."]))
pyswip.prolog.PrologError: Caused by: 'father(michael,X), Hello(X)'.

What version of the product are you using? On what operating system?

PySWIP 2.2
SWI-Prolog 5.8.3
Windows XP

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 12 Jul 2010 at 7:07

empty list are returned as atom '[]'

from pyswip import *

p = Prolog()

assertz = Functor("assertz")
f = Functor("f", 1)

call(assertz(f([])))
call(assertz(f(['a', 'b', 'c'])))

X = Variable()
q = Query(f(X))

while q.nextSolution():
    print type(X.value), str(X.value)

q.closeQuery()

expected output:
<type 'list'> []
<type 'list'> [Atom('251908'), Atom('251780'), Atom('233348')]

actual output:
<class 'pyswip.easy.Atom'> []
<type 'list'> [Atom('251908'), Atom('251780'), Atom('233348')]

The problem lies in the order a term is tested for being a list. The
following getTerm() produces the expected result:  

def getTerm(t):    
    p = PL_term_type(t)
    if PL_is_list(t):
        return getList(t)
    elif p < PL_TERM:
        return _getterm_router[p](t)
    else:
        return getFunctor(t)


Original issue reported on code.google.com by [email protected] on 18 Mar 2008 at 4:28

Variable unify() method always creates new term

If you get a Variable from an argument, and it has a valid handle, this handle 
is always overwritten when you var.unify() it to a value.  I believe the 
existing self.handle should be used so you interact with the caller's term.  If 
self.handle is None then it would then seem sensible to set self.handle to a 
new term.

Original issue reported on code.google.com by [email protected] on 1 Jul 2010 at 9:19

Fix link error in Mac

Currently in mac, if install swi-prolog using homebrew, one needs to do the 
following:

1. Find the `libswipl.dylib` file in the swipl's installation directory
2. create a symbolic link to: `/usr/lib/libswipl.so`
3. Find the installation path of this `pyswip` package (in my case, it's 
/usr/local/lib/python2.7/site-packages/pyswip/core.py because I installed via 
pip), go to line 275, comment out this function's main part, and replace it 
with: `return (find_library('swipl'),None)`.

The end result is something like this:

261 def _findSwiplDar():
262     """
263     This function uses several heuristics to gues where SWI-Prolog is
264     installed in MacOS.
265     
266     :returns:
267         A tuple of (path to the swipl so, path to the resource file)
268 
269     :returns type:
270         ({str, None}, {str, None})
271     """
272 
273     # Help with MacOS is welcome!!
274     return (find_library('swipl'),None)


Then you can start using this library in Mac ;)

Original issue reported on code.google.com by [email protected] on 1 Apr 2014 at 3:23

Segmentation fault when assertz-ing

On Ubuntu Gutsy, x86_64, python 2.4 and 2.5, SWI 5.6.50, I get the following:


Python 2.4.4 (#2, Oct  4 2007, 23:56:01) 
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyswip import Prolog
>>> prolog = Prolog()
>>> prolog.assertz("parent(yves,jm)")
Segmentation fault (core dumped)

Not really informative for now, I'll try to dig more into that

Original issue reported on code.google.com by [email protected] on 21 Feb 2008 at 11:44

Callbacks can cause segv's

What steps will reproduce the problem?
1. Use callbacks
2. See if it's a GC "bad hair day"

PySWIP creates a wrapper function around the foreign callback, and then wraps 
it in the CFUNCTYPE callback wrapper.  The problem is that it passes this down 
to the Prolog implementation, but does not keep a local ref.  It thus becomes a 
collectable object in Python, and can be written over by subsequent uses.

Meanwhile the memory is still registered by Prolog for a callback, and it when 
invoked will jump into memory whose contents might have been arbitrarily 
rewritten.

So you need to keep a ref on your callback wrapper at the Python level.  
Otherwise callbacks will cause segv's or other such craziness at random times.

Original issue reported on code.google.com by [email protected] on 30 Jun 2010 at 11:01

Cannot query

What steps will reproduce the problem?
1. creating a Prolog object
2. trying to use .query(....)
3.

What is the expected output? What do you see instead?
the xpected output is a simple true, instead i get

Eception AttributeError: 'swipl_qid' in bound method _QueryWrapper.
and so on

What version of the product are you using? On what operating system?
i am using the pyswip version 0.2.2, python version
2.7.1, prolog version 5.10 on a 32 bit windows xp

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 16 Dec 2011 at 11:08

Problem with variables in lists

~$ python test.py 
(1) []
(2) [a, b]
(3) g [a, b]
(4) g [_G70, _G71]
(5) [_G70, _G70]
(6) [c, c, c]
(7) [[_G73], [_G73], [_G73]]

Solutions (1) - (4) deliver the expected result, however (5) - (7) are
erroneous. (6) + (7) indicate that all elements in the resulting list are
overwritten with the last element.


(pyswip 0.2.2, SWIPL 5.6.52, Mac OS X)

Original issue reported on code.google.com by [email protected] on 18 Mar 2008 at 5:22

Attachments:

improve library loading

Currently, the library is only found and loaded, when the lib is called 
"libpl.so" and found by CDLL().

Improve this by using find_library() and on linux maybe even pkg-config. Also 
use "libswipl.so" since new versions install it like this.

Original issue reported on code.google.com by [email protected] on 8 Mar 2011 at 5:35

SegFault on runtests

Hi all, 

The segfault problem is back I guess. 
I saw previous issues on this problem. 
I have : pyswip 0.2.3 and I tried several version of swipl (6.6.6 and 7.2.0)
I am on Linux (Ubuntu 14.04LTS) 64bits. 


./runtests : line 5 : 32269 Error de segfault  (core dumped) python -m unittest 
discover


Thank you

Original issue reported on code.google.com by [email protected] on 5 Jun 2015 at 11:56

Segmentation Fault when calling Foreign Function

The foreign function example from the main page causes a segmentation fault. 
More specifically:

  from pyswip import Prolog, registerForeign

  def hello(t):
      print "Hello,", t
  hello.arity = 1

  registerForeign(hello)

  prolog = Prolog()
  list(prolog.query("hello(X)"))

The program also crashes if X is bound, so this is not the issue.

I tried to run this example on two machine configurations: 

Debian 6.0.4, Linux Kernel 2.6.32-5-686
SWI Prolog 5.10.1
Python 2.6.6
ctypes version 1.0.1


Ubuntu 11.10, Linux Kernel 3.0.0-12-generic (i386)
SWI Prolog 5.10.4
Python 2.7.2+
ctypes version 1.0.1

Also, I created a symbolic link to libswipl.so.5.10.1 since libpl does not seem 
to be installed with more recent SWI Prolog versions. 
This should be mentioned on the main page.

If it is of any help, below you'll find an incomplete stack trace. The failure 
occurs in _ctypes.so.
I will try to look into the matter in the meanwhile, but I'd appreciate any 
help.


#0  0xb7a4748b in ?? () from /usr/lib/python2.6/lib-dynload/_ctypes.so
#1  0xb7a4789a in ?? () from /usr/lib/python2.6/lib-dynload/_ctypes.so
#2  0xb7953e2e in PL_next_solution () from /usr/lib/libpl.so
#3  0xb7a477df in ffi_call_SYSV () from 
/usr/lib/python2.6/lib-dynload/_ctypes.so
#4  0xb7a4761e in ffi_call () from /usr/lib/python2.6/lib-dynload/_ctypes.so
#5  0xb7a4227d in _CallProc () from /usr/lib/python2.6/lib-dynload/_ctypes.so
#6  0xb7a39d7e in ?? () from /usr/lib/python2.6/lib-dynload/_ctypes.so
#7  0x0806232a in PyObject_Call ()
#8  0x080e016b in PyEval_EvalFrameEx ()
#9  0x0816931f in ?? ()
#10 0x0808554e in ?? ()
#11 0x0808598c in ?? ()
#12 0x080acd65 in ?? ()
#13 0x0806232a in PyObject_Call ()
#14 0x080e016b in PyEval_EvalFrameEx ()
#15 0x080e2507 in PyEval_EvalCodeEx ()
#16 0x080e2607 in PyEval_EvalCode ()
#17 0x080ffcbd in PyRun_FileExFlags ()
#18 0x080fff22 in PyRun_SimpleFileExFlags ()
#19 0x0805dd81 in Py_Main ()
#20 0x0805cf6b in main ()





Original issue reported on code.google.com by [email protected] on 8 Aug 2012 at 6:11

  • Merged into: #8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.