python / cpython

The Python programming language
https://www.python.org
Other
63.88k stars 30.58k forks source link

symtable.Symbol.is_global() is strange #39933

Closed 361bcbce-9d25-42c1-9b7c-dd935695d2e5 closed 16 years ago

361bcbce-9d25-42c1-9b7c-dd935695d2e5 commented 20 years ago
BPO 896061
Nosy @benjaminp

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = created_at = labels = [] title = 'symtable.Symbol.is_global() is strange' updated_at = user = 'https://bugs.python.org/astrand' ``` bugs.python.org fields: ```python activity = actor = 'benjamin.peterson' assignee = 'jhylton' closed = True closed_date = closer = 'benjamin.peterson' components = ['None'] creation = creator = 'astrand' dependencies = [] files = [] hgrepos = [] issue_num = 896061 keywords = [] message_count = 3.0 messages = ['19975', '19976', '71416'] nosy_count = 3.0 nosy_names = ['jhylton', 'astrand', 'benjamin.peterson'] pr_nums = [] priority = 'normal' resolution = 'fixed' stage = None status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue896061' versions = [] ```

361bcbce-9d25-42c1-9b7c-dd935695d2e5 commented 20 years ago

The symtable.Symbol.is_global() returns false for symbols in plain functions:

If the source looks like this:

foo = 1

def fie():
    print foo

Calling is_global() for the "foo" name returns False (using the fie functions SymbolTable).

With a method, however, it works as expected:

foo = 1

class C:
    def fie(self):
        print foo
361bcbce-9d25-42c1-9b7c-dd935695d2e5 commented 20 years ago

Logged In: YES user_id=344921

I would appreciate if someone could take a look at this. This problem makes the development of pyobfuscate harder: Basically, I'm guessing how things are supposed to work. Bug 896052 is, of course, also relevant.

benjaminp commented 16 years ago

This has finally been fixed.