Stop injecting '_' into python's builtins

  • having a library injecting builtins on import is a bad idea (hard to track)
  • CubicWeb's __init__ does the exact same thing as well
  • most of yams already defines '_' in each module where it is needed

Closes #2098714.

authorRémi Cardona <remi.cardona@logilab.fr>
changesetd570c08e89ae
branchdefault
phasepublic
hiddenno
parent revision#740feff4c420 [reader] show schema file name in backtraces
child revision#4bd91c0919d0 [reader] Finally remove long deprecated bits
files modified by this revision
__init__.py
test/data/schema/Company.py
# HG changeset patch
# User Rémi Cardona <remi.cardona@logilab.fr>
# Date 1444727240 -7200
# Tue Oct 13 11:07:20 2015 +0200
# Node ID d570c08e89ae45ef7f4db934ff516f7a27b5a739
# Parent 740feff4c420e7fa8329e6c4f19546ebeadd8119
Stop injecting '_' into python's builtins

* having a library injecting builtins on import is a bad idea (hard to track)
* CubicWeb's __init__ does the exact same thing as well
* most of yams already defines '_' in each module where it is needed

Closes #2098714.

diff --git a/__init__.py b/__init__.py
@@ -23,19 +23,19 @@
1  from datetime import datetime, date, time
2 
3  from six import string_types, text_type
4  from six.moves import builtins
5 
6 -# XXX set _ builtin to unicode by default, should be overriden if necessary
7 -builtins._ = text_type
8 -
9  from logilab.common.date import strptime, strptime_time
10  from logilab.common import nullobject
11 
12  from yams.__pkginfo__ import version as __version__
13  from yams._exceptions import *
14 
15 +
16 +_ = text_type
17 +
18  MARKER = nullobject()
19 
20  BASE_TYPES = set(('String', 'Password', 'Bytes',
21                    'Int', 'BigInt', 'Float', 'Boolean', 'Decimal',
22                    'Date', 'Time', 'Datetime', 'TZTime', 'TZDatetime', 'Interval'
diff --git a/test/data/schema/Company.py b/test/data/schema/Company.py
@@ -13,13 +13,19 @@
23  # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
24  # details.
25  #
26  # You should have received a copy of the GNU Lesser General Public License along
27  # with yams. If not, see <http://www.gnu.org/licenses/>.
28 +from six import text_type
29 +
30  from yams.buildobjs import EntityType, RelationType, RelationDefinition, \
31       SubjectRelation, String
32 
33 +
34 +_ = text_type
35 +
36 +
37  class Company(EntityType):
38      name = String()
39 
40  class Subcompany(Company):
41      __specializes_schema__ = True