|
28 | 28 |
|
29 | 29 | from functools import partial
|
30 | 30 | from mimetypes import guess_type
|
31 |
| -import sys |
32 | 31 |
|
33 | 32 | from flask import abort, current_app, request
|
34 | 33 | from gridfs import GridFS, NoFile
|
|
40 | 39 | from flask_pymongo.wrappers import MongoClient
|
41 | 40 |
|
42 | 41 |
|
43 |
| -PY2 = sys.version_info[0] == 2 |
44 |
| - |
45 |
| -# Python 3 compatibility |
46 |
| -if PY2: |
47 |
| - text_type = (str, unicode) |
48 |
| - num_type = (int, long) |
49 |
| -else: |
50 |
| - text_type = str |
51 |
| - num_type = int |
52 |
| - |
53 |
| - |
54 | 42 | DESCENDING = pymongo.DESCENDING
|
55 | 43 | """Descending sort order."""
|
56 | 44 |
|
@@ -151,11 +139,11 @@ def get_upload(filename):
|
151 | 139 | :param int cache_for: number of seconds that browsers should be
|
152 | 140 | instructed to cache responses
|
153 | 141 | """
|
154 |
| - if not isinstance(base, text_type): |
| 142 | + if not isinstance(base, str): |
155 | 143 | raise TypeError("'base' must be string or unicode")
|
156 |
| - if not isinstance(version, num_type): |
| 144 | + if not isinstance(version, int): |
157 | 145 | raise TypeError("'version' must be an integer")
|
158 |
| - if not isinstance(cache_for, num_type): |
| 146 | + if not isinstance(cache_for, int): |
159 | 147 | raise TypeError("'cache_for' must be an integer")
|
160 | 148 |
|
161 | 149 | storage = GridFS(self.db, base)
|
@@ -200,7 +188,7 @@ def save_upload(filename):
|
200 | 188 | :param kwargs: extra attributes to be stored in the file's document,
|
201 | 189 | passed directly to :meth:`gridfs.GridFS.put`
|
202 | 190 | """
|
203 |
| - if not isinstance(base, text_type): |
| 191 | + if not isinstance(base, str): |
204 | 192 | raise TypeError("'base' must be string or unicode")
|
205 | 193 | if not (hasattr(fileobj, "read") and callable(fileobj.read)):
|
206 | 194 | raise TypeError("'fileobj' must have read() method")
|
|
0 commit comments