Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error why handling unicode chars #12

Open
rohdef opened this issue Oct 24, 2011 · 4 comments
Open

Error why handling unicode chars #12

rohdef opened this issue Oct 24, 2011 · 4 comments

Comments

@rohdef
Copy link
Owner

rohdef commented Oct 24, 2011

What steps will reproduce the problem?

  1. Create python class using utf-8
  2. From another file create object of recently created class
  3. Try to complete its methods

What is the expected output? What do you see instead?
Expected: method's list
Instead we got a nice traceback, something like attached.

What version of the product are you using? On what operating system?
PySmell 0.7.1 on Gentoo
Python 2.5

Please provide any additional information below.
Solution to this problem was replacing str() with unicode() in
codefinder.py at lines: 301, 314, 316
(I don't know why, but I had to change[remove '.value'] also lines 337 and
340 in codefinder.py, because of "object has no attribute 'value'". Is
this another issue?)

@rohdef
Copy link
Owner Author

rohdef commented Oct 24, 2011

i have this problem, too.
when I use emacs.
M-x pysmell-make-tags RET
this step is OK.
then
M-/ can't work, appear this problem.

debian lenny, python 2.5, Pymacs 0.24 beta1, pysmell 0.7.3

@rohdef rohdef closed this as completed Oct 24, 2011
@rohdef rohdef reopened this Oct 24, 2011
@rohdef
Copy link
Owner Author

rohdef commented Oct 24, 2011

if the .py file has multi-byte character , pysmell doesn't work!

just like this :

pymacs-report-error: Python: Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/Pymacs/pymacs.py", line 147, in loop
value = eval(text)
File "", line 1, in
File "/usr/lib/python2.5/site-packages/pysmell/emacshelper.py", line 24, in
get_completions
options = idehelper.detectCompletionType(fullPath, origSource, lineNo, origCol,
base, PYSMELLDICT)
File "/usr/lib/python2.5/site-packages/pysmell/idehelper.py", line 216, in
detectCompletionType
AST = getSafeTree(origSource, lineNo)
File "/usr/lib/python2.5/site-packages/pysmell/codefinder.py", line 487, in
getSafeTree
tree = compiler.parse(replacedSource)
File "/usr/lib/python2.5/compiler/transformer.py", line 52, in parse
return Transformer().parsesuite(buf)
File "/usr/lib/python2.5/compiler/transformer.py", line 129, in parsesuite
return self.transform(parser.suite(text))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 103-107:
ordinal not in range(128)

@rohdef
Copy link
Owner Author

rohdef commented Oct 24, 2011

change codefinder.py ,lines 487
to :
tree = compiler.parse(replacedSource.encode('ascii', 'ignore'))

@rohdef
Copy link
Owner Author

rohdef commented Oct 24, 2011

Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/pysmell-0.7.1-py2.5.egg/pysmell/idehelper.py", line 262, in detectCompletionType
klass, parents = inferInstance(fullPath, AST, lineNo, var, PYSMELLDICT)
File "/usr/lib/python2.5/site-packages/pysmell-0.7.1-py2.5.egg/pysmell/idehelper.py", line 105, in inferInstance
names, klasses = getNames(AST)
File "/usr/lib/python2.5/site-packages/pysmell-0.7.1-py2.5.egg/pysmell/codefinder.py", line 527, in getNames
compiler.walk(tree, inferer, walker=ExampleASTVisitor(), verbose=1)
File "/usr/lib/python2.5/compiler/visitor.py", line 106, in walk
walker.preorder(tree, visitor)
File "/usr/lib/python2.5/compiler/visitor.py", line 63, in preorder
self.dispatch(tree, *args) # XXX *args make sense?
File "/usr/lib/python2.5/compiler/visitor.py", line 84, in dispatch
meth(node, *args)
File "/usr/lib/python2.5/site-packages/pysmell-0.7.1-py2.5.egg/pysmell/codefinder.py", line 505, in handleChildren
BaseVisitor.handleChildren(self, node)

......

File "/usr/lib/python2.5/site-packages/pysmell-0.7.1-py2.5.egg/pysmell/codefinder.py", line 129, in handleChildren
self.visit(c)
File "/usr/lib/python2.5/compiler/visitor.py", line 84, in dispatch
meth(node, _args)
File "/usr/lib/python2.5/site-packages/pysmell-0.7.1-py2.5.egg/pysmell/codefinder.py", line 102, in decorated
self.handleChildren(args[0])
meth(node, *args)
File "/usr/lib/python2.5/site-packages/pysmell-0.7.1-py2.5.egg/pysmell/codefinder.py", line 101, in decorated
fun(self, *args, *_kwargs)
File "/usr/lib/python2.5/site-packages/pysmell-0.7.1-py2.5.egg/pysmell/codefinder.py", line 516, in visitAssign
self.names[name] = getName(node.expr)
File "/usr/lib/python2.5/site-packages/pysmell-0.7.1-py2.5.egg/pysmell/codefinder.py", line 316, in getName
return repr(str(node.value))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 2-3: ordinal not in range(128)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant