summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-12 21:19:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-12 21:19:09 +0000
commita6926104f3d4de1083c7e77d572291625c3619a1 (patch)
treeaaf06239363d4760fe8442d44a1fbc00c9bc7412
parentAdding upstream version 2.1.0. (diff)
downloadidentify-a6926104f3d4de1083c7e77d572291625c3619a1.tar.xz
identify-a6926104f3d4de1083c7e77d572291625c3619a1.zip
Adding upstream version 2.1.2.upstream/2.1.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--identify/extensions.py1
-rw-r--r--identify/identify.py11
-rw-r--r--setup.cfg2
-rw-r--r--tests/identify_test.py12
4 files changed, 23 insertions, 3 deletions
diff --git a/identify/extensions.py b/identify/extensions.py
index 778b695..48864fc 100644
--- a/identify/extensions.py
+++ b/identify/extensions.py
@@ -183,6 +183,7 @@ EXTENSIONS = {
'txsprofile': {'text', 'ini', 'txsprofile'},
'txt': {'text', 'plain-text'},
'v': {'text', 'verilog'},
+ 'vb': {'text', 'vb'},
'vbproj': {'text', 'xml', 'vbproj'},
'vcxproj': {'text', 'xml', 'vcxproj'},
'vdx': {'text', 'vdx'},
diff --git a/identify/identify.py b/identify/identify.py
index 51c1288..52d2c2d 100644
--- a/identify/identify.py
+++ b/identify/identify.py
@@ -1,3 +1,4 @@
+import errno
import os.path
import re
import shlex
@@ -205,8 +206,14 @@ def parse_shebang_from_file(path: str) -> Tuple[str, ...]:
if not os.access(path, os.X_OK):
return ()
- with open(path, 'rb') as f:
- return parse_shebang(f)
+ try:
+ with open(path, 'rb') as f:
+ return parse_shebang(f)
+ except OSError as e:
+ if e.errno == errno.EINVAL:
+ return ()
+ else:
+ raise
COPYRIGHT_RE = re.compile(r'^\s*(Copyright|\(C\)) .*$', re.I | re.MULTILINE)
diff --git a/setup.cfg b/setup.cfg
index 4aafd64..ae7dbb4 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = identify
-version = 2.1.0
+version = 2.1.2
description = File identification library for Python
long_description = file: README.md
long_description_content_type = text/markdown
diff --git a/tests/identify_test.py b/tests/identify_test.py
index 8cc5856..f881f0b 100644
--- a/tests/identify_test.py
+++ b/tests/identify_test.py
@@ -1,8 +1,11 @@
+import builtins
+import errno
import io
import os
import socket
import stat
from tempfile import TemporaryDirectory
+from unittest import mock
import pytest
@@ -330,6 +333,15 @@ def test_parse_shebang_from_file_simple(tmpdir):
assert identify.parse_shebang_from_file(x.strpath) == ('python',)
+def test_parse_shebang_open_raises_einval(tmpdir):
+ x = tmpdir.join('f')
+ x.write('#!/usr/bin/env not-expected\n')
+ make_executable(x)
+ error = OSError(errno.EINVAL, f'Invalid argument {x}')
+ with mock.patch.object(builtins, 'open', side_effect=error):
+ assert identify.parse_shebang_from_file(x.strpath) == ()
+
+
def make_executable(filename):
original_mode = os.stat(filename).st_mode
os.chmod(