[pypy-commit] pypy default: Add enforceargs to rpython.rlib.rpath functions
rlamy
noreply at buildbot.pypy.org
Wed Sep 10 04:08:14 CEST 2014
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch:
Changeset: r73413:5b5351812a83
Date: 2014-09-10 03:07 +0100
http://bitbucket.org/pypy/pypy/changeset/5b5351812a83/
Log: Add enforceargs to rpython.rlib.rpath functions
diff --git a/rpython/rlib/rpath.py b/rpython/rlib/rpath.py
--- a/rpython/rlib/rpath.py
+++ b/rpython/rlib/rpath.py
@@ -4,6 +4,7 @@
import os, stat
from rpython.rlib import rposix
+from rpython.rlib.objectmodel import enforceargs
# ____________________________________________________________
@@ -11,6 +12,7 @@
# Generic implementations in RPython for both POSIX and NT
#
+ at enforceargs(str)
def risdir(s):
"""Return true if the pathname refers to an existing directory."""
try:
@@ -25,10 +27,12 @@
# POSIX-only implementations
#
+ at enforceargs(str)
def _posix_risabs(s):
"""Test whether a path is absolute"""
return s.startswith('/')
+ at enforceargs(str)
def _posix_rnormpath(path):
"""Normalize path, eliminating double slashes, etc."""
slash, dot = '/', '.'
@@ -56,6 +60,7 @@
path = slash*initial_slashes + path
return path or dot
+ at enforceargs(str)
def _posix_rabspath(path):
"""Return an absolute, **non-normalized** path.
**This version does not let exceptions propagate.**"""
@@ -67,6 +72,7 @@
except OSError:
return path
+ at enforceargs(str, str)
def _posix_rjoin(a, b):
"""Join two pathname components, inserting '/' as needed.
If the second component is an absolute path, the first one
@@ -87,11 +93,13 @@
# NT-only implementations
#
+ at enforceargs(str)
def _nt_risabs(s):
"""Test whether a path is absolute"""
s = _nt_rsplitdrive(s)[1]
return s.startswith('/') or s.startswith('\\')
+ at enforceargs(str)
def _nt_rnormpath(path):
"""Normalize path, eliminating double slashes, etc."""
backslash, dot = '\\', '.'
@@ -142,6 +150,7 @@
comps.append(dot)
return prefix + backslash.join(comps)
+ at enforceargs(str)
def _nt_rabspath(path):
try:
if path == '':
@@ -150,6 +159,7 @@
except OSError:
return path
+ at enforceargs(str)
def _nt_rsplitdrive(p):
"""Split a pathname into drive/UNC sharepoint and relative path
specifiers.
@@ -177,6 +187,7 @@
return p[:2], p[2:]
return '', p
+ at enforceargs(str, str)
def _nt_rjoin(path, p):
"""Join two or more pathname components, inserting "\\" as needed."""
result_drive, result_path = _nt_rsplitdrive(path)
More information about the pypy-commit
mailing list