Move imports outside _escape_bytes as suggested in review

This commit is contained in:
Bruno Oliveira 2015-09-30 17:02:19 -03:00
parent 6ae16eba36
commit c9480c5b8b
1 changed files with 3 additions and 2 deletions

View File

@ -1041,6 +1041,8 @@ class Metafunc(FuncargnamesCompatAttr):
if _PY3: if _PY3:
import codecs
def _escape_bytes(val): def _escape_bytes(val):
""" """
If val is pure ascii, returns it as a str(), otherwise escapes If val is pure ascii, returns it as a str(), otherwise escapes
@ -1055,7 +1057,6 @@ if _PY3:
""" """
if val: if val:
# source: http://goo.gl/bGsnwC # source: http://goo.gl/bGsnwC
import codecs
encoded_bytes, _ = codecs.escape_encode(val) encoded_bytes, _ = codecs.escape_encode(val)
return encoded_bytes.decode('ascii') return encoded_bytes.decode('ascii')
else: else:
@ -1064,7 +1065,7 @@ if _PY3:
else: else:
def _escape_bytes(val): def _escape_bytes(val):
""" """
In py2 bytes and str are the same, so return it unchanged if it In py2 bytes and str are the same type, so return it unchanged if it
is a full ascii string, otherwise escape it into its binary form. is a full ascii string, otherwise escape it into its binary form.
""" """
try: try: