Skip to content

Commit

Permalink
Fall back to glob.glob() on Python 2.4
Browse files Browse the repository at this point in the history
glob.iglob() was introduced with Python 2.5, but pyinotify claims
compatibility with Python 2.4. Here, we fall back to glob.glob() if iglob()
isn't available.
  • Loading branch information
jdswinbank committed Nov 19, 2013
1 parent b828a12 commit 9905931
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions python2/pyinotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,19 @@ def __init__(self, version):
import time
import re
import asyncore
import glob
import subprocess

try:
from functools import reduce
except ImportError:
pass # Will fail on Python 2.4 which has reduce() builtin anyway.

try:
from glob import iglob as glob
except ImportError:
# Python 2.4 does not have glob.iglob().
from glob import glob as glob

try:
import ctypes
import ctypes.util
Expand Down Expand Up @@ -1830,7 +1835,7 @@ def __add_watch(self, path, mask, proc_fun, auto_add, exclude_filter):

def __glob(self, path, do_glob):
if do_glob:
return glob.iglob(path)
return glob(path)
else:
return [path]

Expand Down

0 comments on commit 9905931

Please sign in to comment.