Opened 16 months ago

Last modified 11 months ago

#14144 new defect

Python 3 compatibility

Reported by: pulkomandy@… Owned by: ttressieres
Priority: normal Component: DownloadsPlugin
Severity: normal Keywords:
Cc: Trac Release:


Hello, This plugin seems to need only one change to run with Python 3.

  File "/usr/local/lib/python3.10/dist-packages/tracdownloads/", line 827
    except Exception, error:
SyntaxError: multiple exception types must be parenthesized (, line 827)

As said by Python, adding the parentheses there fixes the problem. Could you integrate that in the next release? Thanks!

Attachments (0)

Change History (1)

comment:1 Changed 11 months ago by pulkomandy@…

Some more patching is needed, otherwise the downloads themselves don't work. This seems to be working for me:

Index: tracdownloads/
--- tracdownloads/        (révision 18497)
+++ tracdownloads/        (copie de travail)
@@ -311,7 +311,7 @@

     def _edit_item(self, table, id, item):
         fields = item.keys()
-        values = item.values()
+        values = list(item.values())
         with self.env.db_transaction as db:
                 UPDATE %s SET %s WHERE id=%%s
@@ -513,7 +513,7 @@
                     listener.download_changed(context, new_download, download)

                 # Guess mime type.
-                with open(filepath.encode('utf-8'), 'r') as fileobj:
+                with open(filepath.encode('utf-8'), 'rb') as fileobj:
                     file_data =
                 mimeview = Mimeview(self.env)
                 mime_type = mimeview.get_mimetype(filepath, file_data)
@@ -824,7 +824,7 @@
             with open(filepath.encode('utf-8'), 'wb+') as fileobj:
                 shutil.copyfileobj(file, fileobj)
-        except Exception, error:
+        except (Exception, error):

Modify Ticket

Change Properties
Set your email in Preferences
as new The owner will remain ttressieres.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.