class_docstr: Use of __package__ supersedes the use of __name__/__path__ to calculate
  what package a module belongs to. The basic algorithm is [__package__]::
  
    def resolve_name(name, package, level):
        level -= 1
        base = package.rsplit('.', level)[0]
        return '{0}.{1}'.format(base, name)
  
  But since there is no guarantee that __package__ has been set (or not been
  set to None [None]), there has to be a way to calculate the attribute's value
  [__name__]::
  
    def calc_package(caller_name, has___path__):
        if has__path__:
            return caller_name
        else:
            return caller_name.rsplit('.', 1)[0]
  
  Then the normal algorithm for relative name imports can proceed as if
  __package__ had been set.
class_docstr_tok: ["Use","of","__package__","supersedes","the","use","of","__name__\/__path__","to","calculate","what","package","a","module","belongs","to",".","The","basic","algorithm","is","[","__package__","]",":",":","def","resolve_name","(","name",",","package",",","level",")",":","level","-=","1","base","=","package.rsplit","(","'",".","'",",","level",")","[","0","]","return","'","{","0","}",".","{","1","}","'.format","(","base",",","name",")","But","since","there","is","no","guarantee","that","__package__","has","been","set","(","or","not","been","set","to","None","[","None","]",")",",","there","has","to","be","a","way","to","calculate","the","attribute","'s","value","[","__name__","]",":",":","def","calc_package","(","caller_name",",","has___path__",")",":","if","has__path__",":","return","caller_name","else",":","return","caller_name.rsplit","(","'",".","'",",","1",")","[","0","]","Then","the","normal","algorithm","for","relative","name","imports","can","proceed","as","if","__package__","had","been","set","."]
code: def test_bunk__package__(self):
      globals = {"__package__": 42}
      with self.assertRaises(TypeError):
          self.__import__("", globals, {}, ["relimport"], 1)
  
imports: import unittest
  import warnings
  from test.test_importlib import util
label_desc: Use image node_id 9 for calling the Using__package__ obj's underlying member method code with example usage: obj.test_bunk__package__() without return types