Skip to content

Out of order commands excecution? #39612

Closed

Description

@nadavhoresh
BPO 850110
Nosy @mwhudson

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:

assignee = 'https://github.com/mwhudson'
closed_at = <Date 2003-12-01.14:31:04.000>
created_at = <Date 2003-11-27.08:54:21.000>
labels = ['interpreter-core', 'invalid']
title = 'Out of order commands excecution?'
updated_at = <Date 2003-12-01.14:31:04.000>
user = 'https://bugs.python.org/nadavhoresh'

bugs.python.org fields:

activity = <Date 2003-12-01.14:31:04.000>
actor = 'nadavhoresh'
assignee = 'mwh'
closed = True
closed_date = None
closer = None
components = ['Interpreter Core']
creation = <Date 2003-11-27.08:54:21.000>
creator = 'nadavhoresh'
dependencies = []
files = []
hgrepos = []
issue_num = 850110
keywords = []
message_count = 6.0
messages = ['19155', '19156', '19157', '19158', '19159', '19160']
nosy_count = 3.0
nosy_names = ['mwh', 'nnorwitz', 'nadavhoresh']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue850110'
versions = ['Python 2.3']

Activity

  1. nadavhoresh commented on Nov 27, 2003

    nadavhoreshmannequin
    MannequinAuthor

    Consider the following:

    >>> import string
    >>> def test1():
    	join = string.join
    
    	
    >>> def test2():
    	join = string.join
    	string = string.split

    >> test1()
    >> test2()

    Traceback (most recent call last):
      File "<pyshell#9>", line 1, in -toplevel-
        test2()
      File "<pyshell#7>", line 2, in test2
        join = string.join
    UnboundLocalError: local variable 'string' referenced
    before assignment
    >>> 

    How the second statement in test2 generates an error in
    first one?

    Nadav.

  2. mwhudson commented on Nov 27, 2003

    @mwhudson

    Logged In: YES
    user_id=6656

    Well, that's just how it works. This must be documented
    somewhere... see if

    http://www.python.org/doc/faq/programming.html#what-are-the-rules-for-local-and-global-variables-in-python

    helps (and maybe the question before).

  3. nadavhoresh commented on Nov 30, 2003

    nadavhoreshmannequin
    MannequinAuthor

    Logged In: YES
    user_id=75473

    I've looked at the FAQ and it is not seems to sesolve the
    issue: In test2 "string" becomes a local variable in the
    second line, while in the first line (join = string.join)
    "string" should point to the (global) string module.

    Nadav.

  4. nnorwitz commented on Dec 1, 2003

    nnorwitzmannequin
    Mannequin

    Logged In: YES
    user_id=33168

    If a variable is local in a function, it is local throughout
    the whole function. It doesn't become local at the first
    assignment, but from the beginning of the function. Does
    that help?

  5. mwhudson commented on Dec 1, 2003

    @mwhudson

    Logged In: YES
    user_id=6656

    Well, you reopened the bug, so you're obviously not happy.
    What do you want to see changed? The behaviour? No chance.
    Better documentation? Feel free to supply a patch (or just
    suggest wording and a location, others can do the latex).

  6. nadavhoresh commented on Dec 1, 2003

    nadavhoreshmannequin
    MannequinAuthor

    Logged In: YES
    user_id=75473

    I understand that this is just a documentation issue. I
    guess that probably the interpreter builds the variables
    table before executing the first line of code. But, I afraid
    that I am not familiar with the internal of python to raise
    such statements.

    Thank you very much for your help

    Nadav.

  7. transferred this issue fromon Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions