Code

Opened 15 months ago

Closed 15 months ago

Last modified 14 months ago

#19665 closed Bug (fixed)

'Command' object has no attribute 'stderr'

Reported by: stefankoegl Owned by: claudep
Component: Core (Management commands) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When running some self-written management commands with the current stable/1.5.x branch (currently d571894fc09b34b8b43cb8f1790c743a47679851), I get the following AttributeError

$ ./manage.py assign-upload-timestamps
/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py:219: DeprecationWarning: You have no filters defined on the 'mail_admins' logging handler: adding implicit debug-false-only filter. See http://docs.djangoproject.com/en/dev/releases/1.4/#request-exceptions-are-now-always-logged
  DeprecationWarning)

Traceback (most recent call last):
  File "./manage.py", line 36, in <module>
    execute_manager(settings)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 469, in execute_manager
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 226, in run_from_argv
    self.stderr.write('%s: %s' % (e.__class__.__name__, e))
AttributeError: 'Command' object has no attribute 'stderr'

As no part of the trace refers to code of my application, I assume a bug in Django 1.5.

Attachments (1)

19665-1.diff (2.3 KB) - added by claudep 15 months ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 15 months ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to claudep
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

comment:2 Changed 15 months ago by claudep

I'm still curious to know what error did your command raises so as self.stderr was not even initialized, as it is one of the first thing execute is doing. Try to replace self.stderr by sys.stderr in your Django code to find out.

Changed 15 months ago by claudep

comment:3 Changed 15 months ago by claudep

  • Has patch set

Patch attached in case someone wants to quickly review it.

comment:4 Changed 15 months ago by charettes

  • Triage Stage changed from Accepted to Ready for checkin
  • Version changed from 1.5-alpha-1 to master

Patch looks good and admin_scripts tests pass on Python 2.7.3 and 3.2.3 (SQlite) while the additional test fails without the fix.

Last edited 15 months ago by charettes (previous) (diff)

comment:5 Changed 15 months ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In b9c8bbf3726a1956be1db70ffd3bef04a2e5311a:

Fixed #19665 -- Ensured proper stderr output for Command.run_from_argv

Thanks Stefan Koegl for the report and Simon Charette for the review.

comment:6 Changed 15 months ago by Claude Paroz <claude@…>

In 2d8b0315f46d24c6567a05422bd609f3a689bda8:

[1.5.x] Fixed #19665 -- Ensured proper stderr output for Command.run_from_argv

Thanks Stefan Koegl for the report and Simon Charette for the review.
Backport of b9c8bbf37 from master.

comment:7 Changed 14 months ago by Claude Paroz <claude@…>

In 2d8b0315f46d24c6567a05422bd609f3a689bda8:

[1.5.x] Fixed #19665 -- Ensured proper stderr output for Command.run_from_argv

Thanks Stefan Koegl for the report and Simon Charette for the review.
Backport of b9c8bbf37 from master.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.