From 16d3e04cb80a975eef0e0ad6f0f6dc4800860d3c Mon Sep 17 00:00:00 2001 From: Michael Fenn Date: Thu, 19 Mar 2015 15:10:44 -0400 Subject: compat: use eval instead of ast.literal_eval on python 2.4 --- doc/development/compat.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'doc/development') diff --git a/doc/development/compat.txt b/doc/development/compat.txt index 8700c46d3..5ac08ea68 100644 --- a/doc/development/compat.txt +++ b/doc/development/compat.txt @@ -129,6 +129,8 @@ below, since some of these implementations may be feature-incomplete. +----------------+--------------------------------+--------------------------------------------+ | MutableMapping | :class:`UserDict.DictMixin` | :class:`collections.MutableMapping` (2.6+) | +----------------+--------------------------------+--------------------------------------------+ +| literal_eval | :func:`ast.literal_eval` | :func:`eval` | ++----------------+--------------------------------+--------------------------------------------+ walk_packages ~~~~~~~~~~~~~ @@ -171,6 +173,14 @@ mind. :class:`collections.MutableMapping` is available in Python 2.6+, and will be used if available. +literal_eval +~~~~~~~~~~~~ + +:func:`ast.literal_eval` is a safe version of :func:`eval` that will only +allow delaration of literal strings, ints, list, dicts, etc. This was +introduced in Python 2.6, and as such Python 2.4 uses the plain-old +:func:`eval`. + Other Symbols ------------- -- cgit v1.2.3-1-g7c22 From eb11693747aa069f97538b2d6fca97ac1d5e97bb Mon Sep 17 00:00:00 2001 From: Michael Fenn Date: Thu, 19 Mar 2015 15:37:43 -0400 Subject: doc: fix literal_eval entry in table and clarify header --- doc/development/compat.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc/development') diff --git a/doc/development/compat.txt b/doc/development/compat.txt index 5ac08ea68..14522b6b3 100644 --- a/doc/development/compat.txt +++ b/doc/development/compat.txt @@ -113,7 +113,7 @@ with Python 2.4 (and occasionally 2.5). Be sure to read the notes below, since some of these implementations may be feature-incomplete. +----------------+--------------------------------+--------------------------------------------+ -| Name | Python 2.4 | Python 2.4+ | +| Name | Python 2.4 | Python 2.5+ | +================+================================+============================================+ | formatdate | :func:`email.Utils.formatdate` | :func:`email.utils.formatdate` | +----------------+--------------------------------+--------------------------------------------+ @@ -129,7 +129,7 @@ below, since some of these implementations may be feature-incomplete. +----------------+--------------------------------+--------------------------------------------+ | MutableMapping | :class:`UserDict.DictMixin` | :class:`collections.MutableMapping` (2.6+) | +----------------+--------------------------------+--------------------------------------------+ -| literal_eval | :func:`ast.literal_eval` | :func:`eval` | +| literal_eval | :func:`eval` | :func:`ast.literal_eval` | +----------------+--------------------------------+--------------------------------------------+ walk_packages -- cgit v1.2.3-1-g7c22 From 72938c5ed7de6e3bb8a286f12e2dc486d83b2f51 Mon Sep 17 00:00:00 2001 From: Michael Fenn Date: Thu, 19 Mar 2015 16:36:58 -0400 Subject: doc: ast.literal_eval in is only in 2.6+ --- doc/development/compat.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc/development') diff --git a/doc/development/compat.txt b/doc/development/compat.txt index 14522b6b3..132bf67c0 100644 --- a/doc/development/compat.txt +++ b/doc/development/compat.txt @@ -129,7 +129,7 @@ below, since some of these implementations may be feature-incomplete. +----------------+--------------------------------+--------------------------------------------+ | MutableMapping | :class:`UserDict.DictMixin` | :class:`collections.MutableMapping` (2.6+) | +----------------+--------------------------------+--------------------------------------------+ -| literal_eval | :func:`eval` | :func:`ast.literal_eval` | +| literal_eval | :func:`eval` | :func:`ast.literal_eval`(2.6+) | +----------------+--------------------------------+--------------------------------------------+ walk_packages -- cgit v1.2.3-1-g7c22