Re: [Cython] Compiler crash in RemoveUnreachableCode
Andriy Kornatskyy, 20.01.2014 22:16: > May be that issue is namespace package related? Both (wheezy.http and > dependent wheezy.core) use namespace_packages directive in setuptools. No, I think it's a problem with importing in Cython compiled modules. ISTM that some extension modules got "reloaded", i.e. their module dict got cleared and they got reinitialised, thus recreating all global objects that other modules had already imported (and still keep a reference to). > Here is another bug (details below): > > 1. virtualenv env > 2. env/bin/easy_install cython > 3. env/bin/easy_install lxml wheezy.core > > It seems to have an issue while trying to install 2 or more libs at once. > ... > Installed > env/lib/python2.7/site-packages/lxml-3.3.0beta5-py2.7-macosx-10.9-x86_64.egg > Processing dependencies for lxml > Finished processing dependencies for lxml > Searching for wheezy.core > Reading https://pypi.python.org/simple/wheezy.core/ > Best match: wheezy.core 0.1.129 > Downloading > https://pypi.python.org/packages/source/w/wheezy.core/wheezy.core-0.1.129.tar.gz#md5=ea3d5f744bc0525d61f9fb48d897972d > Processing wheezy.core-0.1.129.tar.gz > Writing > /var/folders/g8/2kym1h8n7qbgrwg4qkfqw1gwgn/T/easy_install-UC_pgJ/wheezy.core-0.1.129/setup.cfg > Running wheezy.core-0.1.129/setup.py -q bdist_egg --dist-dir > /var/folders/g8/2kym1h8n7qbgrwg4qkfqw1gwgn/T/easy_install-UC_pgJ/wheezy.core-0.1.129/egg-dist-tmp-9sntQ1 > Traceback (most recent call last): > ... > File > “env/lib/python2.7/site-packages/Cython-0.20-py2.7-macosx-10.9-x86_64.egg/Cython/Compiler/ModuleNode.py", > line 109, in process_implementation > self.generate_c_code(env, options, result) > File > "env/lib/python2.7/site-packages/Cython-0.20-py2.7-macosx-10.9-x86_64.egg/Cython/Compiler/ModuleNode.py", > line 302, in generate_c_code > rootwriter = Code.CCodeWriter(emit_linenums=emit_linenums, > c_line_in_traceback=options.c_line_in_traceback) > File "Code.py", line 1406, in Cython.Compiler.Code.CCodeWriter.__init__ > (/var/folders/g8/2kym1h8n7qbgrwg4qkfqw1gwgn/T/easy_install-JVXbGE/Cython-0.20/Cython/Compiler/Code.c:30697) > > File > "env/lib/python2.7/site-packages/Cython-0.20-py2.7-macosx-10.9-x86_64.egg/Cython/StringIOTree.py", > line 11, in __init__ > stream = StringIO() > TypeError: 'NoneType' object is not callable Looks like the same thing. Stefan ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
[Cython] bytearray tests fail with default unsigned char
hi, the bytearray tests are broken when chars are unsigned. tests/run/bytearraymethods.pyx defines following function: def bytearray_append(b, char c, int i, object o): this gets converted to an effective __Pyx_PyInt_AsUnsignedChar which then errors out when -1 is passed in. chars are unsigned like they are by default on arm, s390x and powerpc. This causes a couple build failures in debian: https://buildd.debian.org/status/package.php?p=cython https://buildd.debian.org/status/fetch.php?pkg=cython&arch=armel&ver=0.20-1&stamp=1390316252 the tests can be fixed by adding signed char to the interface. to reproduce on x86 with gcc (note the -funsigned-char to change the default): cython tests/run/bytearraymethods.pyx gcc -funsigned-char bytearraymethods.c -fPIC $(python-config --includes) $(python-config --libs) -shared -O2 -o bytearraymethods.so python -c "import doctest; import bytearraymethods; doctest.testmod(bytearraymethods)" Traceback (most recent call last): File "", line 1, in NameError: name 'bytearraymethods' is not defined root@ubuntu:/# python -c "import doctest; import bytearraymethods; doctest.testmod(bytearraymethods)" ** File "bytearraymethods.so", line ?, in bytearraymethods.__test__.bytearray_append (line 202) Failed example: b = bytearray_append(b, -1, ord('y'), ord('z')) # doctest: +ELLIPSIS Expected: Traceback (most recent call last): ValueError: ... Got: Traceback (most recent call last): File "/usr/lib/python2.7/doctest.py", line 1315, in __run compileflags, 1) in test.globs File "", line 1, in b = bytearray_append(b, -1, ord('y'), ord('z')) # doctest: +ELLIPSIS File "bytearraymethods.pyx", line 202, in bytearraymethods.bytearray_append (bytearraymethods.c:1339) def bytearray_append(bytearray b, char c, int i, object o): OverflowError: can't convert negative value to char ** ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel
[Cython] segfault due to using DECREF instead of XDECREF
(apologies to the moderator for multiple postings -- I'm trying to figure out which of my email addresses is actually being exported to the public!) Hi, It seems that cython's static code analysis is failing on the following code. It thinks that a particular variable (myobject2) must not be NULL, but in fact it is, so the __Pyx_DECREF_SET segfaults. This came from third-party code, so I could fix it with an explicit initialization to None, but I'd love to have Cython deal with it directly. Thanks for your help! #<<>> # When compiled with Cython 0.19.2 or 0.20dev, the following code # segfaults on import import random def myfunc(): ## uncommenting the following fixes things #myobject2 = None myfalse = random.random() > 2 if myfalse: myobject = None myobject2 = None if not myfalse: # here Cython uses __Pyx_XDECREF_SET myobject = None print "Made it past myobject assignment" if not myfalse or myobject2 is None: # here Cython uses Pyx_DECREF_SET because it has determined # that __pyx_v_myobject2 can't be null, but it really, really can! # (if no one assigned myobject2 yet) myobject2 = None print "Made it past myobject2 assignment" myfunc() #<<>> #<>> #>> [prompt]$ python setup.py build_ext --inplace [prompt]$ ls tmpnone.* tmpnone.c tmpnone.py tmpnone.so [prompt]$ python Python 2.6.6 (r266:84292, Nov 21 2013, 12:39:37) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import tmpnone Made it past myobject assignment Segmentation fault ___ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel