Pylons / pyramid_layout

Pyramid add-on for managing UI layouts.
Other
24 stars 26 forks source link

Fixed Python 3.1 and 3.2 support by removing unicode literals #14

Closed msiedlarek closed 11 years ago

msiedlarek commented 11 years ago

This fix comes at a price - it introduces tiny but unavoidable compatibility module with one function replacing unicode literal which doesn't work in Python 3.1-3.2 (brought back in Python 3.3 by PEP 414). I believe though, that support for two modern Python versions, packaged in many of current stable Linux distributions, is worth it.

The compatibility code has been shamelessly copied from zope.schema.

chrisrossi commented 11 years ago

Can you write a test that exposes the problem in 3.2?

msiedlarek commented 11 years ago

It would be something like import pyramid_layout.zcml wrapped up in a TestCase, but sure, why not :)

msiedlarek commented 11 years ago

You can test it by checking out the current master and copying this file:

https://github.com/msiedlarek/pyramid_layout/blob/python3.2-support/pyramid_layout/tests/test_zcml.py

to pyramid_layout/tests directory and executing the tests.

On Python 3.2 for example the test will fail like this:

(env)user@host:~/pyramid_layout$ python --version
Python 3.2.3
(env)user@host:~/pyramid_layout$ python setup.py nosetests
running nosetests
running egg_info
writing requirements to pyramid_layout.egg-info/requires.txt
writing pyramid_layout.egg-info/PKG-INFO
writing top-level names to pyramid_layout.egg-info/top_level.txt
writing dependency_links to pyramid_layout.egg-info/dependency_links.txt
writing manifest file 'pyramid_layout.egg-info/SOURCES.txt'
running build_ext
.................................E
======================================================================
ERROR: #14 Unicode literals in `zcml` module
----------------------------------------------------------------------
Traceback (most recent call last):
  File "path/to/pyramid_layout/pyramid_layout/tests/test_zcml.py", line 25, in test_unicode_literals
    import pyramid_layout.zcml #pragma NO COVERAGE
  File "path/to/pyramid_layout/pyramid_layout/zcml.py", line 10
    title=u"The interface or class this panel is for.",
                                                     ^
SyntaxError: invalid syntax

Name                               Stmts   Miss  Cover   Missing
----------------------------------------------------------------
pyramid_layout                         1      0   100%   
pyramid_layout.config                183      0   100%   
pyramid_layout.interfaces              5      0   100%   
pyramid_layout.layout                 46      0   100%   
pyramid_layout.panel                  18      0   100%   
pyramid_layout.tests                   0      0   100%   
pyramid_layout.tests.test_config     416      0   100%   
pyramid_layout.tests.test_layout     103      0   100%   
pyramid_layout.tests.test_panel       44      0   100%   
pyramid_layout.tests.test_zcml         2      0   100%   
----------------------------------------------------------------
TOTAL                                818      0   100%   
----------------------------------------------------------------------
Ran 34 tests in 0.070s

FAILED (errors=1)