Modify

Opened 3 weeks ago

Closed 3 weeks ago

Last modified 3 weeks ago

#14388 closed defect (fixed)

Refactor for Python 3?

Reported by: Rob Hills Owned by: Rob Hills
Priority: normal Component: TracSqlHelperScript
Severity: normal Keywords:
Cc: Trac Release: 1.6

Description

Exception thrown when called from Trac Hours plugin init...

2025-07-03 21:24:54,482 Trac[loader] ERROR: Skipping "trachours.setup = trachours.db": 
Traceback (most recent call last):
  File "/usr/lib/python3.11/cmd.py", line 214, in onecmd
    func = getattr(self, 'do_' + cmd)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TracAdmin' object has no attribute 'do_upgrade'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/webapps/dev.tracker.wacg.medimorphosis.com.au/.venv/lib/python3.11/site-packages/trac/loader.py", line 80, in _load_eggs
    entry.load(require=True)
  File "/var/webapps/dev.tracker.wacg.medimorphosis.com.au/.venv/lib/python3.11/site-packages/pkg_resources/__init__.py", line 2777, in load
    return self.resolve()
           ^^^^^^^^^^^^^^
  File "/var/webapps/dev.tracker.wacg.medimorphosis.com.au/.venv/lib/python3.11/site-packages/pkg_resources/__init__.py", line 2783, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/webapps/dev.tracker.wacg.medimorphosis.com.au/.venv/lib/python3.11/site-packages/trachours/db.py", line 17, in <module>
    from tracsqlhelper import *
  File "/var/webapps/dev.tracker.wacg.medimorphosis.com.au/.venv/lib/python3.11/site-packages/tracsqlhelper/__init__.py", line 29
    except Exception, e:
           ^^^^^^^^^^^^

Attachments (0)

Change History (7)

comment:1 Changed 3 weeks ago by Jun Omae

Please contribute patch to make compatible with Python 3 and Trac 1.6. I think the plugin is no longer needed....

comment:2 Changed 3 weeks ago by Rob Hills

Proposed patch - fixes the issue in my test Trac 1.6:

diff --git a/setup.py b/setup.py
index b24a480..66f4c20 100755
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@
 
 from setuptools import setup, find_packages
 
-version = '0.3.1'
+version = '0.4.0'
 
 setup(name='TracSQLHelper',
       version=version,
diff --git a/tracsqlhelper/__init__.py b/tracsqlhelper/__init__.py
index 80a7bec..d629712 100755
--- a/tracsqlhelper/__init__.py
+++ b/tracsqlhelper/__init__.py
@@ -26,7 +26,7 @@ class SQLHelper(object):
                 cursor = db.cursor()
                 cursor.execute(sql, params)
                 _data = self.actions(cursor)
-            except Exception, e:
+            except Exception as e:
                 env.log.error("""There was a problem executing sql:%s
     with parameters:%s
     Exception:%s""" %(sql, params, e))

comment:3 Changed 3 weeks ago by Jun Omae

In 18698:

TracSQLHelper 0.4.0: make compatible with Python 3 (refs #14388)

comment:4 Changed 3 weeks ago by Jun Omae

Ah, sorry for forgetting to include the patch author in the commit message....

comment:5 Changed 3 weeks ago by Jun Omae

I'm going to fix the following.

  • unicode keyword
  • Using dict.keys() and dict.items()
  • update_row_from_dict has SQL injection

comment:6 Changed 3 weeks ago by Jun Omae

Owner: set to Jun Omae
Resolution: fixed
Status: newclosed

In 18700:

TracSQLHelper 0.4.0: make compatible with Trac 1.6 and add small unit tests (closes #14388)

comment:7 Changed 3 weeks ago by Jun Omae

Owner: changed from Jun Omae to Rob Hills

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Rob Hills.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.