Skip to content

Commit

Permalink
Merge branch 'NextThought-py32'
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Jun 5, 2015
2 parents 4a7f507 + 9c0bab2 commit 7491556
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 25 deletions.
20 changes: 10 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
language: python
sudo: false
python:
- 2.6
- 2.7
- 3.3
- 3.4
- pypy
- pypy3
env:
- TOXENV=py26
- TOXENV=py27
- TOXENV=py32
- TOXENV=py33
- TOXENV=py34
- TOXENV=pypy
- TOXENV=pypy3
install:
- pip install
- pip install zope.applicationcontrol[test]
- pip install tox
script:
- python setup.py -q test -q
- tox
notifications:
email: false
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ def alltests():
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Natural Language :: English',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
Expand Down
20 changes: 13 additions & 7 deletions src/zope/applicationcontrol/runtimeinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
appsetup = None

PY3 = sys.version_info[0] == 3
if PY3:
_u = str
else:
_u = unicode

@implementer(IRuntimeInfo)
@adapter(IApplicationControl)
Expand All @@ -62,12 +66,14 @@ def getDeveloperMode(self):

def getPreferredEncoding(self):
"""See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
if locale is not None:
try:
return locale.getpreferredencoding()
except locale.Error:
pass
return sys.getdefaultencoding()
try:
result = locale.getpreferredencoding()
except (locale.Error, AttributeError):
result = ''
# Under some systems, getpreferredencoding() can return ''
# (e.g., Python 2.7/MacOSX/LANG=en_us.UTF-8). This then blows
# up with 'unknown encoding'
return result or sys.getdefaultencoding()

def getFileSystemEncoding(self):
"""See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
Expand Down Expand Up @@ -105,7 +111,7 @@ def getSystemPlatform(self):
except ValueError:
continue
info.append(t)
return u" ".join(info)
return _u(" ").join(info)

def getCommandLine(self):
"""See zope.app.applicationcontrol.interfaces.IRuntimeInfo"""
Expand Down
21 changes: 14 additions & 7 deletions src/zope/applicationcontrol/tests/test_runtimeinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
stupid_version_string = "3085t0klvn93850voids"

PY3 = sys.version_info[0] == 3
if PY3:
_u = str
else:
_u = unicode


@implementer(IZopeVersion)
class TestZopeVersion(object):
Expand All @@ -47,12 +52,14 @@ def _Test__new(self):
return RuntimeInfo(applicationController)

def _getPreferredEncoding(self):
if locale is not None:
try:
return locale.getpreferredencoding()
except locale.Error:
pass
return sys.getdefaultencoding()
try:
result = locale.getpreferredencoding()
except (locale.Error, AttributeError):
result = ''
# Under some systems, getpreferredencoding() can return ''
# (e.g., Python 2.7/MacOSX/LANG=en_us.UTF-8). This then blows
# up with 'unknown encoding'
return result or sys.getdefaultencoding()

def _getFileSystemEncoding(self):
enc = sys.getfilesystemencoding()
Expand All @@ -77,7 +84,7 @@ def test_ZopeVersion(self):
runtime_info = self._Test__new()

# we expect that there is no utility
self.assertEqual(runtime_info.getZopeVersion(), u"Unavailable")
self.assertEqual(runtime_info.getZopeVersion(), _u("Unavailable"))

siteManager = component.getSiteManager()
siteManager.registerUtility(TestZopeVersion(), IZopeVersion)
Expand Down
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py26,py27,py33,py34,pypy,pypy3
py26,py27,py32,py33,py34,pypy,pypy3

[testenv]
commands =
Expand All @@ -16,3 +16,9 @@ deps =
zope.testing
zope.testrunner

[testenv:py26]
commands =
{[testenv]commands}
deps =
{[testenv]deps}
ordereddict

0 comments on commit 7491556

Please sign in to comment.