@@ -646,6 +646,8 @@ def _link_package_versions(self, link, search):
646646 try :
647647 support_this_python = check_requires_python (link .requires_python )
648648 except specifiers .InvalidSpecifier :
649+ logger .debug ("Package %s has an invalid Requires-Python entry: %s" ,
650+ link .filename , link .requires_python )
649651 support_this_python = True
650652
651653 if not support_this_python :
@@ -841,7 +843,8 @@ def links(self):
841843 url = self .clean_link (
842844 urllib_parse .urljoin (self .base_url , href )
843845 )
844- pyrequire = unescape (anchor .get ('data-requires-python' ))
846+ pyrequire = anchor .get ('data-requires-python' )
847+ pyrequire = unescape (pyrequire ) if pyrequire else None
845848 yield Link (url , self , requires_python = pyrequire )
846849
847850 _clean_re = re .compile (r'[^a-z0-9$&+,/:;=?@.#%_\\|-]' , re .I )
@@ -863,10 +866,11 @@ def __init__(self, url, comes_from=None, requires_python=None):
863866 url:
864867 url of the resource pointed to (href of the link)
865868 comes_from:
866- <Not sure>
869+ instance of HTMLPage where the link was found, or string.
867870 requires_python:
868871 String containing the `Requires-Python` metadata field, specified
869- in PEP 345.
872+ in PEP 345. This may be specified by a data-requires-python
873+ attribute in the HTML link tag, as described in PEP 503.
870874 """
871875
872876 # url can be a UNC windows share
@@ -875,10 +879,7 @@ def __init__(self, url, comes_from=None, requires_python=None):
875879
876880 self .url = url
877881 self .comes_from = comes_from
878- if not requires_python :
879- self .requires_python = None
880- else :
881- self .requires_python = requires_python
882+ self .requires_python = requires_python if requires_python else None
882883
883884 def __str__ (self ):
884885 if self .requires_python :
0 commit comments