Code Monkey home page Code Monkey logo

Comments (11)

dbrgn avatar dbrgn commented on July 20, 2024

This works for me (both with current beta as well as with the dev branch).

>>> jedi.Script(u'import json\njson.l', 2, len('json.l'), '').complete()
[<Completion: loads>, <Completion: load>]

I'm on Arch Linux with Python 2.7.3. Can you post your system configuration?

from jedi.

tkf avatar tkf commented on July 20, 2024

Python 2.7.2+ on Ubuntu 11.10

from jedi.

tkf avatar tkf commented on July 20, 2024

Ah, and tested against both dev branch and 0.5b3

from jedi.

tkf avatar tkf commented on July 20, 2024

I can reproduce this also in Python 2.6.7

from jedi.

tkf avatar tkf commented on July 20, 2024

I think this is because of some fix between Python 2.7.2 and 2.7.3, as test of Emacs Jedi with Python 2.7.3 is passing in Travis CI but the same test with Python 2.7.2 fails in my desktop. Also the same test with Python 2.6 in Travis CI fails.

https://travis-ci.org/#!/tkf/emacs-jedi/builds/3027374

from jedi.

dbrgn avatar dbrgn commented on July 20, 2024

You're right, I can reproduce this with Python 2.6.8...

I tried to debug this, but don't understand Jedi enough yet to find the bug. All I found was that under Python 2.6, scopes is an empty list while under Python 2.7.3 it contains <Module: /usr/lib/python2.7/json/__init__.py@1-None>.

from jedi.

davidhalter avatar davidhalter commented on July 20, 2024

Could you try the same thing with a str cast?
I'm already doing some strange things with strings, where I'm not entirely sure what's happening:
https://github.com/davidhalter/jedi/blob/master/jedi/_compatibility.py#L81

Could be this change:

  • Issue #1548891: The cStringIO.StringIO() constructor now encodes unicode
    arguments with the system default encoding just like the write() method
    does, instead of converting it to a raw buffer. This also fixes handling of
    unicode input in the shlex module (#6988, #1170).

Found in: http://hg.python.org/cpython/file/d46c1973d3c4/Misc/NEWS

from jedi.

tkf avatar tkf commented on July 20, 2024

Your code in https://github.com/davidhalter/jedi/blob/master/jedi/_compatibility.py#L81

# BytesIO (Python 2.5 has no io module)
try:
    from cStringIO import StringIO as BytesIO
except ImportError:
    from io import BytesIO

Shouldn't this be other way around, like this?:

try:
    from io import BytesIO
except ImportError:
    from cStringIO import StringIO as BytesIO

The current code imports BytesIO.io only in Python3 where cStringIO does not exist.

So, in Python 2.6/2.7:

% python -c 'import jedi; print jedi._compatibility.BytesIO'
<built-in function StringIO>

Python 3.2

% cd jedi
% python3 -c 'import _compatibility; print(_compatibility.BytesIO)'
<class '_io.BytesIO'>

from jedi.

tkf avatar tkf commented on July 20, 2024

Casting it to str works. I am doing source.encode() before passing it to Jedi.source for Python 2.x

tkf/emacs-jedi@360ed14

from jedi.

davidhalter avatar davidhalter commented on July 20, 2024

BTW: I'm still struggling with that:
http://bugs.python.org/issue12486

from jedi.

tkf avatar tkf commented on July 20, 2024

Thanks for the fix! I can confirm that completion works with str and unicode in Python 2.6 and 2.7.

from jedi.

Related Issues (20)

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.