Skip to content

Commit 9baee62

Browse files
committed
Fix "panic: runtime error: invalid memory address or nil pointer dereference" (bazel-contrib#1871)
1 parent d3cec48 commit 9baee62

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

gazelle/python/configure.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ func (py *Configurer) Configure(c *config.Config, rel string, f *rule.File) {
9090

9191
configs := c.Exts[languageName].(pythonconfig.Configs)
9292

93-
config, exists := configs[rel]
93+
config, exists := configs[filepath.FromSlash(rel)]
9494
if !exists {
9595
parent := configs.ParentForPackage(rel)
9696
config = parent.NewChild()
97-
configs[rel] = config
97+
configs[filepath.FromSlash(rel)] = config
9898
}
9999

100100
if f == nil {

gazelle/python/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func matchesAnyGlob(s string, globs []string) bool {
7070
// in depth-first post-order.
7171
func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateResult {
7272
cfgs := args.Config.Exts[languageName].(pythonconfig.Configs)
73-
cfg := cfgs[args.Rel]
73+
cfg := cfgs[filepath.FromSlash(args.Rel)]
7474

7575
if !cfg.ExtensionEnabled() {
7676
return language.GenerateResult{}

gazelle/python/resolve.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (*Resolver) Name() string { return languageName }
5656
// returned, including an empty slice, the rule will be indexed.
5757
func (py *Resolver) Imports(c *config.Config, r *rule.Rule, f *rule.File) []resolve.ImportSpec {
5858
cfgs := c.Exts[languageName].(pythonconfig.Configs)
59-
cfg := cfgs[f.Pkg]
59+
cfg := cfgs[filepath.FromSlash(f.Pkg)]
6060
srcs := r.AttrStrings("srcs")
6161
provides := make([]resolve.ImportSpec, 0, len(srcs)+1)
6262
for _, src := range srcs {
@@ -143,7 +143,7 @@ func (py *Resolver) Resolve(
143143
deps := treeset.NewWith(godsutils.StringComparator)
144144
if modulesRaw != nil {
145145
cfgs := c.Exts[languageName].(pythonconfig.Configs)
146-
cfg := cfgs[from.Pkg]
146+
cfg := cfgs[filepath.FromSlash(from.Pkg)]
147147
pythonProjectRoot := cfg.PythonProjectRoot()
148148
modules := modulesRaw.(*treeset.Set)
149149
it := modules.Iterator()

0 commit comments

Comments
 (0)