]> granicus.if.org Git - python/commitdiff
ceval, PyEval_MergeCompilerFlags: wasn't merging in the
authorTim Peters <tim.peters@gmail.com>
Fri, 17 Aug 2001 20:47:47 +0000 (20:47 +0000)
committerTim Peters <tim.peters@gmail.com>
Fri, 17 Aug 2001 20:47:47 +0000 (20:47 +0000)
CO_FUTURE_DIVISION flag.  Redid this to use Jeremy's PyCF_MASK #define
instead, so we dont have to remember to fiddle individual feature names
here again.

pythonrun.h:  Also #define a PyCF_MASK_OBSOLETE mask.  This isn't used
yet, but will be as part of the PEP 264 implementation (compile() mustn't
raise an error just because old code uses a flag name that's become
obsolete; a warning may be appropriate, but not an error; so compile() has
to know about obsolete flags too, but nobody is going to remember to
update compile() with individual obsolete flag names across releases either
-- i.e., this is the flip side of PyEval_MergeCompilerFlags's oversight).

Include/pythonrun.h
Python/ceval.c

index 95ac15ce5e40353527f0802df929c582e8d7415c..6d3a6d8ee5849e467e382289502b223cf8968570 100644 (file)
@@ -8,6 +8,8 @@ extern "C" {
 #endif
 
 #define PyCF_MASK (CO_GENERATOR_ALLOWED | CO_FUTURE_DIVISION)
+#define PyCF_MASK_OBSOLETE (CO_NESTED)
+
 typedef struct {
        int cf_flags;  /* bitmask of CO_xxx flags relevant to future */
 } PyCompilerFlags;
index 6ee8ae36a30cb0e59080e77485c2539ba5554011..d3898fb7336d6b9c41bbc4af4eb7aba21a483a61 100644 (file)
@@ -2928,13 +2928,10 @@ PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
 
        if (current_frame != NULL) {
                const int codeflags = current_frame->f_code->co_flags;
-               if (codeflags & CO_NESTED) {
+               const int compilerflags = codeflags & PyCF_MASK;
+               if (compilerflags) {
                        result = 1;
-                       cf->cf_flags |= CO_NESTED;
-               }
-               if (codeflags & CO_GENERATOR_ALLOWED) {
-                       result = 1;
-                       cf->cf_flags |= CO_GENERATOR_ALLOWED;
+                       cf->cf_flags |= compilerflags;
                }
        }
        return result;