THRIFT-3438 Enable py:new_style by default
Client: Python
Patch: Nobuaki Sukegawa

This closes #759
diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc
index 81e4643..00be6e7 100644
--- a/compiler/cpp/src/generate/t_py_generator.cc
+++ b/compiler/cpp/src/generate/t_py_generator.cc
@@ -54,7 +54,16 @@
     std::map<std::string, std::string>::const_iterator iter;
 
     iter = parsed_options.find("new_style");
-    gen_newstyle_ = (iter != parsed_options.end());
+    if (iter != parsed_options.end()) {
+      pwarning(0, "new_style is enabled by default, so the option will be removed in the near future.\n");
+    }
+
+    gen_newstyle_ = true;
+    iter = parsed_options.find("old_style");
+    if (iter != parsed_options.end()) {
+      gen_newstyle_ = false;
+      pwarning(0, "old_style is deprecated and may be removed in the future.\n");
+    }
 
     iter = parsed_options.find("slots");
     gen_slots_ = (iter != parsed_options.end());
@@ -63,7 +72,7 @@
     gen_dynamic_ = (iter != parsed_options.end());
 
     if (gen_dynamic_) {
-      gen_newstyle_ = 0; // dynamic is newstyle
+      gen_newstyle_ = false; // dynamic is newstyle
       gen_dynbaseclass_ = "TBase";
       gen_dynbaseclass_frozen_ = "TFrozenBase";
       gen_dynbaseclass_exc_ = "TExceptionBase";
@@ -2574,7 +2583,8 @@
 THRIFT_REGISTER_GENERATOR(
     py,
     "Python",
-    "    new_style:       Generate new-style classes.\n"
+    "    new_style:       No effect. Kept for backward compatibility.\n"
+    "    old_style:       Deprecated. Generate old-style classes.\n"
     "    twisted:         Generate Twisted-friendly RPC services.\n"
     "    tornado:         Generate code for use with Tornado.\n"
     "    utf8strings:     Encode/decode strings using utf8 in the generated code.\n"
diff --git a/test/py/Makefile.am b/test/py/Makefile.am
index 1f710f1..d1d2278 100755
--- a/test/py/Makefile.am
+++ b/test/py/Makefile.am
@@ -29,10 +29,10 @@
         gen-py-default/DebugProtoTest/__init__.py \
         gen-py-slots/ThriftTest/__init__.py           \
         gen-py-slots/DebugProtoTest/__init__.py \
-        gen-py-newstyle/ThriftTest/__init__.py           \
-        gen-py-newstyle/DebugProtoTest/__init__.py \
-        gen-py-newstyleslots/ThriftTest/__init__.py           \
-        gen-py-newstyleslots/DebugProtoTest/__init__.py \
+        gen-py-oldstyle/ThriftTest/__init__.py \
+        gen-py-oldstyle/DebugProtoTest/__init__.py \
+        gen-py-oldstyleslots/ThriftTest/__init__.py \
+        gen-py-oldstyleslots/DebugProtoTest/__init__.py \
         gen-py-dynamic/ThriftTest/__init__.py           \
         gen-py-dynamic/DebugProtoTest/__init__.py \
         gen-py-dynamicslots/ThriftTest/__init__.py           \
@@ -64,13 +64,13 @@
 	test -d gen-py-slots || $(MKDIR_P) gen-py-slots
 	$(THRIFT) --gen py:slots -out gen-py-slots $<
 
-gen-py-newstyle/%/__init__.py: ../%.thrift $(THRIFT)
-	test -d gen-py-newstyle || $(MKDIR_P) gen-py-newstyle
-	$(THRIFT) --gen py:new_style -out gen-py-newstyle $<
+gen-py-oldstyle/%/__init__.py: ../%.thrift $(THRIFT)
+	test -d gen-py-oldstyle || $(MKDIR_P) gen-py-oldstyle
+	$(THRIFT) --gen py:old_style -out gen-py-oldstyle $<
 
-gen-py-newstyleslots/%/__init__.py: ../%.thrift $(THRIFT)
-	test -d gen-py-newstyleslots || $(MKDIR_P) gen-py-newstyleslots
-	$(THRIFT) --gen py:new_style,slots -out gen-py-newstyleslots $<
+gen-py-oldstyleslots/%/__init__.py: ../%.thrift $(THRIFT)
+	test -d gen-py-oldstyleslots || $(MKDIR_P) gen-py-oldstyleslots
+	$(THRIFT) --gen py:old_style,slots -out gen-py-oldstyleslots $<
 
 gen-py-dynamic/%/__init__.py: ../%.thrift $(THRIFT)
 	test -d gen-py-dynamic || $(MKDIR_P) gen-py-dynamic
@@ -81,4 +81,4 @@
 	$(THRIFT) --gen py:dynamic,slots -out gen-py-dynamicslots $<
 
 clean-local:
-	$(RM) -r gen-py gen-py-slots gen-py-default gen-py-newstyle gen-py-newstyleslots gen-py-dynamic gen-py-dynamicslots
+	$(RM) -r gen-py gen-py-slots gen-py-default gen-py-oldstyle gen-py-oldstyleslots gen-py-dynamic gen-py-dynamicslots
diff --git a/test/py/RunClientServer.py b/test/py/RunClientServer.py
index f83f557..8a7ead5 100755
--- a/test/py/RunClientServer.py
+++ b/test/py/RunClientServer.py
@@ -250,7 +250,7 @@
   parser = OptionParser()
   parser.add_option('--all', action="store_true", dest='all')
   parser.add_option('--genpydirs', type='string', dest='genpydirs',
-                    default='default,slots,newstyle,newstyleslots,dynamic,dynamicslots',
+                    default='default,slots,oldstyle,dynamic,dynamicslots',
                     help='directory extensions for generated code, used as suffixes for \"gen-py-*\" added sys.path for individual tests')
   parser.add_option("--port", type="int", dest="port", default=9090,
                     help="port number for server to listen on")