Change in osmocom-bb[master]: trx_toolkit: make codec.py work with EOL Python 3.5

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Thu Apr 8 01:22:25 UTC 2021


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/23677 )


Change subject: trx_toolkit: make codec.py work with EOL Python 3.5
......................................................................

trx_toolkit: make codec.py work with EOL Python 3.5

Our build system is based on Debian 9 and EOL Python 3.5, so we have
to maintain backwards compatibility (sigh).  Some type hints moved
to comments, some had to be commented out completely.  Hopefully,
we can 'un-vandalize' the code by reverting this change once there
will be no requirement to support EOL stuff.

Change-Id: I7211cfbb7549b6e700aa3dd44464ff762fd51185
Related: OS#4006, SYS#4895
---
M src/target/trx_toolkit/codec.py
1 file changed, 12 insertions(+), 12 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/77/23677/1

diff --git a/src/target/trx_toolkit/codec.py b/src/target/trx_toolkit/codec.py
index 7a42c9b..9387592 100644
--- a/src/target/trx_toolkit/codec.py
+++ b/src/target/trx_toolkit/codec.py
@@ -55,17 +55,17 @@
 	''' Base class representing one field in a Message. '''
 
 	# Default length (0 means the whole buffer)
-	DEF_LEN: int = 0
+	DEF_LEN = 0 # type: int
 
 	# Default parameters
-	DEF_PARAMS: dict = { }
+	DEF_PARAMS = { } # type: dict
 
 	# Presence of a field during decoding and encoding
-	get_pres: Callable[[dict], bool]
+	## get_pres: Callable[[dict], bool]
 	# Length of a field for self.from_bytes()
-	get_len: Callable[[dict, bytes], int]
+	## get_len: Callable[[dict, bytes], int]
 	# Value of a field for self.to_bytes()
-	get_val: Callable[[dict], Any]
+	## get_val: Callable[[dict], Any]
 
 	def __init__(self, name: str, **kw) -> None:
 		self.name = name
@@ -201,7 +201,7 @@
 	}
 
 	# To be defined by derived types
-	STRUCT: Tuple['BitField', ...] = ()
+	STRUCT = () # type: Tuple['BitField', ...]
 
 	def __init__(self, **kw) -> None:
 		Field.__init__(self, self.__class__.__name__, **kw)
@@ -248,8 +248,8 @@
 	''' One field in a BitFieldSet. '''
 
 	# Special fields for BitFieldSet
-	offset: int = 0
-	mask: int = 0
+	offset = 0 # type: int
+	mask = 0 # type: int
 
 	class Spare:
 		''' Spare filling in a BitFieldSet. '''
@@ -272,7 +272,7 @@
 		self.bl = bl
 
 		# (Optional) fixed value for encoding and decoding
-		self.val: Optional[int] = kw.get('val', None)
+		self.val = kw.get('val', None) # type: Optional[int]
 
 	def enc_val(self, vals: dict) -> int:
 		if self.val is None:
@@ -291,11 +291,11 @@
 class Envelope:
 	''' A group of related fields. '''
 
-	STRUCT: Tuple[Codec, ...] = ()
+	STRUCT = () # type: Tuple[Codec, ...]
 
 	def __init__(self, check_len: bool = True):
 		# TODO: ensure uniqueue field names in self.STRUCT
-		self.c: dict = { }
+		self.c = { } # type: dict
 		self.check_len = check_len
 
 	def __getitem__(self, key: str) -> Any:
@@ -368,7 +368,7 @@
 	''' A sequence of repeating elements (e.g. TLVs). '''
 
 	# The item of sequence
-	ITEM: Optional[Envelope] = None
+	ITEM = None # type: Optional[Envelope]
 
 	def __init__(self, **kw) -> None:
 		if (self.ITEM is None) and ('item' not in kw):

-- 
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/23677
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I7211cfbb7549b6e700aa3dd44464ff762fd51185
Gerrit-Change-Number: 23677
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210408/548dc8ec/attachment.htm>


More information about the gerrit-log mailing list