Index: doc/upvar.n
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/upvar.n,v
retrieving revision 1.12
diff -u -r1.12 upvar.n
--- doc/upvar.n	10 May 2005 18:34:03 -0000	1.12
+++ doc/upvar.n	30 Oct 2006 19:57:59 -0000
@@ -29,7 +29,8 @@
 by that name in the procedure frame given by \fIlevel\fR (or at
 global level, if \fIlevel\fR is \fB#0\fR) accessible
 in the current procedure by the name given in the corresponding
-\fImyVar\fR argument.
+\fImyVar\fR argument. It is an error for \fImyVar\fR to be a qualified
+name, i.e., to contain the substring "::".
 The variable named by \fIotherVar\fR need not exist at the time of the
 call;  it will be created the first time \fImyVar\fR is referenced, just like
 an ordinary variable.  There must not exist a variable by the
Index: generic/tclVar.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclVar.c,v
retrieving revision 1.126
diff -u -r1.126 tclVar.c
--- generic/tclVar.c	27 Oct 2006 13:20:33 -0000	1.126
+++ generic/tclVar.c	30 Oct 2006 19:58:01 -0000
@@ -3320,6 +3320,17 @@
 		return TCL_ERROR;
 	    }
 	}
+	p = strstr(myName, "::");
+	if (p != NULL) {
+	    /*
+	     * myName looks like a qualified name
+	     */
+	    
+	    Tcl_AppendResult((Tcl_Interp *) iPtr, "bad variable name \"",
+		    myName, "\": upvar won't create a variable ",
+		    "with a name containing '::'", NULL);
+	    return TCL_ERROR;
+	}
 
 	/*
 	 * Lookup and eventually create the new variable. Set the flag bit
Index: tests/var.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/var.test,v
retrieving revision 1.27
diff -u -r1.27 var.test
--- tests/var.test	9 Oct 2006 19:15:45 -0000	1.27
+++ tests/var.test	30 Oct 2006 19:58:03 -0000
@@ -243,14 +243,16 @@
         set vvv
     }
 } {121212}
-test var-3.7 {MakeUpvar, my var has ::s} {
+test var-3.7 {MakeUpvar, my var has ::s} -body {
     catch {unset a}
     set a 789789
     upvar #0 a test_ns_var::lnk
     namespace eval test_ns_var {
         set lnk
     }
-} {789789}
+} -returnCodes {
+    error
+} -result {bad variable name "test_ns_var::lnk": upvar won't create a variable with a name containing '::'}
 test var-3.8 {MakeUpvar, my var already exists in global ns} {
     catch {unset aaaaa}
     catch {unset xxxxx}
@@ -263,7 +265,7 @@
     catch {unset aaaaa}
     set aaaaa 789789
     list [catch {upvar #0 aaaaa test_ns_fred::lnk} msg] $msg
-} {1 {can't create "test_ns_fred::lnk": parent namespace doesn't exist}}
+} {1 {bad variable name "test_ns_fred::lnk": upvar won't create a variable with a name containing '::'}}
 test var-3.10 {MakeUpvar, } {
     namespace eval {} {
 	set bar 0
