Edgewall Software
Modify

Opened 8 years ago

Closed 8 years ago

#12491 closed defect (fixed)

Python >= 2.6 should be required for recaptcha2 module

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:

Require simplejson for Python < 2.6. Skip loading Recaptcha2Captcha if json unavailable.

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

Attachments (0)

Change History (5)

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)

comment:3 by Ryan J Ollos, 8 years ago

Made use of with_statement Python 2.5-compatible in [14812].

comment:4 by Ryan J Ollos, 8 years ago

The following error is shown in logs on startup, confirming the finding on the mailing list:

10:40:03 PM Trac[loader] ERROR: Skipping "spamfilter.blogspam = tracspamfilter.filters.blogspam [json]": (version conflict "VersionConflict: (Python 2.7.11- (/usr/lib/python2.7/lib-dynload), Requirement.parse('python>=2.6'))")

Also, several errors like the following:

10:40:03 PM Trac[loader] ERROR: Skipping "tracopt.perm.authz_policy = tracopt.perm.authz_policy [configobj]": 
Traceback (most recent call last):
  File "/home/user/pve-2.7/local/lib/python2.7/site-packages/trac/loader.py", line 68, in _load_eggs
    entry.load(require=True)
  File "/home/user/pve-2.7/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2228, in load
    self.require(*args, **kwargs)
  File "/home/user/pve-2.7/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2245, in require
    items = working_set.resolve(reqs, env, installer)
  File "/home/user/pve-2.7/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 808, in resolve
    if not req_extras.markers_pass(req):
  File "/home/user/pve-2.7/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 993, in markers_pass
    return not req.marker or any(extra_evals) or req.marker.evaluate()
  File "/home/user/pve-2.7/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/markers.py", line 278, in evaluate
    return _evaluate_markers(self._markers, current_environment)
  File "/home/user/pve-2.7/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/markers.py", line 203, in _evaluate_markers
    lhs_value = _get_env(environment, lhs.value)
  File "/home/user/pve-2.7/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/markers.py", line 185, in _get_env
    "{0!r} does not exist in evaluation environment.".format(name)
UndefinedEnvironmentName: 'extra' does not exist in evaluation environment.

comment:5 by Ryan J Ollos, 8 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Fixed in [14813].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.