kamahen / pykythe

Generate code Python source cross-reference facts in Kythe format
Other
21 stars 3 forks source link

import os.path gives wrong ref for os #19

Open kamahen opened 5 years ago

kamahen commented 5 years ago

import os.path binds os to os.path instead of os.

import os.path as foo works as expected; and so does import os; print(os.path).

kamahen commented 5 years ago

This is more common than I had suspected. Usually, only a top-level import is done, or a "from ... import ..." is done. A quick grep through /usr/lib/python3.7 gives 73 out of 613 files:

$ find /usr/lib/python3.7 -name '*.py' -print0 | xargs -0 cat | egrep 'import [a-z]*\.[a-z]' | sed 's/^ *import/import/' | sort | uniq -c | sort -rn
     13 import collections.abc
     11 import importlib.util
      9 import urllib.parse
      7 import os.path
      7 import importlib.machinery
      5 import email.utils
      5 import email.message
      4 import xml.etree.ElementTree as ET
      4 import urllib.request
      3 import xml.dom
      3 import http.client
      3 import distutils.versionpredicate
      3 import concurrent.futures
      2 import xmlrpc.client as xmlrpclib
      2 import urllib.parse, urllib.request
      2 import logging.handlers
      2 import http.server
      2 import email.quoprimime
      2 import email.generator
      2 import email.base64mime
      2 import distutils.command
      1 import xml.sax.saxutils
      1 import xml.sax.handler
      1 import xml.sax.expatreader
      1 import xml.sax
      1 import xml.dom.minidom
      1 import xml.dom.expatbuilder
      1 import urllib.response
      1 import urllib.request, urllib.parse
      1 import urllib.error
      1 import multiprocessing.process
      1 import java.lang
      1 import importlib.machinery # importlib first so we can test #15386 via -m
      1 import http.cookiejar
      1 import http.client, urllib.parse
      1 import http.client  # only for the default HTTP port
      1 import encodings.mbcs
      1 import encodings.aliases
      1 import email.policy
      1 import email.parser
      1 import email.errors
      1 import email.charset
      1 import distutils.version
      1 import distutils.dir_util
      1 import curses.ascii
      1 import ctypes.wintypes
      1 import ctypes.util
      1 import concurrent.futures._base
kamahen commented 4 years ago

Fixed. Will close with next push.