Skip to content

Commit 3a59e3e

Browse files
committed
Fix JSONDecodeError import in functions
1 parent 4ee330d commit 3a59e3e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.pyc
33
*.swp
44
*.egg
5+
.idea/*
56
env/
67
.venv/
78
.eggs/
@@ -16,4 +17,4 @@ __pycache__/
1617
.coverage
1718
htmlcov/
1819
Pipfile*
19-
hold
20+
hold

src/falconpy/_util/_functions.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@
4141
from warnings import warn
4242
from json import loads
4343
try:
44-
from simplejson import JSONDecodeError
45-
except (ImportError, ModuleNotFoundError): # Support import as a module
46-
from json.decoder import JSONDecodeError
44+
from simplejson import JSONDecodeError as SimplejsonJSONDecodeError
45+
except (ImportError, ModuleNotFoundError):
46+
SimplejsonJSONDecodeError = None# Support import as a module
47+
48+
from json.decoder import JSONDecodeError as StdJSONDecodeError
49+
#create a tuple of all possible JSONDecodeError types for exception handling
50+
JSONDecodeError = (SimplejsonJSONDecodeError, StdJSONDecodeError) if SimplejsonJSONDecodeError else (StdJSONDecodeError,)
4751
from typing import Dict, Any, Union, Optional, List, TYPE_CHECKING
4852
from copy import deepcopy
4953
from logging import Logger

0 commit comments

Comments
 (0)