diff options
author | Guido van Rossum <guido@python.org> | 1997-10-08 15:22:32 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-10-08 15:22:32 (GMT) |
commit | 45ac47c0b2798cc3a29cf5111694aba5e9347e08 (patch) | |
tree | b7ea3bec9aeb66f0a482c3914893c256ec3bc9ca | |
parent | 845037018d9255b4cdb567d977dfaeae4b47b5e0 (diff) | |
download | cpython-45ac47c0b2798cc3a29cf5111694aba5e9347e08.zip cpython-45ac47c0b2798cc3a29cf5111694aba5e9347e08.tar.gz cpython-45ac47c0b2798cc3a29cf5111694aba5e9347e08.tar.bz2 |
Allow open file as parameter (must be seekable) (Jack)
-rw-r--r-- | Lib/imghdr.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/imghdr.py b/Lib/imghdr.py index c320594..422471f 100644 --- a/Lib/imghdr.py +++ b/Lib/imghdr.py @@ -2,13 +2,19 @@ #-------------------------# -# Recognize sound headers # +# Recognize image headers # #-------------------------# -def what(filename, h=None): +def what(file, h=None): if h is None: - f = open(filename, 'r') - h = f.read(32) + if type(file) == type(''): + f = open(file, 'rb') + h = f.read(32) + else: + location = file.tell() + h = file.read(32) + file.seek(location) + f = None else: f = None try: |