diff options
| author | Eli Collins <elic@assurancetechnologies.com> | 2012-04-12 13:35:27 -0400 |
|---|---|---|
| committer | Eli Collins <elic@assurancetechnologies.com> | 2012-04-12 13:35:27 -0400 |
| commit | a4a2d2414f7fa5d92abbc3f0d71da17425563994 (patch) | |
| tree | c920db0ef4e6e1e5343d52ab7f5aa33864998260 /passlib | |
| parent | 046cfe8a3489ccf87e06a5a9982b283eb71945b0 (diff) | |
| download | passlib-a4a2d2414f7fa5d92abbc3f0d71da17425563994.tar.gz | |
starting branch to add ironpython support
* adds hack to disable saslprep() since stringprep is missing
Diffstat (limited to 'passlib')
| -rw-r--r-- | passlib/tests/test_utils.py | 8 | ||||
| -rw-r--r-- | passlib/utils/__init__.py | 25 |
2 files changed, 30 insertions, 3 deletions
diff --git a/passlib/tests/test_utils.py b/passlib/tests/test_utils.py index 4c3a6d2..678ae06 100644 --- a/passlib/tests/test_utils.py +++ b/passlib/tests/test_utils.py @@ -241,7 +241,13 @@ class MiscTest(TestCase): def test_saslprep(self): "test saslprep() unicode normalizer" - from passlib.utils import saslprep as sp + from passlib.utils import saslprep as sp, _ipy_missing_stringprep + + if IRONPYTHON: + self.assertTrue(_ipy_missing_stringprep, + "alert passlib author that IPY has stringprep support!") + self.assertRaises(NotImplementedError, sp, u('abc')) + raise self.skipTest("stringprep missing under IPY") # invalid types self.assertRaises(TypeError, sp, None) diff --git a/passlib/utils/__init__.py b/passlib/utils/__init__.py index e0b9e75..a283299 100644 --- a/passlib/utils/__init__.py +++ b/passlib/utils/__init__.py @@ -1,5 +1,13 @@ """passlib.utils -- helpers for writing password hashes""" #============================================================================= +# Python VM identification +#============================================================================= +import sys +PYPY = hasattr(sys, "pypy_version_info") +JYTHON = sys.platform.startswith('java') +IRONPYTHON = 'IronPython' in sys.version + +#============================================================================= #imports #============================================================================= #core @@ -9,9 +17,15 @@ from functools import update_wrapper import logging; log = logging.getLogger(__name__) import math import os -import sys import random -import stringprep +_ipy_missing_stringprep = False +if IRONPYTHON: + try: + import stringprep + except ImportError: + _ipy_missing_stringprep = True +else: + import stringprep import time import unicodedata from warnings import warn @@ -431,6 +445,13 @@ def saslprep(source, errname="value"): return data +# implement stub for ironpython +if _ipy_missing_stringprep: + def saslprep(source, errname="value"): + "ironpython stub for saslprep()" + raise NotImplementedError("saslprep() requires the stdlib 'stringprep' " + "module, which is not available under IronPython") + #============================================================================= # bytes helpers #============================================================================= |
