Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%paste not working on WinXpSP3/ipython-0.13.1.py2-win32-PROPER.exe/python27 #2835

Closed
JoeCodeswell opened this issue Jan 22, 2013 · 3 comments
Milestone

Comments

@JoeCodeswell
Copy link

eg: the following DOES NOT WORK for %paste

class SQLFORM_aug:
    '''Adds buttons to an SQLFORM'''
    # http://www.swaroopch.com/notes/python_en-object_oriented_programming/    
    # class variables [no self.]
    
    b1=IMG(_src=URL('static/images','heart-v-small.jpg'),_alt='test',_onclick=XML("ajax('month_selector', ['month'], 'suggestions');"))
    b2=IMG(_src=URL('static/images','d_arrow-v-small.jpg'),_alt='test',_onclick=XML("ajax('month_selector', ['month'], 'suggestions');"))
    buttonList = XML(CAT(b1,b2))
    
    def __init__(self, theSqlform):      
        # instance variables
        self.theSqlform = theSqlform
        self.addThebuttons()
        
    def addThebuttons(self):
        '''Adds the buttons to the SQLFORM'''
        f = self.theSqlform      
        for itm in f.elements()[0][0]:
            #print itm, '\n\n'
            itm[2].insert(-1, SQLFORM_aug.buttonList)
            #print itm[2], '\n\n'     
            
    def show(self):
        f = self.theSqlform
        for itm in f.elements()[0][0]:
            print itm, '\n\n'

In [8]: %paste
class SQLFORM_aug:
    '''Adds buttons to an SQLFORM'''
    # http://www.swaroopch.com/notes/python_en-object_oriented_programming/
    # class variables [no self.]

    b1=IMG(_src=URL('static/images','heart-v-small.jpg'),_alt='test',_onclick=XML("ajax('month_selector', ['month'], 'su
ggestions');"))
    b2=IMG(_src=URL('static/images','d_arrow-v-small.jpg'),_alt='test',_onclick=XML("ajax('month_selector', ['month'], '
suggestions');"))
    buttonList = XML(CAT(b1,b2))

    def __init__(self, theSqlform):
        # instance variables
        self.theSqlform = theSqlform
        self.addThebuttons()

    def addThebuttons(self):
        '''Adds the buttons to the SQLFORM'''
        f = self.theSqlform
        for itm in f.elements()[0][0]:
            #print itm, '\n\n'
            itm[2].insert(-1, SQLFORM_aug.buttonList)
            #print itm[2], '\n\n'

    def show(self):
        f = self.theSqlform
        for itm in f.elements()[0][0]:
            print itm, '\n\n'
## -- End pasted text --
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
C:\web2py\applications\tabledesign\models\003tud.py in ()
----> 1 get_ipython().magic(u'paste')

C:\Python27\lib\site-packages\IPython\core\interactiveshell.py in magic(self, arg_s)
   2134         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2135         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2136         return self.run_line_magic(magic_name, magic_arg_s)
   2137
   2138     #-------------------------------------------------------------------------

C:\Python27\lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line)
   2060                 args.append(sys._getframe(stack_depth).f_locals)
   2061             with self.builtin_trap:
-> 2062                 result = fn(*args)
   2063             return result
   2064

C:\Python27\lib\site-packages\IPython\frontend\terminal\interactiveshell.py in paste(self, parameter_s)

C:\Python27\lib\site-packages\IPython\core\magic.py in (f, *a, **k)
    189     # but it's overkill for just that one bit of state.
    190     def magic_deco(arg):
--> 191         call = lambda f, *a, **k: f(*a, **k)
    192
    193         if callable(arg):

C:\Python27\lib\site-packages\IPython\frontend\terminal\interactiveshell.py in paste(self, parameter_s)
    287             write("## -- End pasted text --\n")
    288
--> 289         self.store_or_execute(block, name)
    290
    291     # Class-level: add a '%cls' magic only on Windows

C:\Python27\lib\site-packages\IPython\frontend\terminal\interactiveshell.py in store_or_execute(self, block, name)
    150         """ Execute a block, or store it in a variable, per the user's request.
    151         """
--> 152         b = self.cleanup_input(block)
    153         if name:
    154             # If storing it for further editing

C:\Python27\lib\site-packages\IPython\frontend\terminal\interactiveshell.py in cleanup_input(self, block)
    137             lines = block.splitlines()
    138             if len(lines) == 1:
--> 139                 final_blocks.append(self.shell.prefilter(lines[0]))
    140             else:
    141                 final_blocks.append(block)

C:\Python27\lib\site-packages\IPython\core\prefilter.py in prefilter_lines(self, lines, continue_prompt)
    358                              for lnum, line in enumerate(llines) ])
    359         else:
--> 360             out = self.prefilter_line(llines[0], continue_prompt)
    361
    362         return out

C:\Python27\lib\site-packages\IPython\core\prefilter.py in prefilter_line(self, line, continue_prompt)
    325         if not stripped:
    326             if not continue_prompt:
--> 327                 self.shell.displayhook.prompt_count -= 1
    328
    329             return normal_handler.handle(line_info)

AttributeError: can't set attribute

In [9]:

The following DOES work:

class SQLFORM_aug:
    '''Adds buttons to an SQLFORM'''
    # http://www.swaroopch.com/notes/python_en-object_oriented_programming/    
    # class variables [no self.]
    b1=IMG(_src=URL('static/images','heart-v-small.jpg'),_alt='test',_onclick=XML("ajax('month_selector', ['month'], 'suggestions');"))
    b2=IMG(_src=URL('static/images','d_arrow-v-small.jpg'),_alt='test',_onclick=XML("ajax('month_selector', ['month'], 'suggestions');"))
    buttonList = XML(CAT(b1,b2))
    def __init__(self, theSqlform):      
        # instance variables
        self.theSqlform = theSqlform
        self.addThebuttons()
    def addThebuttons(self):
        '''Adds the buttons to the SQLFORM'''
        f = self.theSqlform      
        for itm in f.elements()[0][0]:
            #print itm, '\n\n'
            itm[2].insert(-1, SQLFORM_aug.buttonList)
            #print itm[2], '\n\n'           
    def show(self):
        f = self.theSqlform
        for itm in f.elements()[0][0]:
            print itm, '\n\n'


In [6]: %paste
class SQLFORM_aug:
    '''Adds buttons to an SQLFORM'''
    # http://www.swaroopch.com/notes/python_en-object_oriented_programming/
    # class variables [no self.]
    b1=IMG(_src=URL('static/images','heart-v-small.jpg'),_alt='test',_onclick=XML("ajax('month_selector', ['month'], 'su
ggestions');"))
    b2=IMG(_src=URL('static/images','d_arrow-v-small.jpg'),_alt='test',_onclick=XML("ajax('month_selector', ['month'], '
suggestions');"))
    buttonList = XML(CAT(b1,b2))
    def __init__(self, theSqlform):
        # instance variables
        self.theSqlform = theSqlform
        self.addThebuttons()
    def addThebuttons(self):
        '''Adds the buttons to the SQLFORM'''
        f = self.theSqlform
        for itm in f.elements()[0][0]:
            #print itm, '\n\n'
            itm[2].insert(-1, SQLFORM_aug.buttonList)
            #print itm[2], '\n\n'
    def show(self):
        f = self.theSqlform
        for itm in f.elements()[0][0]:
            print itm, '\n\n'
## -- End pasted text --

In [7]: test()
Table P: ...

@minrk
Copy link
Member

minrk commented Jan 31, 2013

It sounds like the input processing does something funny with empty lines on Windows.

Can you perhaps provide a complete sample that reproduces the issue (without depending on imports that you haven't provided, ideally without anything outside the stdlib)?

PR #2447 is a big change of the input processing, so it may actually address this.

@takluyver
Copy link
Member

The line that throws the error was already removed in #2783. If you've got time, can you try with the current development version of IPython, and let us know if the error is resolved?

@takluyver
Copy link
Member

As the line that threw that error is long gone, I'm going to close this. Please re-open if you can reproduce the problem with an up-to-date version of IPython.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants