Advertisement
Guest User

moriyoshi

a guest
Sep 7th, 2009
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 65.53 KB | None | 0 0
  1. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Grammar/Grammar Python-2.6.2.modified/Grammar/Grammar
  2. --- Python-2.6.2/Grammar/Grammar 2008-08-20 04:52:46.000000000 +0900
  3. +++ Python-2.6.2.modified/Grammar/Grammar 2009-09-08 01:42:08.766227422 +0900
  4. @@ -27,14 +27,14 @@
  5. # file_input is a module or sequence of commands read from an input file;
  6. # eval_input is the input for the eval() and input() functions.
  7. # NB: compound_stmt in single_input is followed by extra NEWLINE!
  8. -single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE
  9. -file_input: (NEWLINE | stmt)* ENDMARKER
  10. +single_input: ';'* (stmt ';'+)* [stmt] NEWLINE
  11. +file_input: separator* (stmt separator+)* [stmt] ENDMARKER
  12. eval_input: testlist NEWLINE* ENDMARKER
  13.  
  14. decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
  15. decorators: decorator+
  16. decorated: decorators (classdef | funcdef)
  17. -funcdef: 'def' NAME parameters ':' suite
  18. +funcdef: 'def' NAME parameters suite 'end'
  19. parameters: '(' [varargslist] ')'
  20. varargslist: ((fpdef ['=' test] ',')*
  21. ('*' NAME [',' '**' NAME] | '**' NAME) |
  22. @@ -42,8 +42,8 @@
  23. fpdef: NAME | '(' fplist ')'
  24. fplist: fpdef (',' fpdef)* [',']
  25.  
  26. -stmt: simple_stmt | compound_stmt
  27. -simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
  28. +stmt: small_stmt | compound_stmt
  29. +separator: ';'|NEWLINE
  30. small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt |
  31. import_stmt | global_stmt | exec_stmt | assert_stmt)
  32. expr_stmt: testlist (augassign (yield_expr|testlist) |
  33. @@ -75,19 +75,20 @@
  34. assert_stmt: 'assert' test [',' test]
  35.  
  36. compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated
  37. -if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
  38. -while_stmt: 'while' test ':' suite ['else' ':' suite]
  39. -for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
  40. -try_stmt: ('try' ':' suite
  41. - ((except_clause ':' suite)+
  42. - ['else' ':' suite]
  43. - ['finally' ':' suite] |
  44. - 'finally' ':' suite))
  45. -with_stmt: 'with' test [ with_var ] ':' suite
  46. +if_stmt: 'if' test suite ('elsif' test suite)* ['else' suite] 'end'
  47. +while_stmt: 'while' test suite ['else' suite] 'end'
  48. +for_stmt: 'for' exprlist 'in' testlist suite ['else' suite] 'end'
  49. +try_stmt: ('try' suite
  50. + ((except_clause suite)+
  51. + ['else' suite]
  52. + ['finally' suite] |
  53. + 'finally' suite) 'end')
  54. +with_stmt: 'with' test [ with_var ] suite 'end'
  55. with_var: 'as' expr
  56. # NB compile.c makes sure that the default except clause is last
  57. except_clause: 'except' [test [('as' | ',') test]]
  58. -suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
  59. +suite: separator+ (stmt separator+)*
  60. +block: '{' separator* (stmt separator+)* [stmt] '}'
  61.  
  62. # Backward compatibility cruft to support:
  63. # [ x for x in lambda: True, lambda: False if x() ]
  64. @@ -95,8 +96,7 @@
  65. # lambda x: 5 if x else 2
  66. # (But not a mix of the two)
  67. testlist_safe: old_test [(',' old_test)+ [',']]
  68. -old_test: or_test | old_lambdef
  69. -old_lambdef: 'lambda' [varargslist] ':' old_test
  70. +old_test: or_test | lambdef
  71.  
  72. test: or_test ['if' or_test 'else' test] | lambdef
  73. or_test: and_test ('or' and_test)*
  74. @@ -119,21 +119,21 @@
  75. NAME | NUMBER | STRING+)
  76. listmaker: test ( list_for | (',' test)* [','] )
  77. testlist_gexp: test ( gen_for | (',' test)* [','] )
  78. -lambdef: 'lambda' [varargslist] ':' test
  79. +lambdef: 'lambda' [varargslist] '{' test '}'
  80. trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
  81. subscriptlist: subscript (',' subscript)* [',']
  82. subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop]
  83. sliceop: ':' [test]
  84. exprlist: expr (',' expr)* [',']
  85. testlist: test (',' test)* [',']
  86. -dictmaker: test ':' test (',' test ':' test)* [',']
  87. +dictmaker: test '=>' test (',' test '=>' test)* [',']
  88.  
  89. -classdef: 'class' NAME ['(' [testlist] ')'] ':' suite
  90. +classdef: 'class' NAME ['(' [testlist] ')'] suite 'end'
  91.  
  92. arglist: (argument ',')* (argument [',']
  93. |'*' test (',' argument)* [',' '**' test]
  94. |'**' test)
  95. -argument: test [gen_for] | test '=' test # Really [keyword '='] test
  96. +argument: test [gen_for] | test '=>' test # Really [keyword '='] test
  97.  
  98. list_iter: list_for | list_if
  99. list_for: 'for' exprlist 'in' testlist_safe [list_iter]
  100. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Include/token.h Python-2.6.2.modified/Include/token.h
  101. --- Python-2.6.2/Include/token.h 2004-08-02 15:10:11.000000000 +0900
  102. +++ Python-2.6.2.modified/Include/token.h 2009-09-08 01:42:08.775225459 +0900
  103. @@ -12,8 +12,6 @@
  104. #define NUMBER 2
  105. #define STRING 3
  106. #define NEWLINE 4
  107. -#define INDENT 5
  108. -#define DEDENT 6
  109. #define LPAR 7
  110. #define RPAR 8
  111. #define LSQB 9
  112. @@ -58,10 +56,11 @@
  113. #define DOUBLESLASH 48
  114. #define DOUBLESLASHEQUAL 49
  115. #define AT 50
  116. +#define RDOUBLEARROW 51
  117. /* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */
  118. -#define OP 51
  119. -#define ERRORTOKEN 52
  120. -#define N_TOKENS 53
  121. +#define OP 52
  122. +#define ERRORTOKEN 53
  123. +#define N_TOKENS 54
  124.  
  125. /* Special definitions for cooperation with parser */
  126.  
  127. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Makefile.pre.in Python-2.6.2.modified/Makefile.pre.in
  128. --- Python-2.6.2/Makefile.pre.in 2009-02-24 20:07:44.000000000 +0900
  129. +++ Python-2.6.2.modified/Makefile.pre.in 2009-09-08 01:59:59.078226650 +0900
  130. @@ -392,10 +392,10 @@
  131.  
  132.  
  133. # Build the shared modules
  134. -sharedmods: $(BUILDPYTHON)
  135. +sharedmods: $(BUILDPYTHON) convert-to-pb
  136. @case $$MAKEFLAGS in \
  137. - *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
  138. - *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
  139. + *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.pb -q build;; \
  140. + *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.pb build;; \
  141. esac
  142.  
  143. # Build static library
  144. @@ -675,17 +675,17 @@
  145. # sample data.
  146.  
  147. TESTOPTS= -l $(EXTRATESTOPTS)
  148. -TESTPROG= $(srcdir)/Lib/test/regrtest.py
  149. +TESTPROG= $(srcdir)/Lib/test/regrtest.pb
  150. TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -E -tt
  151. test: all platform
  152. - -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
  153. + -find $(srcdir)/Lib -name '*.pb[co]' -o -iname "*.py[co]" -print | xargs rm -f
  154. -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
  155. $(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
  156.  
  157. testall: all platform
  158. - -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
  159. - $(TESTPYTHON) $(srcdir)/Lib/compileall.py
  160. - -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
  161. + -find $(srcdir)/Lib -name '*.pb[co]' -o -iname "*.py[co]" -print | xargs rm -f
  162. + $(TESTPYTHON) $(srcdir)/Lib/compileall.pb
  163. + -find $(srcdir)/Lib -name '*.pb[co]' -o -iname "*.py[co]" -print | xargs rm -f
  164. -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
  165. $(TESTPYTHON) $(TESTPROG) $(TESTOPTS) -uall
  166.  
  167. @@ -714,14 +714,14 @@
  168. test_unicodedata test_re test_sre test_select test_poll \
  169. test_linuxaudiodev test_struct test_sunaudiodev test_zlib
  170. quicktest: all platform
  171. - -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
  172. + -find $(srcdir)/Lib -name '*.pb[co]' -o -iname "*.py[co]" -print | xargs rm -f
  173. -$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
  174. $(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
  175.  
  176. MEMTESTOPTS= $(QUICKTESTOPTS) -x test_dl test___all__ test_fork1 \
  177. test_longexp
  178. memtest: all platform
  179. - -rm -f $(srcdir)/Lib/test/*.py[co]
  180. + -rm -f $(srcdir)/Lib/test/*.pb[co] $(srcdir)/Lib/test/*.py[co]
  181. -$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
  182. $(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
  183.  
  184. @@ -850,7 +850,7 @@
  185. else true; \
  186. fi; \
  187. done
  188. - @for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
  189. + @for i in $(srcdir)/Lib/*.pb $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
  190. do \
  191. if test -x $$i; then \
  192. $(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
  193. @@ -871,6 +871,7 @@
  194. case $$i in \
  195. *CVS) ;; \
  196. *.py[co]) ;; \
  197. + *.pb[co]) ;; \
  198. *.orig) ;; \
  199. *~) ;; \
  200. *) \
  201. @@ -887,19 +888,19 @@
  202. done
  203. $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
  204. PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  205. - ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
  206. + ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.pb \
  207. -d $(LIBDEST) -f \
  208. -x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
  209. PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  210. - ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
  211. + ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.pb \
  212. -d $(LIBDEST) -f \
  213. -x 'bad_coding|badsyntax|site-packages' $(DESTDIR)$(LIBDEST)
  214. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  215. - ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
  216. + ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.pb \
  217. -d $(LIBDEST)/site-packages -f \
  218. -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
  219. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  220. - ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
  221. + ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.pb \
  222. -d $(LIBDEST)/site-packages -f \
  223. -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
  224. -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
  225. @@ -1001,7 +1002,7 @@
  226. # Install the dynamically loadable modules
  227. # This goes into $(exec_prefix)
  228. sharedinstall:
  229. - $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
  230. + $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.pb install \
  231. --prefix=$(prefix) \
  232. --install-scripts=$(BINDIR) \
  233. --install-platlib=$(DESTSHARED) \
  234. @@ -1081,7 +1082,7 @@
  235. # This installs a few of the useful scripts in Tools/scripts
  236. scriptsinstall:
  237. SRCDIR=$(srcdir) $(RUNSHARED) \
  238. - ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.py install \
  239. + ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/setup.pb install \
  240. --prefix=$(prefix) \
  241. --install-scripts=$(BINDIR) \
  242. --root=/$(DESTDIR)
  243. @@ -1133,13 +1134,13 @@
  244. # Sanitation targets -- clean leaves libraries, executables and tags
  245. # files, which clobber removes those as well
  246. pycremoval:
  247. - find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
  248. + find $(srcdir) -name '*.pb[co]' -o -iname "*.py[co]" -exec rm -f {} ';'
  249.  
  250. clean: pycremoval
  251. find . -name '*.o' -exec rm -f {} ';'
  252. find . -name '*.s[ol]' -exec rm -f {} ';'
  253. find $(srcdir)/build -name 'fficonfig.h' -exec rm -f {} ';' || true
  254. - find $(srcdir)/build -name 'fficonfig.py' -exec rm -f {} ';' || true
  255. + find $(srcdir)/build -name 'fficonfig.p?' -exec rm -f {} ';' || true
  256.  
  257. profile-removal:
  258. find . -name '*.gc??' -exec rm -f {} ';'
  259. @@ -1172,6 +1173,7 @@
  260. funny:
  261. find $(DISTDIRS) -type d \
  262. -o -name '*.[chs]' \
  263. + -o -name '*.pb' \
  264. -o -name '*.py' \
  265. -o -name '*.doc' \
  266. -o -name '*.sty' \
  267. @@ -1199,12 +1201,27 @@
  268.  
  269. # Perform some verification checks on any modified files.
  270. patchcheck:
  271. - $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
  272. + $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.pb
  273.  
  274. # Dependencies
  275.  
  276. Python/thread.o: @THREADHEADERS@
  277.  
  278. +convert-to-pb: convert-to-pb-do
  279. + -patch -p0 -f -s < ./retouch.patch
  280. +
  281. +convert-to-pb-do: $(BUILDPYTHON)
  282. + find . -iname "*.py" -print | while read file; do \
  283. + dest=`echo $$file | sed -e 's/py$$/pb/g'`; \
  284. + if test ! -e $$dest -o $$file -nt $$dest; then \
  285. + if ./pbtrans.py < $$file > $$dest; then \
  286. + echo "successfully converted $$file"; \
  287. + else \
  288. + echo "failed to convert $$file"; \
  289. + fi; \
  290. + fi; \
  291. + done
  292. +
  293. # Declare targets that aren't real files
  294. .PHONY: all build_all sharedmods oldsharedmods test quicktest memtest
  295. .PHONY: install altinstall oldsharedinstall bininstall altbininstall
  296. @@ -1213,5 +1230,6 @@
  297. .PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
  298. .PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean
  299. .PHONY: smelly funny patchcheck
  300. +.PHONY: convert-to-pb converted-to-pb-do
  301.  
  302. # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
  303. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Modules/_bsddb.c Python-2.6.2.modified/Modules/_bsddb.c
  304. --- Python-2.6.2/Modules/_bsddb.c 2008-09-24 03:54:08.000000000 +0900
  305. +++ Python-2.6.2.modified/Modules/_bsddb.c 2009-09-08 01:42:08.791229814 +0900
  306. @@ -7470,8 +7470,8 @@
  307. * from both DBError and KeyError, since the API only supports
  308. * using one base class. */
  309. PyDict_SetItemString(d, "KeyError", PyExc_KeyError);
  310. - PyRun_String("class DBNotFoundError(DBError, KeyError): pass\n"
  311. - "class DBKeyEmptyError(DBError, KeyError): pass",
  312. + PyRun_String("class DBNotFoundError(DBError, KeyError); end\n"
  313. + "class DBKeyEmptyError(DBError, KeyError); end",
  314. Py_file_input, d, d);
  315. DBNotFoundError = PyDict_GetItemString(d, "DBNotFoundError");
  316. DBKeyEmptyError = PyDict_GetItemString(d, "DBKeyEmptyError");
  317. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Modules/cPickle.c Python-2.6.2.modified/Modules/cPickle.c
  318. --- Python-2.6.2/Modules/cPickle.c 2009-01-25 06:30:14.000000000 +0900
  319. +++ Python-2.6.2.modified/Modules/cPickle.c 2009-09-08 01:42:08.795225613 +0900
  320. @@ -5772,8 +5772,9 @@
  321.  
  322. if (!( t=PyDict_New())) return -1;
  323. if (!( r=PyRun_String(
  324. - "def __str__(self):\n"
  325. - " return self.args and ('%s' % self.args[0]) or '(what)'\n",
  326. + "def __str__(self)\n"
  327. + " return self.args and ('%s' % self.args[0]) or '(what)'\n"
  328. + "end\n",
  329. Py_file_input,
  330. module_dict, t) )) return -1;
  331. Py_DECREF(r);
  332. @@ -5791,10 +5792,11 @@
  333.  
  334. if (!( t=PyDict_New())) return -1;
  335. if (!( r=PyRun_String(
  336. - "def __str__(self):\n"
  337. + "def __str__(self)\n"
  338. " a=self.args\n"
  339. " a=a and type(a[0]) or '(what)'\n"
  340. " return 'Cannot pickle %s objects' % a\n"
  341. + "end\n"
  342. , Py_file_input,
  343. module_dict, t) )) return -1;
  344. Py_DECREF(r);
  345. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Modules/_elementtree.c Python-2.6.2.modified/Modules/_elementtree.c
  346. --- Python-2.6.2/Modules/_elementtree.c 2008-06-09 13:58:54.000000000 +0900
  347. +++ Python-2.6.2.modified/Modules/_elementtree.c 2009-09-08 01:42:08.799229531 +0900
  348. @@ -1810,7 +1810,7 @@
  349. static PyMethodDef treebuilder_methods[] = {
  350. {"data", (PyCFunction) treebuilder_data, METH_VARARGS},
  351. {"start", (PyCFunction) treebuilder_start, METH_VARARGS},
  352. - {"end", (PyCFunction) treebuilder_end, METH_VARARGS},
  353. + {"end_", (PyCFunction) treebuilder_end, METH_VARARGS},
  354. {"xml", (PyCFunction) treebuilder_xml, METH_VARARGS},
  355. {"close", (PyCFunction) treebuilder_close, METH_VARARGS},
  356. {NULL, NULL}
  357. @@ -2285,7 +2285,7 @@
  358. self->handle_xml = PyObject_GetAttrString(target, "xml");
  359. self->handle_start = PyObject_GetAttrString(target, "start");
  360. self->handle_data = PyObject_GetAttrString(target, "data");
  361. - self->handle_end = PyObject_GetAttrString(target, "end");
  362. + self->handle_end = PyObject_GetAttrString(target, "end_");
  363. self->handle_comment = PyObject_GetAttrString(target, "comment");
  364. self->handle_pi = PyObject_GetAttrString(target, "pi");
  365.  
  366. @@ -2502,8 +2502,8 @@
  367. Py_XDECREF(target->end_ns_event_obj); target->end_ns_event_obj = NULL;
  368.  
  369. if (event_set == Py_None) {
  370. - /* default is "end" only */
  371. - target->end_event_obj = PyString_FromString("end");
  372. + /* default is "end_" only */
  373. + target->end_event_obj = PyString_FromString("end_");
  374. Py_RETURN_NONE;
  375. }
  376.  
  377. @@ -2519,7 +2519,7 @@
  378. if (strcmp(event, "start") == 0) {
  379. Py_INCREF(item);
  380. target->start_event_obj = item;
  381. - } else if (strcmp(event, "end") == 0) {
  382. + } else if (strcmp(event, "end_") == 0) {
  383. Py_INCREF(item);
  384. Py_XDECREF(target->end_event_obj);
  385. target->end_event_obj = item;
  386. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Modules/main.c Python-2.6.2.modified/Modules/main.c
  387. --- Python-2.6.2/Modules/main.c 2009-02-19 08:12:48.000000000 +0900
  388. +++ Python-2.6.2.modified/Modules/main.c 2009-09-08 01:42:08.803225531 +0900
  389. @@ -375,10 +375,6 @@
  390. Py_IgnoreEnvironmentFlag++;
  391. break;
  392.  
  393. - case 't':
  394. - Py_TabcheckFlag++;
  395. - break;
  396. -
  397. case 'u':
  398. unbuffered++;
  399. saw_unbuffered_flag = 1;
  400. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Modules/_sre.c Python-2.6.2.modified/Modules/_sre.c
  401. --- Python-2.6.2/Modules/_sre.c 2008-09-10 23:27:00.000000000 +0900
  402. +++ Python-2.6.2.modified/Modules/_sre.c 2009-09-08 01:42:08.807231689 +0900
  403. @@ -3411,7 +3411,7 @@
  404. Py_ssize_t index;
  405.  
  406. PyObject* index_ = Py_False; /* zero */
  407. - if (!PyArg_UnpackTuple(args, "end", 0, 1, &index_))
  408. + if (!PyArg_UnpackTuple(args, "end_", 0, 1, &index_))
  409. return NULL;
  410.  
  411. index = match_getindex(self, index_);
  412. @@ -3561,7 +3561,7 @@
  413. static PyMethodDef match_methods[] = {
  414. {"group", (PyCFunction) match_group, METH_VARARGS},
  415. {"start", (PyCFunction) match_start, METH_VARARGS},
  416. - {"end", (PyCFunction) match_end, METH_VARARGS},
  417. + {"end_", (PyCFunction) match_end, METH_VARARGS},
  418. {"span", (PyCFunction) match_span, METH_VARARGS},
  419. {"groups", (PyCFunction) match_groups, METH_VARARGS|METH_KEYWORDS},
  420. {"groupdict", (PyCFunction) match_groupdict, METH_VARARGS|METH_KEYWORDS},
  421. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Modules/zipimport.c Python-2.6.2.modified/Modules/zipimport.c
  422. --- Python-2.6.2/Modules/zipimport.c 2008-12-14 20:30:16.000000000 +0900
  423. +++ Python-2.6.2.modified/Modules/zipimport.c 2009-09-08 01:42:08.811236006 +0900
  424. @@ -20,12 +20,12 @@
  425. are swapped by initzipimport() if we run in optimized mode. Also,
  426. '/' is replaced by SEP there. */
  427. static struct st_zip_searchorder zip_searchorder[] = {
  428. - {"/__init__.pyc", IS_PACKAGE | IS_BYTECODE},
  429. - {"/__init__.pyo", IS_PACKAGE | IS_BYTECODE},
  430. - {"/__init__.py", IS_PACKAGE | IS_SOURCE},
  431. - {".pyc", IS_BYTECODE},
  432. - {".pyo", IS_BYTECODE},
  433. - {".py", IS_SOURCE},
  434. + {"/__init__.pbc", IS_PACKAGE | IS_BYTECODE},
  435. + {"/__init__.pbo", IS_PACKAGE | IS_BYTECODE},
  436. + {"/__init__.pb", IS_PACKAGE | IS_SOURCE},
  437. + {".pbc", IS_BYTECODE},
  438. + {".pbo", IS_BYTECODE},
  439. + {".pb", IS_SOURCE},
  440. {"", 0}
  441. };
  442.  
  443. @@ -496,10 +496,10 @@
  444.  
  445. if (mi == MI_PACKAGE) {
  446. path[len] = SEP;
  447. - strcpy(path + len + 1, "__init__.py");
  448. + strcpy(path + len + 1, "__init__.pb");
  449. }
  450. else
  451. - strcpy(path + len, ".py");
  452. + strcpy(path + len, ".pb");
  453.  
  454. toc_entry = PyDict_GetItemString(self->files, path);
  455. if (toc_entry != NULL)
  456. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Objects/exceptions.c Python-2.6.2.modified/Objects/exceptions.c
  457. --- Python-2.6.2/Objects/exceptions.c 2008-07-31 02:45:10.000000000 +0900
  458. +++ Python-2.6.2.modified/Objects/exceptions.c 2009-09-08 01:42:08.815223367 +0900
  459. @@ -1580,7 +1580,7 @@
  460. PyDoc_STR("exception object")},
  461. {"start", T_PYSSIZET, offsetof(PyUnicodeErrorObject, start), 0,
  462. PyDoc_STR("exception start")},
  463. - {"end", T_PYSSIZET, offsetof(PyUnicodeErrorObject, end), 0,
  464. + {"end_", T_PYSSIZET, offsetof(PyUnicodeErrorObject, end), 0,
  465. PyDoc_STR("exception end")},
  466. {"reason", T_OBJECT, offsetof(PyUnicodeErrorObject, reason), 0,
  467. PyDoc_STR("exception reason")},
  468. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Parser/listnode.c Python-2.6.2.modified/Parser/listnode.c
  469. --- Python-2.6.2/Parser/listnode.c 2000-09-02 08:29:29.000000000 +0900
  470. +++ Python-2.6.2.modified/Parser/listnode.c 2009-09-08 01:42:08.815223367 +0900
  471. @@ -37,12 +37,6 @@
  472. }
  473. else if (ISTERMINAL(TYPE(n))) {
  474. switch (TYPE(n)) {
  475. - case INDENT:
  476. - ++level;
  477. - break;
  478. - case DEDENT:
  479. - --level;
  480. - break;
  481. default:
  482. if (atbol) {
  483. int i;
  484. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Parser/parsetok.c Python-2.6.2.modified/Parser/parsetok.c
  485. --- Python-2.6.2/Parser/parsetok.c 2008-03-27 07:20:26.000000000 +0900
  486. +++ Python-2.6.2.modified/Parser/parsetok.c 2009-09-08 01:42:08.815223367 +0900
  487. @@ -10,9 +10,6 @@
  488. #include "errcode.h"
  489. #include "graminit.h"
  490.  
  491. -int Py_TabcheckFlag;
  492. -
  493. -
  494. /* Forward */
  495. static node *parsetok(struct tok_state *, grammar *, int, perrdetail *, int *);
  496. static void initerr(perrdetail *err_ret, const char* filename);
  497. @@ -56,12 +53,7 @@
  498. return NULL;
  499. }
  500.  
  501. - tok->filename = filename ? filename : "<string>";
  502. - if (Py_TabcheckFlag || Py_VerboseFlag) {
  503. - tok->altwarning = (tok->filename != NULL);
  504. - if (Py_TabcheckFlag >= 2)
  505. - tok->alterror++;
  506. - }
  507. + tok->filename = filename ? filename : "<string>";
  508.  
  509. return parsetok(tok, g, start, err_ret, flags);
  510. }
  511. @@ -97,11 +89,6 @@
  512. return NULL;
  513. }
  514. tok->filename = filename;
  515. - if (Py_TabcheckFlag || Py_VerboseFlag) {
  516. - tok->altwarning = (filename != NULL);
  517. - if (Py_TabcheckFlag >= 2)
  518. - tok->alterror++;
  519. - }
  520.  
  521. return parsetok(tok, g, start, err_ret, flags);
  522. }
  523. @@ -168,12 +155,6 @@
  524. /* Add the right number of dedent tokens,
  525. except if a certain flag is given --
  526. codeop.py uses this. */
  527. - if (tok->indent &&
  528. - !(*flags & PyPARSE_DONT_IMPLY_DEDENT))
  529. - {
  530. - tok->pendin = -tok->indent;
  531. - tok->indent = 0;
  532. - }
  533. }
  534. else
  535. started = 1;
  536. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Parser/tokenizer.c Python-2.6.2.modified/Parser/tokenizer.c
  537. --- Python-2.6.2/Parser/tokenizer.c 2008-08-05 11:05:23.000000000 +0900
  538. +++ Python-2.6.2.modified/Parser/tokenizer.c 2009-09-08 01:42:08.819228125 +0900
  539. @@ -40,8 +40,8 @@
  540. "NUMBER",
  541. "STRING",
  542. "NEWLINE",
  543. - "INDENT",
  544. - "DEDENT",
  545. + NULL,
  546. + NULL,
  547. "LPAR",
  548. "RPAR",
  549. "LSQB",
  550. @@ -86,6 +86,7 @@
  551. "DOUBLESLASH",
  552. "DOUBLESLASHEQUAL",
  553. "AT",
  554. + "RDOUBLEARROW",
  555. /* This table must match the #defines in token.h! */
  556. "OP",
  557. "<ERRORTOKEN>",
  558. @@ -105,24 +106,16 @@
  559. tok->buf = tok->cur = tok->end = tok->inp = tok->start = NULL;
  560. tok->done = E_OK;
  561. tok->fp = NULL;
  562. - tok->tabsize = TABSIZE;
  563. - tok->indent = 0;
  564. - tok->indstack[0] = 0;
  565. tok->atbol = 1;
  566. - tok->pendin = 0;
  567. tok->prompt = tok->nextprompt = NULL;
  568. tok->lineno = 0;
  569. tok->level = 0;
  570. tok->filename = NULL;
  571. - tok->altwarning = 0;
  572. - tok->alterror = 0;
  573. - tok->alttabsize = 1;
  574. - tok->altindstack[0] = 0;
  575. tok->decoding_state = 0;
  576. tok->decoding_erred = 0;
  577. tok->read_coding_spec = 0;
  578. tok->encoding = NULL;
  579. - tok->cont_line = 0;
  580. + tok->cont_line = 0;
  581. #ifndef PGEN
  582. tok->decoding_readline = NULL;
  583. tok->decoding_buffer = NULL;
  584. @@ -978,6 +971,7 @@
  585. case '=':
  586. switch (c2) {
  587. case '=': return EQEQUAL;
  588. + case '>': return RDOUBLEARROW;
  589. }
  590. break;
  591. case '!':
  592. @@ -1092,22 +1086,6 @@
  593. return OP;
  594. }
  595.  
  596. -static int
  597. -indenterror(struct tok_state *tok)
  598. -{
  599. - if (tok->alterror) {
  600. - tok->done = E_TABSPACE;
  601. - tok->cur = tok->inp;
  602. - return 1;
  603. - }
  604. - if (tok->altwarning) {
  605. - PySys_WriteStderr("%s: inconsistent use of tabs and spaces "
  606. - "in indentation\n", tok->filename);
  607. - tok->altwarning = 0;
  608. - }
  609. - return 0;
  610. -}
  611. -
  612.  
  613. /* Get next token, after space stripping etc. */
  614.  
  615. @@ -1122,96 +1100,8 @@
  616. tok->start = NULL;
  617. blankline = 0;
  618.  
  619. - /* Get indentation level */
  620. - if (tok->atbol) {
  621. - register int col = 0;
  622. - register int altcol = 0;
  623. - tok->atbol = 0;
  624. - for (;;) {
  625. - c = tok_nextc(tok);
  626. - if (c == ' ')
  627. - col++, altcol++;
  628. - else if (c == '\t') {
  629. - col = (col/tok->tabsize + 1) * tok->tabsize;
  630. - altcol = (altcol/tok->alttabsize + 1)
  631. - * tok->alttabsize;
  632. - }
  633. - else if (c == '\014') /* Control-L (formfeed) */
  634. - col = altcol = 0; /* For Emacs users */
  635. - else
  636. - break;
  637. - }
  638. - tok_backup(tok, c);
  639. - if (c == '#' || c == '\n') {
  640. - /* Lines with only whitespace and/or comments
  641. - shouldn't affect the indentation and are
  642. - not passed to the parser as NEWLINE tokens,
  643. - except *totally* empty lines in interactive
  644. - mode, which signal the end of a command group. */
  645. - if (col == 0 && c == '\n' && tok->prompt != NULL)
  646. - blankline = 0; /* Let it through */
  647. - else
  648. - blankline = 1; /* Ignore completely */
  649. - /* We can't jump back right here since we still
  650. - may need to skip to the end of a comment */
  651. - }
  652. - if (!blankline && tok->level == 0) {
  653. - if (col == tok->indstack[tok->indent]) {
  654. - /* No change */
  655. - if (altcol != tok->altindstack[tok->indent]) {
  656. - if (indenterror(tok))
  657. - return ERRORTOKEN;
  658. - }
  659. - }
  660. - else if (col > tok->indstack[tok->indent]) {
  661. - /* Indent -- always one */
  662. - if (tok->indent+1 >= MAXINDENT) {
  663. - tok->done = E_TOODEEP;
  664. - tok->cur = tok->inp;
  665. - return ERRORTOKEN;
  666. - }
  667. - if (altcol <= tok->altindstack[tok->indent]) {
  668. - if (indenterror(tok))
  669. - return ERRORTOKEN;
  670. - }
  671. - tok->pendin++;
  672. - tok->indstack[++tok->indent] = col;
  673. - tok->altindstack[tok->indent] = altcol;
  674. - }
  675. - else /* col < tok->indstack[tok->indent] */ {
  676. - /* Dedent -- any number, must be consistent */
  677. - while (tok->indent > 0 &&
  678. - col < tok->indstack[tok->indent]) {
  679. - tok->pendin--;
  680. - tok->indent--;
  681. - }
  682. - if (col != tok->indstack[tok->indent]) {
  683. - tok->done = E_DEDENT;
  684. - tok->cur = tok->inp;
  685. - return ERRORTOKEN;
  686. - }
  687. - if (altcol != tok->altindstack[tok->indent]) {
  688. - if (indenterror(tok))
  689. - return ERRORTOKEN;
  690. - }
  691. - }
  692. - }
  693. - }
  694. -
  695. tok->start = tok->cur;
  696.  
  697. - /* Return pending indents/dedents */
  698. - if (tok->pendin != 0) {
  699. - if (tok->pendin < 0) {
  700. - tok->pendin++;
  701. - return DEDENT;
  702. - }
  703. - else {
  704. - tok->pendin--;
  705. - return INDENT;
  706. - }
  707. - }
  708. -
  709. again:
  710. tok->start = NULL;
  711. /* Skip spaces */
  712. @@ -1224,36 +1114,6 @@
  713.  
  714. /* Skip comment, while looking for tab-setting magic */
  715. if (c == '#') {
  716. - static char *tabforms[] = {
  717. - "tab-width:", /* Emacs */
  718. - ":tabstop=", /* vim, full form */
  719. - ":ts=", /* vim, abbreviated form */
  720. - "set tabsize=", /* will vi never die? */
  721. - /* more templates can be added here to support other editors */
  722. - };
  723. - char cbuf[80];
  724. - char *tp, **cp;
  725. - tp = cbuf;
  726. - do {
  727. - *tp++ = c = tok_nextc(tok);
  728. - } while (c != EOF && c != '\n' &&
  729. - (size_t)(tp - cbuf + 1) < sizeof(cbuf));
  730. - *tp = '\0';
  731. - for (cp = tabforms;
  732. - cp < tabforms + sizeof(tabforms)/sizeof(tabforms[0]);
  733. - cp++) {
  734. - if ((tp = strstr(cbuf, *cp))) {
  735. - int newsize = atoi(tp + strlen(*cp));
  736. -
  737. - if (newsize >= 1 && newsize <= 40) {
  738. - tok->tabsize = newsize;
  739. - if (Py_VerboseFlag)
  740. - PySys_WriteStderr(
  741. - "Tab size set to %d\n",
  742. - newsize);
  743. - }
  744. - }
  745. - }
  746. while (c != EOF && c != '\n')
  747. c = tok_nextc(tok);
  748. }
  749. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Parser/tokenizer.h Python-2.6.2.modified/Parser/tokenizer.h
  750. --- Python-2.6.2/Parser/tokenizer.h 2008-01-08 03:41:34.000000000 +0900
  751. +++ Python-2.6.2.modified/Parser/tokenizer.h 2009-09-08 01:42:08.819228125 +0900
  752. @@ -24,21 +24,13 @@
  753. int done; /* E_OK normally, E_EOF at EOF, otherwise error code */
  754. /* NB If done != E_OK, cur must be == inp!!! */
  755. FILE *fp; /* Rest of input; NULL if tokenizing a string */
  756. - int tabsize; /* Tab spacing */
  757. - int indent; /* Current indentation index */
  758. - int indstack[MAXINDENT]; /* Stack of indents */
  759. int atbol; /* Nonzero if at begin of new line */
  760. - int pendin; /* Pending indents (if > 0) or dedents (if < 0) */
  761. char *prompt, *nextprompt; /* For interactive prompting */
  762. int lineno; /* Current line number */
  763. int level; /* () [] {} Parentheses nesting level */
  764. /* Used to allow free continuations inside them */
  765. /* Stuff for checking on different tab sizes */
  766. const char *filename; /* For error messages */
  767. - int altwarning; /* Issue warning if alternate tabs don't match */
  768. - int alterror; /* Issue error if alternate tabs don't match */
  769. - int alttabsize; /* Alternate tab spacing */
  770. - int altindstack[MAXINDENT]; /* Stack of alternate indents */
  771. /* Stuff for PEP 0263 */
  772. int decoding_state; /* -1:decoding, 0:init, 1:raw */
  773. int decoding_erred; /* whether erred in decoding */
  774. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/pbtrans.py Python-2.6.2.modified/pbtrans.py
  775. --- Python-2.6.2/pbtrans.py 1970-01-01 09:00:00.000000000 +0900
  776. +++ Python-2.6.2.modified/pbtrans.py 2009-09-08 00:52:17.000000000 +0900
  777. @@ -0,0 +1,194 @@
  778. +#!/usr/bin/env python
  779. +import sys
  780. +from token import *
  781. +from tokenize import generate_tokens, COMMENT, NL
  782. +
  783. +def untokenize(tokens):
  784. + retval = ''
  785. + state = 1
  786. + for _ in tokens:
  787. + token = _[0]
  788. + image = _[1]
  789. + if token == OP:
  790. + if image == '[':
  791. + token = LSQB
  792. + elif image == ']':
  793. + token = RSQB
  794. + elif image == '(':
  795. + token = LPAR
  796. + elif image == ')':
  797. + token = RPAR
  798. + elif image == '{':
  799. + token = LBRACE
  800. + elif image == '}':
  801. + token = RBRACE
  802. + elif image == '.':
  803. + token = DOT
  804. + elif image == ',':
  805. + token = COMMA
  806. + if token in (LSQB, LPAR, DOT):
  807. + if state == 2:
  808. + retval += ' '
  809. + retval += image
  810. + state = 1
  811. + elif token in (RPAR, RSQB, COMMA):
  812. + retval += image
  813. + elif token == OP or token == NAME and image in ('in', 'not', 'and', 'or'):
  814. + retval += ' '
  815. + retval += image
  816. + state = 2
  817. + else:
  818. + if image == 'elif':
  819. + image = 'elsif'
  820. + elif image == 'end':
  821. + image = 'end_'
  822. + if state != 1 and (state != 3 or token != STRING):
  823. + retval += ' '
  824. + retval += image
  825. + if image == 'b' or image == 'u':
  826. + state = 3
  827. + else:
  828. + state = 0
  829. + return retval
  830. +
  831. +partypes = { ')': '(', ']': '[', '}': '{' }
  832. +
  833. +state = 0
  834. +prev_t = None
  835. +atbol = True
  836. +indstack = ['']
  837. +stmtstack = []
  838. +parstatestack = []
  839. +build_line = []
  840. +skip = False
  841. +t_is_newline = False
  842. +lambdastack = []
  843. +skipped_newlines = 0
  844. +prev_t_is_newline = False
  845. +partype = ''
  846. +singlelined = False
  847. +lambdastate = 0
  848. +
  849. +for t in generate_tokens(sys.stdin.readline):
  850. + t_is_newline = t[0] in (NEWLINE, NL)
  851. +
  852. + if t[0] == NAME and t[1] == 'lambda':
  853. + assert lambdastate != 1
  854. + lambdastate = 1
  855. + lambdastack.append(len(parstatestack))
  856. +
  857. + if lambdastate == 1:
  858. + if t[1] == ':':
  859. + skip = True
  860. + build_line.append((OP, '{'))
  861. + lambdastate = 2
  862. + elif lambdastate == 2:
  863. + if lambdastack[-1] == len(parstatestack) and \
  864. + (t[0] == NEWLINE or t[1] == ';' or t[1] == ',' or partypes.get(t[1], None) == partype):
  865. + build_line.append((OP, '}'))
  866. + lambdastack.pop()
  867. + if not lambdastack:
  868. + lambdastate = 0
  869. +
  870. + if state == 0:
  871. + if t_is_newline and not parstatestack:
  872. + print indstack[-1] + untokenize(build_line)
  873. + if atbol:
  874. + if t[0] == NAME and not parstatestack:
  875. + if t[1] in ('if', 'while', 'for', 'try', 'with', 'def', 'class'):
  876. + if (singlelined or (prev_t is not None and prev_t[0] == DEDENT)):
  877. + stmtstack.pop()
  878. + print indstack[-1] + 'end'
  879. + if not singlelined:
  880. + for i in range(skipped_newlines):
  881. + print
  882. + skipped_newlines = 0
  883. + state = 1
  884. + stmtstack.append((len(indstack), t[1]))
  885. + elif stmtstack:
  886. + if stmtstack[-1][1] == 'if':
  887. + if t[1] in ('else', 'elif'):
  888. + state = 1
  889. + elif stmtstack[-1][1] in ('while', 'for'):
  890. + if t[1] in ('else', ):
  891. + state = 1
  892. + elif stmtstack[-1][1] == 'try':
  893. + if t[1] in ('except', 'else', 'finally'):
  894. + state = 1
  895. + if state != 1 and (singlelined or (prev_t is not None and prev_t[0] == DEDENT)):
  896. + stmtstack.pop()
  897. + print indstack[-1] + 'end'
  898. + if not singlelined and t[0] != DEDENT:
  899. + for i in range(skipped_newlines):
  900. + print
  901. + skipped_newlines = 0
  902. + singlelined = False
  903. + else:
  904. + if partype == '(' and t[0] == OP and t[1] == '=':
  905. + t = (t[0], '=>')
  906. + elif state == 1:
  907. + if t[1] == ':' and not parstatestack:
  908. + state = 2
  909. + skip = True
  910. + elif state == 2:
  911. + if t[0] == NEWLINE:
  912. + print indstack[-1] + untokenize(build_line)
  913. + state = 0
  914. + elif t[0] != COMMENT:
  915. + build_line.append((SEMI, ';'))
  916. + state = 3
  917. + if t[0] == NAME and t[1] == 'pass':
  918. + skip = True
  919. + elif state == 3:
  920. + assert t[0] != INDENT
  921. + if t[0] == NEWLINE:
  922. + print indstack[-1] + untokenize(build_line)
  923. + singlelined = True
  924. + state = 0
  925. + elif t[0] == NAME and t[1] == 'pass':
  926. + skip = True
  927. +
  928. + if t[0] == OP:
  929. + if t[1] == '{' or t[1] == '(' or t[1] == '[':
  930. + parstatestack.append(partype)
  931. + partype = t[1]
  932. + elif t[1] == '}':
  933. + assert partype == '{'
  934. + partype = parstatestack.pop()
  935. + elif t[1] == ')':
  936. + assert partype == '('
  937. + partype = parstatestack.pop()
  938. + elif t[1] == ']':
  939. + assert partype == '['
  940. + partype = parstatestack.pop()
  941. + elif t[1] == ':':
  942. + if not parstatestack:
  943. + skip = True
  944. + elif partype == '{':
  945. + t = (t[0], '=>')
  946. +
  947. + if t[0] == DEDENT:
  948. + indstack.pop()
  949. + elif t[0] == INDENT:
  950. + indstack.append(t[1])
  951. + atbol = t_is_newline or t[0] in (COMMENT, INDENT, DEDENT)
  952. + skip = atbol or skip
  953. +
  954. + if t_is_newline:
  955. + if prev_t_is_newline:
  956. + skipped_newlines += 1
  957. + else:
  958. + skipped_newlines = 0
  959. + if not parstatestack:
  960. + build_line = []
  961. + else:
  962. + if not skip:
  963. + build_line.append(t)
  964. +
  965. + prev_t = t
  966. + prev_t_is_newline = t_is_newline
  967. + skip = False
  968. +
  969. +assert len(stmtstack) == 0
  970. +#if build_line:
  971. +# print indstack[-1] + untokenize(build_line)
  972. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Python/ast.c Python-2.6.2.modified/Python/ast.c
  973. --- Python-2.6.2/Python/ast.c 2008-12-06 03:01:46.000000000 +0900
  974. +++ Python-2.6.2.modified/Python/ast.c 2009-09-08 01:42:08.823226644 +0900
  975. @@ -160,11 +160,9 @@
  976.  
  977. switch (TYPE(n)) {
  978. case single_input:
  979. - if (TYPE(CHILD(n, 0)) == NEWLINE)
  980. - return 0;
  981. - else
  982. - return num_stmts(CHILD(n, 0));
  983. case file_input:
  984. + case block:
  985. + case suite:
  986. l = 0;
  987. for (i = 0; i < NCH(n); i++) {
  988. ch = CHILD(n, i);
  989. @@ -174,19 +172,9 @@
  990. return l;
  991. case stmt:
  992. return num_stmts(CHILD(n, 0));
  993. + case small_stmt:
  994. case compound_stmt:
  995. return 1;
  996. - case simple_stmt:
  997. - return NCH(n) / 2; /* Divide by 2 to remove count of semi-colons */
  998. - case suite:
  999. - if (NCH(n) == 1)
  1000. - return num_stmts(CHILD(n, 0));
  1001. - else {
  1002. - l = 0;
  1003. - for (i = 2; i < (NCH(n) - 1); i++)
  1004. - l += num_stmts(CHILD(n, i));
  1005. - return l;
  1006. - }
  1007. default: {
  1008. char buf[128];
  1009.  
  1010. @@ -206,7 +194,7 @@
  1011. PyAST_FromNode(const node *n, PyCompilerFlags *flags, const char *filename,
  1012. PyArena *arena)
  1013. {
  1014. - int i, j, k, num;
  1015. + int i, k;
  1016. asdl_seq *stmts = NULL;
  1017. stmt_ty s;
  1018. node *ch;
  1019. @@ -236,26 +224,12 @@
  1020. return NULL;
  1021. for (i = 0; i < NCH(n) - 1; i++) {
  1022. ch = CHILD(n, i);
  1023. - if (TYPE(ch) == NEWLINE)
  1024. + if (TYPE(ch) != stmt)
  1025. continue;
  1026. - REQ(ch, stmt);
  1027. - num = num_stmts(ch);
  1028. - if (num == 1) {
  1029. - s = ast_for_stmt(&c, ch);
  1030. - if (!s)
  1031. - goto error;
  1032. - asdl_seq_SET(stmts, k++, s);
  1033. - }
  1034. - else {
  1035. - ch = CHILD(ch, 0);
  1036. - REQ(ch, simple_stmt);
  1037. - for (j = 0; j < num; j++) {
  1038. - s = ast_for_stmt(&c, CHILD(ch, j * 2));
  1039. - if (!s)
  1040. - goto error;
  1041. - asdl_seq_SET(stmts, k++, s);
  1042. - }
  1043. - }
  1044. + s = ast_for_stmt(&c, ch);
  1045. + if (!s)
  1046. + goto error;
  1047. + asdl_seq_SET(stmts, k++, s);
  1048. }
  1049. return Module(stmts, arena);
  1050. case eval_input: {
  1051. @@ -268,43 +242,19 @@
  1052. return Expression(testlist_ast, arena);
  1053. }
  1054. case single_input:
  1055. - if (TYPE(CHILD(n, 0)) == NEWLINE) {
  1056. - stmts = asdl_seq_new(1, arena);
  1057. - if (!stmts)
  1058. - goto error;
  1059. - asdl_seq_SET(stmts, 0, Pass(n->n_lineno, n->n_col_offset,
  1060. - arena));
  1061. - if (!asdl_seq_GET(stmts, 0))
  1062. - goto error;
  1063. - return Interactive(stmts, arena);
  1064. - }
  1065. - else {
  1066. - n = CHILD(n, 0);
  1067. - num = num_stmts(n);
  1068. - stmts = asdl_seq_new(num, arena);
  1069. - if (!stmts)
  1070. + stmts = asdl_seq_new(num_stmts(n), arena);
  1071. + if (!stmts)
  1072. + goto error;
  1073. + for (i = 0; i < NCH(n) - 1; i++) {
  1074. + ch = CHILD(n, i);
  1075. + if (TYPE(ch) != stmt)
  1076. + continue;
  1077. + s = ast_for_stmt(&c, ch);
  1078. + if (!s)
  1079. goto error;
  1080. - if (num == 1) {
  1081. - s = ast_for_stmt(&c, n);
  1082. - if (!s)
  1083. - goto error;
  1084. - asdl_seq_SET(stmts, 0, s);
  1085. - }
  1086. - else {
  1087. - /* Only a simple_stmt can contain multiple statements. */
  1088. - REQ(n, simple_stmt);
  1089. - for (i = 0; i < NCH(n); i += 2) {
  1090. - if (TYPE(CHILD(n, i)) == NEWLINE)
  1091. - break;
  1092. - s = ast_for_stmt(&c, CHILD(n, i));
  1093. - if (!s)
  1094. - goto error;
  1095. - asdl_seq_SET(stmts, i / 2, s);
  1096. - }
  1097. - }
  1098. -
  1099. - return Interactive(stmts, arena);
  1100. + asdl_seq_SET(stmts, k++, s);
  1101. }
  1102. + return Interactive(stmts, arena);
  1103. default:
  1104. PyErr_Format(PyExc_SystemError,
  1105. "invalid node %d for PyAST_FromNode", TYPE(n));
  1106. @@ -862,7 +812,7 @@
  1107. static stmt_ty
  1108. ast_for_funcdef(struct compiling *c, const node *n, asdl_seq *decorator_seq)
  1109. {
  1110. - /* funcdef: 'def' NAME parameters ':' suite */
  1111. + /* funcdef: 'def' NAME parameters suite 'end' */
  1112. identifier name;
  1113. arguments_ty args;
  1114. asdl_seq *body;
  1115. @@ -878,7 +828,7 @@
  1116. args = ast_for_arguments(c, CHILD(n, name_i + 1));
  1117. if (!args)
  1118. return NULL;
  1119. - body = ast_for_suite(c, CHILD(n, name_i + 3));
  1120. + body = ast_for_suite(c, CHILD(n, name_i + 2));
  1121. if (!body)
  1122. return NULL;
  1123.  
  1124. @@ -919,11 +869,11 @@
  1125. static expr_ty
  1126. ast_for_lambdef(struct compiling *c, const node *n)
  1127. {
  1128. - /* lambdef: 'lambda' [varargslist] ':' test */
  1129. + /* lambdef: 'lambda' [varargslist] '{' test */
  1130. arguments_ty args;
  1131. expr_ty expression;
  1132.  
  1133. - if (NCH(n) == 3) {
  1134. + if (NCH(n) == 4) {
  1135. args = arguments(NULL, NULL, NULL, NULL, c->c_arena);
  1136. if (!args)
  1137. return NULL;
  1138. @@ -1737,8 +1687,7 @@
  1139. switch (TYPE(n)) {
  1140. case test:
  1141. case old_test:
  1142. - if (TYPE(CHILD(n, 0)) == lambdef ||
  1143. - TYPE(CHILD(n, 0)) == old_lambdef)
  1144. + if (TYPE(CHILD(n, 0)) == lambdef)
  1145. return ast_for_lambdef(c, CHILD(n, 0));
  1146. else if (NCH(n) > 1)
  1147. return ast_for_ifexpr(c, n);
  1148. @@ -2606,64 +2555,30 @@
  1149. static asdl_seq *
  1150. ast_for_suite(struct compiling *c, const node *n)
  1151. {
  1152. - /* suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT */
  1153. + /* suite: separator+ (stmt separator)* */
  1154. asdl_seq *seq;
  1155. stmt_ty s;
  1156. - int i, total, num, end, pos = 0;
  1157. + int i, total, pos = 0;
  1158. node *ch;
  1159.  
  1160. - REQ(n, suite);
  1161. -
  1162. - total = num_stmts(n);
  1163. + total = 0;
  1164. + for (i = 1; i < NCH(n); i++) {
  1165. + ch = CHILD(n, i);
  1166. + if (TYPE(ch) != stmt)
  1167. + continue;
  1168. + total += num_stmts(ch);
  1169. + }
  1170. seq = asdl_seq_new(total, c->c_arena);
  1171. if (!seq)
  1172. return NULL;
  1173. - if (TYPE(CHILD(n, 0)) == simple_stmt) {
  1174. - n = CHILD(n, 0);
  1175. - /* simple_stmt always ends with a NEWLINE,
  1176. - and may have a trailing SEMI
  1177. - */
  1178. - end = NCH(n) - 1;
  1179. - if (TYPE(CHILD(n, end - 1)) == SEMI)
  1180. - end--;
  1181. - /* loop by 2 to skip semi-colons */
  1182. - for (i = 0; i < end; i += 2) {
  1183. - ch = CHILD(n, i);
  1184. - s = ast_for_stmt(c, ch);
  1185. - if (!s)
  1186. - return NULL;
  1187. - asdl_seq_SET(seq, pos++, s);
  1188. - }
  1189. - }
  1190. - else {
  1191. - for (i = 2; i < (NCH(n) - 1); i++) {
  1192. - ch = CHILD(n, i);
  1193. - REQ(ch, stmt);
  1194. - num = num_stmts(ch);
  1195. - if (num == 1) {
  1196. - /* small_stmt or compound_stmt with only one child */
  1197. - s = ast_for_stmt(c, ch);
  1198. - if (!s)
  1199. - return NULL;
  1200. - asdl_seq_SET(seq, pos++, s);
  1201. - }
  1202. - else {
  1203. - int j;
  1204. - ch = CHILD(ch, 0);
  1205. - REQ(ch, simple_stmt);
  1206. - for (j = 0; j < NCH(ch); j += 2) {
  1207. - /* statement terminates with a semi-colon ';' */
  1208. - if (NCH(CHILD(ch, j)) == 0) {
  1209. - assert((j + 1) == NCH(ch));
  1210. - break;
  1211. - }
  1212. - s = ast_for_stmt(c, CHILD(ch, j));
  1213. - if (!s)
  1214. - return NULL;
  1215. - asdl_seq_SET(seq, pos++, s);
  1216. - }
  1217. - }
  1218. - }
  1219. + for (i = 1; i < NCH(n); i++) {
  1220. + ch = CHILD(n, i);
  1221. + if (TYPE(ch) != stmt)
  1222. + continue;
  1223. + s = ast_for_stmt(c, ch);
  1224. + if (!s)
  1225. + return NULL;
  1226. + asdl_seq_SET(seq, pos++, s);
  1227. }
  1228. assert(pos == seq->size);
  1229. return seq;
  1230. @@ -2672,8 +2587,8 @@
  1231. static stmt_ty
  1232. ast_for_if_stmt(struct compiling *c, const node *n)
  1233. {
  1234. - /* if_stmt: 'if' test ':' suite ('elif' test ':' suite)*
  1235. - ['else' ':' suite]
  1236. + /* if_stmt: 'if' test suite ('elif' test suite)*
  1237. + ['else' suite] 'end'
  1238. */
  1239. char *s;
  1240.  
  1241. @@ -2686,50 +2601,50 @@
  1242. expression = ast_for_expr(c, CHILD(n, 1));
  1243. if (!expression)
  1244. return NULL;
  1245. - suite_seq = ast_for_suite(c, CHILD(n, 3));
  1246. + suite_seq = ast_for_suite(c, CHILD(n, 2));
  1247. if (!suite_seq)
  1248. return NULL;
  1249. -
  1250. +
  1251. return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset,
  1252. c->c_arena);
  1253. }
  1254.  
  1255. - s = STR(CHILD(n, 4));
  1256. + s = STR(CHILD(n, 3));
  1257. /* s[2], the third character in the string, will be
  1258. - 's' for el_s_e, or
  1259. - 'i' for el_i_f
  1260. + 'e' for else, or
  1261. + 'i' for elsif
  1262. */
  1263. - if (s[2] == 's') {
  1264. + if (s[3] == 'e') {
  1265. expr_ty expression;
  1266. asdl_seq *seq1, *seq2;
  1267.  
  1268. expression = ast_for_expr(c, CHILD(n, 1));
  1269. if (!expression)
  1270. return NULL;
  1271. - seq1 = ast_for_suite(c, CHILD(n, 3));
  1272. + seq1 = ast_for_suite(c, CHILD(n, 2));
  1273. if (!seq1)
  1274. return NULL;
  1275. - seq2 = ast_for_suite(c, CHILD(n, 6));
  1276. + seq2 = ast_for_suite(c, CHILD(n, 4));
  1277. if (!seq2)
  1278. return NULL;
  1279.  
  1280. return If(expression, seq1, seq2, LINENO(n), n->n_col_offset,
  1281. c->c_arena);
  1282. }
  1283. - else if (s[2] == 'i') {
  1284. + else if (s[3] == 'i') {
  1285. int i, n_elif, has_else = 0;
  1286. expr_ty expression;
  1287. asdl_seq *suite_seq;
  1288. asdl_seq *orelse = NULL;
  1289. - n_elif = NCH(n) - 4;
  1290. + n_elif = NCH(n) - 4; /* 'else' suite 'end' minus one token */
  1291. /* must reference the child n_elif+1 since 'else' token is third,
  1292. not fourth, child from the end. */
  1293. if (TYPE(CHILD(n, (n_elif + 1))) == NAME
  1294. - && STR(CHILD(n, (n_elif + 1)))[2] == 's') {
  1295. + && STR(CHILD(n, (n_elif + 1)))[3] == 'e') {
  1296. has_else = 1;
  1297. - n_elif -= 3;
  1298. + n_elif -= 2;
  1299. }
  1300. - n_elif /= 4;
  1301. + n_elif /= 3;
  1302.  
  1303. if (has_else) {
  1304. asdl_seq *suite_seq2;
  1305. @@ -2737,34 +2652,34 @@
  1306. orelse = asdl_seq_new(1, c->c_arena);
  1307. if (!orelse)
  1308. return NULL;
  1309. - expression = ast_for_expr(c, CHILD(n, NCH(n) - 6));
  1310. + expression = ast_for_expr(c, CHILD(n, NCH(n) - 5));
  1311. if (!expression)
  1312. return NULL;
  1313. suite_seq = ast_for_suite(c, CHILD(n, NCH(n) - 4));
  1314. if (!suite_seq)
  1315. return NULL;
  1316. - suite_seq2 = ast_for_suite(c, CHILD(n, NCH(n) - 1));
  1317. + suite_seq2 = ast_for_suite(c, CHILD(n, NCH(n) - 2));
  1318. if (!suite_seq2)
  1319. return NULL;
  1320.  
  1321. asdl_seq_SET(orelse, 0,
  1322. If(expression, suite_seq, suite_seq2,
  1323. - LINENO(CHILD(n, NCH(n) - 6)),
  1324. - CHILD(n, NCH(n) - 6)->n_col_offset,
  1325. + LINENO(CHILD(n, NCH(n) - 5)),
  1326. + CHILD(n, NCH(n) - 5)->n_col_offset,
  1327. c->c_arena));
  1328. /* the just-created orelse handled the last elif */
  1329. n_elif--;
  1330. }
  1331.  
  1332. for (i = 0; i < n_elif; i++) {
  1333. - int off = 5 + (n_elif - i - 1) * 4;
  1334. + int off = 4 + (n_elif - i - 1) * 3;
  1335. asdl_seq *newobj = asdl_seq_new(1, c->c_arena);
  1336. if (!newobj)
  1337. return NULL;
  1338. expression = ast_for_expr(c, CHILD(n, off));
  1339. if (!expression)
  1340. return NULL;
  1341. - suite_seq = ast_for_suite(c, CHILD(n, off + 2));
  1342. + suite_seq = ast_for_suite(c, CHILD(n, off + 1));
  1343. if (!suite_seq)
  1344. return NULL;
  1345.  
  1346. @@ -2777,22 +2692,22 @@
  1347. expression = ast_for_expr(c, CHILD(n, 1));
  1348. if (!expression)
  1349. return NULL;
  1350. - suite_seq = ast_for_suite(c, CHILD(n, 3));
  1351. + suite_seq = ast_for_suite(c, CHILD(n, 2));
  1352. if (!suite_seq)
  1353. return NULL;
  1354. return If(expression, suite_seq, orelse,
  1355. LINENO(n), n->n_col_offset, c->c_arena);
  1356. - }
  1357. -
  1358. - PyErr_Format(PyExc_SystemError,
  1359. - "unexpected token in 'if' statement: %s", s);
  1360. + } else if (s[3] != '\0' && s[2] != 'd') {
  1361. + PyErr_Format(PyExc_SystemError,
  1362. + "unexpected token in 'if' statement: %s", s);
  1363. + }
  1364. return NULL;
  1365. }
  1366.  
  1367. static stmt_ty
  1368. ast_for_while_stmt(struct compiling *c, const node *n)
  1369. {
  1370. - /* while_stmt: 'while' test ':' suite ['else' ':' suite] */
  1371. + /* while_stmt: 'while' test suite ['else' suite] 'end' */
  1372. REQ(n, while_stmt);
  1373.  
  1374. if (NCH(n) == 4) {
  1375. @@ -2802,23 +2717,23 @@
  1376. expression = ast_for_expr(c, CHILD(n, 1));
  1377. if (!expression)
  1378. return NULL;
  1379. - suite_seq = ast_for_suite(c, CHILD(n, 3));
  1380. + suite_seq = ast_for_suite(c, CHILD(n, 2));
  1381. if (!suite_seq)
  1382. return NULL;
  1383. return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset,
  1384. c->c_arena);
  1385. }
  1386. - else if (NCH(n) == 7) {
  1387. + else if (NCH(n) == 6) {
  1388. expr_ty expression;
  1389. asdl_seq *seq1, *seq2;
  1390.  
  1391. expression = ast_for_expr(c, CHILD(n, 1));
  1392. if (!expression)
  1393. return NULL;
  1394. - seq1 = ast_for_suite(c, CHILD(n, 3));
  1395. + seq1 = ast_for_suite(c, CHILD(n, 2));
  1396. if (!seq1)
  1397. return NULL;
  1398. - seq2 = ast_for_suite(c, CHILD(n, 6));
  1399. + seq2 = ast_for_suite(c, CHILD(n, 4));
  1400. if (!seq2)
  1401. return NULL;
  1402.  
  1403. @@ -2839,11 +2754,11 @@
  1404. expr_ty expression;
  1405. expr_ty target;
  1406. const node *node_target;
  1407. - /* for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] */
  1408. + /* for_stmt: 'for' exprlist 'in' testlist suite ['else' suite] 'end' */
  1409. REQ(n, for_stmt);
  1410.  
  1411. - if (NCH(n) == 9) {
  1412. - seq = ast_for_suite(c, CHILD(n, 8));
  1413. + if (NCH(n) == 7) {
  1414. + seq = ast_for_suite(c, CHILD(n, 6));
  1415. if (!seq)
  1416. return NULL;
  1417. }
  1418. @@ -2862,7 +2777,7 @@
  1419. expression = ast_for_testlist(c, CHILD(n, 3));
  1420. if (!expression)
  1421. return NULL;
  1422. - suite_seq = ast_for_suite(c, CHILD(n, 5));
  1423. + suite_seq = ast_for_suite(c, CHILD(n, 4));
  1424. if (!suite_seq)
  1425. return NULL;
  1426.  
  1427. @@ -2928,18 +2843,18 @@
  1428. ast_for_try_stmt(struct compiling *c, const node *n)
  1429. {
  1430. const int nch = NCH(n);
  1431. - int n_except = (nch - 3)/3;
  1432. + int n_except = (nch - 3)/2;
  1433. asdl_seq *body, *orelse = NULL, *finally = NULL;
  1434.  
  1435. REQ(n, try_stmt);
  1436.  
  1437. - body = ast_for_suite(c, CHILD(n, 2));
  1438. + body = ast_for_suite(c, CHILD(n, 1));
  1439. if (body == NULL)
  1440. return NULL;
  1441.  
  1442. if (TYPE(CHILD(n, nch - 3)) == NAME) {
  1443. if (strcmp(STR(CHILD(n, nch - 3)), "finally") == 0) {
  1444. - if (nch >= 9 && TYPE(CHILD(n, nch - 6)) == NAME) {
  1445. + if (nch >= 9 && TYPE(CHILD(n, nch - 5)) == NAME) {
  1446. /* we can assume it's an "else",
  1447. because nch >= 9 for try-else-finally and
  1448. it would otherwise have a type of except_clause */
  1449. @@ -2949,7 +2864,7 @@
  1450. n_except--;
  1451. }
  1452.  
  1453. - finally = ast_for_suite(c, CHILD(n, nch - 1));
  1454. + finally = ast_for_suite(c, CHILD(n, nch - 2));
  1455. if (finally == NULL)
  1456. return NULL;
  1457. n_except--;
  1458. @@ -2957,7 +2872,7 @@
  1459. else {
  1460. /* we can assume it's an "else",
  1461. otherwise it would have a type of except_clause */
  1462. - orelse = ast_for_suite(c, CHILD(n, nch - 1));
  1463. + orelse = ast_for_suite(c, CHILD(n, nch - 2));
  1464. if (orelse == NULL)
  1465. return NULL;
  1466. n_except--;
  1467. @@ -2977,8 +2892,8 @@
  1468. return NULL;
  1469.  
  1470. for (i = 0; i < n_except; i++) {
  1471. - excepthandler_ty e = ast_for_except_clause(c, CHILD(n, 3 + i * 3),
  1472. - CHILD(n, 5 + i * 3));
  1473. + excepthandler_ty e = ast_for_except_clause(c, CHILD(n, 2 + i * 2),
  1474. + CHILD(n, 3 + i * 2));
  1475. if (!e)
  1476. return NULL;
  1477. asdl_seq_SET(handlers, i, e);
  1478. @@ -3014,7 +2929,7 @@
  1479. ast_for_with_stmt(struct compiling *c, const node *n)
  1480. {
  1481. expr_ty context_expr, optional_vars = NULL;
  1482. - int suite_index = 3; /* skip 'with', test, and ':' */
  1483. + int suite_index = 2; /* skip 'with', test, and ':' */
  1484. asdl_seq *suite_seq;
  1485.  
  1486. assert(TYPE(n) == with_stmt);
  1487. @@ -3030,7 +2945,7 @@
  1488. if (!set_context(c, optional_vars, Store, n)) {
  1489. return NULL;
  1490. }
  1491. - suite_index = 4;
  1492. + suite_index = 3;
  1493. }
  1494.  
  1495. suite_seq = ast_for_suite(c, CHILD(n, suite_index));
  1496. @@ -3044,7 +2959,7 @@
  1497. static stmt_ty
  1498. ast_for_classdef(struct compiling *c, const node *n, asdl_seq *decorator_seq)
  1499. {
  1500. - /* classdef: 'class' NAME ['(' testlist ')'] ':' suite */
  1501. + /* classdef: 'class' NAME ['(' testlist ')'] suite 'end' */
  1502. PyObject *classname;
  1503. asdl_seq *bases, *s;
  1504.  
  1505. @@ -3054,7 +2969,7 @@
  1506. return NULL;
  1507.  
  1508. if (NCH(n) == 4) {
  1509. - s = ast_for_suite(c, CHILD(n, 3));
  1510. + s = ast_for_suite(c, CHILD(n, 2));
  1511. if (!s)
  1512. return NULL;
  1513. classname = NEW_IDENTIFIER(CHILD(n, 1));
  1514. @@ -3064,8 +2979,8 @@
  1515. n->n_col_offset, c->c_arena);
  1516. }
  1517. /* check for empty base list */
  1518. - if (TYPE(CHILD(n,3)) == RPAR) {
  1519. - s = ast_for_suite(c, CHILD(n,5));
  1520. + if (TYPE(CHILD(n, 3)) == RPAR) {
  1521. + s = ast_for_suite(c, CHILD(n, 4));
  1522. if (!s)
  1523. return NULL;
  1524. classname = NEW_IDENTIFIER(CHILD(n, 1));
  1525. @@ -3080,7 +2995,7 @@
  1526. if (!bases)
  1527. return NULL;
  1528.  
  1529. - s = ast_for_suite(c, CHILD(n, 6));
  1530. + s = ast_for_suite(c, CHILD(n, 5));
  1531. if (!s)
  1532. return NULL;
  1533. classname = NEW_IDENTIFIER(CHILD(n, 1));
  1534. @@ -3097,10 +3012,6 @@
  1535. assert(NCH(n) == 1);
  1536. n = CHILD(n, 0);
  1537. }
  1538. - if (TYPE(n) == simple_stmt) {
  1539. - assert(num_stmts(n) == 1);
  1540. - n = CHILD(n, 0);
  1541. - }
  1542. if (TYPE(n) == small_stmt) {
  1543. REQ(n, small_stmt);
  1544. n = CHILD(n, 0);
  1545. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Python/bltinmodule.c Python-2.6.2.modified/Python/bltinmodule.c
  1546. --- Python-2.6.2/Python/bltinmodule.c 2009-02-03 07:44:06.000000000 +0900
  1547. +++ Python-2.6.2.modified/Python/bltinmodule.c 2009-09-08 01:42:08.827227682 +0900
  1548. @@ -1555,7 +1555,7 @@
  1549. static PyObject *
  1550. builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
  1551. {
  1552. - static char *kwlist[] = {"sep", "end", "file", 0};
  1553. + static char *kwlist[] = {"sep", "end_", "file", 0};
  1554. static PyObject *dummy_args;
  1555. PyObject *sep = NULL, *end = NULL, *file = NULL;
  1556. int i, err;
  1557. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Python/compile.c Python-2.6.2.modified/Python/compile.c
  1558. --- Python-2.6.2/Python/compile.c 2008-06-11 16:41:16.000000000 +0900
  1559. +++ Python-2.6.2.modified/Python/compile.c 2009-09-08 01:42:08.831236000 +0900
  1560. @@ -1374,7 +1374,7 @@
  1561. arguments_ty args = s->v.FunctionDef.args;
  1562. asdl_seq* decos = s->v.FunctionDef.decorator_list;
  1563. stmt_ty st;
  1564. - int i, n, docstring;
  1565. + int i, n, docstring = 0;
  1566.  
  1567. assert(s->kind == FunctionDef_kind);
  1568.  
  1569. @@ -1386,20 +1386,22 @@
  1570. s->lineno))
  1571. return 0;
  1572.  
  1573. - st = (stmt_ty)asdl_seq_GET(s->v.FunctionDef.body, 0);
  1574. - docstring = compiler_isdocstring(st);
  1575. - if (docstring && Py_OptimizeFlag < 2)
  1576. - first_const = st->v.Expr.value->v.Str.s;
  1577. - if (compiler_add_o(c, c->u->u_consts, first_const) < 0) {
  1578. - compiler_exit_scope(c);
  1579. - return 0;
  1580. - }
  1581. + n = asdl_seq_LEN(s->v.FunctionDef.body);
  1582. + if (n > 0) {
  1583. + st = (stmt_ty)asdl_seq_GET(s->v.FunctionDef.body, 0);
  1584. + docstring = compiler_isdocstring(st);
  1585. + if (docstring && Py_OptimizeFlag < 2)
  1586. + first_const = st->v.Expr.value->v.Str.s;
  1587. + if (compiler_add_o(c, c->u->u_consts, first_const) < 0) {
  1588. + compiler_exit_scope(c);
  1589. + return 0;
  1590. + }
  1591. + }
  1592.  
  1593. /* unpack nested arguments */
  1594. compiler_arguments(c, args);
  1595.  
  1596. c->u->u_argcount = asdl_seq_LEN(args->args);
  1597. - n = asdl_seq_LEN(s->v.FunctionDef.body);
  1598. /* if there was a docstring, we need to skip the first statement */
  1599. for (i = docstring; i < n; i++) {
  1600. st = (stmt_ty)asdl_seq_GET(s->v.FunctionDef.body, i);
  1601. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Python/import.c Python-2.6.2.modified/Python/import.c
  1602. --- Python-2.6.2/Python/import.c 2009-01-14 09:00:17.000000000 +0900
  1603. +++ Python-2.6.2.modified/Python/import.c 2009-09-08 01:42:08.839235957 +0900
  1604. @@ -95,17 +95,17 @@
  1605.  
  1606. #ifdef RISCOS
  1607. static const struct filedescr _PyImport_StandardFiletab[] = {
  1608. - {"/py", "U", PY_SOURCE},
  1609. - {"/pyc", "rb", PY_COMPILED},
  1610. + {"/pb", "U", PY_SOURCE},
  1611. + {"/pbc", "rb", PY_COMPILED},
  1612. {0, 0}
  1613. };
  1614. #else
  1615. static const struct filedescr _PyImport_StandardFiletab[] = {
  1616. - {".py", "U", PY_SOURCE},
  1617. + {".pb", "U", PY_SOURCE},
  1618. #ifdef MS_WINDOWS
  1619. - {".pyw", "U", PY_SOURCE},
  1620. + {".pbw", "U", PY_SOURCE},
  1621. #endif
  1622. - {".pyc", "rb", PY_COMPILED},
  1623. + {".pbc", "rb", PY_COMPILED},
  1624. {0, 0}
  1625. };
  1626. #endif
  1627. @@ -144,14 +144,14 @@
  1628. _PyImport_Filetab = filetab;
  1629.  
  1630. if (Py_OptimizeFlag) {
  1631. - /* Replace ".pyc" with ".pyo" in _PyImport_Filetab */
  1632. + /* Replace ".pbc" with ".pbo" in _PyImport_Filetab */
  1633. for (; filetab->suffix != NULL; filetab++) {
  1634. #ifndef RISCOS
  1635. - if (strcmp(filetab->suffix, ".pyc") == 0)
  1636. - filetab->suffix = ".pyo";
  1637. + if (strcmp(filetab->suffix, ".pbc") == 0)
  1638. + filetab->suffix = ".pbo";
  1639. #else
  1640. - if (strcmp(filetab->suffix, "/pyc") == 0)
  1641. - filetab->suffix = "/pyo";
  1642. + if (strcmp(filetab->suffix, "/pbc") == 0)
  1643. + filetab->suffix = "/pbo";
  1644. #endif
  1645. }
  1646. }
  1647. @@ -1394,14 +1394,14 @@
  1648. if (stat(buf, &statbuf) == 0 && /* it exists */
  1649. S_ISDIR(statbuf.st_mode) && /* it's a directory */
  1650. case_ok(buf, len, namelen, name)) { /* case matches */
  1651. - if (find_init_module(buf)) { /* and has __init__.py */
  1652. + if (find_init_module(buf)) { /* and has __init__.pb */
  1653. Py_XDECREF(copy);
  1654. return &fd_package;
  1655. }
  1656. else {
  1657. char warnstr[MAXPATHLEN+80];
  1658. sprintf(warnstr, "Not importing directory "
  1659. - "'%.*s': missing __init__.py",
  1660. + "'%.*s': missing __init__.pb",
  1661. MAXPATHLEN, buf);
  1662. if (PyErr_Warn(PyExc_ImportWarning,
  1663. warnstr)) {
  1664. @@ -1422,7 +1422,7 @@
  1665. else {
  1666. char warnstr[MAXPATHLEN+80];
  1667. sprintf(warnstr, "Not importing directory "
  1668. - "'%.*s': missing __init__.py",
  1669. + "'%.*s': missing __init__.pb",
  1670. MAXPATHLEN, buf);
  1671. if (PyErr_Warn(PyExc_ImportWarning,
  1672. warnstr)) {
  1673. @@ -1709,7 +1709,7 @@
  1674.  
  1675.  
  1676. #ifdef HAVE_STAT
  1677. -/* Helper to look for __init__.py or __init__.py[co] in potential package */
  1678. +/* Helper to look for __init__.pb or __init__.pb[co] in potential package */
  1679. static int
  1680. find_init_module(char *buf)
  1681. {
  1682. @@ -1730,7 +1730,7 @@
  1683. return 0;
  1684. buf[i++] = SEP;
  1685. pname = buf + i;
  1686. - strcpy(pname, "__init__.py");
  1687. + strcpy(pname, "__init__.pb");
  1688. if (stat(buf, &statbuf) == 0) {
  1689. if (case_ok(buf,
  1690. save_len + 9, /* len("/__init__") */
  1691. @@ -1768,7 +1768,7 @@
  1692. if (save_len + 13 >= MAXPATHLEN)
  1693. return 0;
  1694. buf[i++] = SEP;
  1695. - strcpy(buf+i, "__init__/py");
  1696. + strcpy(buf+i, "__init__/pb");
  1697. if (isfile(buf)) {
  1698. buf[save_len] = '\0';
  1699. return 1;
  1700. @@ -2192,7 +2192,7 @@
  1701.  
  1702. /* Return the package that an import is being performed in. If globals comes
  1703. from the module foo.bar.bat (not itself a package), this returns the
  1704. - sys.modules entry for foo.bar. If globals is from a package's __init__.py,
  1705. + sys.modules entry for foo.bar. If globals is from a package's __init__.pb,
  1706. the package's entry in sys.modules is returned, as a borrowed reference.
  1707.  
  1708. The *name* of the returned package is returned in buf, with the length of
  1709. @@ -3110,7 +3110,7 @@
  1710.  
  1711. PyDoc_STRVAR(doc_get_magic,
  1712. "get_magic() -> string\n\
  1713. -Return the magic number for .pyc or .pyo files.");
  1714. +Return the magic number for .pbc or .pbo files.");
  1715.  
  1716. PyDoc_STRVAR(doc_get_suffixes,
  1717. "get_suffixes() -> [(suffix, mode, type), ...]\n\
  1718. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Python/pythonrun.c Python-2.6.2.modified/Python/pythonrun.c
  1719. --- Python-2.6.2/Python/pythonrun.c 2009-04-04 23:19:56.000000000 +0900
  1720. +++ Python-2.6.2.modified/Python/pythonrun.c 2009-09-08 01:42:08.839235957 +0900
  1721. @@ -1541,16 +1541,8 @@
  1722. switch (err->error) {
  1723. case E_SYNTAX:
  1724. errtype = PyExc_IndentationError;
  1725. - if (err->expected == INDENT)
  1726. - msg = "expected an indented block";
  1727. - else if (err->token == INDENT)
  1728. - msg = "unexpected indent";
  1729. - else if (err->token == DEDENT)
  1730. - msg = "unexpected unindent";
  1731. - else {
  1732. - errtype = PyExc_SyntaxError;
  1733. - msg = "invalid syntax";
  1734. - }
  1735. + errtype = PyExc_SyntaxError;
  1736. + msg = "invalid syntax";
  1737. break;
  1738. case E_TOKEN:
  1739. msg = "invalid token";
  1740. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Python/sysmodule.c Python-2.6.2.modified/Python/sysmodule.c
  1741. --- Python-2.6.2/Python/sysmodule.c 2009-01-14 09:08:09.000000000 +0900
  1742. +++ Python-2.6.2.modified/Python/sysmodule.c 2009-09-08 01:42:08.843231156 +0900
  1743. @@ -1262,7 +1262,6 @@
  1744. SetFlag(Py_NoUserSiteDirectory);
  1745. SetFlag(Py_NoSiteFlag);
  1746. SetFlag(Py_IgnoreEnvironmentFlag);
  1747. - SetFlag(Py_TabcheckFlag);
  1748. SetFlag(Py_VerboseFlag);
  1749. #ifdef RISCOS
  1750. SetFlag(Py_RISCOSWimpFlag);
  1751. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/Python/_warnings.c Python-2.6.2.modified/Python/_warnings.c
  1752. --- Python-2.6.2/Python/_warnings.c 2008-10-03 04:49:47.000000000 +0900
  1753. +++ Python-2.6.2.modified/Python/_warnings.c 2009-09-08 01:42:08.847225435 +0900
  1754. @@ -194,7 +194,7 @@
  1755. if (len < 0)
  1756. return NULL;
  1757. if (len >= 3 &&
  1758. - strncmp(mod_str + (len - 3), ".py", 3) == 0) {
  1759. + strncmp(mod_str + (len - 3), ".pb", 3) == 0) {
  1760. module = PyString_FromStringAndSize(mod_str, len-3);
  1761. }
  1762. else {
  1763. @@ -513,11 +513,11 @@
  1764. if (file_str == NULL || (len < 0 && PyErr_Occurred()))
  1765. goto handle_error;
  1766.  
  1767. - /* if filename.lower().endswith((".pyc", ".pyo")): */
  1768. + /* if filename.lower().endswith((".pbc", ".pbo")): */
  1769. if (len >= 4 &&
  1770. file_str[len-4] == '.' &&
  1771. tolower(file_str[len-3]) == 'p' &&
  1772. - tolower(file_str[len-2]) == 'y' &&
  1773. + tolower(file_str[len-2]) == 'b' &&
  1774. (tolower(file_str[len-1]) == 'c' ||
  1775. tolower(file_str[len-1]) == 'o'))
  1776. {
  1777. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/retouch.patch Python-2.6.2.modified/retouch.patch
  1778. --- Python-2.6.2/retouch.patch 1970-01-01 09:00:00.000000000 +0900
  1779. +++ Python-2.6.2.modified/retouch.patch 2009-09-08 01:57:34.451231183 +0900
  1780. @@ -0,0 +1,11 @@
  1781. +--- setup.pb 2009-09-08 01:57:04.670228285 +0900
  1782. ++++ setup.pb 2009-09-08 01:57:09.978426876 +0900
  1783. +@@ -1374,7 +1374,7 @@
  1784. + (srcdir,) = sysconfig.get_config_vars('srcdir')
  1785. + ffi_builddir = os.path.join(self.build_temp, 'libffi')
  1786. + ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', '_ctypes', 'libffi'))
  1787. +- ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py')
  1788. ++ ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.pb')
  1789. +
  1790. + from distutils.dep_util import newer_group
  1791. +
  1792. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/RISCOS/Modules/swimodule.c Python-2.6.2.modified/RISCOS/Modules/swimodule.c
  1793. --- Python-2.6.2/RISCOS/Modules/swimodule.c 2008-06-09 13:58:54.000000000 +0900
  1794. +++ Python-2.6.2.modified/RISCOS/Modules/swimodule.c 2009-09-08 01:42:08.847225435 +0900
  1795. @@ -292,13 +292,13 @@
  1796. {
  1797. if (!strcmp(name, "length")) return PyInt_FromLong((long)s->length);
  1798. if (!strcmp(name, "start")) return PyInt_FromLong((long)s->block);
  1799. - if (!strcmp(name,"end")) return PyInt_FromLong(((long)(s->block)+s->length));
  1800. + if (!strcmp(name,"end_")) return PyInt_FromLong(((long)(s->block)+s->length));
  1801. if (!strcmp(name, "__members__"))
  1802. { PyObject *list = PyList_New(3);
  1803. if (list)
  1804. { PyList_SetItem(list, 0, PyString_FromString("length"));
  1805. PyList_SetItem(list, 1, PyString_FromString("start"));
  1806. - PyList_SetItem(list, 2, PyString_FromString("end"));
  1807. + PyList_SetItem(list, 2, PyString_FromString("end_"));
  1808. if (PyErr_Occurred()) { Py_DECREF(list);list = NULL;}
  1809. }
  1810. return list;
  1811. diff -x 'config.status*' -x Makefile.pre -x 'graminit.*' -urN Python-2.6.2/setup.py Python-2.6.2.modified/setup.py
  1812. --- Python-2.6.2/setup.py 2009-04-01 03:20:48.000000000 +0900
  1813. +++ Python-2.6.2.modified/setup.py 2009-09-08 01:42:08.851261910 +0900
  1814. @@ -508,9 +508,6 @@
  1815. # select(2); not on ancient System V
  1816. exts.append( Extension('select', ['selectmodule.c']) )
  1817.  
  1818. - # Fred Drake's interface to the Python parser
  1819. - exts.append( Extension('parser', ['parsermodule.c']) )
  1820. -
  1821. # cStringIO and cPickle
  1822. exts.append( Extension('cStringIO', ['cStringIO.c']) )
  1823. exts.append( Extension('cPickle', ['cPickle.c']) )
  1824. --- Python-2.6.2/Lib/compileall.py 2008-03-05 06:14:04.000000000 +0900
  1825. +++ Python-2.6.2.modified/Lib/compileall.py 2009-09-08 02:37:28.296334022 +0900
  1826. @@ -53,7 +53,7 @@
  1827. continue
  1828. if os.path.isfile(fullname):
  1829. head, tail = name[:-3], name[-3:]
  1830. - if tail == '.py':
  1831. + if tail == '.pb':
  1832. cfile = fullname + (__debug__ and 'c' or 'o')
  1833. ftime = os.stat(fullname).st_mtime
  1834. try: ctime = os.stat(cfile).st_mtime
  1835.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement