File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
src/basilisp/lang/compiler Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212 * Fix an issue with ` basilisp test ` standard streams output that can lead to failures on MS-Windows (#1080 )
1313 * Fix an issue where destructuring a vector would throw an exception rather than returning ` nil ` for invalid key types (#1090 )
1414 * Fix an issue where destructuring default values would take precedence over falsey values in the source data structure (#1078 )
15+ * Fixed a bug where imported Python names containing ` - ` (in lieu of ` _ ` ) could not be referenced using the ` - ` syntax (#1085 )
1516
1617### Removed
1718 * Removed support for Python 3.8 (#1083 )
Original file line number Diff line number Diff line change @@ -3505,8 +3505,13 @@ def __resolve_namespaced_symbol_in_ns(
35053505 namespace portion"""
35063506 assert form .ns is not None
35073507
3508+ # Import names are always munged by the compiler when they're added to imports,
3509+ # but if the user provides an import alias that is left untouched. Check for
3510+ # the munged symbol in `Namespace.imports` and the unmunged in
3511+ # `Namespace.import_aliases`.
35083512 ns_sym = sym .symbol (form .ns )
3509- if ns_sym in which_ns .imports or ns_sym in which_ns .import_aliases :
3513+ import_sym = sym .symbol (munge (form .ns ))
3514+ if import_sym in which_ns .imports or ns_sym in which_ns .import_aliases :
35103515 # Fetch the full namespace name for the aliased namespace/module.
35113516 # We don't need this for actually generating the link later, but
35123517 # we _do_ need it for fetching a reference to the module to check
@@ -3516,7 +3521,7 @@ def __resolve_namespaced_symbol_in_ns(
35163521 assert ns is not None
35173522 ns_name = ns .name
35183523 else :
3519- ns_name = ns_sym .name
3524+ ns_name = import_sym .name
35203525
35213526 safe_module_name = munge (ns_name )
35223527 assert (
Original file line number Diff line number Diff line change 55import inspect
66import logging
77import os
8+ import pathlib
89import re
910import sys
1011import textwrap
@@ -6387,6 +6388,19 @@ def test_aliased_namespace_not_hidden_by_python_module(
63876388 monkeypatch .chdir (cwd )
63886389 os .unlink (module_file_path )
63896390
6391+ def test_import_name_with_underscores_resolves_properly (
6392+ self ,
6393+ lcompile : CompileFn ,
6394+ monkeypatch : pytest .MonkeyPatch ,
6395+ tmp_path : pathlib .Path ,
6396+ ):
6397+ package = tmp_path / "a_b"
6398+ package .mkdir (parents = True )
6399+ file = package / "c.py"
6400+ file .write_text ("val = 10" )
6401+ monkeypatch .syspath_prepend (str (tmp_path ))
6402+ assert lcompile ("(import a-b.c) [a-b.c/val a_b.c/val]" ) == vec .v (10 , 10 )
6403+
63906404 @pytest .mark .parametrize (
63916405 "code" ,
63926406 [
You can’t perform that action at this time.
0 commit comments