# HG changeset patch # User RĂ©mi Cardona # Date 1441987296 -7200 # Node ID 79ff784cd8af07a436f8c4bc26b8aa432c79d64b # Parent 6465a3e9d7ac2689a16c2071b8e173cf01812461 [py3k] introduce cubicweb._ (related to #7589459) The end goal is to stop relying on '_' being in the builtin scope. In the mean time, deprecate the builtin '_' so that consumers are warned. diff -r 6465a3e9d7ac -r 79ff784cd8af __init__.py --- a/__init__.py Fri Sep 18 18:04:05 2015 +0200 +++ b/__init__.py Fri Sep 11 18:01:36 2015 +0200 @@ -28,12 +28,8 @@ module='.*pygments') -import __builtin__ -from six import PY2, binary_type -# '_' is available in builtins to mark internationalized string but should -# not be used to do the actual translation -if not hasattr(__builtin__, '_'): - __builtin__._ = unicode +from six import PY2, binary_type, text_type +from six.moves import builtins CW_SOFTWARE_ROOT = __path__[0] @@ -58,6 +54,14 @@ from cubicweb._exceptions import * from logilab.common.registry import ObjectNotFound, NoSelectableObject, RegistryNotFound + +# '_' is available to mark internationalized string but should not be used to +# do the actual translation +_ = text_type +if not hasattr(builtins, '_'): + builtins._ = deprecated("[3.22] Use 'from cubicweb import _'")(_) + + # convert eid to the right type, raise ValueError if it's not a valid eid @deprecated('[3.17] typed_eid() was removed. replace it with int() when needed.') def typed_eid(eid):