Skip to content

Commit

Permalink
Fix "panic: runtime error: invalid memory address or nil pointer dere…
Browse files Browse the repository at this point in the history
…ference" (bazelbuild#1871)
  • Loading branch information
bartoszpop committed May 1, 2024
1 parent d3cec48 commit 9baee62
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gazelle/python/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ func (py *Configurer) Configure(c *config.Config, rel string, f *rule.File) {

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

config, exists := configs[rel]
config, exists := configs[filepath.FromSlash(rel)]
if !exists {
parent := configs.ParentForPackage(rel)
config = parent.NewChild()
configs[rel] = config
configs[filepath.FromSlash(rel)] = config
}

if f == nil {
Expand Down
2 changes: 1 addition & 1 deletion gazelle/python/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func matchesAnyGlob(s string, globs []string) bool {
// in depth-first post-order.
func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateResult {
cfgs := args.Config.Exts[languageName].(pythonconfig.Configs)
cfg := cfgs[args.Rel]
cfg := cfgs[filepath.FromSlash(args.Rel)]

if !cfg.ExtensionEnabled() {
return language.GenerateResult{}
Expand Down
4 changes: 2 additions & 2 deletions gazelle/python/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (*Resolver) Name() string { return languageName }
// returned, including an empty slice, the rule will be indexed.
func (py *Resolver) Imports(c *config.Config, r *rule.Rule, f *rule.File) []resolve.ImportSpec {
cfgs := c.Exts[languageName].(pythonconfig.Configs)
cfg := cfgs[f.Pkg]
cfg := cfgs[filepath.FromSlash(f.Pkg)]
srcs := r.AttrStrings("srcs")
provides := make([]resolve.ImportSpec, 0, len(srcs)+1)
for _, src := range srcs {
Expand Down Expand Up @@ -143,7 +143,7 @@ func (py *Resolver) Resolve(
deps := treeset.NewWith(godsutils.StringComparator)
if modulesRaw != nil {
cfgs := c.Exts[languageName].(pythonconfig.Configs)
cfg := cfgs[from.Pkg]
cfg := cfgs[filepath.FromSlash(from.Pkg)]
pythonProjectRoot := cfg.PythonProjectRoot()
modules := modulesRaw.(*treeset.Set)
it := modules.Iterator()
Expand Down

0 comments on commit 9baee62

Please sign in to comment.