File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change 10
10
# See the License for the specific language governing permissions and
11
11
# limitations under the License.
12
12
13
- import copy
14
13
import hashlib
15
14
import hmac
16
15
import os .path
@@ -1130,20 +1129,17 @@ def file_upload(request):
1130
1129
Ensure all License-File keys exist in the wheel
1131
1130
See https://peps.python.org/pep-0639/#add-license-file-field
1132
1131
"""
1133
- license_files = copy .deepcopy (meta .license_files )
1134
1132
with tarfile .open (temporary_filename , "r:gz" ) as tar :
1135
1133
# Already validated as a tarfile by _is_valid_dist_file above
1136
- member = tar .next ()
1137
- while member :
1138
- if member .name in license_files :
1139
- license_files .remove (member .name )
1140
- member = tar .next ()
1141
- if license_files != []:
1142
- raise _exc_with_message (
1143
- HTTPBadRequest ,
1144
- f"License-File { license_files [0 ]} does not exist in "
1145
- f"distribution file { filename } " ,
1146
- )
1134
+ for license_file in meta .license_files :
1135
+ try :
1136
+ tar .getmember (license_file )
1137
+ except KeyError :
1138
+ raise _exc_with_message (
1139
+ HTTPBadRequest ,
1140
+ f"License-File { license_file } does not exist in "
1141
+ f"distribution file { filename } " ,
1142
+ )
1147
1143
1148
1144
# Check that if it's a binary wheel, it's on a supported platform
1149
1145
if filename .endswith (".whl" ):
You can’t perform that action at this time.
0 commit comments