@@ -229,8 +229,40 @@ def test_name_resolution(self):
229
229
('logging.handlers:SysLogHandler.NO_SUCH_VALUE' , AttributeError ),
230
230
('logging.handlers.SysLogHandler.NO_SUCH_VALUE' , AttributeError ),
231
231
('ZeroDivisionError' , ImportError ),
232
+ ('os.path.9abc' , ValueError ),
233
+ ('9abc' , ValueError ),
232
234
)
233
235
236
+ # add some Unicode package names to the mix.
237
+
238
+ unicode_words = ('\u0935 \u092e \u0938 ' ,
239
+ '\xe9 ' , '\xc8 ' ,
240
+ '\uc548 \ub155 \ud558 \uc138 \uc694 ' ,
241
+ '\u3055 \u3088 \u306a \u3089 ' ,
242
+ '\u3042 \u308a \u304c \u3068 \u3046 ' ,
243
+ '\u0425 \u043e \u0440 \u043e \u0448 \u043e ' ,
244
+ '\u0441 \u043f \u0430 \u0441 \u0438 \u0431 \u043e ' ,
245
+ '\u73b0 \u4ee3 \u6c49 \u8bed \u5e38 \u7528 \u5b57 \u8868 ' )
246
+
247
+ for uw in unicode_words :
248
+ d = os .path .join (self .dirname , uw )
249
+ os .makedirs (d , exist_ok = True )
250
+ # make an empty __init__.py file
251
+ f = os .path .join (d , '__init__.py' )
252
+ with open (f , 'w' ) as f :
253
+ f .write ('' )
254
+ f .flush ()
255
+ # now import the package we just created; clearing the caches is
256
+ # needed, otherwise the newly created package isn't found
257
+ importlib .invalidate_caches ()
258
+ mod = importlib .import_module (uw )
259
+ success_cases += (uw , mod ),
260
+ if len (uw ) > 1 :
261
+ failure_cases += (uw [:- 1 ], ImportError ),
262
+
263
+ # add an example with a Unicode digit at the start
264
+ failure_cases += ('\u0966 \u0935 \u092e \u0938 ' , ValueError ),
265
+
234
266
for s , expected in success_cases :
235
267
with self .subTest (s = s ):
236
268
o = pkgutil .resolve_name (s )
0 commit comments