jsonpointer 3.6__tar.gz → 3.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {jsonpointer-3.6/jsonpointer.egg-info → jsonpointer-3.7}/PKG-INFO +1 -1
- {jsonpointer-3.6 → jsonpointer-3.7}/bin/jsonpointer +2 -0
- {jsonpointer-3.6 → jsonpointer-3.7/jsonpointer.egg-info}/PKG-INFO +1 -1
- {jsonpointer-3.6 → jsonpointer-3.7}/jsonpointer.py +1 -1
- {jsonpointer-3.6 → jsonpointer-3.7}/setup.cfg +1 -0
- {jsonpointer-3.6 → jsonpointer-3.7}/tests.py +37 -0
- {jsonpointer-3.6 → jsonpointer-3.7}/AUTHORS +0 -0
- {jsonpointer-3.6 → jsonpointer-3.7}/LICENSE.txt +0 -0
- {jsonpointer-3.6 → jsonpointer-3.7}/MANIFEST.in +0 -0
- {jsonpointer-3.6 → jsonpointer-3.7}/README.md +0 -0
- {jsonpointer-3.6 → jsonpointer-3.7}/jsonpointer.egg-info/SOURCES.txt +0 -0
- {jsonpointer-3.6 → jsonpointer-3.7}/jsonpointer.egg-info/dependency_links.txt +0 -0
- {jsonpointer-3.6 → jsonpointer-3.7}/jsonpointer.egg-info/top_level.txt +0 -0
- {jsonpointer-3.6 → jsonpointer-3.7}/setup.py +0 -0
|
@@ -60,6 +60,8 @@ def parse_pointer(args):
|
|
|
60
60
|
# 2026-10-11: Trim file line endings without changing member names.
|
|
61
61
|
try:
|
|
62
62
|
ptr = args.pointer_file.read().rstrip("\r\n")
|
|
63
|
+
except UnicodeDecodeError as e:
|
|
64
|
+
parser.error('could not decode pointer file: %s' % e)
|
|
63
65
|
finally:
|
|
64
66
|
if args.pointer_file is not sys.stdin:
|
|
65
67
|
args.pointer_file.close()
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
# Will be parsed by setup.py to determine package metadata
|
|
34
34
|
__author__ = 'Stefan Kögl <stefan@skoegl.net>'
|
|
35
|
-
__version__ = '3.
|
|
35
|
+
__version__ = '3.7'
|
|
36
36
|
__website__ = 'https://github.com/stefankoegl/python-json-pointer'
|
|
37
37
|
__license__ = 'Modified BSD License'
|
|
38
38
|
|
|
@@ -622,6 +622,30 @@ class CommandLineTests(unittest.TestCase):
|
|
|
622
622
|
os.path.join(self.dir, 'a.json'))
|
|
623
623
|
self.assertEqual(caught.exception.code, 2)
|
|
624
624
|
|
|
625
|
+
def test_closes_pointer_file_after_decoding_error(self):
|
|
626
|
+
path = os.path.join(self.dir, 'invalid-pointer.txt')
|
|
627
|
+
with open(path, 'wb') as f:
|
|
628
|
+
f.write(b'/\xff')
|
|
629
|
+
with self.assertRaises(SystemExit) as caught:
|
|
630
|
+
self._run_with_retained_files(
|
|
631
|
+
'-f', path, os.path.join(self.dir, 'a.json'))
|
|
632
|
+
self.assertEqual(caught.exception.code, 2)
|
|
633
|
+
|
|
634
|
+
def test_pointer_decoding_error_keeps_stdin_open(self):
|
|
635
|
+
cli = runpy.run_path(self.SCRIPT)
|
|
636
|
+
stdin = io.TextIOWrapper(io.BytesIO(b'/\xff'), encoding='utf-8')
|
|
637
|
+
self.addCleanup(stdin.close)
|
|
638
|
+
args = [self.SCRIPT, '-f', '-', os.path.join(self.dir, 'a.json')]
|
|
639
|
+
with mock.patch.object(sys, 'argv', args), \
|
|
640
|
+
mock.patch.object(sys, 'stdin', stdin), \
|
|
641
|
+
mock.patch('builtins.open') as open_file, \
|
|
642
|
+
redirect_stderr(io.StringIO()):
|
|
643
|
+
with self.assertRaises(SystemExit) as caught:
|
|
644
|
+
cli['resolve_files']()
|
|
645
|
+
self.assertEqual(caught.exception.code, 2)
|
|
646
|
+
open_file.assert_not_called()
|
|
647
|
+
self.assertFalse(stdin.closed)
|
|
648
|
+
|
|
625
649
|
def test_closes_inputs_after_json_errors(self):
|
|
626
650
|
self._write('invalid.json', '{"a": }')
|
|
627
651
|
with self.assertRaises(json.JSONDecodeError):
|
|
@@ -711,6 +735,19 @@ class CommandLineTests(unittest.TestCase):
|
|
|
711
735
|
self.assertEqual(proc.returncode, 2)
|
|
712
736
|
self.assertIn("invalid JSON pointer 'a'", proc.stderr)
|
|
713
737
|
|
|
738
|
+
def test_invalid_pointer_file_encoding(self):
|
|
739
|
+
with open(os.path.join(self.dir, 'bad.txt'), 'wb') as f:
|
|
740
|
+
f.write(b'/\xff')
|
|
741
|
+
for options in ([], ['--continue-on-error']):
|
|
742
|
+
with self.subTest(options=options):
|
|
743
|
+
proc = self._run(*options, '-f', 'bad.txt',
|
|
744
|
+
'a.json', 'b.json')
|
|
745
|
+
self.assertEqual(proc.returncode, 2, proc.stderr)
|
|
746
|
+
self.assertEqual(proc.stdout, '')
|
|
747
|
+
self.assertIn('could not decode pointer file:', proc.stderr)
|
|
748
|
+
self.assertIn('decode', proc.stderr)
|
|
749
|
+
self.assertNotIn('Traceback', proc.stderr)
|
|
750
|
+
|
|
714
751
|
def test_empty_pointer(self):
|
|
715
752
|
proc = self._run('', 'a.json')
|
|
716
753
|
self.assertEqual(proc.returncode, 0, proc.stderr)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|