Skip to content

Commit

Permalink
Fixed pickle/unpickle bug; Bumped up version to 1.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Hadi authored and Hadi committed Jan 22, 2021
1 parent 87503e6 commit 0fdf2b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions pyasn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,28 @@ def __repr__(self):
return ret

# Persistence support, for use with pickle.dump(), pickle.load()
# todo: test persistence support. (also persist/reload _asnames and other members, if needed)
# todo: add a test also for persistence support
def __iter__(self):
for elt in self.radix:
yield elt

def __getstate__(self):
return [(elt.prefix, elt.asn) for elt in self]
d = self.__dict__.copy()
del d['radix']
s = ""
for elt in self:
s += "{}\t{}\n".format(elt.prefix, elt.asn)
d["ipasn_str"] = s
return d

def __setstate__(self, state):
for prefix, asn in state:
node = self.radix.add(prefix)
node.asn = asn
ipasn_str = state['ipasn_str']
del state['ipasn_str']
self.__dict__.update(state)
self.radix = Radix()
records = self.radix.load_ipasndb("", ipasn_str)
assert records == self._records # sanity

def __reduce__(self):
return Radix, (), self.__getstate__()

@staticmethod
def convert_32bit_to_asdot_asn_format(asn): # FIXME: simplify to 'convert_32bit_asn_to_asdot'
Expand Down
2 changes: 1 addition & 1 deletion pyasn/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.6.1'
__version__ = '1.6.2'

3 comments on commit 0fdf2b5

@sebix
Copy link
Contributor

@sebix sebix commented on 0fdf2b5 Jan 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this release intended to be released (on pypi) or only for testing?

@hadiasghari
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the new code works well, on pypi at some point. Do you have any thoughts on that?

@sebix
Copy link
Contributor

@sebix sebix commented on 0fdf2b5 Jan 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could do a pre-release on pypi (and on github as well if needed) using a non-digit specifier in the version number. those release can be installed by pip install --pre ..., but won't be installed by a normal pip install. That way, users can simply test a release, without the danger of unintended behavior in production systems.

See https://www.python.org/dev/peps/pep-0440/#pre-releases and https://www.python.org/dev/peps/pep-0440/#pre-release-spelling
So this version's number could be 1.6.2alpha1 or similar.

Please sign in to comment.