[pypy-commit] pypy app_main-refactor: make sure that getenv returns a no_nul string
antocuni
noreply at buildbot.pypy.org
Sat Jun 9 14:01:57 CEST 2012
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: app_main-refactor
Changeset: r55534:3d12fb0d4ab9
Date: 2012-06-09 12:24 +0200
http://bitbucket.org/pypy/pypy/changeset/3d12fb0d4ab9/
Log: make sure that getenv returns a no_nul string
diff --git a/pypy/annotation/test/test_annrpython.py b/pypy/annotation/test/test_annrpython.py
--- a/pypy/annotation/test/test_annrpython.py
+++ b/pypy/annotation/test/test_annrpython.py
@@ -3789,6 +3789,16 @@
assert isinstance(s, annmodel.SomeString)
assert s.no_nul
+ def test_os_getenv(self):
+ import os
+ def fn():
+ return os.environ.get('PATH')
+ a = self.RPythonAnnotator()
+ s = a.build_types(fn, [])
+ assert isinstance(s, annmodel.SomeString)
+ assert s.no_nul
+
+
def g(n):
return [0,1,2,n]
diff --git a/pypy/rpython/module/ll_os_environ.py b/pypy/rpython/module/ll_os_environ.py
--- a/pypy/rpython/module/ll_os_environ.py
+++ b/pypy/rpython/module/ll_os_environ.py
@@ -67,7 +67,7 @@
rffi.free_charp(l_name)
return result
-register_external(r_getenv, [str0], annmodel.SomeString(can_be_None=True),
+register_external(r_getenv, [str0], annmodel.SomeString(can_be_None=True, no_nul=True),
export_name='ll_os.ll_os_getenv',
llimpl=getenv_llimpl)
More information about the pypy-commit
mailing list