summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2010-02-24 14:30:31 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2010-02-24 14:30:31 (GMT)
commit96d071af5418655b8dfbecd0410b6e5d07bfbde5 (patch)
tree02ebdf02ca154c666a08cbc7e9b057a16e1dc918 /generic
parent3201edaaf6efa495d6e2c747817da9ba884a8be5 (diff)
downloadtcl-96d071af5418655b8dfbecd0410b6e5d07bfbde5.zip
tcl-96d071af5418655b8dfbecd0410b6e5d07bfbde5.tar.gz
tcl-96d071af5418655b8dfbecd0410b6e5d07bfbde5.tar.bz2
Fix some nasties with handling duplicate keys in list->dict->list conversions.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclDictObj.c10
-rw-r--r--generic/tclListObj.c8
2 files changed, 14 insertions, 4 deletions
diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c
index dab4418..2751b4a 100644
--- a/generic/tclDictObj.c
+++ b/generic/tclDictObj.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclDictObj.c,v 1.80 2009/11/18 21:59:51 nijtmans Exp $
+ * RCS: @(#) $Id: tclDictObj.c,v 1.81 2010/02/24 14:30:34 dkf Exp $
*/
#include "tclInt.h"
@@ -613,6 +613,14 @@ SetDictFromAny(
if (!isNew) {
Tcl_Obj *discardedValue = Tcl_GetHashValue(hPtr);
+ /*
+ * Not really a well-formed dictionary as there are duplicate
+ * keys, so better get the string rep here so that we can
+ * convert back.
+ */
+
+ (void) Tcl_GetString(objPtr);
+
TclDecrRefCount(discardedValue);
}
Tcl_SetHashValue(hPtr, objv[i+1]);
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 659017c..896dcd3 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclListObj.c,v 1.58 2009/09/30 03:11:26 dgp Exp $
+ * RCS: @(#) $Id: tclListObj.c,v 1.59 2010/02/24 14:30:34 dkf Exp $
*/
#include "tclInt.h"
@@ -1684,10 +1684,12 @@ SetListFromAny(
/*
* Dictionaries are a special case; they have a string representation such
* that *all* valid dictionaries are valid lists. Hence we can convert
- * more directly.
+ * more directly. Only do this when there's no existing string rep; if
+ * there is, it is the string rep that's authoritative (because it could
+ * describe duplicate keys).
*/
- if (objPtr->typePtr == &tclDictType) {
+ if (objPtr->typePtr == &tclDictType && !objPtr->bytes) {
Tcl_Obj *keyPtr, *valuePtr;
Tcl_DictSearch search;
int done, size;