ports/115709: [PATCH] mail/archivemail: [Fix problems with python 2.5]

Alex Samorukov samm at os2.kiev.ua
Wed Aug 22 10:30:02 UTC 2007


>Number:         115709
>Category:       ports
>Synopsis:       [PATCH] mail/archivemail: [Fix problems with python 2.5]
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 22 10:30:01 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Alex Samorukov
>Release:        FreeBSD 6.1-RELEASE-p19 i386
>Organization:
>Environment:
System: FreeBSD ukrlex.net 6.1-RELEASE-p19 FreeBSD 6.1-RELEASE-p19 #7: Mon Aug 13 11:03:22 EEST 2007
>Description:
When running with python 2.5 archivemail fail with error. Error is already
fixed by upstream, patch is taken from http://sourceforge.net/tracker/index.php?func=detail&aid=1670422&group_id=49630&atid=456910
Here is a description from sf.net tracker:

.maildir/local is a Maildir and message is a rfc822.Message instance.
In python2.4 message.fp.name gives the path of the file where this
message is
stored. In python2.5 this doesn't exist but same info is avaliable from
'message.fp._file.name'

I've written a patch for archivemail-0.7.0 to check for python version
and
decide whether to use message.fp.name or message.fp._file.name and the
tool
seems to work fine.


Added file(s):
- files/patch-archivemail

Port maintainer (sergei at FreeBSD.org) is cc'd.

Generated with FreeBSD Port Tools 0.77
>How-To-Repeat:
Update python to 2.5 version. Run the script. You will got 
...
AttributeError: _ProxyFile instance has no attribute 'name' 
error.

>Fix:

--- archivemail-0.7.0.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/mail/archivemail/files/patch-archivemail /usr/home/samorukov/src/archivemail/files/patch-archivemail
--- /usr/ports/mail/archivemail/files/patch-archivemail	Thu Jan  1 03:00:00 1970
+++ /usr/home/samorukov/src/archivemail/files/patch-archivemail	Wed Aug 22 13:01:51 2007
@@ -0,0 +1,94 @@
+--- archivemail.orig	2006-11-03 01:21:22.000000000 +0200
++++ archivemail	2007-05-10 12:04:16.000000000 +0300
+@@ -779,7 +779,10 @@
+     # the headers have no valid dates -- last resort, try the file timestamp
+     # this will not work for mbox mailboxes
+     try:
+-        file_name = message.fp.name
++        if sys.hexversion >= 0x020500F0:
++            file_name = message.fp._file.name
++        else:
++            file_name = message.fp.name
+     except AttributeError:
+         # we are looking at a 'mbox' mailbox - argh! 
+         # Just return the current time - this will never get archived :(
+@@ -788,7 +791,7 @@
+     if not os.path.isfile(file_name):
+         unexpected_error("mailbox file name '%s' has gone missing" % \
+             file_name)    
+-    time_message = os.path.getmtime(message.fp.name)
++    time_message = os.path.getmtime(file_name)
+     vprint("using valid time found from '%s' last-modification time" % \
+         file_name)
+     return time_message
+@@ -806,7 +809,11 @@
+     """
+     status = ""
+     x_status = ""
+-    match = re.search(":2,(.+)$", message.fp.name)
++    if sys.hexversion >= 0x020500F0:
++        fpname = message.fp._file.name
++    else:
++        fpname = message.fp.name
++    match = re.search(":2,(.+)$", fpname)
+     if match:
+         flags = match.group(1)
+         for flag in flags: 
+@@ -825,7 +832,7 @@
+ 
+     # files in the maildir 'cur' directory are no longer new,
+     # they are the same as messages with 'Status: O' headers in mbox
+-    last_dir = os.path.basename(os.path.dirname(message.fp.name))
++    last_dir = os.path.basename(os.path.dirname(fpname))
+     if last_dir == "cur":
+         status = status + "O" 
+ 
+@@ -881,7 +888,10 @@
+         return 1
+     file_name = None
+     try:
+-        file_name = message.fp.name
++        if sys.hexversion >= 0x020500F0:
++            file_name = message.fp._file.name
++        else:
++	    file_name = message.fp.name
+     except AttributeError:
+         pass
+     # maildir mailboxes use the filename suffix to indicate flagged status
+@@ -901,7 +911,10 @@
+         return 0
+     file_name = None
+     try:
+-        file_name = message.fp.name
++        if sys.hexversion >= 0x020500F0:
++            file_name = message.fp._file.name
++        else:
++            file_name = message.fp.name
+     except AttributeError:
+         pass
+     # maildir mailboxes use the filename suffix to indicate read status
+@@ -918,7 +931,10 @@
+     file_name = None
+     message_size = None
+     try:
+-        file_name = message.fp.name
++        if sys.hexversion >= 0x020500F0:
++            file_name = message.fp._file.name
++        else:
++            file_name = message.fp.name
+     except AttributeError:
+         pass
+     if file_name:
+@@ -1269,7 +1285,11 @@
+                     if type == "maildir":
+                         add_status_headers(msg)
+                     archive.write(msg)
+-            if not options.dry_run: delete_queue.append(msg.fp.name) 
++            if sys.hexversion >= 0x020500F0:
++                fpname = msg.fp._file.name
++            else:
++                fpname = msg.fp.name
++            if not options.dry_run: delete_queue.append(fpname) 
+         else:
+             vprint("decision: retain message")
+         msg = original.next()
--- archivemail-0.7.0.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list