Edgewall Software

Opened 8 years ago

Last modified 8 years ago

#12491 closed defect

Python >= 2.6 should be required for recaptcha2 module — at Version 2

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: plugin - spam-filter
Component: plugin/spamfilter Version:
Severity: normal Keywords: stoecker
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Ryan J Ollos)

Noted while reviewing gmessage:trac-users:ibiYYaqNok0/Sz_Nt6eTAAAJ, plugins/1.0/spam-filter/tracspamfilter/captcha/recaptcha2.py@14630:14 imports json, which is only available in Python ≥ 2.6.

setup.py requires json for the tracspamfilter.filters.blogspam module, and json requires Python ≥ 2.6.

It's possible we could address the issue found on the mailing list as well, with the following change (untested):

  • ../spam-filter/setup.py

     
    1212# individuals. For the exact contribution history, see the revision
    1313# history and logs, available at http://projects.edgewall.com/trac/.
    1414
     15import sys
    1516from setuptools import setup, find_packages
    1617
    1718PACKAGE = 'TracSpamFilter'
     
    6061        'dns': ['dnspython>=1.3.5'],
    6162        'spambayes': ['spambayes'],
    6263        'pillow': ['pillow'],
    63         'json': ['python>=2.6'],
     64        'json': ['simplejson' if sys.version_info < (2, 6) else ''],
    6465        'account': ['TracAccountManager >= 0.4'],
    6566        'oauth': ['oauth2'],
    6667        'httplib2': ['httplib2']
     
    9899        spamfilter.captcha.expression = tracspamfilter.captcha.expression
    99100        spamfilter.captcha.rand = tracspamfilter.captcha.rand
    100101        spamfilter.captcha.recaptcha = tracspamfilter.captcha.recaptcha
    101         spamfilter.captcha.recaptcha2 = tracspamfilter.captcha.recaptcha2
     102        spamfilter.captcha.recaptcha2 = tracspamfilter.captcha.recaptcha2[json]
    102103        spamfilter.captcha.keycaptcha = tracspamfilter.captcha.keycaptcha
    103104        spamfilter.captcha.mollom = tracspamfilter.captcha.mollom[oauth,httplib2]
    104105    """,
  • ../spam-filter/tracspamfilter/captcha/recaptcha2.py

     
    1111# individuals. For the exact contribution history, see the revision
    1212# history and logs, available at http://projects.edgewall.com/trac/.
    1313
    14 import json
    1514import urllib
    1615import urllib2
    1716from pkg_resources import get_distribution
     17try:
     18    import json
     19except ImportError:
     20    import simplejson as json
    1821
    1922from trac import __version__ as TRAC_VERSION
    2023from trac.config import Option
  • ../spam-filter/tracspamfilter/filters/blogspam.py

     
    1515# Author: Dirk Stöcker <trac@dstoecker.de>
    1616
    1717from email.Utils import parseaddr
    18 import json
    1918from pkg_resources import get_distribution
     19try:
     20    import json
     21except ImportError:
     22    import simplejson as json
    2023
    2124from trac import __version__ as TRAC_VERSION
    2225from trac.config import IntOption, Option, ListOption

Change History (2)

comment:1 by Jun Omae, 8 years ago

I noticed tracspamfilter for Trac 1.0 with Python 2.5 has syntax errors due to with keywords without from __future__ import with_statement.

comment:2 by Ryan J Ollos, 8 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.