Skip to content

ipython 7.11.0 breaks Cython's IpythonMagic #12068

Closed

Description

@cgohlke

Removing cast_bytes_py2 in #12009 breaks Cython's IpythonMagic:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-84ee719fa1da> in <module>
----> 1 get_ipython().run_cell_magic('cython', '', '\ndef tmp():\n    return 0\n')

X:\Python37\lib\site-packages\IPython\core\interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
   2350             with self.builtin_trap:
   2351                 args = (magic_arg_s, cell)
-> 2352                 result = fn(*args, **kwargs)
   2353             return result
   2354 

<X:\Python37\lib\site-packages\decorator.py:decorator-gen-159> in cython(self, line, cell)

X:\Python37\lib\site-packages\IPython\core\magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

X:\Python37\lib\site-packages\Cython\Build\IpythonMagic.py in cython(self, line, cell)
    322         extension = None
    323         if need_cythonize:
--> 324             extensions = self._cythonize(module_name, code, lib_dir, args, quiet=args.quiet)
    325             if extensions is None:
    326                 # Compilation failed and printed error message

X:\Python37\lib\site-packages\Cython\Build\IpythonMagic.py in _cythonize(self, module_name, code, lib_dir, args, quiet)
    407     def _cythonize(self, module_name, code, lib_dir, args, quiet=True):
    408         pyx_file = os.path.join(lib_dir, module_name + '.pyx')
--> 409         pyx_file = py3compat.cast_bytes_py2(pyx_file, encoding=sys.getfilesystemencoding())
    410 
    411         c_include_dirs = args.include

AttributeError: module 'IPython.utils.py3compat' has no attribute 'cast_bytes_py2'

Activity

  1. farisachugthai commented on Dec 28, 2019

    @farisachugthai
    Contributor

    That last line shows that this is a Cython bug.

    Also, it's a really easy fix. All they have to do is delete the line. os.path.join returns a string and then they use it as an arg to io.open.

  2. cgohlke commented on Dec 28, 2019

    @cgohlke
    ContributorAuthor

    That last line shows that this is a Cython bug.

    Sorry, I don't follow. I can't find in the IPython's whatsnew log that/when IPython.utils.py3compat was deprecated.

    All they have to do is delete the line.

    Cython still supports Python 2.

  3. Carreau commented on Dec 28, 2019

    @Carreau
    Member

    Reopening, because Cython is widely used I might reintroduced this just for them for a few releases.

    All of these functions were deprecated in April 2017 when we released IPython 6 that dropped Python 2. We kept them around to give time for people to migrate. They are also highly IPython specific and usually cython have vendored fallback for these.

  4. added 3 commits that reference this issue on Dec 28, 2019
    052a2e4
    112b4c0
    9a8d1a3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions