Skip to content

Commit 3471c0c

Browse files
author
dzsekijo
committed
check if fuse_python_api value is suitable (not just the presence of a value!)
1 parent 2f204ba commit 3471c0c

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

fuse.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ def get_compat_0_1():
7575
# deprecated way of API specification
7676
compat_0_1 = __getenv__('FUSE_PYTHON_COMPAT', '^(0.1|ALL)$', lambda x: True)
7777

78+
fuse_python_api = get_fuse_python_api()
79+
7880
##########
7981
###
8082
### Parsing for FUSE.
@@ -653,11 +655,11 @@ def __init__(self, *args, **kw):
653655
unchanged.
654656
655657
The parser class is `FuseOptParse` unless you specify one using the
656-
``parser_class`` keyword. (See `FuseOptPatse documentation for
658+
``parser_class`` keyword. (See `FuseOptParse` documentation for
657659
available options.)
658660
"""
659661

660-
if not fuse_python_api and not compat_0_1:
662+
if not fuse_python_api:
661663
raise RuntimeError, __name__ + """.fuse_python_api not defined.
662664
663665
! Please define """ + __name__ + """.fuse_python_api internally (eg.
@@ -673,6 +675,21 @@ def __init__(self, *args, **kw):
673675
! If you are actually developing a filesystem, probably (1) is the way to go.
674676
! If you are using a filesystem written before 2007 Q2, probably (2) is what
675677
! you want."
678+
"""
679+
680+
def malformed():
681+
raise RuntimeError, \
682+
"malformatted fuse_python_api value " + `fuse_python_api`
683+
if not isinstance(fuse_python_api, tuple):
684+
malformed()
685+
for i in fuse_python_api:
686+
if not isinstance(i, int) or i < 0:
687+
malformed()
688+
689+
if fuse_python_api > FUSE_PYTHON_API_VERSION:
690+
raise RuntimeError, """
691+
! You require FUSE-Python API version """ + `fuse_python_api` + """.
692+
! However, the latest available is """ + `FUSE_PYTHON_API_VERSION` + """.
676693
"""
677694

678695
self.fuse_args = \

0 commit comments

Comments
 (0)