Modify

Opened 5 years ago

Closed 5 years ago

#10467 closed defect (fixed)

api.py - "with" gives SyntaxError building with python2.5 but ok with python2.6

Reported by: dale.miller@… Owned by: Russ Tyndall
Priority: normal Component: NeverNotifyUpdaterPlugin
Severity: normal Keywords:
Cc: dale.miller@… Trac Release: 1.0

Description

I have Trac on two procecessors:

  • openSUSE 10.3 with Python 2.5.1
  • openSUSE 11.2 with Python 2.6.2

I am upgrading to Trac 1.0 and got this error.

using nevernotifyupdaterplugin_0.13-r12113.zip

python setup.py bdist_egg (with Python 2.5.1)

build/bdist.linux-x86_64/egg/nevernotifyupdaterplugin/api.py:34: Warning: 'with' will become a reserved keyword in Python 2.6
  File "build/bdist.linux-x86_64/egg/nevernotifyupdaterplugin/api.py", line 34
    with self.env.db_query as db:

            ^
SyntaxError: invalid syntax

Builds clean using Python 2.6.2

From the Warning message - it is strange that it does not build on 2.5.1 but does on 2.6.2. It looks like they decided not to make "with" a reserved word in python 2.6.

Attachments (0)

Change History (7)

comment:1 Changed 5 years ago by anonymous

I did a diff between the api.py for 0.12 and for 0.13 and I should be able to use the 0.12 for my needs.

> diff Trac-plugins-0.12/nevernotifyupdaterplugin/0.12/nevernotifyupdaterplugin/api.py Trac-plugins-1.0/nevernotifyupdaterplugin/0.13/nevernotifyupdaterplugin/api.py
17a18
>
31,32d31
<         cursor = self.db.cursor()
<         # Suppress the updater from the recipients
35,41c34,43
<         cursor.execute("SELECT author FROM ticket_change WHERE ticket=%s "
<                        "ORDER BY time DESC LIMIT 1", (tktid,))
<         for updater, in cursor: break
<         else:
<           cursor.execute("SELECT reporter FROM ticket WHERE id=%s",
<                          (tktid,))
<           for updater, in cursor: break
---
>         with self.env.db_query as db:
>             cursor = db.cursor()
>             # Suppress the updater from the recipients
>             cursor.execute("SELECT author FROM ticket_change WHERE ticket=%s "
>                            "ORDER BY time DESC LIMIT 1", (tktid,))
>             for updater, in cursor: break
>             else:
>               cursor.execute("SELECT reporter FROM ticket WHERE id=%s",
>                              (tktid,))
>               for updater, in cursor: break
43,44c45,46
<         cursor.execute("SELECT value FROM session_attribute WHERE name='email' and sid=%s;",(updater,))
<         for up_em, in cursor: break
---
>             cursor.execute("SELECT value FROM session_attribute WHERE name='email' and sid=%s;",(updater,))
>             for up_em, in cursor: break
}

comment:3 Changed 5 years ago by Russ Tyndall

Resolution: fixed
Status: newclosed

(In [12150]) added a from future import with_statement so this works in py2.5 fix #10467

comment:4 Changed 5 years ago by Russ Tyndall

Thanks much for the bug report. I think the 0.13 branch should work in python 2.5 now

comment:5 Changed 5 years ago by Dale

Resolution: fixed
Status: closedreopened

reopened ticket -

on python-2.5.1

byte-compiling build/bdist.linux-x86_64/egg/nevernotifyupdaterplugin/api.py to api.pyc
  File "build/bdist.linux-x86_64/egg/nevernotifyupdaterplugin/api.py", line 6
    from __future__ import with_statement
SyntaxError: from __future__ imports must occur at the beginning of the file

on python-2.6.2

byte-compiling build/bdist.linux-x86_64/egg/nevernotifyupdaterplugin/api.py to api.pyc
SyntaxError: ('from __future__ imports must occur at the beginning of the file', ('build/bdist.linux-x86_64/egg/nevernotifyupdaterplugin/api.py', 6, None, 'from __future__ import with_statement\n'))

comment:6 Changed 5 years ago by Dale

Moving the from __future__ import with statement line to be first line of file gives successful build in both python-2.5.1 and 2.6.1

comment:7 Changed 5 years ago by Russ Tyndall

Resolution: fixed
Status: reopenedclosed

(In [12151]) make from future work (move to top). Thanks again fix #10467

Modify Ticket

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