Re: [Checkins] SVN: zope.i18nmessageid/branches/regebro-python3/src/zope/i18nmessageid/messages.txt Paper over different exception type raised under Python3.

Tres Seaver <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/19/2010 10:22 AM, Lennart Regebro wrote:
> Hi, can you explain this?
> 
> After this change, the tests now break under Python 3.1, while they
> worked before...
> 
> On Fri, Nov 19, 2010 at 15:51, Tres Seaver <[email protected]> wrote:
>> Log message for revision 118497:
>>  Paper over different exception type raised under Python3.
>>
>> Changed:
>>  U   zope.i18nmessageid/branches/regebro-python3/src/zope/i18nmessageid/messages.txt
>>
>> -=-
>> Modified: zope.i18nmessageid/branches/regebro-python3/src/zope/i18nmessageid/messages.txt
>> ===================================================================
>> --- zope.i18nmessageid/branches/regebro-python3/src/zope/i18nmessageid/messages.txt     2010-11-19 14:50:37 UTC (rev 118496)
>> +++ zope.i18nmessageid/branches/regebro-python3/src/zope/i18nmessageid/messages.txt     2010-11-19 14:51:42 UTC (rev 118497)
>> @@ -65,21 +65,17 @@
>>  The message's attributes are considered part of the immutable message
>>  object.  They cannot be changed once the message id is created:
>>
>> -  >>> robot.domain = "planetexpress"
>> -  Traceback (most recent call last):
>> -  ...
>> -  TypeError: readonly attribute
>> +  >>> def _assertReadonlyAttribute(thing, attrname, value):
>> +  ...     try:
>> +  ...         setattr(thing, attrname, value)
>> +  ...     except Exception, e:
>> +  ...         assert str(e) == 'readonly attribute'
>> +  ...     else:
>> +  ...         raise AssertionError("Assigned to read-only attribute")
>> +  >>> _assertReadonlyAttribute(robot, 'domain', "planetexpress")
>> +  >>> _assertReadonlyAttribute(robot, 'default', u"${name} is not a robot.")
>> +  >>> _assertReadonlyAttribute(robot, 'mapping',  {u'name': u'Bender'})
>>
>> -  >>> robot.default = u"${name} is not a robot."
>> -  Traceback (most recent call last):
>> -  ...
>> -  TypeError: readonly attribute
>> -
>> -  >>> robot.mapping = {u'name': u'Bender'}
>> -  Traceback (most recent call last):
>> -  ...
>> -  TypeError: readonly attribute
>> -
>>  If you need to change their information, you'll have to make a new
>>  message id object:

Hmm, the tests failed for me without that change under Python 3.1, but
pass with it:

 $ cd /tmp/regebro
 $ rm -r build
 $ /opt/Python-3.1.2/bin/python3 setup.py build test
 ...
 =======================================================================
 Could not import C version:
 No module named _zope_i18nmessageid_message
 =======================================================================
 Doctest: zope.i18nmessageid.message.Message ... ok
 Doctest: messages.txt ... ok

 ----------------------------------------------------------------------
 Ran 2 tests in 0.011s

 OK

At this point, I can't reproduce the failture I was seeng even against
r118496  (assigning to the readonly attributes was raising
AttributeError, not TypeError).  I guess we can just revert my change.

How are you running the tests under Python3, BTW?


Tres.
- -- 
===================================================================
Tres Seaver          +1 540-429-0999          [email protected]
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzmmYAACgkQ+gerLs4ltQ4CyQCfSZrgNu9Y5i3senKIMBHtv6ry
t1kAn2CCAZ8I1IzAjfzzaCBRjhVIOY0/
=6WHe
-----END PGP SIGNATURE-----
_______________________________________________
Zope-Dev maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.