Author: Armin Rigo <ar...@tunes.org> Branch: py3.5 Changeset: r90066:e697cc164d5a Date: 2017-02-12 10:15 +0100 http://bitbucket.org/pypy/pypy/changeset/e697cc164d5a/
Log: Direct access to the interp-level fsencode/fsdecode, for tests diff --git a/pypy/interpreter/test/test_fsencode.py b/pypy/interpreter/test/test_fsencode.py --- a/pypy/interpreter/test/test_fsencode.py +++ b/pypy/interpreter/test/test_fsencode.py @@ -87,3 +87,17 @@ # ValueError directly, or return a wrapped bytes with the 0 # embedded---and then space.fsencode_w() should raise ValueError. space.raises_w(space.w_ValueError, space.fsencode_w, w_u) + + def test_interface_from___pypy__(self): + space = self.space + strs = [u"/home/bar/baz", u"c:\\"] + if self.special_char: + strs.append(self.special_char) + for st in strs: + w_st = space.newunicode(st) + w_enc = space.fsencode(w_st) + space.appexec([w_st, w_enc], """(u, s): + import __pypy__ + assert __pypy__.fsencode(u) == s + assert __pypy__.fsdecode(s) == u + """) diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py --- a/pypy/module/__pypy__/__init__.py +++ b/pypy/module/__pypy__/__init__.py @@ -91,6 +91,8 @@ 'normalize_exc' : 'interp_magic.normalize_exc', 'StdErrPrinter' : 'interp_stderrprinter.W_StdErrPrinter', 'stack_almost_full' : 'interp_magic.stack_almost_full', + 'fsencode' : 'interp_magic.fsencode', + 'fsdecode' : 'interp_magic.fsdecode', } submodules = { diff --git a/pypy/module/__pypy__/interp_magic.py b/pypy/module/__pypy__/interp_magic.py --- a/pypy/module/__pypy__/interp_magic.py +++ b/pypy/module/__pypy__/interp_magic.py @@ -180,3 +180,11 @@ def stack_almost_full(space): """Return True if the stack is more than 15/16th full.""" return space.wrap(rstack.stack_almost_full()) + +def fsencode(space, w_obj): + """Direct access to the interp-level fsencode()""" + return space.fsencode(w_obj) + +def fsdecode(space, w_obj): + """Direct access to the interp-level fsdecode()""" + return space.fsdecode(w_obj) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit