@@ -339,9 +339,21 @@ abstract class Container extends @container {
339339
340340 /** Holds if this folder is the root folder for the standard library. */
341341 predicate isStdLibRoot ( int major , int minor ) {
342- allowable_version ( major , minor ) and
343- this .isImportRoot ( ) and
344- this .getBaseName ( ) .regexpMatch ( "python" + major + "." + minor )
342+ major = major_version ( ) and minor = minor_version ( ) and
343+ this .isStdLibRoot ( )
344+ }
345+
346+ /** Holds if this folder is the root folder for the standard library. */
347+ predicate isStdLibRoot ( ) {
348+ /* Look for a standard lib module and find its import path
349+ * We use `os` as it is the most likely to be imported and
350+ * `tty` because it is small for testing.
351+ */
352+ exists ( Module m |
353+ m .getName ( ) = "os" or m .getName ( ) = "tty"
354+ |
355+ m .getFile ( ) .getImportRoot ( ) = this
356+ )
345357 }
346358
347359 /** Gets the path element from which this container would be loaded. */
@@ -375,12 +387,6 @@ private string get_path(string name) {
375387 py_flags_versioned ( name , result , _)
376388}
377389
378- private predicate allowable_version ( int major , int minor ) {
379- major = 2 and minor in [ 6 ..7 ]
380- or
381- major = 3 and minor in [ 3 ..6 ]
382- }
383-
384390class Location extends @location {
385391
386392 /** Gets the file for this location */
0 commit comments