Modify

Opened 12 years ago

Closed 12 years ago

#10412 closed enhancement (fixed)

acct_mgr-0.4dev breaking 2.4 compatibility

Reported by: Jun Omae Owned by: Steffen Hoffmann
Priority: normal Component: AccountManagerPlugin
Severity: normal Keywords: compatibility
Cc: Trac Release: 0.12

Description

I tried acct_mgr-0.4dev on Python 2.4. I got the following error and cannot extract messages. It seems breaking 2.4 compatibility. It works well to me with acct_mgr-0.4dev-r12103_2.4compat.diff.

$ ~/venv/trac-0.12/bin/python -V
Python 2.4.3
$ ~/venv/trac-0.12/bin/python setup.py extract_messages
running extract_messages
extracting messages from acct_mgr/__init__.py
extracting messages from acct_mgr/admin.py
extracting messages from acct_mgr/api.py
...
extracting messages from acct_mgr/templates/user_table.html
Traceback (most recent call last):
  File "setup.py", line 52, in ?
    entry_points = {
  File "/usr/lib/python2.4/distutils/core.py", line 149, in setup
    dist.run_commands()
  File "/usr/lib/python2.4/distutils/dist.py", line 946, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.4/distutils/dist.py", line 966, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.4/site-packages/usr/lib/python2.4/site-packages/babel/messages/frontend.py", line 313, in run
  File "/usr/lib/python2.4/site-packages/usr/lib/python2.4/site-packages/babel/messages/extract.py", line 170, in extract_from_dir
  File "/usr/lib/python2.4/site-packages/usr/lib/python2.4/site-packages/babel/messages/extract.py", line 201, in extract_from_file
  File "/usr/lib/python2.4/site-packages/usr/lib/python2.4/site-packages/babel/messages/extract.py", line 275, in extract
  File "/usr/lib/python2.4/site-packages/genshi/filters/i18n.py", line 1237, in extract
    for message in translator.extract(tmpl.stream, gettext_functions=keywords):
  File "/usr/lib/python2.4/site-packages/genshi/template/base.py", line 442, in stream
    self._stream = list(self._prepare(self._stream))
  File "/usr/lib/python2.4/site-packages/genshi/template/base.py", line 478, in _prepare
    yield kind, (directives, list(substream)), pos
  File "/usr/lib/python2.4/site-packages/genshi/template/base.py", line 478, in _prepare
    yield kind, (directives, list(substream)), pos
  File "/usr/lib/python2.4/site-packages/genshi/template/base.py", line 473, in _prepare
    namespaces, pos)
  File "/usr/lib/python2.4/site-packages/genshi/template/directives.py", line 711, in attach
    namespaces, pos)
  File "/usr/lib/python2.4/site-packages/genshi/template/directives.py", line 83, in attach
    return cls(value, template, namespaces, *pos[1:]), stream
  File "/usr/lib/python2.4/site-packages/genshi/template/directives.py", line 704, in __init__
    offset + (err.offset or 0))
genshi.template.base.TemplateSyntaxError: invalid syntax in expression "odd_even = 'odd' if idx % 2 else 'even'" of "with" directive (/home/jun66j5/src/trac/trac-hacks/accountmanagerplugin/trunk/acct_mgr/templates/user_table.html, line 28)

Attachments (1)

acct_mgr-0.4dev-r12103_2.4compat.diff (2.7 KB) - added by Jun Omae 12 years ago.

Download all attachments as: .zip

Change History (7)

Changed 12 years ago by Jun Omae

comment:1 Changed 12 years ago by Steffen Hoffmann

Keywords: compatibility added

Thanks for the report. Sure, my change in [10738] introduced Python2.5 idioms.

What I like most is your suggestion for oddeven, nice. I don't get the idea behind adding yet another try.. level into acct_mgr/register.py - please explain that. Thanks for taking care.

comment:2 in reply to:  1 Changed 12 years ago by Jun Omae

Replying to hasienda:

I don't get the idea behind adding yet another try.. level into acct_mgr/register.py - please explain that.

Sorry for the lack of explanation.

We cannot combine both except and finally blocks on Python 2.4. http://docs.python.org/whatsnew/2.5.html#pep-341-unified-try-except-finally

$ python2.4
Python 2.4.3 (#1, Jun 18 2012, 08:55:31)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> try:
...   pass
... except:
...   pass
... finally:
  File "<stdin>", line 5
    finally:
          ^
SyntaxError: invalid syntax
>>>
$ python2.5
Python 2.5.6 (r256:88840, Feb 29 2012, 04:03:24)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> try:
...   pass
... except:
...   pass
... finally:
...   pass
...
>>>

comment:3 Changed 12 years ago by Steffen Hoffmann

(In [12104]) AccountManagerPlugin: Replace more current coding style for Python2.4 compatibility, refs #10412.

Many thanks for Jun Omae's report, suggested fix and explanation on the issue. Nevertheless with Trac-1.1dev about to drop even Python2.5 compatibility the days of Python2.4 are counted - even in Trac plugins.

comment:4 Changed 12 years ago by Steffen Hoffmann

Thanks for the explanation.

I understand, but can't reproduce anymore after upgrading my development system to Debian 6. Minimum Python version is 2.5 in there, but I guess I'll be forced to install a private 2.4 again in a virtual env, if such issues recur more often.

comment:5 in reply to:  4 Changed 12 years ago by Ryan J Ollos

Replying to hasienda:

I understand, but can't reproduce anymore after upgrading my development system to Debian 6. Minimum Python version is 2.5 in there, but I guess I'll be forced to install a private 2.4 again in a virtual env, if such issues recur more often.

Same problem for me, being on Debian 6 also. If you find a package source for 2.4, I'd be interested to know.

comment:6 Changed 12 years ago by Steffen Hoffmann

Resolution: fixed
Status: newclosed

(In [12398]) AccountManagerPlugin: Releasing version 0.4, pushing development to acct_mgr-0.5dev.

Availability of that code as stable release closes #874, #3459, #4677, #5295, #5691, #6616, #7577, #8076, #8685, #8770, #8791, #8990, #9052, #9079, #9090, #9139, #9246, #9252, #9547, #9618, #9676, #9843, #9852, #9940, #10023, #10028, #10123, #10142, #10204, #10276, #10397, #10412, #10594, #10625 and #10644.

Some more issues have been worked-on, yet without confirmed resolution, refs #5464 (for JiraToTracIntegration), #8927 and #10134.

And finally there are some issues and enhancement requests showing progress, but known to require more work to resolve them satisfactorily, refs #843, #1600, #5964, #8217, #8933.

Thanks to all contributors and followers, that enabled and encouraged a good portion of this development work.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Steffen Hoffmann.
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.