Corrections based on test results.

This commit is contained in:
Matt Davis
2022-10-09 21:19:25 -04:00
parent d24c0a6882
commit 7177ca15fe
+19 -3
View File
@@ -10,8 +10,11 @@ import os
import re
import sys
import urllib.parse
from json.decoder import JSONDecodeError
from pathlib import Path
import click
from pipenv.cmdparse import Script
from pipenv.environment import Environment
from pipenv.environments import Setting, is_in_virtualenv, normalize_pipfile_path
@@ -758,7 +761,11 @@ class Project:
from .vendor.plette.lockfiles import PIPFILE_SPEC_CURRENT
if self.lockfile_exists:
sources = self.lockfile_content.get("_meta", {}).get("sources", [])
sources = (
self.load_lockfile(expand_env_vars=False)
.get("_meta", {})
.get("sources", [])
)
elif "source" in self.parsed_pipfile:
sources = [dict(source) for source in self.parsed_pipfile["source"]]
else:
@@ -992,8 +999,17 @@ class Project:
def load_lockfile(self, expand_env_vars=True):
lockfile_modified = False
with io.open(self.lockfile_location, encoding="utf-8") as lock:
j = json.load(lock)
self._lockfile_newlines = preferred_newlines(lock)
try:
j = json.load(lock)
self._lockfile_newlines = preferred_newlines(lock)
except JSONDecodeError:
click.secho(
"Pipfile.lock is corrupted; ignoring contents.",
fg="yellow",
bold=True,
err=True,
)
j = {}
if not j.get("_meta"):
with open(self.pipfile_location) as pf:
default_lockfile = plette.Lockfile.with_meta_from(