summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2011-08-25 18:20:10 -0400
committerEli Collins <elic@assurancetechnologies.com>2011-08-25 18:20:10 -0400
commit3d80e7151ca8b69f115e03bcb91c8ca266ed9e03 (patch)
tree4d14a469fdca18061657476c71d6adcd3033568d
parent00df5078b8760575321b91fdc878d0c9a04d6c12 (diff)
downloadpasslib-3d80e7151ca8b69f115e03bcb91c8ca266ed9e03.tar.gz
beginning 1.6 dev
* removed previously deprecated support for ConfigParser interpolated files * removed previously deprecated support for set_backend(None)
-rw-r--r--CHANGES22
-rw-r--r--passlib/__init__.py2
-rw-r--r--passlib/context.py66
-rw-r--r--passlib/utils/handlers.py21
4 files changed, 32 insertions, 79 deletions
diff --git a/CHANGES b/CHANGES
index 041597a..9aa4eb8 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,8 +4,26 @@
Release History
===============
+**1.6** (NOT YET RELEASED)
+
+ Removal of Deprecated Features
+
+ * Config files should now use :class:`SafeConfigParser` interpolation.
+
+ :meth:`CryptPolicy.from_file` and :meth:`CryptPolicy.from_string`
+ previously used :class:`!ConfigParser` interpolation.
+ Release 1.5 switched to :class:`SafeConfigParser`,
+ but kept support for the old format as a (deprecated) fallback.
+ This fallback has been removed in 1.6; any remaining
+ legacy config files may need to escape some ``%`` characters
+ in order to load correctly.
+
+ * Calls to :meth:`~passlib.hash.HasManyBackends.set_backend` should now
+ use the string ``"any"`` instead of the value ``None``. ``None``
+ was deprecated in release 1.5, and is no longer supported.
+
**1.5.1** (2011-08-17)
-
+
Minor bugfix release; now compatible with Google App Engine.
* bugfix: make ``passlib.hash.__loader__`` attribute writable -
@@ -23,7 +41,7 @@ Release History
* under GAE, disable all unittests which require writing to filesystem.
* more unittest coverage for :mod:`passlib.apps` and :mod:`passlib.hosts`.
-
+
* improved version datestamps in build script.
**1.5** (2011-07-11)
diff --git a/passlib/__init__.py b/passlib/__init__.py
index cda8b7c..b2c7ec9 100644
--- a/passlib/__init__.py
+++ b/passlib/__init__.py
@@ -1,3 +1,3 @@
"""passlib - suite of password hashing & generation routinges"""
-__version__ = '1.5.1'
+__version__ = '1.6.dev0'
diff --git a/passlib/context.py b/passlib/context.py
index 4cdb07c..cd0420f 100644
--- a/passlib/context.py
+++ b/passlib/context.py
@@ -6,16 +6,11 @@ from __future__ import with_statement
from passlib.utils import py32_lang
#core
from cStringIO import StringIO
-# Py2k #
- #note: importing ConfigParser to handle passlib 1.4 / earlier files
-from ConfigParser import SafeConfigParser,ConfigParser,InterpolationSyntaxError
-# Py3k #
-#if py32_lang:
-# #Py3.2 removed old ConfigParser, put SafeConfigParser in it's place
-# from ConfigParser import ConfigParser as SafeConfigParser
-#else:
-# from ConfigParser import SafeConfigParser
-# end Py3k #
+if py32_lang:
+ #Py3.2 removed old ConfigParser, put SafeConfigParser in it's place
+ from ConfigParser import ConfigParser as SafeConfigParser
+else:
+ from ConfigParser import SafeConfigParser
import inspect
import re
import hashlib
@@ -126,31 +121,6 @@ def parse_policy_items(source):
value = _parse_policy_value(cat, name, opt, value)
yield cat, name, opt, value
-# Py2k #
-def _is_legacy_parse_error(err):
- "helper for parsing config files"
- #NOTE: passlib 1.4 and earlier used ConfigParser,
- # when they should have been using SafeConfigParser
- # (which passlib 1.5+ switched to)
- # this has no real security effects re: passlib,
- # but some 1.4 config files that have "vary_rounds = 10%"
- # may throw an error under SafeConfigParser,
- # and should read "vary_rounds = 10%%"
- #
- # passlib 1.6 and on will only use SafeConfigParser,
- # but passlib 1.5 tries to detect the above 10% error,
- # issue a warning, and retry w/ ConfigParser,
- # for backward compat.
- #
- # this function's purpose is to encapsulate that
- # backward-compat behavior.
- value = err.args[0]
- #'%' must be followed by '%' or '(', found: '%'
- if value == "'%' must be followed by '%' or '(', found: '%'":
- return True
- return False
-# end Py2k #
-
#--------------------------------------------------------
#policy class proper
#--------------------------------------------------------
@@ -256,37 +226,13 @@ class CryptPolicy(object):
@classmethod
def _from_stream(cls, stream, section, filename=None):
"helper for from_string / from_path"
- # Py2k #
- pos = stream.tell()
- # end Py2k #
-
p = SafeConfigParser()
if py32_lang:
# Py3.2 deprecated readfp
p.read_file(stream, filename or "<???>")
else:
p.readfp(stream, filename or "<???>")
-
- # Py2k #
- try:
- items = p.items(section)
- except InterpolationSyntaxError, err:
- if not _is_legacy_parse_error(err):
- raise
- #support for deprecated 1.4 behavior, will be removed in 1.6
- if filename:
- warn("from_path(): the file %r contains an unescaped '%%', this will be fatal in passlib 1.6" % (filename,), stacklevel=3)
- else:
- warn("from_string(): the provided string contains an unescaped '%', this will be fatal in passlib 1.6", stacklevel=3)
- p = ConfigParser()
- stream.seek(pos)
- p.readfp(stream)
- items = p.items(section)
-
- # py3k #
- #items = p.items(section)
- # end py3k #
-
+ items = p.items(section)
return cls(**dict(items))
@classmethod
diff --git a/passlib/utils/handlers.py b/passlib/utils/handlers.py
index 410ffca..1f906a2 100644
--- a/passlib/utils/handlers.py
+++ b/passlib/utils/handlers.py
@@ -982,7 +982,7 @@ class HasManyBackends(GenericHandler):
document this class's usage
.. attribute:: backends
-
+
tuple containing names of the backends which are supported.
two common names are ``"os_crypt"`` (if backend uses :mod:`crypt`),
and ``"builtin"`` (if the backend is a pure-python fallback).
@@ -995,7 +995,7 @@ class HasManyBackends(GenericHandler):
private class attr used by :meth:`has_backend`
to check if a specific backend is available.
- one of these should be provided by subclass
+ one of these should be provided by subclass
for each backend listed in :attr:`backends`.
"""
@@ -1040,12 +1040,7 @@ class HasManyBackends(GenericHandler):
:returns:
``True`` if backend is currently supported, else ``False``.
"""
- if name in (None, "any", "default"):
- if name is None:
- warn("has_backend(None) is deprecated,"
- " and support will be removed in Passlib 1.6;"
- " use has_backend('any') instead.",
- DeprecationWarning, stacklevel=2)
+ if name in ("any", "default"):
try:
cls.set_backend()
return True
@@ -1089,21 +1084,15 @@ class HasManyBackends(GenericHandler):
* if ``"any"`` or ``"default"`` was specified,
and NO backends are currently available.
-
+
return value should be ignored.
-
+
.. note::
:exc:`~passlib.utils.MissingBackendError` derives
from :exc:`RuntimeError`, since this usually indicates
lack of an external library or OS feature.
"""
- if name is None:
- warn("set_backend(None) is deprecated,"
- " and support will be removed in Passlib 1.6;"
- " use set_backend('any') instead.",
- DeprecationWarning, stacklevel=2)
- name = "any"
if name == "any":
name = cls._backend
if name: