Armin Rigo avatar Armin Rigo committed 2c31a39

Add an error message on translating locals() which points people to the
right direction, after a discussion on #pypy where people complained
about doing something more automatically.

Comments (0)

Files changed (1)

rpython/flowspace/specialcase.py

 def sc_we_are_translated(space, we_are_translated, args):
     return Constant(True)
 
+def sc_locals(space, locals, args):
+    raise Exception(
+        "A function calling locals() is not RPython.  "
+        "Note that if you're translating code outside the PyPy "
+        "repository, a likely cause is that py.test's --assert=rewrite "
+        "mode is getting in the way.  You should copy the file "
+        "pytest.ini from the root of the PyPy repository into your "
+        "own project.")
+
 SPECIAL_CASES = {__import__: sc_import, r_uint: sc_r_uint,
-        we_are_translated: sc_we_are_translated}
+        we_are_translated: sc_we_are_translated,
+        locals: sc_locals}
 for fn in OperationName:
     SPECIAL_CASES[fn] = sc_operator
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.