Skip to content

Commit

Permalink
Merge pull request #59 from package-url/57-python2
Browse files Browse the repository at this point in the history
Fix Python 2 compatibility issue #57
  • Loading branch information
pombredanne authored Feb 2, 2021
2 parents c3e72c2 + 65f96fd commit 291e11b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

0.9.4 (2021-02-02)
------------------

- Fix Python 2 compatibility issue #57

0.9.3 (2020-10-06)
------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name='packageurl-python',
version='0.9.3',
version='0.9.4',
license='MIT',
description='A "purl" aka. Package URL parser and builder',
long_description='Python library to parse and build "purl" aka. Package URLs. '
Expand Down
5 changes: 3 additions & 2 deletions src/packageurl/contrib/django/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ def purl_to_lookups(purl):
Return a lookups dict built from the provided `purl` string.
Those lookups can be used as QuerySet filters.
"""
normalized_purl = f'pkg:{purl}' if not purl.startswith('pkg:') else purl
if not purl.startswith('pkg:'):
purl = 'pkg:' + purl

try:
package_url = PackageURL.from_string(normalized_purl)
package_url = PackageURL.from_string(purl)
except ValueError:
return # Not a valid PackageURL

Expand Down

0 comments on commit 291e11b

Please sign in to comment.