[Cython] Function calls and ref counts

2016-03-15 Thread John Ehresman

Hi,

I ran into a bug where a python object was deleted in the middle of a 
function that was using it because a callback decref'd the one and only 
reference to the object.  This doesn't happen with python bytecode 
because ref counts of the callable and of all args are essentially 
incref'd before the call and then decref'd after.  Doing the same in 
Cython generated C code might be the way to fix this.


The pure python mode code below reproduces the crash with cython 0.23 
when compiled to C and the Crash function called.


Thanks,

John


import cython

@cython.cclass
class Record:
  cython.declare(ref=object)

  def setref(self, ref):
self.ref = ref

GLOBAL_RECORD = Record()

@cython.cclass
class CrashCls:

  def method(self):

cython.declare(rec=Record)

rec = GLOBAL_RECORD

print id(self)
rec.ref = None
assert isinstance(self, CrashCls)  # <-- should crash

def Crash():
  cython.declare(rec=Record)

  rec = GLOBAL_RECORD

  o = CrashCls()
  rec.ref = o.method
  del o

  args = ()
  rec.ref(*args)

___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Function calls and ref counts

2016-03-15 Thread Jeroen Demeyer

I cannot reproduce the problem...

It might be relevant to mention things like OS and Python version.

___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Manylinux wheels for Cython

2016-03-15 Thread Matthew Brett
Hi,

On Mon, Mar 7, 2016 at 5:47 PM, Matthew Brett  wrote:
> Hi,
>
> I don't know whether y'all have been following over at distutils-sig,
> but there's a new distutils PEP that defines a `manylinux` format for
> Linux wheels that work on many different x86 Linux distributions:
>
> https://www.python.org/dev/peps/pep-0513/
> https://github.com/pypa/manylinux
>
> The latest version of pip will install these, if the client Linux
> system is compatible with the manylinux spec:
>
> https://pip.pypa.io/en/stable/news/
>
> I've already built and used manylinux Cython wheels, which y'all are
> welcome to test with:
>
> pip install -f https://nipy.bic.berkeley.edu/manylinux cython
>
> (The wheels there don't have the right manylinux filenames yet, but
> they have the same contents as the ones that would go up to pypi).
>
> I've already had good use from these wheels in speeding up project
> builds into docker containers and virtualenvs, and I'd love to upload
> these to pypi.   I have permissions on pypi to do this, but I wanted
> to check in with y'all first...

There is now a test wheel for Cython 0.23.4 and Python 3.5 on the
testpypi server.

This is me downloading and installing - a matter of a few seconds:

$ python -m pip install -U pip
Downloading/unpacking pip from
https://pypi.python.org/packages/py2.py3/p/pip/pip-8.1.0-py2.py3-none-any.whl#md5=c6eca6736b2b8f7280fb25e44be7c51b
  Downloading pip-8.1.0-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded
Installing collected packages: pip
  Found existing installation: pip 1.5.6
Uninstalling pip:
  Successfully uninstalled pip
Successfully installed pip
Cleaning up...
$ pip install -i https://testpypi.python.org/pypi/ cython
Collecting cython
  Using cached 
https://testpypi.python.org/packages/cp35/C/Cython/Cython-0.23.4-cp35-cp35m-manylinux1_x86_64.whl
Installing collected packages: cython
Successfully installed cython-0.23.4
$ cython --version
Cython version 0.23.4

The installed Cython version compiles all the Demo *.pyx files OK.

See also : 
https://mail.python.org/pipermail/wheel-builders/2016-March/50.html

Best,

Matthew
___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Cython alpha 0.24

2016-03-15 Thread Jeroen Demeyer

On 2016-03-13 14:03, Robert Bradshaw wrote:

If we accept cross-project includes


I missed the memo that cross-project includes are not "accepted". They 
do work, just add include_path=sys.path to the cythonize() call. All I'm 
doing with my patch is to remove the need to explicitly add that in 
setup.py.

___
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel