You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by "Graham Dumpleton (JIRA)" <ji...@apache.org> on 2005/04/27 03:33:23 UTC

[jira] Created: (MODPYTHON-48) psp.PSP doesn't work for a text string

psp.PSP doesn't work for a text string
--------------------------------------

         Key: MODPYTHON-48
         URL: http://issues.apache.org/jira/browse/MODPYTHON-48
     Project: mod_python
        Type: Bug
    Versions: 3.1.4    
    Reporter: Graham Dumpleton


The following code doesn't work.

  from mod_python import apache
  from mod_python import psp

  def handler(req):
       content_file = psp.PSP(req, string='hello world')
       content_file.run()
       return apache.OK

The problems range from typos in the Python code, the Python code
not actually compiling the parsed string and core dumps in PSP parser
due to double deletes.

Issues have been discussed on mailing list. Some of the main posts are:

  http://www.modpython.org/pipermail/mod_python/2005-April/017932.html
  http://www.modpython.org/pipermail/mod_python/2005-April/017938.html
  http://www.modpython.org/pipermail/mod_python/2005-April/017946.html

Patches are required to lib/python/mod_python/psp.py and src/_pspmodule.c.
These are include below. An independent check of whether removing explicit
destruction of the buffer in _pspmodule.c is the correct thing to do should be
done. Whether "__psp__" is an appropriate second argument to compile() in
change should be considered.

*** ../mod_python-3.1.3/lib/python/mod_python/psp.py    Tue Feb 17 06:47:27 2004
--- lib/python/mod_python/psp.py        Wed Apr 27 11:00:19 2005
***************
*** 111,122 ****
              self.load_from_file()
          else:
  
!             cached = strcache.get(string)
              if cached:
                  self.code = cached
              else:
!                 self.code = _psp.parsestring(string)
!                 strcache.store(string)
  
      def cache_get(self, filename, mtime):
  
--- 111,124 ----
              self.load_from_file()
          else:
  
!             cached = mem_scache.get(string)
              if cached:
                  self.code = cached
              else:
!                 source = _psp.parsestring(string)
!               code = compile(source, "__psp__", "exec")
!                 mem_scache.store(string,code)
!               self.code = code
  
      def cache_get(self, filename, mtime):
  
***************
*** 358,365 ****
  
      def get(self, key):
          if self.cache.has_key(key):
!             hist, val = self.cache[key]
!             self.cache[key] = (hits+1, code)
              return val
          else:
              return None
--- 360,367 ----
  
      def get(self, key):
          if self.cache.has_key(key):
!             hits, val = self.cache[key]
!             self.cache[key] = (hits+1, val)
              return val
          else:
              return None


*** ../mod_python-3.1.3/src/_pspmodule.c        Tue Feb 17 06:47:27 2004
--- src/_pspmodule.c    Wed Apr 27 10:43:51 2005
***************
*** 146,152 ****
      bs = yy_scan_string(PyString_AsString(str), scanner);
      yylex(scanner);
  
!     yy_delete_buffer(bs, scanner);
      yylex_destroy(scanner);
      
      psp_string_0(&parser->pycode);
--- 146,152 ----
      bs = yy_scan_string(PyString_AsString(str), scanner);
      yylex(scanner);
  
!     /* yy_delete_buffer(bs, scanner); */
      yylex_destroy(scanner);
      
      psp_string_0(&parser->pycode); 



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (MODPYTHON-48) psp.PSP doesn't work for a text string

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-48?page=all ]
     
Graham Dumpleton closed MODPYTHON-48:
-------------------------------------


> psp.PSP doesn't work for a text string
> --------------------------------------
>
>          Key: MODPYTHON-48
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-48
>      Project: mod_python
>         Type: Bug
>     Versions: 3.1.4
>     Reporter: Graham Dumpleton
>      Fix For: 3.2.7
>  Attachments: psp.diff, psp2.diff
>
> The following code doesn't work.
>   from mod_python import apache
>   from mod_python import psp
>   def handler(req):
>        content_file = psp.PSP(req, string='hello world')
>        content_file.run()
>        return apache.OK
> The problems range from typos in the Python code, the Python code
> not actually compiling the parsed string and core dumps in PSP parser
> due to double deletes.
> Issues have been discussed on mailing list. Some of the main posts are:
>   http://www.modpython.org/pipermail/mod_python/2005-April/017932.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017938.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017946.html
> Patches are required to lib/python/mod_python/psp.py and src/_pspmodule.c.
> These are include below. An independent check of whether removing explicit
> destruction of the buffer in _pspmodule.c is the correct thing to do should be
> done. Whether "__psp__" is an appropriate second argument to compile() in
> change should be considered.
> *** ../mod_python-3.1.3/lib/python/mod_python/psp.py    Tue Feb 17 06:47:27 2004
> --- lib/python/mod_python/psp.py        Wed Apr 27 11:00:19 2005
> ***************
> *** 111,122 ****
>               self.load_from_file()
>           else:
>   
> !             cached = strcache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 self.code = _psp.parsestring(string)
> !                 strcache.store(string)
>   
>       def cache_get(self, filename, mtime):
>   
> --- 111,124 ----
>               self.load_from_file()
>           else:
>   
> !             cached = mem_scache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 source = _psp.parsestring(string)
> !               code = compile(source, "__psp__", "exec")
> !                 mem_scache.store(string,code)
> !               self.code = code
>   
>       def cache_get(self, filename, mtime):
>   
> ***************
> *** 358,365 ****
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hist, val = self.cache[key]
> !             self.cache[key] = (hits+1, code)
>               return val
>           else:
>               return None
> --- 360,367 ----
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hits, val = self.cache[key]
> !             self.cache[key] = (hits+1, val)
>               return val
>           else:
>               return None
> *** ../mod_python-3.1.3/src/_pspmodule.c        Tue Feb 17 06:47:27 2004
> --- src/_pspmodule.c    Wed Apr 27 10:43:51 2005
> ***************
> *** 146,152 ****
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     yy_delete_buffer(bs, scanner);
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode);
> --- 146,152 ----
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     /* yy_delete_buffer(bs, scanner); */
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode); 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Re: [jira] Resolved: (MODPYTHON-48) psp.PSP doesn't work for a text string

Posted by dharana <dh...@dharana.net>.
I've commented on the issue about an indent typo. I attached psp2.diff 
to the issue which fixes this. After applying said patch it works 
flawlessly.

Nicolas Lehuen (JIRA) wrote:
>      [ http://issues.apache.org/jira/browse/MODPYTHON-48?page=all ]
>      
> Nicolas Lehuen resolved MODPYTHON-48:
> -------------------------------------
> 
>     Resolution: Fixed
> 
> Checked-in Graham's fix.
> 
> 
>>psp.PSP doesn't work for a text string
>>--------------------------------------
>>
>>         Key: MODPYTHON-48
>>         URL: http://issues.apache.org/jira/browse/MODPYTHON-48
>>     Project: mod_python
>>        Type: Bug
>>    Versions: 3.1.4
>>    Reporter: Graham Dumpleton
>> Attachments: psp.diff
>>
>>The following code doesn't work.
>>  from mod_python import apache
>>  from mod_python import psp
>>  def handler(req):
>>       content_file = psp.PSP(req, string='hello world')
>>       content_file.run()
>>       return apache.OK
>>The problems range from typos in the Python code, the Python code
>>not actually compiling the parsed string and core dumps in PSP parser
>>due to double deletes.
>>Issues have been discussed on mailing list. Some of the main posts are:
>>  http://www.modpython.org/pipermail/mod_python/2005-April/017932.html
>>  http://www.modpython.org/pipermail/mod_python/2005-April/017938.html
>>  http://www.modpython.org/pipermail/mod_python/2005-April/017946.html
>>Patches are required to lib/python/mod_python/psp.py and src/_pspmodule.c.
>>These are include below. An independent check of whether removing explicit
>>destruction of the buffer in _pspmodule.c is the correct thing to do should be
>>done. Whether "__psp__" is an appropriate second argument to compile() in
>>change should be considered.
>>*** ../mod_python-3.1.3/lib/python/mod_python/psp.py    Tue Feb 17 06:47:27 2004
>>--- lib/python/mod_python/psp.py        Wed Apr 27 11:00:19 2005
>>***************
>>*** 111,122 ****
>>              self.load_from_file()
>>          else:
>>  
>>!             cached = strcache.get(string)
>>              if cached:
>>                  self.code = cached
>>              else:
>>!                 self.code = _psp.parsestring(string)
>>!                 strcache.store(string)
>>  
>>      def cache_get(self, filename, mtime):
>>  
>>--- 111,124 ----
>>              self.load_from_file()
>>          else:
>>  
>>!             cached = mem_scache.get(string)
>>              if cached:
>>                  self.code = cached
>>              else:
>>!                 source = _psp.parsestring(string)
>>!               code = compile(source, "__psp__", "exec")
>>!                 mem_scache.store(string,code)
>>!               self.code = code
>>  
>>      def cache_get(self, filename, mtime):
>>  
>>***************
>>*** 358,365 ****
>>  
>>      def get(self, key):
>>          if self.cache.has_key(key):
>>!             hist, val = self.cache[key]
>>!             self.cache[key] = (hits+1, code)
>>              return val
>>          else:
>>              return None
>>--- 360,367 ----
>>  
>>      def get(self, key):
>>          if self.cache.has_key(key):
>>!             hits, val = self.cache[key]
>>!             self.cache[key] = (hits+1, val)
>>              return val
>>          else:
>>              return None
>>*** ../mod_python-3.1.3/src/_pspmodule.c        Tue Feb 17 06:47:27 2004
>>--- src/_pspmodule.c    Wed Apr 27 10:43:51 2005
>>***************
>>*** 146,152 ****
>>      bs = yy_scan_string(PyString_AsString(str), scanner);
>>      yylex(scanner);
>>  
>>!     yy_delete_buffer(bs, scanner);
>>      yylex_destroy(scanner);
>>      
>>      psp_string_0(&parser->pycode);
>>--- 146,152 ----
>>      bs = yy_scan_string(PyString_AsString(str), scanner);
>>      yylex(scanner);
>>  
>>!     /* yy_delete_buffer(bs, scanner); */
>>      yylex_destroy(scanner);
>>      
>>      psp_string_0(&parser->pycode); 
> 
> 

-- 
dharana


[jira] Resolved: (MODPYTHON-48) psp.PSP doesn't work for a text string

Posted by "Nicolas Lehuen (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-48?page=all ]
     
Nicolas Lehuen resolved MODPYTHON-48:
-------------------------------------

    Resolution: Fixed

Checked-in Graham's fix.

> psp.PSP doesn't work for a text string
> --------------------------------------
>
>          Key: MODPYTHON-48
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-48
>      Project: mod_python
>         Type: Bug
>     Versions: 3.1.4
>     Reporter: Graham Dumpleton
>  Attachments: psp.diff
>
> The following code doesn't work.
>   from mod_python import apache
>   from mod_python import psp
>   def handler(req):
>        content_file = psp.PSP(req, string='hello world')
>        content_file.run()
>        return apache.OK
> The problems range from typos in the Python code, the Python code
> not actually compiling the parsed string and core dumps in PSP parser
> due to double deletes.
> Issues have been discussed on mailing list. Some of the main posts are:
>   http://www.modpython.org/pipermail/mod_python/2005-April/017932.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017938.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017946.html
> Patches are required to lib/python/mod_python/psp.py and src/_pspmodule.c.
> These are include below. An independent check of whether removing explicit
> destruction of the buffer in _pspmodule.c is the correct thing to do should be
> done. Whether "__psp__" is an appropriate second argument to compile() in
> change should be considered.
> *** ../mod_python-3.1.3/lib/python/mod_python/psp.py    Tue Feb 17 06:47:27 2004
> --- lib/python/mod_python/psp.py        Wed Apr 27 11:00:19 2005
> ***************
> *** 111,122 ****
>               self.load_from_file()
>           else:
>   
> !             cached = strcache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 self.code = _psp.parsestring(string)
> !                 strcache.store(string)
>   
>       def cache_get(self, filename, mtime):
>   
> --- 111,124 ----
>               self.load_from_file()
>           else:
>   
> !             cached = mem_scache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 source = _psp.parsestring(string)
> !               code = compile(source, "__psp__", "exec")
> !                 mem_scache.store(string,code)
> !               self.code = code
>   
>       def cache_get(self, filename, mtime):
>   
> ***************
> *** 358,365 ****
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hist, val = self.cache[key]
> !             self.cache[key] = (hits+1, code)
>               return val
>           else:
>               return None
> --- 360,367 ----
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hits, val = self.cache[key]
> !             self.cache[key] = (hits+1, val)
>               return val
>           else:
>               return None
> *** ../mod_python-3.1.3/src/_pspmodule.c        Tue Feb 17 06:47:27 2004
> --- src/_pspmodule.c    Wed Apr 27 10:43:51 2005
> ***************
> *** 146,152 ****
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     yy_delete_buffer(bs, scanner);
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode);
> --- 146,152 ----
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     /* yy_delete_buffer(bs, scanner); */
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode); 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (MODPYTHON-48) psp.PSP doesn't work for a text string

Posted by "dharana (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-48?page=all ]

dharana updated MODPYTHON-48:
-----------------------------

    Attachment: psp2.diff

> psp.PSP doesn't work for a text string
> --------------------------------------
>
>          Key: MODPYTHON-48
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-48
>      Project: mod_python
>         Type: Bug
>     Versions: 3.1.4
>     Reporter: Graham Dumpleton
>  Attachments: psp.diff, psp2.diff
>
> The following code doesn't work.
>   from mod_python import apache
>   from mod_python import psp
>   def handler(req):
>        content_file = psp.PSP(req, string='hello world')
>        content_file.run()
>        return apache.OK
> The problems range from typos in the Python code, the Python code
> not actually compiling the parsed string and core dumps in PSP parser
> due to double deletes.
> Issues have been discussed on mailing list. Some of the main posts are:
>   http://www.modpython.org/pipermail/mod_python/2005-April/017932.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017938.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017946.html
> Patches are required to lib/python/mod_python/psp.py and src/_pspmodule.c.
> These are include below. An independent check of whether removing explicit
> destruction of the buffer in _pspmodule.c is the correct thing to do should be
> done. Whether "__psp__" is an appropriate second argument to compile() in
> change should be considered.
> *** ../mod_python-3.1.3/lib/python/mod_python/psp.py    Tue Feb 17 06:47:27 2004
> --- lib/python/mod_python/psp.py        Wed Apr 27 11:00:19 2005
> ***************
> *** 111,122 ****
>               self.load_from_file()
>           else:
>   
> !             cached = strcache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 self.code = _psp.parsestring(string)
> !                 strcache.store(string)
>   
>       def cache_get(self, filename, mtime):
>   
> --- 111,124 ----
>               self.load_from_file()
>           else:
>   
> !             cached = mem_scache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 source = _psp.parsestring(string)
> !               code = compile(source, "__psp__", "exec")
> !                 mem_scache.store(string,code)
> !               self.code = code
>   
>       def cache_get(self, filename, mtime):
>   
> ***************
> *** 358,365 ****
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hist, val = self.cache[key]
> !             self.cache[key] = (hits+1, code)
>               return val
>           else:
>               return None
> --- 360,367 ----
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hits, val = self.cache[key]
> !             self.cache[key] = (hits+1, val)
>               return val
>           else:
>               return None
> *** ../mod_python-3.1.3/src/_pspmodule.c        Tue Feb 17 06:47:27 2004
> --- src/_pspmodule.c    Wed Apr 27 10:43:51 2005
> ***************
> *** 146,152 ****
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     yy_delete_buffer(bs, scanner);
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode);
> --- 146,152 ----
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     /* yy_delete_buffer(bs, scanner); */
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode); 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MODPYTHON-48) psp.PSP doesn't work for a text string

Posted by "Nicolas Lehuen (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-48?page=comments#action_63896 ]
     
Nicolas Lehuen commented on MODPYTHON-48:
-----------------------------------------

There was just a mix between tabs and spaces in the patch, which I corrected, to stick to our coding conventions.

> psp.PSP doesn't work for a text string
> --------------------------------------
>
>          Key: MODPYTHON-48
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-48
>      Project: mod_python
>         Type: Bug
>     Versions: 3.1.4
>     Reporter: Graham Dumpleton
>  Attachments: psp.diff, psp2.diff
>
> The following code doesn't work.
>   from mod_python import apache
>   from mod_python import psp
>   def handler(req):
>        content_file = psp.PSP(req, string='hello world')
>        content_file.run()
>        return apache.OK
> The problems range from typos in the Python code, the Python code
> not actually compiling the parsed string and core dumps in PSP parser
> due to double deletes.
> Issues have been discussed on mailing list. Some of the main posts are:
>   http://www.modpython.org/pipermail/mod_python/2005-April/017932.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017938.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017946.html
> Patches are required to lib/python/mod_python/psp.py and src/_pspmodule.c.
> These are include below. An independent check of whether removing explicit
> destruction of the buffer in _pspmodule.c is the correct thing to do should be
> done. Whether "__psp__" is an appropriate second argument to compile() in
> change should be considered.
> *** ../mod_python-3.1.3/lib/python/mod_python/psp.py    Tue Feb 17 06:47:27 2004
> --- lib/python/mod_python/psp.py        Wed Apr 27 11:00:19 2005
> ***************
> *** 111,122 ****
>               self.load_from_file()
>           else:
>   
> !             cached = strcache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 self.code = _psp.parsestring(string)
> !                 strcache.store(string)
>   
>       def cache_get(self, filename, mtime):
>   
> --- 111,124 ----
>               self.load_from_file()
>           else:
>   
> !             cached = mem_scache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 source = _psp.parsestring(string)
> !               code = compile(source, "__psp__", "exec")
> !                 mem_scache.store(string,code)
> !               self.code = code
>   
>       def cache_get(self, filename, mtime):
>   
> ***************
> *** 358,365 ****
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hist, val = self.cache[key]
> !             self.cache[key] = (hits+1, code)
>               return val
>           else:
>               return None
> --- 360,367 ----
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hits, val = self.cache[key]
> !             self.cache[key] = (hits+1, val)
>               return val
>           else:
>               return None
> *** ../mod_python-3.1.3/src/_pspmodule.c        Tue Feb 17 06:47:27 2004
> --- src/_pspmodule.c    Wed Apr 27 10:43:51 2005
> ***************
> *** 146,152 ****
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     yy_delete_buffer(bs, scanner);
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode);
> --- 146,152 ----
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     /* yy_delete_buffer(bs, scanner); */
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode); 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MODPYTHON-48) psp.PSP doesn't work for a text string

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-48?page=comments#action_63892 ]
     
Graham Dumpleton commented on MODPYTHON-48:
-------------------------------------------

There shouldn't have been anything wrong with the indenting in the attached diff file.
When one creates a diff file, because it puts magic characters at the start of the line,
if there are tabs in the line it can look wrongly formatted, but the "patch" program
which is used to apply the patches sorts it all out okay.

> psp.PSP doesn't work for a text string
> --------------------------------------
>
>          Key: MODPYTHON-48
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-48
>      Project: mod_python
>         Type: Bug
>     Versions: 3.1.4
>     Reporter: Graham Dumpleton
>  Attachments: psp.diff, psp2.diff
>
> The following code doesn't work.
>   from mod_python import apache
>   from mod_python import psp
>   def handler(req):
>        content_file = psp.PSP(req, string='hello world')
>        content_file.run()
>        return apache.OK
> The problems range from typos in the Python code, the Python code
> not actually compiling the parsed string and core dumps in PSP parser
> due to double deletes.
> Issues have been discussed on mailing list. Some of the main posts are:
>   http://www.modpython.org/pipermail/mod_python/2005-April/017932.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017938.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017946.html
> Patches are required to lib/python/mod_python/psp.py and src/_pspmodule.c.
> These are include below. An independent check of whether removing explicit
> destruction of the buffer in _pspmodule.c is the correct thing to do should be
> done. Whether "__psp__" is an appropriate second argument to compile() in
> change should be considered.
> *** ../mod_python-3.1.3/lib/python/mod_python/psp.py    Tue Feb 17 06:47:27 2004
> --- lib/python/mod_python/psp.py        Wed Apr 27 11:00:19 2005
> ***************
> *** 111,122 ****
>               self.load_from_file()
>           else:
>   
> !             cached = strcache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 self.code = _psp.parsestring(string)
> !                 strcache.store(string)
>   
>       def cache_get(self, filename, mtime):
>   
> --- 111,124 ----
>               self.load_from_file()
>           else:
>   
> !             cached = mem_scache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 source = _psp.parsestring(string)
> !               code = compile(source, "__psp__", "exec")
> !                 mem_scache.store(string,code)
> !               self.code = code
>   
>       def cache_get(self, filename, mtime):
>   
> ***************
> *** 358,365 ****
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hist, val = self.cache[key]
> !             self.cache[key] = (hits+1, code)
>               return val
>           else:
>               return None
> --- 360,367 ----
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hits, val = self.cache[key]
> !             self.cache[key] = (hits+1, val)
>               return val
>           else:
>               return None
> *** ../mod_python-3.1.3/src/_pspmodule.c        Tue Feb 17 06:47:27 2004
> --- src/_pspmodule.c    Wed Apr 27 10:43:51 2005
> ***************
> *** 146,152 ****
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     yy_delete_buffer(bs, scanner);
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode);
> --- 146,152 ----
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     /* yy_delete_buffer(bs, scanner); */
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode); 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (MODPYTHON-48) psp.PSP doesn't work for a text string

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-48?page=all ]

Graham Dumpleton updated MODPYTHON-48:
--------------------------------------

    Fix Version: 3.2.7

> psp.PSP doesn't work for a text string
> --------------------------------------
>
>          Key: MODPYTHON-48
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-48
>      Project: mod_python
>         Type: Bug
>     Versions: 3.1.4
>     Reporter: Graham Dumpleton
>      Fix For: 3.2.7
>  Attachments: psp.diff, psp2.diff
>
> The following code doesn't work.
>   from mod_python import apache
>   from mod_python import psp
>   def handler(req):
>        content_file = psp.PSP(req, string='hello world')
>        content_file.run()
>        return apache.OK
> The problems range from typos in the Python code, the Python code
> not actually compiling the parsed string and core dumps in PSP parser
> due to double deletes.
> Issues have been discussed on mailing list. Some of the main posts are:
>   http://www.modpython.org/pipermail/mod_python/2005-April/017932.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017938.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017946.html
> Patches are required to lib/python/mod_python/psp.py and src/_pspmodule.c.
> These are include below. An independent check of whether removing explicit
> destruction of the buffer in _pspmodule.c is the correct thing to do should be
> done. Whether "__psp__" is an appropriate second argument to compile() in
> change should be considered.
> *** ../mod_python-3.1.3/lib/python/mod_python/psp.py    Tue Feb 17 06:47:27 2004
> --- lib/python/mod_python/psp.py        Wed Apr 27 11:00:19 2005
> ***************
> *** 111,122 ****
>               self.load_from_file()
>           else:
>   
> !             cached = strcache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 self.code = _psp.parsestring(string)
> !                 strcache.store(string)
>   
>       def cache_get(self, filename, mtime):
>   
> --- 111,124 ----
>               self.load_from_file()
>           else:
>   
> !             cached = mem_scache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 source = _psp.parsestring(string)
> !               code = compile(source, "__psp__", "exec")
> !                 mem_scache.store(string,code)
> !               self.code = code
>   
>       def cache_get(self, filename, mtime):
>   
> ***************
> *** 358,365 ****
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hist, val = self.cache[key]
> !             self.cache[key] = (hits+1, code)
>               return val
>           else:
>               return None
> --- 360,367 ----
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hits, val = self.cache[key]
> !             self.cache[key] = (hits+1, val)
>               return val
>           else:
>               return None
> *** ../mod_python-3.1.3/src/_pspmodule.c        Tue Feb 17 06:47:27 2004
> --- src/_pspmodule.c    Wed Apr 27 10:43:51 2005
> ***************
> *** 146,152 ****
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     yy_delete_buffer(bs, scanner);
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode);
> --- 146,152 ----
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     /* yy_delete_buffer(bs, scanner); */
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode); 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (MODPYTHON-48) psp.PSP doesn't work for a text string

Posted by "Graham Dumpleton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-48?page=all ]

Graham Dumpleton updated MODPYTHON-48:
--------------------------------------

    Attachment: psp.diff

Formatting of code in body of report got screwed up, so patches added as attachment.

> psp.PSP doesn't work for a text string
> --------------------------------------
>
>          Key: MODPYTHON-48
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-48
>      Project: mod_python
>         Type: Bug
>     Versions: 3.1.4
>     Reporter: Graham Dumpleton
>  Attachments: psp.diff
>
> The following code doesn't work.
>   from mod_python import apache
>   from mod_python import psp
>   def handler(req):
>        content_file = psp.PSP(req, string='hello world')
>        content_file.run()
>        return apache.OK
> The problems range from typos in the Python code, the Python code
> not actually compiling the parsed string and core dumps in PSP parser
> due to double deletes.
> Issues have been discussed on mailing list. Some of the main posts are:
>   http://www.modpython.org/pipermail/mod_python/2005-April/017932.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017938.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017946.html
> Patches are required to lib/python/mod_python/psp.py and src/_pspmodule.c.
> These are include below. An independent check of whether removing explicit
> destruction of the buffer in _pspmodule.c is the correct thing to do should be
> done. Whether "__psp__" is an appropriate second argument to compile() in
> change should be considered.
> *** ../mod_python-3.1.3/lib/python/mod_python/psp.py    Tue Feb 17 06:47:27 2004
> --- lib/python/mod_python/psp.py        Wed Apr 27 11:00:19 2005
> ***************
> *** 111,122 ****
>               self.load_from_file()
>           else:
>   
> !             cached = strcache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 self.code = _psp.parsestring(string)
> !                 strcache.store(string)
>   
>       def cache_get(self, filename, mtime):
>   
> --- 111,124 ----
>               self.load_from_file()
>           else:
>   
> !             cached = mem_scache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 source = _psp.parsestring(string)
> !               code = compile(source, "__psp__", "exec")
> !                 mem_scache.store(string,code)
> !               self.code = code
>   
>       def cache_get(self, filename, mtime):
>   
> ***************
> *** 358,365 ****
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hist, val = self.cache[key]
> !             self.cache[key] = (hits+1, code)
>               return val
>           else:
>               return None
> --- 360,367 ----
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hits, val = self.cache[key]
> !             self.cache[key] = (hits+1, val)
>               return val
>           else:
>               return None
> *** ../mod_python-3.1.3/src/_pspmodule.c        Tue Feb 17 06:47:27 2004
> --- src/_pspmodule.c    Wed Apr 27 10:43:51 2005
> ***************
> *** 146,152 ****
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     yy_delete_buffer(bs, scanner);
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode);
> --- 146,152 ----
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     /* yy_delete_buffer(bs, scanner); */
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode); 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MODPYTHON-48) psp.PSP doesn't work for a text string

Posted by "dharana (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/MODPYTHON-48?page=comments#action_63889 ]
     
dharana commented on MODPYTHON-48:
----------------------------------

Attached psp.diff has bad indentation in this part:

!                 source = _psp.parsestring(string)
! 		code = compile(source, "__psp__", "exec")
!                 mem_scache.store(string,code)
! 		self.code = code


It should be

!                 source = _psp.parsestring(string)
! 		  code = compile(source, "__psp__", "exec")
!                 mem_scache.store(string,code)
! 		  self.code = code

Aside from that, from the fact that the diff mentions 3.1.3 instead of 3.1.4 and aside from the missing header warning it correctly and definitely fixes the bug. Confirmed here.

I've attached graham's patch with the indent typos and the 3.1.4 fixed. Hope it's ok.

> psp.PSP doesn't work for a text string
> --------------------------------------
>
>          Key: MODPYTHON-48
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-48
>      Project: mod_python
>         Type: Bug
>     Versions: 3.1.4
>     Reporter: Graham Dumpleton
>  Attachments: psp.diff, psp2.diff
>
> The following code doesn't work.
>   from mod_python import apache
>   from mod_python import psp
>   def handler(req):
>        content_file = psp.PSP(req, string='hello world')
>        content_file.run()
>        return apache.OK
> The problems range from typos in the Python code, the Python code
> not actually compiling the parsed string and core dumps in PSP parser
> due to double deletes.
> Issues have been discussed on mailing list. Some of the main posts are:
>   http://www.modpython.org/pipermail/mod_python/2005-April/017932.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017938.html
>   http://www.modpython.org/pipermail/mod_python/2005-April/017946.html
> Patches are required to lib/python/mod_python/psp.py and src/_pspmodule.c.
> These are include below. An independent check of whether removing explicit
> destruction of the buffer in _pspmodule.c is the correct thing to do should be
> done. Whether "__psp__" is an appropriate second argument to compile() in
> change should be considered.
> *** ../mod_python-3.1.3/lib/python/mod_python/psp.py    Tue Feb 17 06:47:27 2004
> --- lib/python/mod_python/psp.py        Wed Apr 27 11:00:19 2005
> ***************
> *** 111,122 ****
>               self.load_from_file()
>           else:
>   
> !             cached = strcache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 self.code = _psp.parsestring(string)
> !                 strcache.store(string)
>   
>       def cache_get(self, filename, mtime):
>   
> --- 111,124 ----
>               self.load_from_file()
>           else:
>   
> !             cached = mem_scache.get(string)
>               if cached:
>                   self.code = cached
>               else:
> !                 source = _psp.parsestring(string)
> !               code = compile(source, "__psp__", "exec")
> !                 mem_scache.store(string,code)
> !               self.code = code
>   
>       def cache_get(self, filename, mtime):
>   
> ***************
> *** 358,365 ****
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hist, val = self.cache[key]
> !             self.cache[key] = (hits+1, code)
>               return val
>           else:
>               return None
> --- 360,367 ----
>   
>       def get(self, key):
>           if self.cache.has_key(key):
> !             hits, val = self.cache[key]
> !             self.cache[key] = (hits+1, val)
>               return val
>           else:
>               return None
> *** ../mod_python-3.1.3/src/_pspmodule.c        Tue Feb 17 06:47:27 2004
> --- src/_pspmodule.c    Wed Apr 27 10:43:51 2005
> ***************
> *** 146,152 ****
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     yy_delete_buffer(bs, scanner);
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode);
> --- 146,152 ----
>       bs = yy_scan_string(PyString_AsString(str), scanner);
>       yylex(scanner);
>   
> !     /* yy_delete_buffer(bs, scanner); */
>       yylex_destroy(scanner);
>       
>       psp_string_0(&parser->pycode); 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira