File: errorcode.patch

package info (click to toggle)
tclthread3 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,752 kB
  • sloc: ansic: 8,259; tcl: 1,711; sh: 436; makefile: 38
file content (52 lines) | stat: -rw-r--r-- 1,381 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Author: Sergei Golovan
Description: Patch relaxes the assumption that ::errorCode and ::errorInfo always exist
Last-Modified: Sat, 16 Jan 2021 11:42:55 +0300
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/tclthread/+bug/1821197

--- a/lib/ttrace.tcl
+++ b/lib/ttrace.tcl
@@ -297,20 +297,36 @@
 
     proc delentry {cmd var} {
 	variable epoch
-	set ei $::errorInfo
-	set ec $::errorCode
+	if {[info exists ::errorInfo]} {set ei $::errorInfo}
+	if {[info exists ::errorCode]} {set ec $::errorCode}
 	catch {_unset ${epoch}-$cmd $var}
-	set ::errorInfo $ei
-	set ::errorCode $ec
+	if {[info exists ei]} {
+	    set ::errorInfo $ei
+	} else {
+	    unset -nocomplain ::errorInfo
+	}
+	if {[info exists ec]} {
+	    set ::errorCode $ec
+	} else {
+	    unset -nocomplain ::errorCode
+	}
     }
 
     proc getentry {cmd var} {
 	variable epoch
-	set ei $::errorInfo
-	set ec $::errorCode
+	if {[info exists ::errorInfo]} {set ei $::errorInfo}
+	if {[info exists ::errorCode]} {set ec $::errorCode}
 	if {[catch {_set ${epoch}-$cmd $var} val]} {
-	    set ::errorInfo $ei
-	    set ::errorCode $ec
+	    if {[info exists ei]} {
+	        set ::errorInfo $ei
+	    } else {
+	        unset -nocomplain ::errorInfo
+	    }
+	    if {[info exists ec]} {
+	        set ::errorCode $ec
+	    } else {
+	        unset -nocomplain ::errorCode
+	    }
 	    set val ""
 	}
 	return $val