[pypy-commit] pypy py3.5: Found out how to have an argument called "in" without too much troubles

arigo pypy.commits at gmail.com
Sun Mar 5 07:03:21 EST 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r90566:41d8c8e03b7e
Date: 2017-03-05 13:02 +0100
http://bitbucket.org/pypy/pypy/changeset/41d8c8e03b7e/

Log:	Found out how to have an argument called "in" without too much
	troubles

diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -1,3 +1,4 @@
+import sys
 from pypy.interpreter.mixedmodule import MixedModule
 from rpython.rlib import rposix
 from rpython.rlib import rdynload
diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -2347,14 +2347,11 @@
     except OSError as e:
         raise wrap_oserror(space, e, eintr_retry=False)
 
- at unwrap_spec(out=c_int, in_=c_int, count=int)
-def sendfile(space, out, in_, w_offset, count):
-    # NB. argument name difference with CPython: "in" versus "in_".
-    # According to a comment in posixmodule.c, the authors are aware that
-    # "in" is a Python keyword and so the argument name is bogus, but don't
-    # do anything about it anyway.  PyPy calls it "in_" instead because
-    # "in" would require all sorts of special cases.  I hope nobody
-    # relies on the strange name of CPython.
+ at unwrap_spec(out=c_int, count=int)
+def sendfile(space, out, w_in, w_offset, count):
+    # why is an argument called "in"???  that doesn't make sense (it is
+    # a reserved word), but that's what CPython does
+    in_ = space.c_int_w(w_in)
 
     # XXX only supports the common arguments for now (BSD takes more).
     # Until that is fixed, we only expose sendfile() on linux.


More information about the pypy-commit mailing list