Edgewall Software
Modify

Opened 10 years ago

Closed 10 years ago

#11498 closed defect (fixed)

Failures of unit tests for authz_policy.py with ConfigObj 5.0.1

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 0.12.6
Component: general Version: 0.12-stable
Severity: normal Keywords: authzpolicy unicode configobj
Cc: Branch:
Release Notes:

Fix breaking authz_policy.py with unicode characters using ConfigObj 5.0.0 and later.

API Changes:
Internal Changes:

Description

I got the following on 0.12-stable. Also the same occur on 1.0-stable.

======================================================================
FAIL: test_unicode_resource_name (tracopt.perm.tests.authz_policy.AuthzPolicyTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jun66j5/src/trac/tests/4ae2068eece9886ff8772338043cb9830e129de0/src/tracopt/perm/tests/authz_policy.py", line 75, in test_unicode_resource_name
    self.check_permission('WIKI_VIEW', 'anonymous', resource, None))
AssertionError: False != None

======================================================================
FAIL: test_unicode_username (tracopt.perm.tests.authz_policy.AuthzPolicyTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jun66j5/src/trac/tests/4ae2068eece9886ff8772338043cb9830e129de0/src/tracopt/perm/tests/authz_policy.py", line 69, in test_unicode_username
    self.check_permission('WIKI_VIEW', u'änon', resource, None))
AssertionError: True != False

----------------------------------------------------------------------
Ran 1313 tests in 35.507s

It seems to be related to the following warning.

tracopt/perm/authz_policy.py:263: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  if who in valid_users or \

Installed libraries:

Babel==0.9.6
Genshi==0.6
MySQL-python==1.2.5
Pygments==1.6
configobj==5.0.1
distribute==0.6.24
lxml==3.3.1
psycopg2==2.5.2
pytz==2013.9
six==1.5.2
twill==0.9
wsgiref==0.1.2

Attachments (0)

Change History (6)

comment:1 by Jun Omae, 10 years ago

Milestone: next-minor-0.12.x0.12.6
Owner: set to Jun Omae
Status: newassigned

Unicode characters handling seems to be changed after configobj 5.0.0.

configobj 4.7.2

>>> io = StringIO('[wiki:résumé]\nänon = *')
>>> get_distribution('configobj')
configobj 4.7.2 (/home/jun66j5/venv/py25/lib/python2.5/site-packages)
>>> ConfigObj(io, encoding='utf-8')
ConfigObj({u'wiki:r\xe9sum\xe9': {u'\xe4non': u'*'}})

configobj 5.0.1

>>> io = StringIO('[wiki:résumé]\nänon = *')
>>> get_distribution('configobj')
configobj 5.0.1 (/home/jun66j5/venv/py26/lib/python2.6/site-packages)
>>> ConfigObj(io, encoding='utf-8')
ConfigObj({'wiki:r\xc3\xa9sum\xc3\xa9': {'\xc3\xa4non': '*'}})

Proposed changes can be found in jomae.git@t11498 and jomae.git@t11498_0.12.6dev.

comment:2 by Ryan J Ollos, 10 years ago

easy_install ConfigObj in a Python 2.5 environment results in the install of ConfigObj 5.0.1 with errors. Like what was suggested for Babel in comment:12:ticket:11258, it would be nice if there was a Python version check in the setup script for ConfigObj. Additionally, it would be nice if a Python 2.5 environment were able to locate and install ConfigObj 4.7.2 rather than 5.0.1. I opened a ticket for the issue here.

Last edited 10 years ago by Ryan J Ollos (previous) (diff)

comment:3 by Jun Omae, 10 years ago

I noticed that extra_require in setup.py on 0.12-stable doesn't have ConfigObj. Should we backport [12037/branches/1.0-stable/setup.py] to 0.12-stable?

in reply to:  3 ; comment:4 by Ryan J Ollos, 10 years ago

Replying to jomae:

I noticed that extra_require in setup.py on 0.12-stable doesn't have ConfigObj. Should we backport [12037/branches/1.0-stable/setup.py] to 0.12-stable?

I think it makes sense to backport it.

I had to do some testing to remind myself how this works. After [12037/branches/1.0-stable/setup.py], if ConfigObj is not installed, the component is not shown on the plugin admin panel. If enabled by editing trac.ini, the log shows:

03:10:54 AM Trac[loader] DEBUG: Loading tracopt.perm.authz_policy from /home/user/Workspace/t11498/teo-rjollos.git
03:10:54 AM Trac[loader] DEBUG: Skipping "tracopt.perm.authz_policy = tracopt.perm.authz_policy [configobj]": ("DistributionNotFound: ConfigObj" not found)

Whereas prior to the change the plugin would be shown on the admin page and would load when enabled,

03:13:52 AM Trac[loader] DEBUG: Loading tracopt.perm.authz_policy from /home/user/Workspace/t11498/teo-rjollos.git

but then we just get many entries of the following in the logs when ConfigObj isn't installed:

03:06:42 AM Trac[authz_policy] ERROR: configobj package not found

The behavior with [12037/branches/1.0-stable/setup.py] seems much better. Later on I think it would be nice to show tracopt.perm.authz_policy.* on the plugin admin panel when ConfigObj is not installed, but not allow it to be enabled and provide an indication of why it can't be enabled.

Last edited 10 years ago by Ryan J Ollos (previous) (diff)

in reply to:  4 comment:5 by Jun Omae, 10 years ago

Keywords: configobj added

The behavior with [12037/branches/1.0-stable/setup.py] seems much better.

Thanks for information! I'll backport it to 0.12-stable.

comment:6 by Jun Omae, 10 years ago

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

Backported in [12556] and fixed in [12557]. Also merged in [12558] and [12559].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae 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.