From 361c4785417d9580ef132e0490261dfde9bc3ec1 Mon Sep 17 00:00:00 2001 From: David Halter Date: Sun, 13 May 2012 16:24:33 +0200 Subject: [PATCH] support for unicode/str and float/int literals (different returns) --- evaluate.py | 9 +++------ parsetest.py | 2 +- test/completion/functions.py | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/evaluate.py b/evaluate.py index 179b23b3..d5bc1407 100644 --- a/evaluate.py +++ b/evaluate.py @@ -837,13 +837,10 @@ def follow_call(scope, call): if isinstance(current, parsing.Array): result = [Array(current)] else: - # TODO add better care for int/unicode, now str/float are just used - # instead if not isinstance(current, parsing.NamePart): - if current.type == parsing.Call.STRING: - scopes = get_scopes_for_name(builtin.Builtin.scope, 'str') - elif current.type == parsing.Call.NUMBER: - scopes = get_scopes_for_name(builtin.Builtin.scope, 'float') + if current.type in (parsing.Call.STRING, parsing.Call.NUMBER): + t = type(current.name).__name__ + scopes = get_scopes_for_name(builtin.Builtin.scope, t) else: debug.warning('unknown type:', current.type, current) # make instances of those number/string objects diff --git a/parsetest.py b/parsetest.py index cb42c438..62ce38ef 100644 --- a/parsetest.py +++ b/parsetest.py @@ -160,7 +160,7 @@ a. def gen(): yield 1 - yield "" + yield u"" gen_exe = gen() diff --git a/test/completion/functions.py b/test/completion/functions.py index a4536bb4..76501f64 100644 --- a/test/completion/functions.py +++ b/test/completion/functions.py @@ -241,5 +241,5 @@ gen_exe = gen() next(gen_exe).upper #? ['real'] next(gen_exe).real -#? float() str() +#? int() str() next(gen_exe)