Skip to content

Commit 2f921b8

Browse files
committed
Handle unicode module names
When the module name is given as unicode things should just work. This can be common when using the unicode_literals __future__ import for example.
1 parent 811d7a2 commit 2f921b8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

apipkg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,4 @@ def __setattr__(self, name, value):
174174
def __delattr__(self, name):
175175
delattr(getmod(), name)
176176

177-
return AliasModule(modname)
177+
return AliasModule(str(modname))

test_apipkg.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,10 @@ def test_aliasmodule_aliases_an_attribute():
424424
assert "<AliasModule 'mymod' for 'pprint.PrettyPrinter'>" == r
425425
assert am.format
426426

427+
def test_aliasmodule_unicode():
428+
am = apipkg.AliasModule(py.builtin._totext("mymod"), "pprint")
429+
assert am
430+
427431
def test_aliasmodule_repr():
428432
am = apipkg.AliasModule("mymod", "sys")
429433
r = repr(am)

0 commit comments

Comments
 (0)