Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pyasn1/compat/integer.py: 17%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

6 statements  

1# 

2# This file is part of pyasn1 software. 

3# 

4# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com> 

5# License: https://pyasn1.readthedocs.io/en/latest/license.html 

6# 

7def to_bytes(value, signed=False, length=0): 

8 length = max(value.bit_length(), length) 

9 

10 if signed and length % 8 == 0: 

11 length += 1 

12 

13 return value.to_bytes(length // 8 + (length % 8 and 1 or 0), 'big', signed=signed)