This file is indexed.

/usr/lib/python3/dist-packages/postgresql/test/test_bytea_codec.py is in python3-postgresql 1.1.0-2build2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
##
# .test.test_bytea_codec
##
import unittest
import struct
from ..encodings import bytea

byte = struct.Struct('B')

class test_bytea_codec(unittest.TestCase):
	def testDecoding(self):
		for x in range(255):
			c = byte.pack(x)
			b = c.decode('bytea')
			# normalize into octal escapes
			if c == b'\\' and b == "\\\\":
				b = "\\" + oct(b'\\'[0])[2:]
			elif not b.startswith("\\"):
				b = "\\" + oct(ord(b))[2:]
			if int(b[1:], 8) != x:
				self.fail(
					"bytea encoding failed at %d; encoded %r to %r" %(x, c, b,)
				)

	def testEncoding(self):
		self.assertEqual('bytea'.encode('bytea'), b'bytea')
		self.assertEqual('\\\\'.encode('bytea'), b'\\')
		self.assertRaises(ValueError, '\\'.encode, 'bytea')
		self.assertRaises(ValueError, 'foo\\'.encode, 'bytea')
		self.assertRaises(ValueError, r'foo\0'.encode, 'bytea')
		self.assertRaises(ValueError, r'foo\00'.encode, 'bytea')
		self.assertRaises(ValueError, r'\f'.encode, 'bytea')
		self.assertRaises(ValueError, r'\800'.encode, 'bytea')
		self.assertRaises(ValueError, r'\7f0'.encode, 'bytea')
		for x in range(255):
			seq = ('\\' + oct(x)[2:].lstrip('0').rjust(3, '0'))
			dx = ord(seq.encode('bytea'))
			if dx != x:
				self.fail(
					"generated sequence failed to map back; current is %d, " \
					"rendered %r, transformed to %d" %(x, seq, dx)
				)

if __name__ == '__main__':
	unittest.main()