From: drscrypt on
Hello,

A script I have used for a long time to send a notification email is
failing after upgrading tcllib from 1.10 to 1.12. I am attaching the
error trace below. The funny thing is even though it results in an
error and stops the script, the email does go out fine.


Any ideas what is causing the problem? Should I revert to the previous
version?


DrS



> error writing "sock908": invalid argument
> while executing
> "puts -nonewline $channel [$converter -mode encode -- $state(string)]"
> ("string" arm line 15)
> invoked from within
> "switch -- $state(value) {
> file {
> set closeP 1
> if {[info exists state(root)]} {
> # FRINK: nocheck
> vari..."
> (procedure "mime::copymessageaux" line 75)
> invoked from within
> "mime::copymessageaux $token $channel "
> invoked from within
> "mime::copymessage $part $channel"
> ("foreach" body line 3)
> invoked from within
> "foreach part $state(parts) {
> puts $channel "\n--$boundary"
> mime::copymessage $part $channel
> ..."
> ("default" arm line 4)
> invoked from within
> "switch -glob -- $state(content) {
> message/* {
> puts $channel ""
> foreach part $state(parts) {
> ..."
> ("parts" arm line 7)
> invoked from within
> "switch -- $state(value) {
> file {
> set closeP 1
> if {[info exists state(root)]} {
> # FRINK: nocheck
> vari..."
> (procedure "mime::copymessageaux" line 75)
> invoked from within
> "mime::copymessageaux $token $channel "
> invoked from within
> "::mime::copymessage $part $state(sd) "
> invoked from within
> "wtextaux $token $part "
> invoked from within
> "smtp::sendmessage $msgMime


From: drscrypt on
On 6/16/2010 10:53 AM, drscrypt(a)gmail.com wrote:
>
> Any ideas what is causing the problem? Should I revert to the previous
> version?
>


Taking a closer look at the mime.tcl, I see several statements that
don't make sense:


> if {[string compare $converter ""]} {
> append result [$converter -mode encode -- $X]
> } else {
> append result $X
> }
>
> ...
> if {[string compare $converter ""]} {
> append result [$converter -mode encode -- $state(string)]
> } else {
> append result $state(string)
> }



If the converter is empty, why is it being used as the proc name in the
if statement? Or should the if-then-else be reversed?


DrS



From: Jeff Godfrey on
On 6/16/2010 2:54 PM, drscrypt(a)gmail.com wrote:
> On 6/16/2010 10:53 AM, drscrypt(a)gmail.com wrote:
>>
>> Any ideas what is causing the problem? Should I revert to the previous
>> version?
>>
>
>
> Taking a closer look at the mime.tcl, I see several statements that
> don't make sense:
>
>
>> if {[string compare $converter ""]} {
>> append result [$converter -mode encode -- $X]
>> } else {
>> append result $X
>> }
>>
>> ...
>> if {[string compare $converter ""]} {
>> append result [$converter -mode encode -- $state(string)]
>> } else {
>> append result $state(string)
>> }
>
>
>
> If the converter is empty, why is it being used as the proc name in the
> if statement? Or should the if-then-else be reversed?
>
>
> DrS

A non-zero result from [string compare] means the compared strings are
*not* equal. So the above is verifying that $converter is not empty...

Jeff
From: drscrypt on
On 6/16/2010 4:11 PM, Jeff Godfrey wrote:

>
> A non-zero result from [string compare] means the compared strings are
> *not* equal. So the above is verifying that $converter is not empty...
>
> Jeff


Oops - sorry! For some reason, I kept reading it as if it said [string
equal].


DrS


From: drscrypt on
On 6/16/2010 10:53 AM, drscrypt(a)gmail.com wrote:

> Any ideas what is causing the problem? Should I revert to the previous
> version?
>


Here is the quick and probably dirty resolution to the problem: It
seems like the last update to mime was in 2008 - hopefully the
maintainer(s) will see this and replace it with the correct fix:


Towards the end of the ::mime::copymessageaux in mime.tcl, there is this
code. If you put a catch around the the two puts and the flush, all is ok:


> if {[string compare $converter ""]} {
> puts -nonewline $channel [$converter -mode encode -- $state(string)]
> } else {
> puts -nonewline $channel $state(string)
> }
> }
> default {
> error "Unknown value \"$state(value)\""
> }
> }
>
> flush $channel